inventory tags plugin: clean up plugin code

This includes various code quality improvements such as stronger access
control and removing redundant code.
This commit is contained in:
Jordan Atwood
2018-10-25 11:30:01 -07:00
parent 8b4b4c3ba1
commit 0d79490f6d

View File

@@ -92,7 +92,7 @@ public class InventoryTagsPlugin extends Plugin
@Getter(AccessLevel.PACKAGE) @Getter(AccessLevel.PACKAGE)
private boolean hasTaggedItems; private boolean hasTaggedItems;
private boolean editorMode = false; private boolean editorMode;
@Provides @Provides
InventoryTagsConfig provideConfig(ConfigManager configManager) InventoryTagsConfig provideConfig(ConfigManager configManager)
@@ -111,12 +111,12 @@ public class InventoryTagsPlugin extends Plugin
return tag; return tag;
} }
void setTag(int itemId, String tag) private void setTag(int itemId, String tag)
{ {
configManager.setConfiguration(InventoryTagsConfig.GROUP, ITEM_KEY_PREFIX + itemId, tag); configManager.setConfiguration(InventoryTagsConfig.GROUP, ITEM_KEY_PREFIX + itemId, tag);
} }
void unsetTag(int itemId) private void unsetTag(int itemId)
{ {
configManager.unsetConfiguration(InventoryTagsConfig.GROUP, ITEM_KEY_PREFIX + itemId); configManager.unsetConfiguration(InventoryTagsConfig.GROUP, ITEM_KEY_PREFIX + itemId);
} }
@@ -228,7 +228,7 @@ public class InventoryTagsPlugin extends Plugin
final String group = getTag(itemId); final String group = getTag(itemId);
final MenuEntry newMenu = new MenuEntry(); final MenuEntry newMenu = new MenuEntry();
final Color color = getGroupNameColor(groupName); final Color color = getGroupNameColor(groupName);
newMenu.setOption(group != null && groupName.equals(group) ? MENU_REMOVE : MENU_SET); newMenu.setOption(groupName.equals(group) ? MENU_REMOVE : MENU_SET);
newMenu.setTarget(ColorUtil.prependColorTag(groupName, MoreObjects.firstNonNull(color, Color.WHITE))); newMenu.setTarget(ColorUtil.prependColorTag(groupName, MoreObjects.firstNonNull(color, Color.WHITE)));
newMenu.setIdentifier(itemId); newMenu.setIdentifier(itemId);
newMenu.setParam1(widgetId); newMenu.setParam1(widgetId);