diff --git a/src/main/java/com/gmail/justbru00/epic/rename/spikeyutils/I.java b/src/main/java/com/gmail/justbru00/epic/rename/spikeyutils/I.java deleted file mode 100644 index 74fc429..0000000 --- a/src/main/java/com/gmail/justbru00/epic/rename/spikeyutils/I.java +++ /dev/null @@ -1,81 +0,0 @@ -package com.gmail.justbru00.epic.rename.spikeyutils; - -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; - -public class I { - public static ItemStack getFiller() { - ItemStack i = new ItemStack(Material.LIGHT_GRAY_STAINED_GLASS_PANE); - ItemMeta itemMeta = i.getItemMeta(); - itemMeta.setDisplayName(ChatColor.RESET + ""); - i.setItemMeta(itemMeta); - return i; - } - - public static ItemStack getVisibleFiller() { - ItemStack i = new ItemStack(Material.GRAY_STAINED_GLASS_PANE); - ItemMeta itemMeta = i.getItemMeta(); - itemMeta.setDisplayName(ChatColor.RESET + ""); - i.setItemMeta(itemMeta); - return i; - } - - public static ItemStack getEnabled() { - ItemStack i = new ItemStack(Material.LIME_DYE); - ItemMeta itemMeta = i.getItemMeta(); - itemMeta.setDisplayName(ChatColor.GREEN + "Enabled"); - i.setItemMeta(itemMeta); - return i; - } - - public static ItemStack getDisabled() { - ItemStack i = new ItemStack(Material.RED_DYE); - ItemMeta itemMeta = i.getItemMeta(); - itemMeta.setDisplayName(ChatColor.RED + "Disabled"); - i.setItemMeta(itemMeta); - return i; - } - - public static ItemStack getConfirm() { - ItemStack i = new ItemStack(Material.LIME_DYE); - ItemMeta itemMeta = i.getItemMeta(); - itemMeta.setDisplayName(ChatColor.GREEN + "Confirm"); - i.setItemMeta(itemMeta); - return i; - } - - public static ItemStack getDeny() { - ItemStack i = new ItemStack(Material.RED_DYE); - ItemMeta itemMeta = i.getItemMeta(); - itemMeta.setDisplayName(ChatColor.RED + "Deny"); - i.setItemMeta(itemMeta); - return i; - } - - public static ItemStack getBack() { - ItemStack i = new ItemStack(Material.ARROW); - ItemMeta itemMeta = i.getItemMeta(); - itemMeta.setDisplayName(ChatColor.RED + "Back"); - i.setItemMeta(itemMeta); - return i; - } - - public static ItemStack getNext() { - ItemStack i = new ItemStack(Material.ARROW); - ItemMeta itemMeta = i.getItemMeta(); - itemMeta.setDisplayName(ChatColor.RED + "Next"); - i.setItemMeta(itemMeta); - return i; - } - - public static ItemStack setName(ItemStack i, String s) { - ItemMeta itemMeta = i.getItemMeta(); - itemMeta.setDisplayName(s); - ItemStack itemStack = i.clone(); - itemStack.setItemMeta(itemMeta); - return itemStack; - } - -} diff --git a/src/main/java/com/gmail/justbru00/epic/rename/spikeyutils/StringUtils.java b/src/main/java/com/gmail/justbru00/epic/rename/spikeyutils/StringUtils.java deleted file mode 100644 index d5f3d85..0000000 --- a/src/main/java/com/gmail/justbru00/epic/rename/spikeyutils/StringUtils.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.gmail.justbru00.epic.rename.spikeyutils; - -import org.bukkit.ChatColor; - -public class StringUtils { - - public static String formatColors(String string) { - return ChatColor.translateAlternateColorCodes('&', string); - } - - - public static String centerText(String string) { - StringBuilder tmp = new StringBuilder(); - - int num = 27 - ChatColor.stripColor(string).length(); - - for (int x = 0; x < num; x++) { - tmp.append(" "); - } - - return tmp.toString() + string; - } -} diff --git a/src/main/java/com/gmail/justbru00/epic/rename/spikeyutils/inventory/BaseInventory.java b/src/main/java/com/gmail/justbru00/epic/rename/spikeyutils/inventory/BaseInventory.java deleted file mode 100644 index 3f237e8..0000000 --- a/src/main/java/com/gmail/justbru00/epic/rename/spikeyutils/inventory/BaseInventory.java +++ /dev/null @@ -1,105 +0,0 @@ -package com.gmail.justbru00.epic.rename.spikeyutils.inventory; - -import com.gmail.justbru00.epic.rename.spikeyutils.StringUtils; -import com.google.common.collect.Maps; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.inventory.ClickType; -import org.bukkit.event.inventory.InventoryClickEvent; -import org.bukkit.event.inventory.InventoryCloseEvent; -import org.bukkit.event.player.PlayerDropItemEvent; -import org.bukkit.inventory.Inventory; -import org.bukkit.inventory.InventoryHolder; -import org.bukkit.inventory.ItemStack; -import org.bukkit.plugin.Plugin; -import org.jetbrains.annotations.NotNull; - -import java.util.HashMap; -import java.util.Map; -import java.util.function.Consumer; - -public class BaseInventory implements InventoryHolder, Listener { - private Inventory inventory; - private HashMap> clickableItems; - private boolean isOpen = false; - private Player player; - - public BaseInventory(int rows, Plugin plugin, String title, Player player) { - clickableItems = Maps.newHashMap(); - this.inventory = Bukkit.createInventory(this, rows*9, StringUtils.formatColors(title)); - Bukkit.getPluginManager().registerEvents(this, plugin); - this.player = player; - } - - public void addItem(int slot, ItemStack item) { - clickableItems.remove(slot); - inventory.setItem(slot, item); - } - - public void addItem(int slot, ItemStack item, Consumer runnable) { - clickableItems.put(slot, runnable); - inventory.setItem(slot, item); - } - - public void fillInventory(ItemStack item) { - for (int x = 0; x < inventory.getSize(); x++) { - if (clickableItems.containsKey(x)) clickableItems.remove(x); - inventory.setItem(x, item); - } - } - - public void open(Player player) { - isOpen = true; - player.openInventory(inventory); - - } - - - @Override - public @NotNull Inventory getInventory() { - return inventory; - } - - @EventHandler - public void onClick(InventoryClickEvent event) { - - if (event.getClickedInventory() == null) return; - if (!((Player) event.getWhoClicked()).equals(player)) return; - - if (!event.getClickedInventory().equals(inventory)) { - if (event.getClickedInventory().equals(event.getWhoClicked().getInventory()) && isOpen) { - event.setCancelled(true); - } - return; - } - - - event.setCancelled(true); - - for (Map.Entry> entry : clickableItems.entrySet()) { - if (event.getSlot() != entry.getKey()) continue; - if (event.getClick().equals(ClickType.LEFT)) entry.getValue().accept(ClickType.LEFT); - if (event.getClick().equals(ClickType.RIGHT)) entry.getValue().accept(ClickType.RIGHT); - if (event.getClick().equals(ClickType.SHIFT_LEFT)) entry.getValue().accept(ClickType.SHIFT_LEFT); - if (event.getClick().equals(ClickType.SHIFT_RIGHT)) entry.getValue().accept(ClickType.SHIFT_RIGHT); - } - } - - @EventHandler - public void onClose(InventoryCloseEvent event) { - if (!event.getInventory().equals(inventory)) return; - - isOpen = false; - } - - @EventHandler - public void dropItemEvent(PlayerDropItemEvent event) { - if (!event.getPlayer().equals(player)) return; - if (!isOpen) return; - event.setCancelled(true); - - } - -} diff --git a/src/main/java/com/gmail/justbru00/epic/rename/spikeyutils/inventory/ConfirmInventory.java b/src/main/java/com/gmail/justbru00/epic/rename/spikeyutils/inventory/ConfirmInventory.java deleted file mode 100644 index b7ec240..0000000 --- a/src/main/java/com/gmail/justbru00/epic/rename/spikeyutils/inventory/ConfirmInventory.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.gmail.justbru00.epic.rename.spikeyutils.inventory; - -import com.gmail.justbru00.epic.rename.spikeyutils.I; -import org.bukkit.entity.Player; -import org.bukkit.plugin.Plugin; - -import java.util.function.Consumer; - -public class ConfirmInventory extends BaseInventory { - public ConfirmInventory(Plugin plugin, String title, Player player, Consumer consumer) { - super(1, plugin, title, player); - - fillInventory(I.getFiller()); - - addItem(2, I.getDeny(), (clickType) -> { - player.closeInventory(); - consumer.accept(false); - - - }); - - addItem(6, I.getConfirm(), (clickType) -> { - player.closeInventory(); - consumer.accept(true); - - }); - } -} diff --git a/src/main/java/com/gmail/justbru00/epic/rename/utils/v3/LoreUtil.java b/src/main/java/com/gmail/justbru00/epic/rename/utils/v3/LoreUtil.java index ec79086..c0ce649 100644 --- a/src/main/java/com/gmail/justbru00/epic/rename/utils/v3/LoreUtil.java +++ b/src/main/java/com/gmail/justbru00/epic/rename/utils/v3/LoreUtil.java @@ -8,7 +8,6 @@ import java.util.ArrayList; import java.util.List; -import com.gmail.justbru00.epic.rename.spikeyutils.inventory.ConfirmInventory; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -225,39 +224,24 @@ public static void loreHandle(String[] args, Player player) { if (Main.USE_NEW_GET_HAND) { // Use 1.9+ method - new ConfirmInventory(Main.plugin, "Set Lore", player, (b) -> { - if (b) { - ItemStack iH = RenameUtil.getInHand(player); - ItemStack toLore = iH.clone(); - ItemMeta toLoreMeta = toLore.getItemMeta(); - toLoreMeta.setLore(LoreUtil.buildLoreFromArgs(args, true)); - toLore.setItemMeta(toLoreMeta); - iH.setAmount(0); - player.getInventory().setItemInMainHand(toLore); - Main.cooldownAPI.updateCooldown(player, 6); - Messager.msgPlayer(Main.getMsgFromConfig("lore.success"), player); - } else { - player.sendMessage("Lore not applied."); - } - }).open(player); - return; + ItemStack toLore = inHand.clone(); + ItemMeta toLoreMeta = toLore.getItemMeta(); + toLoreMeta.setLore(LoreUtil.buildLoreFromArgs(args, true)); + toLore.setItemMeta(toLoreMeta); + inHand.setAmount(0); + player.getInventory().setItemInMainHand(toLore); + Main.cooldownAPI.updateCooldown(player, 6); + Messager.msgPlayer(Main.getMsgFromConfig("lore.success"), player); } else { // Use older method. - new ConfirmInventory(Main.plugin, "Set Lore", player, (b) -> { - if (b) { - ItemStack iH = RenameUtil.getInHand(player); - ItemStack toLore = iH.clone(); - ItemMeta toLoreMeta = toLore.getItemMeta(); - toLoreMeta.setLore(LoreUtil.buildLoreFromArgs(args, true)); - toLore.setItemMeta(toLoreMeta); - iH.setAmount(0); - player.setItemInHand(toLore); - Main.cooldownAPI.updateCooldown(player, 6); - Messager.msgPlayer(Main.getMsgFromConfig("lore.success"), player); - } else { - player.sendMessage("Lore not applied."); - } - }).open(player); - return; + ItemStack iH = RenameUtil.getInHand(player); + ItemStack toLore = iH.clone(); + ItemMeta toLoreMeta = toLore.getItemMeta(); + toLoreMeta.setLore(LoreUtil.buildLoreFromArgs(args, true)); + toLore.setItemMeta(toLoreMeta); + iH.setAmount(0); + player.setItemInHand(toLore); + Main.cooldownAPI.updateCooldown(player, 6); + Messager.msgPlayer(Main.getMsgFromConfig("lore.success"), player); } } else {