diff --git a/src/com/massivecraft/massivecore/chestgui/ChestActionAbstract.java b/src/com/massivecraft/massivecore/chestgui/ChestActionAbstract.java index 44efc329..5da92846 100644 --- a/src/com/massivecraft/massivecore/chestgui/ChestActionAbstract.java +++ b/src/com/massivecraft/massivecore/chestgui/ChestActionAbstract.java @@ -4,8 +4,6 @@ import com.massivecraft.massivecore.util.IdUtil; import com.massivecraft.massivecore.util.MUtil; import org.bukkit.entity.Player; import org.bukkit.event.inventory.InventoryClickEvent; -import org.bukkit.inventory.Inventory; -import org.bukkit.inventory.ItemStack; public class ChestActionAbstract implements ChestAction { @@ -19,27 +17,6 @@ public class ChestActionAbstract implements ChestAction Player player = IdUtil.getAsPlayer(event.getWhoClicked()); if (MUtil.isntPlayer(player)) return false; - // Variables - Inventory inventory = event.getInventory(); - ChestGui gui = ChestGui.get(inventory); - int slot = event.getSlot(); - - // Transform item - ItemStack itemBefore = event.getCurrentItem(); - ItemStack itemAfter = transformItem(itemBefore); - - if (itemAfter != null) - { - inventory.setItem(slot, itemAfter); - } - - // Transform action - ChestAction actionAfter = transformAction(); - if (actionAfter != null) - { - gui.setAction(slot, actionAfter); - } - return onClick(event, player); } @@ -48,14 +25,4 @@ public class ChestActionAbstract implements ChestAction return false; } - public ItemStack transformItem(ItemStack clickedItem) - { - return null; - } - - public ChestAction transformAction() - { - return null; - } - } diff --git a/src/com/massivecraft/massivecore/chestgui/ChestActionToggle.java b/src/com/massivecraft/massivecore/chestgui/ChestActionToggle.java deleted file mode 100644 index f24bb4eb..00000000 --- a/src/com/massivecraft/massivecore/chestgui/ChestActionToggle.java +++ /dev/null @@ -1,84 +0,0 @@ -package com.massivecraft.massivecore.chestgui; - -import org.bukkit.entity.Player; -import org.bukkit.event.inventory.InventoryClickEvent; -import org.bukkit.inventory.ItemStack; - -public class ChestActionToggle extends ChestActionAbstract implements ChestButton -{ - // -------------------------------------------- // - // FIELDS - // -------------------------------------------- // - - private final ItemStack enabledItem; - public ItemStack getEnabledItem() { return this.enabledItem; } - - private final ItemStack disabledItem; - public ItemStack getDisabledItem() { return this.disabledItem; } - - private final ChestAction enableAction; - public ChestAction getEnableAction() { return this.enableAction; } - - private final ChestAction disableAction; - public ChestAction getDisableAction() { return this.disableAction; } - - private boolean enabled; - - // -------------------------------------------- // - // CONSTRUCT - // -------------------------------------------- // - - public ChestActionToggle(ItemStack enabledItem, ItemStack disabledItem, ChestAction enableAction, ChestAction disableAction, boolean enabled) - { - this.enabledItem = enabledItem; - this.disabledItem = disabledItem; - this.enableAction = enableAction; - this.disableAction = disableAction; - - this.enabled = enabled; - } - - // -------------------------------------------- // - // OVERRIDE: CHEST ACTION - // -------------------------------------------- // - - @Override - public boolean onClick(InventoryClickEvent event, Player player) - { - // If it is enabled then use the disable action - // If it is disabled use the enable action - boolean ret; - ChestAction inner = this.enabled ? this.getDisableAction() : this.getEnableAction(); - ret = inner.onClick(event); - - this.enabled = !this.enabled; - - return ret; - } - - // This method is run /before/ onClick - // so this.enabled has not yet changed value - @Override - public ItemStack transformItem(ItemStack clickedItem) - { - // Currently enabled means it will be disabled, so show the disable item and vice versa - return this.enabled ? this.getDisabledItem() : this.getEnabledItem(); - } - - // -------------------------------------------- // - // OVERRIDE: CHEST BUTTON - // -------------------------------------------- // - - @Override - public ChestAction getAction() - { - return this; - } - - @Override - public ItemStack getItem() - { - return this.enabled ? this.getEnabledItem() : this.getDisabledItem(); - } - -} diff --git a/src/com/massivecraft/massivecore/chestgui/ChestGui.java b/src/com/massivecraft/massivecore/chestgui/ChestGui.java index afe028f5..8c7a6b19 100644 --- a/src/com/massivecraft/massivecore/chestgui/ChestGui.java +++ b/src/com/massivecraft/massivecore/chestgui/ChestGui.java @@ -177,7 +177,7 @@ public class ChestGui } - public ChestGui constructFromButtons(List buttons) + public static ChestGui constructFromButtons(List buttons, String title) { int size = buttons.size(); int modulo = size % 9; @@ -186,7 +186,7 @@ public class ChestGui size = size + 9 - modulo; } - Inventory inventory = Bukkit.createInventory(null, size); + Inventory inventory = Bukkit.createInventory(null, size, title); ChestGui gui = getCreative(inventory); for (int i = 0; i < buttons.size(); i++)