Merge pull request #7999 from MagicfTail/split-loot-upload

Split saveLoot config into submit loot and sync panel configs
This commit is contained in:
Tomas Slusny
2019-02-25 08:06:18 +00:00
committed by GitHub
3 changed files with 21 additions and 8 deletions

View File

@@ -51,11 +51,23 @@ public interface LootTrackerConfig extends Config
@ConfigItem(
keyName = "saveLoot",
name = "Save loot",
description = "Save loot between client sessions (requires being logged in)"
name = "Submit loot tracker data",
description = "Submit loot tracker data (requires being logged in)"
)
default boolean saveLoot()
{
return true;
}
@ConfigItem(
keyName = "syncPanel",
name = "Synchronize panel contents",
description = "Synchronize you local loot tracker with your online (requires being logged in). This means" +
" that panel is filled with portion of your remote data on startup and deleting data in panel deletes them" +
" also on server."
)
default boolean syncPanel()
{
return true;
}
}

View File

@@ -99,6 +99,7 @@ class LootTrackerPanel extends PluginPanel
private final ItemManager itemManager;
private final LootTrackerPlugin plugin;
private final LootTrackerConfig config;
private boolean groupLoot;
private boolean hideIgnoredItems;
@@ -130,10 +131,11 @@ class LootTrackerPanel extends PluginPanel
INVISIBLE_ICON_HOVER = new ImageIcon(ImageUtil.alphaOffset(invisibleImg, -220));
}
LootTrackerPanel(final LootTrackerPlugin plugin, final ItemManager itemManager)
LootTrackerPanel(final LootTrackerPlugin plugin, final ItemManager itemManager, final LootTrackerConfig config)
{
this.itemManager = itemManager;
this.plugin = plugin;
this.config = config;
this.hideIgnoredItems = true;
setBorder(new EmptyBorder(6, 6, 6, 6));
@@ -297,7 +299,7 @@ class LootTrackerPanel extends PluginPanel
// Delete all loot, or loot matching the current view
LootTrackerClient client = plugin.getLootTrackerClient();
if (client != null)
if (client != null && config.syncPanel())
{
client.delete(currentView);
}
@@ -472,7 +474,7 @@ class LootTrackerPanel extends PluginPanel
LootTrackerClient client = plugin.getLootTrackerClient();
// Without loot being grouped we have no way to identify single kills to be deleted
if (client != null && groupLoot)
if (client != null && groupLoot && config.syncPanel())
{
client.delete(box.getId());
}

View File

@@ -195,7 +195,7 @@ public class LootTrackerPlugin extends Plugin
protected void startUp() throws Exception
{
ignoredItems = Text.fromCSV(config.getIgnoredItems());
panel = new LootTrackerPanel(this, itemManager);
panel = new LootTrackerPanel(this, itemManager, config);
spriteManager.getSpriteAsync(SpriteID.TAB_INVENTORY, 0, panel::loadHeaderIcon);
final BufferedImage icon = ImageUtil.getResourceStreamFromClass(getClass(), "panel_icon.png");
@@ -227,9 +227,8 @@ public class LootTrackerPlugin extends Plugin
{
Collection<LootRecord> lootRecords;
if (!config.saveLoot())
if (!config.syncPanel())
{
// don't load loot if we're not saving loot
return;
}