diff --git a/src/main/java/me/darkolythe/deepstorageplus/DeepStoragePlus.java b/src/main/java/me/darkolythe/deepstorageplus/DeepStoragePlus.java index 2576727..5d7813e 100644 --- a/src/main/java/me/darkolythe/deepstorageplus/DeepStoragePlus.java +++ b/src/main/java/me/darkolythe/deepstorageplus/DeepStoragePlus.java @@ -106,6 +106,7 @@ public void onEnable() { getServer().getPluginManager().registerEvents(iolistener, plugin); getServer().getPluginManager().registerEvents(storagebreakslistener, plugin); getServer().getPluginManager().registerEvents(configmanager, plugin); + getServer().getPluginManager().registerEvents(new InteractionListener(), plugin); getCommand("deepstorageplus").setExecutor(new CommandHandler(itemList)); getCommand("dsp").setExecutor(new CommandHandler(itemList)); diff --git a/src/main/java/me/darkolythe/deepstorageplus/dsu/listeners/InteractionListener.java b/src/main/java/me/darkolythe/deepstorageplus/dsu/listeners/InteractionListener.java new file mode 100644 index 0000000..7374ddb --- /dev/null +++ b/src/main/java/me/darkolythe/deepstorageplus/dsu/listeners/InteractionListener.java @@ -0,0 +1,28 @@ +package me.darkolythe.deepstorageplus.dsu.listeners; + +import me.darkolythe.deepstorageplus.utils.ItemList; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.block.Action; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; + +public class InteractionListener implements Listener { + + @EventHandler + public void onJukeboxInteraction(PlayerInteractEvent event) { + if (event.getAction() != Action.RIGHT_CLICK_BLOCK){ + return; + } + + Block block = event.getClickedBlock(); + if (block != null && block.getType() == Material.JUKEBOX) { + ItemStack item = event.getPlayer().getInventory().getItemInMainHand(); + if (!event.isCancelled() && ItemList.isStorageContainerItem(item)) { + event.setCancelled(true); + } + } + } +} diff --git a/src/main/java/me/darkolythe/deepstorageplus/dsu/listeners/InventoryListener.java b/src/main/java/me/darkolythe/deepstorageplus/dsu/listeners/InventoryListener.java index 1f15b2f..a877907 100644 --- a/src/main/java/me/darkolythe/deepstorageplus/dsu/listeners/InventoryListener.java +++ b/src/main/java/me/darkolythe/deepstorageplus/dsu/listeners/InventoryListener.java @@ -77,10 +77,12 @@ private void onStorageInteract(InventoryClickEvent event) { if (event.getSlot() % 9 == 8) { //rightmost column if (event.getSlot() != 53) { //if containers clicked if (cursor != null && cursor.getType() != Material.AIR) { //if putting container in - if (item != null && ItemList.isDSPItem(item, ItemList.STORAGE_SLOT_MODEL_ID)) { + if (ItemList.isDSPItem(item, ItemList.STORAGE_SLOT_MODEL_ID)) { event.setCancelled(true); if (cursor.hasItemMeta()) { //if putting a Storage Container in the dsu + System.out.println("meta check passed"); if (ItemList.isStorageContainerItem(cursor)) { + System.out.println("cursor is container"); inv.setItem(event.getSlot(), cursor); cursor.setAmount(0); main.dsuupdatemanager.updateItems(inv, null); diff --git a/src/main/java/me/darkolythe/deepstorageplus/dsu/managers/DSUManager.java b/src/main/java/me/darkolythe/deepstorageplus/dsu/managers/DSUManager.java index ed1debc..02fce99 100644 --- a/src/main/java/me/darkolythe/deepstorageplus/dsu/managers/DSUManager.java +++ b/src/main/java/me/darkolythe/deepstorageplus/dsu/managers/DSUManager.java @@ -2,15 +2,17 @@ import de.tr7zw.changeme.nbtapi.NBTItem; import me.darkolythe.deepstorageplus.DeepStoragePlus; -import me.darkolythe.deepstorageplus.utils.ItemBuilder; import me.darkolythe.deepstorageplus.utils.ItemList; import me.darkolythe.deepstorageplus.utils.LanguageManager; +import me.darkolythe.deepstorageplus.utils.item.misc.DSUWall; +import me.darkolythe.deepstorageplus.utils.item.misc.EmptyStorageSlot; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.BundleMeta; import org.bukkit.inventory.meta.ItemMeta; import java.util.*; @@ -90,8 +92,7 @@ public static ItemStack getDSUWall() { if (dsuWall != null) return dsuWall; - return dsuWall = new ItemBuilder(Material.PAPER) - .setModelData(20002) + return dsuWall = new DSUWall() .setName(ChatColor.DARK_GRAY + LanguageManager.getValue("dsuwalls")) .setItemMeta() .getItem(); @@ -101,8 +102,7 @@ public static ItemStack getDSUWall() { Create an Empty Block item to fill the dsu Inventory */ public static ItemStack getEmptyBlock() { - return new ItemBuilder(Material.PAPER) - .setModelData(20005) + return new EmptyStorageSlot() .setName(ChatColor.YELLOW + LanguageManager.getValue("emptystorageblock")) .setItemMeta() .getItem(); @@ -220,12 +220,13 @@ private static Material getType(String lore) { Update the container with the itemstack being added */ public static void addDataToContainer(ItemStack container, ItemStack item) { - if (container.hasItemMeta() && container.getItemMeta().hasDisplayName() && container.getItemMeta().getDisplayName().contains(LanguageManager.getValue("storagecontainer"))) { + if (container.getItemMeta() != null && ItemList.isStorageContainerItem(container)) { Material mat = item.getType(); int amount = item.getAmount(); int storage = countStorage(container, LanguageManager.getValue("currentstorage") + ": "); int types = countStorage(container, LanguageManager.getValue("currenttypes") + ": "); + HashSet mats = getTypes(container.getItemMeta().getLore()); int canAdd = Math.min(storage, amount); if (mats.contains(mat)) { //if the material is already stored in the container diff --git a/src/main/java/me/darkolythe/deepstorageplus/dsu/managers/SorterManager.java b/src/main/java/me/darkolythe/deepstorageplus/dsu/managers/SorterManager.java index 4efd4c8..36975e7 100644 --- a/src/main/java/me/darkolythe/deepstorageplus/dsu/managers/SorterManager.java +++ b/src/main/java/me/darkolythe/deepstorageplus/dsu/managers/SorterManager.java @@ -2,9 +2,10 @@ import me.darkolythe.deepstorageplus.DeepStoragePlus; import me.darkolythe.deepstorageplus.dsu.StorageUtils; -import me.darkolythe.deepstorageplus.utils.ItemBuilder; import me.darkolythe.deepstorageplus.utils.ItemList; import me.darkolythe.deepstorageplus.utils.LanguageManager; +import me.darkolythe.deepstorageplus.utils.item.misc.DSUWall; +import me.darkolythe.deepstorageplus.utils.item.misc.EmptyLinkModuleSlot; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Location; @@ -14,7 +15,6 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; import java.util.*; import java.util.stream.Collectors; @@ -50,8 +50,7 @@ public static ItemStack getSorterWall() { if (sorterWall != null) return sorterWall; - return sorterWall = new ItemBuilder(Material.PAPER) - .setModelData(20002) + return sorterWall = new DSUWall() .setName(ChatColor.DARK_GRAY + LanguageManager.getValue("sorterwalls")) .setItemMeta() .getItem(); @@ -61,8 +60,7 @@ public static ItemStack getSorterWall() { Create an Empty Block item to fill the dsu Inventory */ public static ItemStack getEmptyBlock() { - return new ItemBuilder(Material.PAPER) - .setModelData(20004) + return new EmptyLinkModuleSlot() .setName(ChatColor.YELLOW + LanguageManager.getValue("emptysorterblock")) .setItemMeta() .getItem(); diff --git a/src/main/java/me/darkolythe/deepstorageplus/utils/ItemList.java b/src/main/java/me/darkolythe/deepstorageplus/utils/ItemList.java index 4dd57a9..f5e1583 100644 --- a/src/main/java/me/darkolythe/deepstorageplus/utils/ItemList.java +++ b/src/main/java/me/darkolythe/deepstorageplus/utils/ItemList.java @@ -1,44 +1,53 @@ package me.darkolythe.deepstorageplus.utils; import me.darkolythe.deepstorageplus.DeepStoragePlus; +import me.darkolythe.deepstorageplus.utils.item.misc.LinkModule; +import me.darkolythe.deepstorageplus.utils.item.misc.SpeedUpgrade; +import me.darkolythe.deepstorageplus.utils.item.misc.WirelessReceiver; +import me.darkolythe.deepstorageplus.utils.item.misc.WirelessTerminal; +import me.darkolythe.deepstorageplus.utils.item.storagecells.StorageCell; +import me.darkolythe.deepstorageplus.utils.item.storagecontainer.StorageContainer; +import me.darkolythe.deepstorageplus.utils.item.wrench.SorterWrench; +import me.darkolythe.deepstorageplus.utils.item.wrench.StorageWrench; import org.bukkit.ChatColor; import org.bukkit.Material; -import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; import java.util.*; -import static me.darkolythe.deepstorageplus.dsu.managers.WirelessManager.createReceiver; -import static me.darkolythe.deepstorageplus.dsu.managers.WirelessManager.createTerminal; - public class ItemList { private DeepStoragePlus main; + // Wrenches public static final int SORTER_WRENCH_MODEL_ID = 20000; public static final int STORAGE_WRENCH_MODEL_ID = 20001; + + // Misc public static final int GUI_BACKGROUND_MODEL_ID = 20002; public static final int LINK_MODULE_MODEL_ID = 20003; public static final int LINK_SLOT_MODEL_ID = 20004; - public static final int STORAGE_SLOT_MODEL_ID = 20005; - public static final int RECEIVER_MODEL_ID = 20006; - public static final int TERMINAL_MODEL_ID = 20007; + public static final int SPEEDUPGRADE_MODEL_ID = 20005; + public static final int STORAGE_SLOT_MODEL_ID = 20006; + public static final int RECEIVER_MODEL_ID = 20007; + public static final int TERMINAL_MODEL_ID = 20008; - public static final int STORAGE_CELL_1K_MODEL_ID = 20008; - public static final int STORAGE_CELL_4K_MODEL_ID = 20009; - public static final int STORAGE_CELL_16K_MODEL_ID = 20010; - public static final int STORAGE_CELL_64K_MODEL_ID = 20011; - public static final int STORAGE_CELL_256K_MODEL_ID = 20012; - public static final int STORAGE_CELL_1M_MODEL_ID = 20013; + // Storage Cells + public static final int STORAGE_CELL_1K_MODEL_ID = 20009; + public static final int STORAGE_CELL_4K_MODEL_ID = 20010; + public static final int STORAGE_CELL_16K_MODEL_ID = 20011; + public static final int STORAGE_CELL_64K_MODEL_ID = 20012; + public static final int STORAGE_CELL_256K_MODEL_ID = 20013; + public static final int STORAGE_CELL_1M_MODEL_ID = 20014; - public static final int STORAGE_CONTAINER_1K_MODEL_ID = 20014; - public static final int STORAGE_CONTAINER_4K_MODEL_ID = 20015; - public static final int STORAGE_CONTAINER_16K_MODEL_ID = 20016; - public static final int STORAGE_CONTAINER_64K_MODEL_ID = 20017; - public static final int STORAGE_CONTAINER_256K_MODEL_ID = 20018; - public static final int STORAGE_CONTAINER_1M_MODEL_ID = 20019; + // Storage Containers + public static final int STORAGE_CONTAINER_1K_MODEL_ID = 20015; + public static final int STORAGE_CONTAINER_4K_MODEL_ID = 20016; + public static final int STORAGE_CONTAINER_16K_MODEL_ID = 20017; + public static final int STORAGE_CONTAINER_64K_MODEL_ID = 20018; + public static final int STORAGE_CONTAINER_256K_MODEL_ID = 20019; + public static final int STORAGE_CONTAINER_1M_MODEL_ID = 20020; public ItemStack storageCell1K; public ItemStack storageCell4K; @@ -66,105 +75,90 @@ public class ItemList { public ItemList(DeepStoragePlus plugin) { this.main = plugin; // set it equal to an instance of main - // Storage Cells - this.storageCell1K = new ItemBuilder(Material.PAPER) - .setModelData(STORAGE_CELL_1K_MODEL_ID) + this.storageCell1K = new StorageCell() + .setCustomModelData(STORAGE_CELL_1K_MODEL_ID) .setName(getStorageCellName(ChatColor.WHITE, "storagecell", ChatColor.GRAY, "1K")) .setItemMeta() .getItem(); - this.storageCell4K = new ItemBuilder(Material.PAPER) - .setModelData(STORAGE_CELL_4K_MODEL_ID) + this.storageCell4K = new StorageCell() + .setCustomModelData(STORAGE_CELL_4K_MODEL_ID) .setName(getStorageCellName(ChatColor.WHITE, "storagecell", ChatColor.WHITE, "4K")) .setItemMeta() .getItem(); - this.storageCell16K = new ItemBuilder(Material.PAPER) - .setModelData(STORAGE_CELL_16K_MODEL_ID) + this.storageCell16K = new StorageCell() + .setCustomModelData(STORAGE_CELL_16K_MODEL_ID) .setName(getStorageCellName(ChatColor.WHITE, "storagecell", ChatColor.YELLOW, "16K")) .setItemMeta() .getItem(); - this.storageCell64K = new ItemBuilder(Material.PAPER) - .setModelData(STORAGE_CELL_64K_MODEL_ID) + this.storageCell64K = new StorageCell() + .setCustomModelData(STORAGE_CELL_64K_MODEL_ID) .setName(getStorageCellName(ChatColor.WHITE, "storagecell", ChatColor.GREEN, "64K")) .setItemMeta() .getItem(); - this.storageCell256K = new ItemBuilder(Material.PAPER) - .setModelData(STORAGE_CELL_256K_MODEL_ID) + this.storageCell256K = new StorageCell() + .setCustomModelData(STORAGE_CELL_256K_MODEL_ID) .setName(getStorageCellName(ChatColor.WHITE, "storagecell", ChatColor.BLUE, "256K")) .setItemMeta() .getItem(); - this.storageCell1M = new ItemBuilder(Material.PAPER) - .setModelData(STORAGE_CELL_1M_MODEL_ID) + this.storageCell1M = new StorageCell() + .setCustomModelData(STORAGE_CELL_1M_MODEL_ID) .setName(getStorageCellName(ChatColor.WHITE, "storagecell", ChatColor.LIGHT_PURPLE, "1M")) .setItemMeta() .getItem(); // Storage Containers - this.storageContainer1K = new ItemBuilder(Material.GOLDEN_AXE) - .setModelData(STORAGE_CONTAINER_1K_MODEL_ID) + this.storageContainer1K = new StorageContainer() + .setCustomModelData(STORAGE_CONTAINER_1K_MODEL_ID) .setName(getStorageCellName(ChatColor.WHITE, "storagecontainer", ChatColor.GRAY, "1K")) .setLore(getStorageMaxConfig("1kmax")) - .setUnbreakable() - .setFlags(ItemFlag.HIDE_ATTRIBUTES, ItemFlag.HIDE_UNBREAKABLE) .setItemMeta() .getItem(); - this.storageContainer4K = new ItemBuilder(Material.GOLDEN_AXE) - .setModelData(STORAGE_CONTAINER_4K_MODEL_ID) + this.storageContainer4K = new StorageContainer() + .setCustomModelData(STORAGE_CONTAINER_4K_MODEL_ID) .setName(getStorageCellName(ChatColor.WHITE, "storagecontainer", ChatColor.WHITE, "4K")) .setLore(getStorageMaxConfig("4kmax")) - .setUnbreakable() - .setFlags(ItemFlag.HIDE_ATTRIBUTES, ItemFlag.HIDE_UNBREAKABLE) .setItemMeta() .getItem(); - this.storageContainer16K = new ItemBuilder(Material.GOLDEN_AXE) - .setModelData(STORAGE_CONTAINER_16K_MODEL_ID) + this.storageContainer16K = new StorageContainer() + .setCustomModelData(STORAGE_CONTAINER_16K_MODEL_ID) .setName(getStorageCellName(ChatColor.WHITE, "storagecontainer", ChatColor.YELLOW, "16K")) .setLore(getStorageMaxConfig("16kmax")) - .setUnbreakable() - .setFlags(ItemFlag.HIDE_ATTRIBUTES, ItemFlag.HIDE_UNBREAKABLE) .setItemMeta() .getItem(); - this.storageContainer64K = new ItemBuilder(Material.GOLDEN_AXE) - .setModelData(STORAGE_CONTAINER_64K_MODEL_ID) + this.storageContainer64K = new StorageContainer() + .setCustomModelData(STORAGE_CONTAINER_64K_MODEL_ID) .setName(getStorageCellName(ChatColor.WHITE, "storagecontainer", ChatColor.GREEN, "64K")) .setLore(getStorageMaxConfig("64kmax")) - .setUnbreakable() - .setFlags(ItemFlag.HIDE_ATTRIBUTES, ItemFlag.HIDE_UNBREAKABLE) .setItemMeta() .getItem(); - this.storageContainer256K = new ItemBuilder(Material.GOLDEN_AXE) - .setModelData(STORAGE_CONTAINER_256K_MODEL_ID) + this.storageContainer256K = new StorageContainer() + .setCustomModelData(STORAGE_CONTAINER_256K_MODEL_ID) .setName(getStorageCellName(ChatColor.WHITE, "storagecontainer", ChatColor.BLUE, "256K")) .setLore(getStorageMaxConfig("256kmax")) - .setUnbreakable() - .setFlags(ItemFlag.HIDE_ATTRIBUTES, ItemFlag.HIDE_UNBREAKABLE) .setItemMeta() .getItem(); - this.storageContainer1M = new ItemBuilder(Material.GOLDEN_AXE) - .setModelData(STORAGE_CONTAINER_1M_MODEL_ID) + this.storageContainer1M = new StorageContainer() + .setCustomModelData(STORAGE_CONTAINER_1M_MODEL_ID) .setName(getStorageCellName(ChatColor.WHITE, "storagecontainer", ChatColor.LIGHT_PURPLE, "1M")) .setLore(getStorageMaxConfig("1mmax")) - .setUnbreakable() - .setFlags(ItemFlag.HIDE_ATTRIBUTES, ItemFlag.HIDE_UNBREAKABLE) .setItemMeta() .getItem(); - this.creativeStorageContainer = new ItemBuilder(Material.GOLDEN_AXE) - .setModelData(STORAGE_CONTAINER_1M_MODEL_ID) - .setName(getStorageCellName(ChatColor.DARK_PURPLE, "creativestoragecontainer", ChatColor.GRAY, "")) + this.creativeStorageContainer = new StorageContainer() + .setCustomModelData(STORAGE_CONTAINER_1M_MODEL_ID) + .setName(getStorageCellName(ChatColor.WHITE, "storagecontainer", ChatColor.GRAY, "")) .setLore(Integer.MAX_VALUE) - .setUnbreakable() - .setFlags(ItemFlag.HIDE_ATTRIBUTES, ItemFlag.HIDE_UNBREAKABLE) .setItemMeta() .getItem(); @@ -176,14 +170,12 @@ public ItemList(DeepStoragePlus plugin) { // Link Module, Wireless Receiver and Wireless Terminal this.linkModule = createLinkModule(); - this.receiver = new ItemBuilder(Material.PAPER) - .setModelData(RECEIVER_MODEL_ID) + this.receiver = new WirelessReceiver() .setName(ChatColor.AQUA + LanguageManager.getValue("receiver")) .setItemMeta() .getItem(); - this.terminal = new ItemBuilder(Material.PAPER) - .setModelData(TERMINAL_MODEL_ID) + this.terminal = new WirelessTerminal() .setName(ChatColor.AQUA + LanguageManager.getValue("terminal")) .setLore(Arrays.asList( ChatColor.GRAY + "---------------------", @@ -242,6 +234,10 @@ public static boolean isStorageContainerItem(ItemStack item) { return false; } + if (item.getType() != Material.MUSIC_DISC_13) { + return false; + } + if (item.getItemMeta() == null || !item.hasItemMeta()) { return false; } @@ -262,8 +258,7 @@ public static boolean isDSPItem(ItemStack item, int modelId) { } public static ItemStack createStorageWrench() { - return new ItemBuilder(Material.PAPER) - .setModelData(STORAGE_WRENCH_MODEL_ID) + return new StorageWrench() .setName(ChatColor.AQUA + LanguageManager.getValue("storageloader")) .setLore(Arrays.asList( ChatColor.GRAY + LanguageManager.getValue("clickempty"), @@ -276,30 +271,28 @@ public static ItemStack createStorageWrench() { } public static ItemStack createSorterWrench() { - return new ItemBuilder(Material.PAPER) - .setModelData(SORTER_WRENCH_MODEL_ID) + return new SorterWrench() .setName(ChatColor.AQUA + LanguageManager.getValue("sorterloader")) .setItemMeta() .getItem(); } public static ItemStack createLinkModule() { - return new ItemBuilder(Material.PAPER) - .setModelData(LINK_MODULE_MODEL_ID) + return new LinkModule() .setName(ChatColor.AQUA + LanguageManager.getValue("linkmodule")) .setLore(Arrays.asList( - ChatColor.GRAY + "Click DSU to save", - ChatColor.GRAY + "DSU coordinates to this link module." + ChatColor.GRAY + "Click DSU to save coordinates", + ChatColor.GRAY + "to this link module." )) .setItemMeta() .getItem(); } public static ItemStack createSpeedUpgrade() { - return new ItemBuilder(Material.GLOWSTONE_DUST) + return new SpeedUpgrade() .setName(ChatColor.WHITE + ChatColor.BOLD.toString() + LanguageManager.getValue("ioupgrade")) .setLore(Collections.singletonList(ChatColor.GRAY + LanguageManager.getValue("clicktoupgrade"))) - .setFlags(ItemFlag.HIDE_ENCHANTS) + .hideEnchantment() .setItemMeta() .setEnchanted() .getItem(); diff --git a/src/main/java/me/darkolythe/deepstorageplus/utils/LanguageManager.java b/src/main/java/me/darkolythe/deepstorageplus/utils/LanguageManager.java index 7ce5a2a..2d3540d 100644 --- a/src/main/java/me/darkolythe/deepstorageplus/utils/LanguageManager.java +++ b/src/main/java/me/darkolythe/deepstorageplus/utils/LanguageManager.java @@ -1,6 +1,7 @@ package me.darkolythe.deepstorageplus.utils; import me.darkolythe.deepstorageplus.DeepStoragePlus; +import org.bukkit.ChatColor; import java.util.HashMap; import java.util.Map; @@ -86,10 +87,6 @@ public static void setup(DeepStoragePlus main) { } public static String getValue(String key) { - if (translateMap.containsKey(key)) { - return translateMap.get(key); - } else { - return "[Invalid Translate Key]"; - } + return ChatColor.translateAlternateColorCodes('&', translateMap.getOrDefault(key, "[Invalid Translate Key]")); } } diff --git a/src/main/java/me/darkolythe/deepstorageplus/utils/item/DSPItem.java b/src/main/java/me/darkolythe/deepstorageplus/utils/item/DSPItem.java new file mode 100644 index 0000000..546bc36 --- /dev/null +++ b/src/main/java/me/darkolythe/deepstorageplus/utils/item/DSPItem.java @@ -0,0 +1,16 @@ +package me.darkolythe.deepstorageplus.utils.item; + +import org.bukkit.inventory.ItemStack; + +import java.util.List; + +public interface DSPItem { + + public DSPItem setName(String name); + + public DSPItem setLore(List lore); + + public DSPItem setItemMeta(); + + public ItemStack getItem(); +} diff --git a/src/main/java/me/darkolythe/deepstorageplus/utils/item/misc/DSUWall.java b/src/main/java/me/darkolythe/deepstorageplus/utils/item/misc/DSUWall.java new file mode 100644 index 0000000..b323cb9 --- /dev/null +++ b/src/main/java/me/darkolythe/deepstorageplus/utils/item/misc/DSUWall.java @@ -0,0 +1,45 @@ +package me.darkolythe.deepstorageplus.utils.item.misc; + +import me.darkolythe.deepstorageplus.utils.ItemList; +import me.darkolythe.deepstorageplus.utils.item.DSPItem; +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +import java.util.List; +import java.util.Objects; + +public class DSUWall implements DSPItem{ + + private final ItemStack item; + private final ItemMeta meta; + + public DSUWall() { + this.item = new ItemStack(Material.PAPER); + this.meta = Objects.requireNonNull(item.getItemMeta()); + + meta.setCustomModelData(ItemList.GUI_BACKGROUND_MODEL_ID); + } + + @Override + public DSUWall setName(String name) { + meta.setDisplayName(name); + return this; + } + + @Override + public DSUWall setLore(List lore) { + return this; + } + + @Override + public DSUWall setItemMeta() { + item.setItemMeta(meta); + return this; + } + + @Override + public ItemStack getItem() { + return item; + } +} diff --git a/src/main/java/me/darkolythe/deepstorageplus/utils/item/misc/EmptyLinkModuleSlot.java b/src/main/java/me/darkolythe/deepstorageplus/utils/item/misc/EmptyLinkModuleSlot.java new file mode 100644 index 0000000..8828a3f --- /dev/null +++ b/src/main/java/me/darkolythe/deepstorageplus/utils/item/misc/EmptyLinkModuleSlot.java @@ -0,0 +1,45 @@ +package me.darkolythe.deepstorageplus.utils.item.misc; + +import me.darkolythe.deepstorageplus.utils.ItemList; +import me.darkolythe.deepstorageplus.utils.item.DSPItem; +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +import java.util.List; +import java.util.Objects; + +public class EmptyLinkModuleSlot implements DSPItem { + + private final ItemStack item; + private final ItemMeta meta; + + public EmptyLinkModuleSlot() { + this.item = new ItemStack(Material.PAPER); + this.meta = Objects.requireNonNull(item.getItemMeta()); + + meta.setCustomModelData(ItemList.LINK_SLOT_MODEL_ID); + } + + @Override + public EmptyLinkModuleSlot setName(String name) { + meta.setDisplayName(name); + return this; + } + + @Override + public EmptyLinkModuleSlot setLore(List lore) { + return this; + } + + @Override + public EmptyLinkModuleSlot setItemMeta() { + item.setItemMeta(meta); + return this; + } + + @Override + public ItemStack getItem() { + return item; + } +} diff --git a/src/main/java/me/darkolythe/deepstorageplus/utils/item/misc/EmptyStorageSlot.java b/src/main/java/me/darkolythe/deepstorageplus/utils/item/misc/EmptyStorageSlot.java new file mode 100644 index 0000000..7e1d50b --- /dev/null +++ b/src/main/java/me/darkolythe/deepstorageplus/utils/item/misc/EmptyStorageSlot.java @@ -0,0 +1,45 @@ +package me.darkolythe.deepstorageplus.utils.item.misc; + +import me.darkolythe.deepstorageplus.utils.ItemList; +import me.darkolythe.deepstorageplus.utils.item.DSPItem; +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +import java.util.List; +import java.util.Objects; + +public class EmptyStorageSlot implements DSPItem { + + private final ItemStack item; + private final ItemMeta meta; + + public EmptyStorageSlot() { + this.item = new ItemStack(Material.PAPER); + this.meta = Objects.requireNonNull(item.getItemMeta()); + + meta.setCustomModelData(ItemList.STORAGE_SLOT_MODEL_ID); + } + + @Override + public EmptyStorageSlot setName(String name) { + meta.setDisplayName(name); + return this; + } + + @Override + public EmptyStorageSlot setLore(List lore) { + return this; + } + + @Override + public EmptyStorageSlot setItemMeta() { + item.setItemMeta(meta); + return this; + } + + @Override + public ItemStack getItem() { + return item; + } +} diff --git a/src/main/java/me/darkolythe/deepstorageplus/utils/item/misc/LinkModule.java b/src/main/java/me/darkolythe/deepstorageplus/utils/item/misc/LinkModule.java new file mode 100644 index 0000000..c058159 --- /dev/null +++ b/src/main/java/me/darkolythe/deepstorageplus/utils/item/misc/LinkModule.java @@ -0,0 +1,48 @@ +package me.darkolythe.deepstorageplus.utils.item.misc; + +import me.darkolythe.deepstorageplus.utils.ItemList; +import me.darkolythe.deepstorageplus.utils.item.DSPItem; +import org.bukkit.Material; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.inventory.ItemFlag; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +import java.util.List; +import java.util.Objects; + +public class LinkModule implements DSPItem{ + + private final ItemStack item; + private final ItemMeta meta; + + public LinkModule() { + this.item = new ItemStack(Material.PAPER); + this.meta = Objects.requireNonNull(item.getItemMeta()); + + meta.setCustomModelData(ItemList.LINK_MODULE_MODEL_ID); + } + + @Override + public LinkModule setName(String name) { + meta.setDisplayName(name); + return this; + } + + @Override + public LinkModule setLore(List lore) { + meta.setLore(lore); + return this; + } + + @Override + public LinkModule setItemMeta() { + item.setItemMeta(meta); + return this; + } + + @Override + public ItemStack getItem() { + return item; + } +} diff --git a/src/main/java/me/darkolythe/deepstorageplus/utils/item/misc/SpeedUpgrade.java b/src/main/java/me/darkolythe/deepstorageplus/utils/item/misc/SpeedUpgrade.java new file mode 100644 index 0000000..32b6d64 --- /dev/null +++ b/src/main/java/me/darkolythe/deepstorageplus/utils/item/misc/SpeedUpgrade.java @@ -0,0 +1,58 @@ +package me.darkolythe.deepstorageplus.utils.item.misc; + +import me.darkolythe.deepstorageplus.utils.ItemList; +import me.darkolythe.deepstorageplus.utils.item.DSPItem; +import org.bukkit.Material; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.inventory.ItemFlag; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +import java.util.List; +import java.util.Objects; + +public class SpeedUpgrade implements DSPItem{ + + private final ItemStack item; + private final ItemMeta meta; + + public SpeedUpgrade() { + this.item = new ItemStack(Material.PAPER); + this.meta = Objects.requireNonNull(item.getItemMeta()); + + meta.setCustomModelData(ItemList.SPEEDUPGRADE_MODEL_ID); + } + + @Override + public SpeedUpgrade setName(String name) { + meta.setDisplayName(name); + return this; + } + + @Override + public SpeedUpgrade setLore(List lore) { + meta.setLore(lore); + return this; + } + + @Override + public SpeedUpgrade setItemMeta() { + item.setItemMeta(meta); + return this; + } + + @Override + public ItemStack getItem() { + return item; + } + + public SpeedUpgrade hideEnchantment() { + meta.addItemFlags(ItemFlag.HIDE_ENCHANTS); + return this; + } + + public SpeedUpgrade setEnchanted() { + item.addUnsafeEnchantment(Enchantment.ARROW_INFINITE, 1); + return this; + } +} diff --git a/src/main/java/me/darkolythe/deepstorageplus/utils/item/misc/WirelessReceiver.java b/src/main/java/me/darkolythe/deepstorageplus/utils/item/misc/WirelessReceiver.java new file mode 100644 index 0000000..49c4bb2 --- /dev/null +++ b/src/main/java/me/darkolythe/deepstorageplus/utils/item/misc/WirelessReceiver.java @@ -0,0 +1,46 @@ +package me.darkolythe.deepstorageplus.utils.item.misc; + +import me.darkolythe.deepstorageplus.utils.ItemList; +import me.darkolythe.deepstorageplus.utils.item.DSPItem; +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +import java.util.List; +import java.util.Objects; + +public class WirelessReceiver implements DSPItem{ + + private final ItemStack item; + private final ItemMeta meta; + + public WirelessReceiver() { + this.item = new ItemStack(Material.PAPER); + this.meta = Objects.requireNonNull(item.getItemMeta()); + + this.meta.setCustomModelData(ItemList.RECEIVER_MODEL_ID); + } + + @Override + public WirelessReceiver setName(String name) { + meta.setDisplayName(name); + return this; + } + + @Override + public WirelessReceiver setLore(List lore) { + meta.setLore(lore); + return this; + } + + @Override + public WirelessReceiver setItemMeta() { + item.setItemMeta(meta); + return this; + } + + @Override + public ItemStack getItem() { + return item; + } +} diff --git a/src/main/java/me/darkolythe/deepstorageplus/utils/item/misc/WirelessTerminal.java b/src/main/java/me/darkolythe/deepstorageplus/utils/item/misc/WirelessTerminal.java new file mode 100644 index 0000000..ad77b4a --- /dev/null +++ b/src/main/java/me/darkolythe/deepstorageplus/utils/item/misc/WirelessTerminal.java @@ -0,0 +1,58 @@ +package me.darkolythe.deepstorageplus.utils.item.misc; + +import me.darkolythe.deepstorageplus.utils.ItemList; +import me.darkolythe.deepstorageplus.utils.item.DSPItem; +import org.bukkit.Material; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.inventory.ItemFlag; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +import java.util.List; +import java.util.Objects; + +public class WirelessTerminal implements DSPItem{ + + private final ItemStack item; + private final ItemMeta meta; + + public WirelessTerminal() { + this.item = new ItemStack(Material.PAPER); + this.meta = Objects.requireNonNull(item.getItemMeta()); + + this.meta.setCustomModelData(ItemList.TERMINAL_MODEL_ID); + } + + @Override + public WirelessTerminal setName(String name) { + meta.setDisplayName(name); + return this; + } + + @Override + public WirelessTerminal setLore(List lore) { + meta.setLore(lore); + return this; + } + + @Override + public WirelessTerminal setItemMeta() { + item.setItemMeta(meta); + return this; + } + + @Override + public ItemStack getItem() { + return item; + } + + public WirelessTerminal hideEnchantment() { + meta.addItemFlags(ItemFlag.HIDE_ENCHANTS); + return this; + } + + public WirelessTerminal setEnchanted() { + item.addUnsafeEnchantment(Enchantment.ARROW_INFINITE, 1); + return this; + } +} diff --git a/src/main/java/me/darkolythe/deepstorageplus/utils/item/storagecells/StorageCell.java b/src/main/java/me/darkolythe/deepstorageplus/utils/item/storagecells/StorageCell.java new file mode 100644 index 0000000..0bd1924 --- /dev/null +++ b/src/main/java/me/darkolythe/deepstorageplus/utils/item/storagecells/StorageCell.java @@ -0,0 +1,49 @@ +package me.darkolythe.deepstorageplus.utils.item.storagecells; + +import me.darkolythe.deepstorageplus.utils.item.DSPItem; +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.BundleMeta; +import org.bukkit.inventory.meta.ItemMeta; + +import java.util.List; +import java.util.Objects; + +public class StorageCell implements DSPItem{ + + private final ItemStack item; + private final ItemMeta meta; + + public StorageCell() { + this.item = new ItemStack(Material.PAPER); + this.meta = Objects.requireNonNull(item.getItemMeta()); + } + + @Override + public StorageCell setName(String name) { + meta.setDisplayName(name); + return this; + } + + @Override + public StorageCell setLore(List lore) { + meta.setLore(lore); + return this; + } + + @Override + public StorageCell setItemMeta() { + item.setItemMeta(meta); + return this; + } + + @Override + public ItemStack getItem() { + return item; + } + + public StorageCell setCustomModelData(int modelData) { + meta.setCustomModelData(modelData); + return this; + } +} diff --git a/src/main/java/me/darkolythe/deepstorageplus/utils/ItemBuilder.java b/src/main/java/me/darkolythe/deepstorageplus/utils/item/storagecontainer/StorageContainer.java similarity index 50% rename from src/main/java/me/darkolythe/deepstorageplus/utils/ItemBuilder.java rename to src/main/java/me/darkolythe/deepstorageplus/utils/item/storagecontainer/StorageContainer.java index e620d13..a459c9f 100644 --- a/src/main/java/me/darkolythe/deepstorageplus/utils/ItemBuilder.java +++ b/src/main/java/me/darkolythe/deepstorageplus/utils/item/storagecontainer/StorageContainer.java @@ -1,75 +1,64 @@ -package me.darkolythe.deepstorageplus.utils; +package me.darkolythe.deepstorageplus.utils.item.storagecontainer; +import me.darkolythe.deepstorageplus.utils.LanguageManager; +import me.darkolythe.deepstorageplus.utils.item.DSPItem; import org.bukkit.ChatColor; import org.bukkit.Material; -import org.bukkit.enchantments.Enchantment; -import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import java.util.ArrayList; import java.util.List; +import java.util.Objects; -public class ItemBuilder { +public class StorageContainer implements DSPItem{ private final ItemStack item; private final ItemMeta meta; - public ItemBuilder(Material material) { - this.item = new ItemStack(material); - this.meta = item.getItemMeta(); + public StorageContainer() { + this.item = new ItemStack(Material.MUSIC_DISC_13); + this.meta = Objects.requireNonNull(item.getItemMeta()); } - public ItemBuilder setName(String name) { + @Override + public StorageContainer setName(String name) { meta.setDisplayName(name); return this; } - public ItemBuilder setLore(int maxSize) { - List lore = new ArrayList<>(); - - lore.add(ChatColor.GREEN + LanguageManager.getValue("currentstorage") + ": " + 0 + "/" + maxSize); - lore.add(ChatColor.GREEN + LanguageManager.getValue("currenttypes") + ": " + 0 + "/" + 7); - - for (int i = 0; i < 7; i++) { - lore.add(ChatColor.GRAY + " - " + LanguageManager.getValue("empty")); - } - - this.setLore(lore); - return this; - } - - public ItemBuilder setLore(List lore) { + @Override + public StorageContainer setLore(List lore) { meta.setLore(lore); return this; } - public ItemBuilder setModelData(int modelData) { - meta.setCustomModelData(modelData); - return this; - } - - public ItemBuilder setUnbreakable() { - meta.setUnbreakable(true); - return this; - } - - public ItemBuilder setEnchanted() { - item.addUnsafeEnchantment(Enchantment.DURABILITY, 1); + @Override + public StorageContainer setItemMeta() { + item.setItemMeta(meta); return this; } - public ItemBuilder setFlags(ItemFlag... flags) { - meta.addItemFlags(flags); - return this; + @Override + public ItemStack getItem() { + return item; } - public ItemBuilder setItemMeta() { - item.setItemMeta(meta); + public StorageContainer setCustomModelData(int modelData){ + meta.setCustomModelData(modelData); return this; } - public ItemStack getItem() { - return item; + public StorageContainer setLore(int maxSize) { + List lore = new ArrayList<>(); + + lore.add(ChatColor.GREEN + LanguageManager.getValue("currentstorage") + ": " + 0 + "/" + maxSize); + lore.add(ChatColor.GREEN + LanguageManager.getValue("currenttypes") + ": " + 0 + "/7"); + + for (int i = 0; i < 7; i++) { + lore.add(ChatColor.GRAY + " - " + LanguageManager.getValue("empty")); + } + + return setLore(lore); } } diff --git a/src/main/java/me/darkolythe/deepstorageplus/utils/item/wrench/SorterWrench.java b/src/main/java/me/darkolythe/deepstorageplus/utils/item/wrench/SorterWrench.java new file mode 100644 index 0000000..09a6258 --- /dev/null +++ b/src/main/java/me/darkolythe/deepstorageplus/utils/item/wrench/SorterWrench.java @@ -0,0 +1,47 @@ +package me.darkolythe.deepstorageplus.utils.item.wrench; + +import me.darkolythe.deepstorageplus.utils.ItemList; +import me.darkolythe.deepstorageplus.utils.item.DSPItem; +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +import java.util.List; +import java.util.Objects; + +public class SorterWrench implements DSPItem{ + + private final ItemStack item; + private final ItemMeta meta; + + public SorterWrench() { + this.item = new ItemStack(Material.PAPER); + this.meta = Objects.requireNonNull(item.getItemMeta()); + + meta.setCustomModelData(ItemList.SORTER_WRENCH_MODEL_ID); + } + + + @Override + public SorterWrench setName(String name) { + meta.setDisplayName(name); + return this; + } + + @Override + public SorterWrench setLore(List lore) { + meta.setLore(lore); + return this; + } + + @Override + public SorterWrench setItemMeta() { + item.setItemMeta(meta); + return this; + } + + @Override + public ItemStack getItem() { + return item; + } +} diff --git a/src/main/java/me/darkolythe/deepstorageplus/utils/item/wrench/StorageWrench.java b/src/main/java/me/darkolythe/deepstorageplus/utils/item/wrench/StorageWrench.java new file mode 100644 index 0000000..a5c8f1d --- /dev/null +++ b/src/main/java/me/darkolythe/deepstorageplus/utils/item/wrench/StorageWrench.java @@ -0,0 +1,46 @@ +package me.darkolythe.deepstorageplus.utils.item.wrench; + +import me.darkolythe.deepstorageplus.utils.ItemList; +import me.darkolythe.deepstorageplus.utils.item.DSPItem; +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +import java.util.List; +import java.util.Objects; + +public class StorageWrench implements DSPItem{ + + private final ItemStack item; + private final ItemMeta meta; + + public StorageWrench() { + this.item = new ItemStack(Material.PAPER); + this.meta = Objects.requireNonNull(item.getItemMeta()); + + this.meta.setCustomModelData(ItemList.STORAGE_WRENCH_MODEL_ID); + } + + @Override + public StorageWrench setName(String name) { + meta.setDisplayName(name); + return this; + } + + @Override + public StorageWrench setLore(List lore) { + meta.setLore(lore); + return this; + } + + @Override + public StorageWrench setItemMeta() { + item.setItemMeta(meta); + return this; + } + + @Override + public ItemStack getItem() { + return item; + } +}