diff --git a/resource/plugin.yml b/resource/plugin.yml index ea10df0..723a6fa 100644 --- a/resource/plugin.yml +++ b/resource/plugin.yml @@ -1,4 +1,4 @@ -version: 3.15.6.2 +version: 3.15.7.0 main: me.rockyhawk.commandpanels.CommandPanels name: CommandPanels author: RockyHawk diff --git a/src/me/rockyhawk/commandpanels/CommandPanels.java b/src/me/rockyhawk/commandpanels/CommandPanels.java index fcffd1e..41f143e 100644 --- a/src/me/rockyhawk/commandpanels/CommandPanels.java +++ b/src/me/rockyhawk/commandpanels/CommandPanels.java @@ -239,7 +239,7 @@ public class CommandPanels extends JavaPlugin{ })); //get tag - tag = tex.papi(config.getString("config.format.tag") + " "); + tag = tex.colour(config.getString("config.format.tag") + " "); Bukkit.getLogger().info("[CommandPanels] RockyHawk's CommandPanels v" + this.getDescription().getVersion() + " Plugin Loaded!"); } @@ -261,10 +261,10 @@ public class CommandPanels extends JavaPlugin{ ItemMeta renamedMeta = renamed.getItemMeta(); //set cp placeholders if(usePlaceholders){ - customName = tex.papiNoColour(panel,p,customName); + customName = tex.placeholdersNoColour(panel,p,customName); } if(useColours){ - customName = tex.papi(customName); + customName = tex.colour(customName); } assert renamedMeta != null; @@ -279,11 +279,11 @@ public class CommandPanels extends JavaPlugin{ List clore; if (lore != null) { if(usePlaceholders && useColours){ - clore = tex.papi(panel, p, lore, true); + clore = tex.placeholdersList(panel, p, lore, true); }else if(usePlaceholders){ - clore = tex.papiNoColour(panel,p, lore); + clore = tex.placeholdersNoColour(panel,p, lore); }else if(useColours){ - clore = tex.papi(panel, p, lore, false); + clore = tex.placeholdersList(panel, p, lore, false); }else{ clore = lore; } @@ -328,7 +328,7 @@ public class CommandPanels extends JavaPlugin{ ArrayList opanelsTemp = new ArrayList(); for(String tempName : apanels){ if(opanelsTemp.contains(tempName)){ - sender.sendMessage(tex.papi(tag) + ChatColor.RED + " Error duplicate panel name: " + tempName); + sender.sendMessage(tex.colour(tag) + ChatColor.RED + " Error duplicate panel name: " + tempName); return false; } opanelsTemp.add(tempName); @@ -392,7 +392,7 @@ public class CommandPanels extends JavaPlugin{ } public void helpMessage(CommandSender p) { - p.sendMessage(tex.papi( tag + ChatColor.GREEN + "Commands:")); + p.sendMessage(tex.colour( tag + ChatColor.GREEN + "Commands:")); p.sendMessage(ChatColor.GOLD + "/cp [player:item] [player] " + ChatColor.WHITE + "Open a command panel."); if (p.hasPermission("commandpanel.reload")) { p.sendMessage(ChatColor.GOLD + "/cpr " + ChatColor.WHITE + "Reloads plugin config."); diff --git a/src/me/rockyhawk/commandpanels/Utils.java b/src/me/rockyhawk/commandpanels/Utils.java index 34db691..8a8435f 100644 --- a/src/me/rockyhawk/commandpanels/Utils.java +++ b/src/me/rockyhawk/commandpanels/Utils.java @@ -150,7 +150,7 @@ public class Utils implements Listener { //end custom command PlaceHolders //make the command - String command = plugin.tex.papi(panel,p,commands.get(i)); + String command = plugin.tex.placeholders(panel,p,commands.get(i)); int val = plugin.commandTags.commandPayWall(p,command); if(val == 0){ diff --git a/src/me/rockyhawk/commandpanels/api/Panel.java b/src/me/rockyhawk/commandpanels/api/Panel.java index 4c44b9c..463a941 100644 --- a/src/me/rockyhawk/commandpanels/api/Panel.java +++ b/src/me/rockyhawk/commandpanels/api/Panel.java @@ -79,7 +79,8 @@ public class Panel{ public ItemStack getHotbarItem(Player p){ ConfigurationSection itemSection = panelConfig.getConfigurationSection("open-with-item"); - return plugin.itemCreate.makeItemFromConfig(this,itemSection, p, true, true, false); + ItemStack s = plugin.itemCreate.makeItemFromConfig(this,itemSection, p, true, true, false); + return plugin.nbt.setNBT(s,"CommandPanelsHotbar",panelName); } public boolean hasHotbarItem(){ diff --git a/src/me/rockyhawk/commandpanels/classresources/ExecuteOpenVoids.java b/src/me/rockyhawk/commandpanels/classresources/ExecuteOpenVoids.java index 928dea8..e96bef1 100644 --- a/src/me/rockyhawk/commandpanels/classresources/ExecuteOpenVoids.java +++ b/src/me/rockyhawk/commandpanels/classresources/ExecuteOpenVoids.java @@ -7,11 +7,9 @@ import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Sound; import org.bukkit.command.CommandSender; -import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.Player; import org.bukkit.event.inventory.InventoryType; -import org.bukkit.inventory.ItemStack; import java.util.List; import java.util.Objects; @@ -33,14 +31,14 @@ public class ExecuteOpenVoids { panel.setConfig(YamlConfiguration.loadConfiguration(panel.getFile())); } if (!sender.hasPermission("commandpanel.panel." + panel.getConfig().getString("perm"))) { - sender.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.perms"))); + sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms"))); return; } //if the sender has OTHER perms, or if sendOpenedMessage is false, implying it is not for another person if(sender.hasPermission("commandpanel.other") || !openForOtherUser) { //check for disabled worlds if(!plugin.panelPerms.isPanelWorldEnabled(p,panel.getConfig())){ - sender.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.perms"))); + sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms"))); return; } @@ -77,7 +75,7 @@ public class ExecuteOpenVoids { } } }catch(Exception s){ - p.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.error") + " " + "commands-on-open: " + panel.getConfig().getString("commands-on-open"))); + p.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.error") + " " + "commands-on-open: " + panel.getConfig().getString("commands-on-open"))); } } @@ -87,66 +85,58 @@ public class ExecuteOpenVoids { try { p.playSound(p.getLocation(), Sound.valueOf(Objects.requireNonNull(panel.getConfig().getString("sound-on-open")).toUpperCase()), 1F, 1F); } catch (Exception s) { - p.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.error") + " " + "sound-on-open: " + panel.getConfig().getString("sound-on-open"))); + p.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.error") + " " + "sound-on-open: " + panel.getConfig().getString("sound-on-open"))); } } } if(openForOtherUser) { - sender.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Panel Opened for " + p.getDisplayName())); + sender.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Panel Opened for " + p.getDisplayName())); } } catch (Exception r) { plugin.debug(r,null); - sender.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.error"))); + sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.error"))); plugin.openPanels.closePanelForLoader(p.getName()); p.closeInventory(); } }else{ - sender.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.perms"))); + sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms"))); } } //this will give a hotbar item to a player - public void giveHotbarItem(CommandSender sender, Player p, ConfigurationSection cf, boolean sendGiveMessage){ - if (sender.hasPermission("commandpanel.item." + cf.getString("perm")) && cf.contains("open-with-item")) { + public void giveHotbarItem(CommandSender sender, Player p, Panel panel, boolean sendGiveMessage){ + if (sender.hasPermission("commandpanel.item." + panel.getConfig().getString("perm")) && panel.getConfig().contains("open-with-item")) { //check for disabled worlds - if(!plugin.panelPerms.isPanelWorldEnabled(p,cf)){ - sender.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.perms"))); + if(!plugin.panelPerms.isPanelWorldEnabled(p,panel.getConfig())){ + sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms"))); return; } - ItemStack s; - try { - s = plugin.itemCreate.makeItemFromConfig(null,Objects.requireNonNull(cf.getConfigurationSection("open-with-item")), p, false, true, false); - }catch(Exception n){ - sender.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.error") + " open-with-item: material")); - return; - } - plugin.setName(null,s, cf.getString("open-with-item.name"), cf.getStringList("open-with-item.lore"),p,false, true, true); //if the sender has OTHER perms, or if sendGiveMessage is false, implying it is not for another person if(sender.hasPermission("commandpanel.other") || !sendGiveMessage) { try { - if(cf.contains("open-with-item.stationary")) { - p.getInventory().setItem(Integer.parseInt(Objects.requireNonNull(cf.getString("open-with-item.stationary"))), s); + if(panel.getConfig().contains("open-with-item.stationary")) { + p.getInventory().setItem(Integer.parseInt(Objects.requireNonNull(panel.getConfig().getString("open-with-item.stationary"))), panel.getHotbarItem(p)); }else{ - p.getInventory().addItem(s); + p.getInventory().addItem(panel.getHotbarItem(p)); } if(sendGiveMessage) { - sender.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Item Given to " + p.getDisplayName())); + sender.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Item Given to " + p.getDisplayName())); } } catch (Exception r) { - sender.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.notitem"))); + sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.notitem"))); } }else{ - sender.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.perms"))); + sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms"))); } return; } - if (!cf.contains("open-with-item")) { - sender.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.noitem"))); + if (!panel.getConfig().contains("open-with-item")) { + sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.noitem"))); return; } - sender.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.perms"))); + sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms"))); } public void beforeLoadCommands(Panel panel, Player p){ @@ -163,7 +153,7 @@ public class ExecuteOpenVoids { } } }catch(Exception s){ - p.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.error") + " " + "pre-load-commands: " + panel.getConfig().getString("pre-load-commands"))); + p.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.error") + " " + "pre-load-commands: " + panel.getConfig().getString("pre-load-commands"))); plugin.debug(s,p); } } diff --git a/src/me/rockyhawk/commandpanels/classresources/ItemCreation.java b/src/me/rockyhawk/commandpanels/classresources/ItemCreation.java index 5d9ff1e..0e5e9e8 100644 --- a/src/me/rockyhawk/commandpanels/classresources/ItemCreation.java +++ b/src/me/rockyhawk/commandpanels/classresources/ItemCreation.java @@ -41,14 +41,14 @@ public class ItemCreation { @SuppressWarnings("deprecation") public ItemStack makeItemFromConfig(Panel panel, ConfigurationSection itemSection, Player p, boolean placeholders, boolean colours, boolean addNBT){ - String material = plugin.tex.papiNoColour(panel,p,itemSection.getString("material")); + String material = plugin.tex.placeholdersNoColour(panel,p,itemSection.getString("material")); try { if (Objects.requireNonNull(material).equalsIgnoreCase("AIR")) { return null; } }catch(NullPointerException e){ plugin.debug(e,p); - p.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.error") + " material: could not load material!")); + p.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.error") + " material: could not load material!")); return null; } ItemStack s = null; @@ -120,7 +120,7 @@ public class ItemCreation { BookMeta bookMeta = (BookMeta) s.getItemMeta(); bookMeta.setTitle(matraw.split("\\s")[1]); bookMeta.setAuthor(matraw.split("\\s")[1]); - List bookLines = plugin.tex.papi(panel,p,itemSection.getStringList("write"),true); + List bookLines = plugin.tex.placeholdersList(panel,p,itemSection.getStringList("write"),true); String result = bookLines.stream().map(String::valueOf).collect(Collectors.joining("\n" + ChatColor.RESET, "", "")); bookMeta.setPages(result); s.setItemMeta(bookMeta); @@ -148,22 +148,22 @@ public class ItemCreation { assert meta != null; meta.setOwningPlayer(Bukkit.getOfflinePlayer(UUID.fromString(skullname))); } catch (Exception var23) { - p.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.error") + " material: cps= self")); + p.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.error") + " material: cps= self")); plugin.debug(var23,p); } }else{ meta.setOwner(p.getName()); } s.setItemMeta(meta); - }else if (plugin.tex.papiNoColour(panel,p,matraw.split("\\s")[1]).length() <= 16) { + }else if (plugin.tex.placeholdersNoColour(panel,p,matraw.split("\\s")[1]).length() <= 16) { //if cps= username - s = plugin.customHeads.getPlayerHead(plugin.tex.papiNoColour(panel,p,matraw.split("\\s")[1])); + s = plugin.customHeads.getPlayerHead(plugin.tex.placeholdersNoColour(panel,p,matraw.split("\\s")[1])); } else { //custom data cps= base64 - s = plugin.customHeads.getCustomHead(plugin.tex.papiNoColour(panel,p,matraw.split("\\s")[1])); + s = plugin.customHeads.getCustomHead(plugin.tex.placeholdersNoColour(panel,p,matraw.split("\\s")[1])); } } catch (Exception var32) { - p.sendMessage(plugin.tex.papi( plugin.tag + plugin.config.getString("config.format.error") + " head material: Could not load skull")); + p.sendMessage(plugin.tex.colour( plugin.tag + plugin.config.getString("config.format.error") + " head material: Could not load skull")); plugin.debug(var32,p); } } @@ -181,11 +181,11 @@ public class ItemCreation { try { s = api.getItemHead(matraw.split("\\s")[1].trim()); } catch (Exception var22) { - p.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.error") + " hdb: could not load skull!")); + p.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.error") + " hdb: could not load skull!")); plugin.debug(var22,p); } } else { - p.sendMessage(plugin.tex.papi(plugin.tag + "Download HeadDatabaseHook from Spigot to use this feature!")); + p.sendMessage(plugin.tex.colour(plugin.tag + "Download HeadDatabaseHook from Spigot to use this feature!")); } } @@ -212,7 +212,7 @@ public class ItemCreation { This will do maps from custom images the maps will be in the 'maps' folder, so CommandPanels/maps/image.png <-- here - Commandpanels/panels/example.yml + CommandPanels/panels/example.yml The images should be 128x128 */ try{ @@ -235,10 +235,10 @@ public class ItemCreation { meta.setMapView(map); s.setItemMeta(meta); }else{ - p.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.error") + " map: File not found.")); + p.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.error") + " map: File not found.")); } }catch(Exception map){ - p.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.error") + " map: " + itemSection.getString("map"))); + p.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.error") + " map: " + itemSection.getString("map"))); plugin.debug(map,p); } } @@ -258,7 +258,7 @@ public class ItemCreation { s.setItemMeta(EnchantMeta); } } catch (Exception ench) { - p.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.error") + " enchanted: " + itemSection.getString("enchanted"))); + p.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.error") + " enchanted: " + itemSection.getString("enchanted"))); plugin.debug(ench,p); } } @@ -310,7 +310,7 @@ public class ItemCreation { } catch (Exception er) { //don't colour the armor plugin.debug(er,p); - p.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.error") + " leatherarmor: " + itemSection.getString("leatherarmor"))); + p.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.error") + " leatherarmor: " + itemSection.getString("leatherarmor"))); } } @@ -327,7 +327,7 @@ public class ItemCreation { } catch (Exception er) { //don't add the effect plugin.debug(er,p); - p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.RED + plugin.config.getString("config.format.error") + " potion: " + itemSection.getString("potion"))); + p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + plugin.config.getString("config.format.error") + " potion: " + itemSection.getString("potion"))); } } if (itemSection.contains("damage")) { @@ -335,10 +335,10 @@ public class ItemCreation { //if the damage is not unbreakable and should be a value if (plugin.legacy.LOCAL_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_12)) { try { - s.setDurability(Short.parseShort(Objects.requireNonNull(plugin.tex.papi(panel,p, itemSection.getString("damage"))))); + s.setDurability(Short.parseShort(Objects.requireNonNull(plugin.tex.placeholders(panel,p, itemSection.getString("damage"))))); } catch (Exception e) { plugin.debug(e, p); - p.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.error") + " damage: " + itemSection.getString("damage"))); + p.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.error") + " damage: " + itemSection.getString("damage"))); } } else { if(itemSection.getString("damage").equalsIgnoreCase("-1")){ @@ -350,21 +350,26 @@ public class ItemCreation { try { Damageable itemDamage = (Damageable) s.getItemMeta(); - itemDamage.setDamage(Integer.parseInt(Objects.requireNonNull(plugin.tex.papi(panel,p, itemSection.getString("damage"))))); + itemDamage.setDamage(Integer.parseInt(Objects.requireNonNull(plugin.tex.placeholders(panel,p, itemSection.getString("damage"))))); s.setItemMeta((ItemMeta) itemDamage); } catch (Exception e) { plugin.debug(e, p); - p.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.error") + " damage: " + itemSection.getString("damage"))); + p.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.error") + " damage: " + itemSection.getString("damage"))); } } } + if (itemSection.contains("nbt")) { + for(String key : itemSection.getConfigurationSection("nbt").getKeys(false)){ + s = plugin.nbt.setNBT(s,key,itemSection.getString("nbt." + key)); + } + } if (itemSection.contains("stack")) { //change the stack amount (placeholders accepted) - s.setAmount((int)Double.parseDouble(Objects.requireNonNull(plugin.tex.papi(panel,p,itemSection.getString("stack"))))); + s.setAmount((int)Double.parseDouble(Objects.requireNonNull(plugin.tex.placeholders(panel,p,itemSection.getString("stack"))))); } } catch (IllegalArgumentException | NullPointerException var33) { plugin.debug(var33,p); - p.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.error") + " material: " + itemSection.getString("material"))); + p.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.error") + " material: " + itemSection.getString("material"))); return null; } plugin.setName(panel,s, itemSection.getString("name"), itemSection.getStringList("lore"), p, placeholders, colours, hideAttributes); @@ -390,8 +395,8 @@ public class ItemCreation { //if output is true, and values match it will be this item, vice versa outputValue = cf.getBoolean("hasvalue.output"); } - String value = ChatColor.stripColor(plugin.tex.papi(panel,p,cf.getString("hasvalue.value"))); - String compare = ChatColor.stripColor(plugin.tex.papi(panel,p,cf.getString("hasvalue.compare"))); + String value = ChatColor.stripColor(plugin.tex.placeholders(panel,p,cf.getString("hasvalue.value"))); + String compare = ChatColor.stripColor(plugin.tex.placeholders(panel,p,cf.getString("hasvalue.compare"))); if (compare.equals(value) == outputValue) { //onOpen being 3 means it is the editor panel.. hasvalue items cannot be included to avoid item breaking String section = hasSection(panel,Objects.requireNonNull(cf.getConfigurationSection("hasvalue")), p); @@ -407,8 +412,8 @@ public class ItemCreation { //if output is true, and values match it will be this item, vice versa outputValue = cf.getBoolean("hasvalue" + count + ".output"); } - value = ChatColor.stripColor(plugin.tex.papi(panel,p,cf.getString("hasvalue" + count + ".value"))); - compare = ChatColor.stripColor(plugin.tex.papi(panel,p,cf.getString("hasvalue" + count + ".compare"))); + value = ChatColor.stripColor(plugin.tex.placeholders(panel,p,cf.getString("hasvalue" + count + ".value"))); + compare = ChatColor.stripColor(plugin.tex.placeholders(panel,p,cf.getString("hasvalue" + count + ".compare"))); if (compare.equals(value) == outputValue) { //onOpen being 3 means it is the editor panel.. hasvalue items cannot be included to avoid item breaking String section = hasSection(panel,Objects.requireNonNull(cf.getConfigurationSection("hasvalue" + count)), p); @@ -426,8 +431,8 @@ public class ItemCreation { //if output is true, and values match it will be this item, vice versa outputValue = cf.getBoolean("hasgreater.output"); } - double value = Double.parseDouble(ChatColor.stripColor(plugin.tex.papiNoColour(panel,p,cf.getString("hasgreater.value")))); - double compare = Double.parseDouble(ChatColor.stripColor(plugin.tex.papiNoColour(panel,p,cf.getString("hasgreater.compare")))); + double value = Double.parseDouble(ChatColor.stripColor(plugin.tex.placeholdersNoColour(panel,p,cf.getString("hasgreater.value")))); + double compare = Double.parseDouble(ChatColor.stripColor(plugin.tex.placeholdersNoColour(panel,p,cf.getString("hasgreater.compare")))); if ((compare >= value) == outputValue) { //onOpen being 3 means it is the editor panel.. hasgreater items cannot be included to avoid item breaking String section = hasSection(panel,Objects.requireNonNull(cf.getConfigurationSection("hasgreater")), p); @@ -442,8 +447,8 @@ public class ItemCreation { //if output is true, and values match it will be this item, vice versa outputValue = cf.getBoolean("hasgreater" + count + ".output"); } - value = Double.parseDouble(ChatColor.stripColor(plugin.tex.papiNoColour(panel,p,cf.getString("hasgreater" + count + ".value")))); - compare = Double.parseDouble(ChatColor.stripColor(plugin.tex.papiNoColour(panel,p,cf.getString("hasgreater" + count + ".compare")))); + value = Double.parseDouble(ChatColor.stripColor(plugin.tex.placeholdersNoColour(panel,p,cf.getString("hasgreater" + count + ".value")))); + compare = Double.parseDouble(ChatColor.stripColor(plugin.tex.placeholdersNoColour(panel,p,cf.getString("hasgreater" + count + ".compare")))); if ((compare >= value) == outputValue) { //onOpen being 3 means it is the editor panel.. hasgreater items cannot be included to avoid item breaking String section = hasSection(panel,Objects.requireNonNull(cf.getConfigurationSection("hasgreater" + count)), p); diff --git a/src/me/rockyhawk/commandpanels/classresources/OpenEditorGuis.java b/src/me/rockyhawk/commandpanels/classresources/OpenEditorGuis.java index 7f44605..494f727 100644 --- a/src/me/rockyhawk/commandpanels/classresources/OpenEditorGuis.java +++ b/src/me/rockyhawk/commandpanels/classresources/OpenEditorGuis.java @@ -28,8 +28,8 @@ public class OpenEditorGuis { ArrayList panelItems = new ArrayList<>(); //all panels from ALL files (panel materials) try { for(Panel panel : plugin.panelList) { //will loop through all the files in folder - panelNames.add(plugin.tex.papi(panel.getName())); - panelTitles.add(plugin.tex.papi(panel.getConfig().getString("title"))); + panelNames.add(plugin.tex.colour(panel.getName())); + panelTitles.add(plugin.tex.colour(panel.getConfig().getString("title"))); if (panel.getConfig().contains("open-with-item.material")) { panelItems.add(panel.getHotbarItem(p)); } else { diff --git a/src/me/rockyhawk/commandpanels/classresources/placeholders/CreateText.java b/src/me/rockyhawk/commandpanels/classresources/placeholders/CreateText.java index 3bade37..add337d 100644 --- a/src/me/rockyhawk/commandpanels/classresources/placeholders/CreateText.java +++ b/src/me/rockyhawk/commandpanels/classresources/placeholders/CreateText.java @@ -15,22 +15,29 @@ public class CreateText { this.plugin = pl; } + //CommandPanels send message function with all placeholders + public void sendMessage(Panel panel, Player p, String message){ + if(!message.equals("")) { + p.sendMessage(placeholders(panel, p,plugin.tag + message)); + } + } + //CommandPanels send message function public void sendMessage(Player p, String message){ if(!message.equals("")) { - p.sendMessage(papi(plugin.tag + message)); + p.sendMessage(colour(plugin.tag + message)); } } //CommandPanels send message function without the tag public void sendString(Player p, String message){ if(!message.equals("")) { - p.sendMessage(papi(message)); + p.sendMessage(colour(message)); } } //papi except if it is a String List - public List papiNoColour(Panel panel, Player p, List setpapi) { + public List placeholdersNoColour(Panel panel, Player p, List setpapi) { try { int tempInt = 0; for (String temp : setpapi) { @@ -49,7 +56,7 @@ public class CreateText { } //papi except if it is a String List - public List papi(Panel panel, Player p, List setpapi, boolean placeholder) { + public List placeholdersList(Panel panel, Player p, List setpapi, boolean placeholder) { try { if(placeholder) { int tempInt = 0; @@ -79,7 +86,7 @@ public class CreateText { } //regular string papi, but only colours so Player doesn't need to be there - public String papi(String setpapi) { + public String colour(String setpapi) { try { setpapi = plugin.hex.translateHexColorCodes(ChatColor.translateAlternateColorCodes('&', setpapi)); return setpapi; @@ -89,7 +96,7 @@ public class CreateText { } //string papi with no colours - public String papiNoColour(Panel panel, Player p, String setpapi) { + public String placeholdersNoColour(Panel panel, Player p, String setpapi) { try { setpapi = plugin.placeholders.setCpPlaceholders(panel, p,setpapi); if (plugin.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) { @@ -103,7 +110,7 @@ public class CreateText { } //regular string papi - public String papi(Panel panel, Player p, String setpapi) { + public String placeholders(Panel panel, Player p, String setpapi) { try { setpapi = plugin.placeholders.setCpPlaceholders(panel, p,setpapi); if (plugin.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) { diff --git a/src/me/rockyhawk/commandpanels/classresources/placeholders/Placeholders.java b/src/me/rockyhawk/commandpanels/classresources/placeholders/Placeholders.java index 69c792d..eae39b3 100644 --- a/src/me/rockyhawk/commandpanels/classresources/placeholders/Placeholders.java +++ b/src/me/rockyhawk/commandpanels/classresources/placeholders/Placeholders.java @@ -37,7 +37,7 @@ public class Placeholders { List inputMessages = new ArrayList(plugin.config.getStringList("config.input-message")); for (String temp : inputMessages) { temp = temp.replaceAll("%cp-args%", Objects.requireNonNull(plugin.config.getString("config.input-cancel"))); - p.sendMessage(plugin.tex.papi(panel,p, temp)); + p.sendMessage(plugin.tex.placeholders(panel,p, temp)); } return "cpc"; } @@ -50,7 +50,7 @@ public class Placeholders { str = str.replaceAll("%cp-player-y%", String.valueOf(Math.round(p.getLocation().getY()))); str = str.replaceAll("%cp-player-z%", String.valueOf(Math.round(p.getLocation().getZ()))); str = str.replaceAll("%cp-online-players%", Integer.toString(Bukkit.getServer().getOnlinePlayers().size())); - str = str.replaceAll("%cp-tag%", plugin.tex.papi(plugin.tag)); + str = str.replaceAll("%cp-tag%", plugin.tex.colour(plugin.tag)); //set custom placeholders to their values if(panel != null) { @@ -83,6 +83,24 @@ public class Placeholders { } } + //placeholder to check if an item has NBT %cp-nbt-slot:key% + while (str.contains("%cp-nbt-")) { + try { + int start = str.indexOf("%cp-nbt-"); + int end = str.indexOf("%", str.indexOf("%cp-nbt-")+1); + String slot_key = str.substring(start, end).replace("%cp-nbt-", "").replace("%",""); + String value; + value = plugin.nbt.getNBT(p.getOpenInventory().getTopInventory().getItem(Integer.parseInt(slot_key.split(":")[0])),slot_key.split(":")[1]); + if(value == null){ + value = "empty"; + } + str = str.replace(str.substring(start, end) + "%", value); + }catch (Exception ex){ + plugin.debug(ex,p); + break; + } + } + //DO placeholders for detection of other items in a panel //get material value from slot in current open inventory (panel) while (str.contains("%cp-material-")) { @@ -283,7 +301,7 @@ public class Placeholders { String playerLocation = str.substring(start, end).replace("%cp-player-online-", ""); Player[] playerFind = Bukkit.getOnlinePlayers().toArray(new Player[Bukkit.getOnlinePlayers().size()]); if (Integer.parseInt(playerLocation) > playerFind.length) { - str = str.replace(str.substring(start, end) + "-find%", plugin.tex.papi(Objects.requireNonNull(plugin.config.getString("config.format.offline")))); + str = str.replace(str.substring(start, end) + "-find%", plugin.tex.colour(Objects.requireNonNull(plugin.config.getString("config.format.offline")))); } else { str = str.replace(str.substring(start, end) + "-find%", playerFind[Integer.parseInt(playerLocation) - 1].getName()); } diff --git a/src/me/rockyhawk/commandpanels/commands/Commandpanel.java b/src/me/rockyhawk/commandpanels/commands/Commandpanel.java index 9bbe264..d5b4664 100644 --- a/src/me/rockyhawk/commandpanels/commands/Commandpanel.java +++ b/src/me/rockyhawk/commandpanels/commands/Commandpanel.java @@ -32,7 +32,7 @@ public class Commandpanel implements CommandExecutor { return true; } if(panel == null){ - sender.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.nopanel"))); + sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.nopanel"))); return true; } boolean disableCommand = false; @@ -52,18 +52,18 @@ public class Commandpanel implements CommandExecutor { plugin.openVoids.openCommandPanel(sender, plugin.getServer().getPlayer(args[1]), panel.copy(), true); } }else{ - sender.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.RED + "Usage: /cp [item] [player]")); + sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Usage: /cp [item] [player]")); } return true; }else if(args.length == 3){ if (args[1].equals("item")) { - plugin.openVoids.giveHotbarItem(sender,plugin.getServer().getPlayer(args[2]),panel.getConfig(),true); + plugin.openVoids.giveHotbarItem(sender,plugin.getServer().getPlayer(args[2]),panel,true); }else{ - sender.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.RED + "Usage: /cp item [player]")); + sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Usage: /cp item [player]")); } return true; } else { - sender.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.RED + "Please execute command directed to a Player!")); + sender.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "Please execute command directed to a Player!")); return true; } }else{ @@ -77,7 +77,7 @@ public class Commandpanel implements CommandExecutor { return true; }else if(args.length == 2){ if (args[1].equals("item")) { - plugin.openVoids.giveHotbarItem(sender, p, panel.getConfig(), false); + plugin.openVoids.giveHotbarItem(sender, p, panel, false); }else{ if(!disableCommand) { plugin.openVoids.openCommandPanel(sender, plugin.getServer().getPlayer(args[1]), panel.copy(), true); @@ -85,12 +85,12 @@ public class Commandpanel implements CommandExecutor { } return true; }else if(args.length == 3){ - plugin.openVoids.giveHotbarItem(sender, plugin.getServer().getPlayer(args[2]), panel.getConfig(),true); + plugin.openVoids.giveHotbarItem(sender, plugin.getServer().getPlayer(args[2]), panel,true); return true; } } } - sender.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.RED + "Usage: /cp [player:item] [player]")); + sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Usage: /cp [player:item] [player]")); return true; } } diff --git a/src/me/rockyhawk/commandpanels/commands/Commandpanelsdebug.java b/src/me/rockyhawk/commandpanels/commands/Commandpanelsdebug.java index de9bf36..a4cdb90 100644 --- a/src/me/rockyhawk/commandpanels/commands/Commandpanelsdebug.java +++ b/src/me/rockyhawk/commandpanels/commands/Commandpanelsdebug.java @@ -20,27 +20,27 @@ public class Commandpanelsdebug implements CommandExecutor { //command /cpd if(!(sender instanceof Player)) { plugin.debug.consoleDebug = !plugin.debug.consoleDebug; - sender.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.GREEN + "Global Debug Mode: " + plugin.debug.consoleDebug)); + sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.GREEN + "Global Debug Mode: " + plugin.debug.consoleDebug)); return true; } Player p = (Player)sender; if(plugin.debug.isEnabled(p)){ plugin.debug.debugSet.remove(p); - sender.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.GREEN + "Personal Debug Mode Disabled!")); + sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.GREEN + "Personal Debug Mode Disabled!")); }else{ plugin.debug.debugSet.add(p); - sender.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.GREEN + "Personal Debug Mode Enabled!")); + sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.GREEN + "Personal Debug Mode Enabled!")); } }else{ - sender.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.RED + "Usage: /cpd")); + sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Usage: /cpd")); } }else{ - sender.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.perms"))); + sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms"))); } return true; } - sender.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.RED + "Usage: /cpd")); + sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Usage: /cpd")); return true; } } \ No newline at end of file diff --git a/src/me/rockyhawk/commandpanels/commands/Commandpanelslist.java b/src/me/rockyhawk/commandpanels/commands/Commandpanelslist.java index 2a95097..db9de26 100644 --- a/src/me/rockyhawk/commandpanels/commands/Commandpanelslist.java +++ b/src/me/rockyhawk/commandpanels/commands/Commandpanelslist.java @@ -23,11 +23,11 @@ public class Commandpanelslist implements CommandExecutor { //check to make sure the panels isn't empty try { if (plugin.panelList == null) { - sender.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.RED + "No panels found!")); + sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "No panels found!")); return true; } }catch(Exception b){ - sender.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.RED + "No panels found!")); + sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "No panels found!")); return true; } @@ -39,10 +39,10 @@ public class Commandpanelslist implements CommandExecutor { page = Integer.parseInt(args[0]); skip = page*8-8; }catch (Exception e){ - sender.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.RED + "Inaccessible Page")); + sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Inaccessible Page")); } } - sender.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.DARK_AQUA + "Panels: (Page " + page + ")")); + sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.DARK_AQUA + "Panels: (Page " + page + ")")); for (int f = skip; panels.size() > f && skip+8 > f; f++) { sender.sendMessage(ChatColor.DARK_GREEN + panels.get(f).getFile().getAbsolutePath().replace(plugin.panelsf.getAbsolutePath(),"") + ChatColor.GREEN + " " + panels.get(f).getName()); if(panels.size()-1 == f){ @@ -51,11 +51,11 @@ public class Commandpanelslist implements CommandExecutor { } sender.sendMessage(ChatColor.AQUA + "Type /cpl " + (page+1) + " to read next page"); }else{ - sender.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.perms"))); + sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms"))); } return true; } - sender.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.RED + "Usage: /cpl")); + sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Usage: /cpl")); return true; } } \ No newline at end of file diff --git a/src/me/rockyhawk/commandpanels/commands/Commandpanelsreload.java b/src/me/rockyhawk/commandpanels/commands/Commandpanelsreload.java index 6a480bc..d9f5f25 100644 --- a/src/me/rockyhawk/commandpanels/commands/Commandpanelsreload.java +++ b/src/me/rockyhawk/commandpanels/commands/Commandpanelsreload.java @@ -42,14 +42,14 @@ public class Commandpanelsreload implements CommandExecutor { registerCommands(); } - plugin.tag = plugin.tex.papi(plugin.config.getString("config.format.tag") + " "); - sender.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.reload"))); + plugin.tag = plugin.tex.colour(plugin.config.getString("config.format.tag") + " "); + sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.reload"))); }else{ - sender.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.perms"))); + sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms"))); } return true; } - sender.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.RED + "Usage: /cpr")); + sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Usage: /cpr")); return true; } diff --git a/src/me/rockyhawk/commandpanels/commands/Commandpanelversion.java b/src/me/rockyhawk/commandpanels/commands/Commandpanelversion.java index fae6e2a..9b4d887 100644 --- a/src/me/rockyhawk/commandpanels/commands/Commandpanelversion.java +++ b/src/me/rockyhawk/commandpanels/commands/Commandpanelversion.java @@ -19,29 +19,29 @@ public class Commandpanelversion implements CommandExecutor { if (sender.hasPermission("commandpanel.version")) { //version command String latestVersion = plugin.updater.githubNewUpdate(false); - sender.sendMessage(plugin.tex.papi(plugin.tag)); + sender.sendMessage(plugin.tex.colour(plugin.tag)); sender.sendMessage(ChatColor.GREEN + "This Version " + ChatColor.GRAY + plugin.getDescription().getVersion()); sender.sendMessage(ChatColor.GREEN + "Latest Version " + ChatColor.GRAY + latestVersion); sender.sendMessage(ChatColor.GRAY + "-------------------"); sender.sendMessage(ChatColor.GREEN + "Developer " + ChatColor.GRAY + "RockyHawk"); sender.sendMessage(ChatColor.GREEN + "Command " + ChatColor.GRAY + "/cp"); } else { - sender.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.perms"))); + sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms"))); } }else if(args.length == 1){ if (sender.hasPermission("commandpanel.update")) { if (args[0].equals("cancel")) { plugin.updater.downloadVersionManually = null; - sender.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.GREEN + "Will not download a new version on restart.")); + sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.GREEN + "Will not download a new version on restart.")); } else { plugin.updater.downloadVersionManually = args[0]; - sender.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.GREEN + "Downloading version " + ChatColor.GRAY + args[0] + ChatColor.GREEN + " upon server restart.")); + sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.GREEN + "Downloading version " + ChatColor.GRAY + args[0] + ChatColor.GREEN + " upon server restart.")); } }else{ - sender.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.perms"))); + sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms"))); } }else{ - sender.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.RED + "Usage: /cpv [update:latest:cancel]")); + sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Usage: /cpv [update:latest:cancel]")); } return true; } diff --git a/src/me/rockyhawk/commandpanels/commandtags/CommandTagEvent.java b/src/me/rockyhawk/commandpanels/commandtags/CommandTagEvent.java index d6ef6f1..277d8a8 100644 --- a/src/me/rockyhawk/commandpanels/commandtags/CommandTagEvent.java +++ b/src/me/rockyhawk/commandpanels/commandtags/CommandTagEvent.java @@ -40,7 +40,7 @@ public class CommandTagEvent extends Event { this.name = split[0].trim(); this.raw = split[1].trim().split("\\s"); if(doApiPlaceholders) { - this.args = plugin.tex.papi(panel1, player, split[1].trim()).split("\\s"); + this.args = plugin.tex.placeholders(panel1, player, split[1].trim()).split("\\s"); }else{ this.args = ChatColor.translateAlternateColorCodes('&',plugin.placeholders.setCpPlaceholders(panel, p,split[1].trim())).split("\\s"); } diff --git a/src/me/rockyhawk/commandpanels/commandtags/CommandTags.java b/src/me/rockyhawk/commandpanels/commandtags/CommandTags.java index ce9f71c..d9ac40c 100644 --- a/src/me/rockyhawk/commandpanels/commandtags/CommandTags.java +++ b/src/me/rockyhawk/commandpanels/commandtags/CommandTags.java @@ -30,7 +30,7 @@ public class CommandTags { CommandTagEvent tags = new CommandTagEvent(plugin,panel,p,commandRAW); Bukkit.getPluginManager().callEvent(tags); if(!tags.commandTagUsed){ - Bukkit.dispatchCommand(p, plugin.tex.papi(panel,p,commandRAW.trim())); + Bukkit.dispatchCommand(p, plugin.tex.placeholders(panel,p,commandRAW.trim())); } } diff --git a/src/me/rockyhawk/commandpanels/commandtags/tags/economy/SellItemTags.java b/src/me/rockyhawk/commandpanels/commandtags/tags/economy/SellItemTags.java index 98a560b..06b8590 100644 --- a/src/me/rockyhawk/commandpanels/commandtags/tags/economy/SellItemTags.java +++ b/src/me/rockyhawk/commandpanels/commandtags/tags/economy/SellItemTags.java @@ -56,7 +56,7 @@ public class SellItemTags implements Listener { } else { assert api != null; api.addTokens(e.p, Long.parseLong(e.args[0])); - plugin.tex.sendMessage(e.p, Objects.requireNonNull(plugin.config.getString("purchase.item.success")).replaceAll("%cp-args%", e.args[1])); + plugin.tex.sendMessage(e.p, plugin.config.getString("purchase.item.success").replaceAll("%cp-args%", e.args[1])); } } else { plugin.tex.sendMessage(e.p, ChatColor.RED + "Selling Requires TokenManager to work!"); @@ -96,7 +96,7 @@ public class SellItemTags implements Listener { PotionMeta potionMeta = (PotionMeta) itm.getItemMeta(); assert potionMeta != null; if (!potionMeta.getBasePotionData().getType().name().equalsIgnoreCase(potion)) { - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.RED + "Your item has the wrong potion effect")); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "Your item has the wrong potion effect")); return false; } } diff --git a/src/me/rockyhawk/commandpanels/commandtags/tags/other/DataTags.java b/src/me/rockyhawk/commandpanels/commandtags/tags/other/DataTags.java index 962911d..101643e 100644 --- a/src/me/rockyhawk/commandpanels/commandtags/tags/other/DataTags.java +++ b/src/me/rockyhawk/commandpanels/commandtags/tags/other/DataTags.java @@ -19,31 +19,31 @@ public class DataTags implements Listener { if(e.name.equalsIgnoreCase("set-data=")){ e.commandTagUsed(); if(e.args.length == 3){ - plugin.panelData.setUserData(getOffline(e.args[2]),e.args[0],plugin.tex.papiNoColour(e.panel,e.p,e.args[1]),true); + plugin.panelData.setUserData(getOffline(e.args[2]),e.args[0],plugin.tex.placeholdersNoColour(e.panel,e.p,e.args[1]),true); return; } //this will overwrite data. set-data= [data point] [data value] [optional player] - plugin.panelData.setUserData(e.p.getUniqueId(),e.args[0],plugin.tex.papiNoColour(e.panel,e.p,e.args[1]),true); + plugin.panelData.setUserData(e.p.getUniqueId(),e.args[0],plugin.tex.placeholdersNoColour(e.panel,e.p,e.args[1]),true); return; } if(e.name.equalsIgnoreCase("add-data=")){ e.commandTagUsed(); if(e.args.length == 3){ - plugin.panelData.setUserData(getOffline(e.args[2]),e.args[0],plugin.tex.papiNoColour(e.panel,e.p,e.args[1]),false); + plugin.panelData.setUserData(getOffline(e.args[2]),e.args[0],plugin.tex.placeholdersNoColour(e.panel,e.p,e.args[1]),false); return; } //this will not overwrite existing data. add-data= [data point] [data value] [optional player] - plugin.panelData.setUserData(e.p.getUniqueId(),e.args[0],plugin.tex.papiNoColour(e.panel,e.p,e.args[1]),false); + plugin.panelData.setUserData(e.p.getUniqueId(),e.args[0],plugin.tex.placeholdersNoColour(e.panel,e.p,e.args[1]),false); return; } if(e.name.equalsIgnoreCase("math-data=")){ e.commandTagUsed(); if(e.args.length == 3){ - plugin.panelData.doDataMath(getOffline(e.args[2]),e.args[0],plugin.tex.papiNoColour(e.panel,e.p,e.args[1])); + plugin.panelData.doDataMath(getOffline(e.args[2]),e.args[0],plugin.tex.placeholdersNoColour(e.panel,e.p,e.args[1])); return; } //only works if data is number, goes math-data= [data point] [operator:number] [optional player] eg, math-data= -1 OR /3 - plugin.panelData.doDataMath(e.p.getUniqueId(),e.args[0],plugin.tex.papiNoColour(e.panel,e.p,e.args[1])); + plugin.panelData.doDataMath(e.p.getUniqueId(),e.args[0],plugin.tex.placeholdersNoColour(e.panel,e.p,e.args[1])); return; } if(e.name.equalsIgnoreCase("clear-data=")){ diff --git a/src/me/rockyhawk/commandpanels/commandtags/tags/other/PlaceholderTags.java b/src/me/rockyhawk/commandpanels/commandtags/tags/other/PlaceholderTags.java index c471832..f40937e 100644 --- a/src/me/rockyhawk/commandpanels/commandtags/tags/other/PlaceholderTags.java +++ b/src/me/rockyhawk/commandpanels/commandtags/tags/other/PlaceholderTags.java @@ -31,7 +31,7 @@ public class PlaceholderTags implements Listener { //do not change the placeholder String placeholder = contents.substring(0,contents.indexOf(':')); //only convert placeholders for the value - String value = plugin.tex.papi(e.panel,e.p,contents.substring(contents.indexOf(':')+1)); + String value = plugin.tex.placeholders(e.panel,e.p,contents.substring(contents.indexOf(':')+1)); e.panel.placeholders.addPlaceholder(placeholder,value); i = i+contents.length()-1; } @@ -57,7 +57,7 @@ public class PlaceholderTags implements Listener { //only convert placeholders for the value if (!e.panel.placeholders.keys.containsKey(placeholder)) { //only convert placeholders for the value - String value = plugin.tex.papi(e.panel, e.p, contents.substring(contents.indexOf(':') + 1)); + String value = plugin.tex.placeholders(e.panel, e.p, contents.substring(contents.indexOf(':') + 1)); e.panel.placeholders.addPlaceholder(placeholder, value); } i = i + contents.length() - 1; diff --git a/src/me/rockyhawk/commandpanels/commandtags/tags/other/SpecialTags.java b/src/me/rockyhawk/commandpanels/commandtags/tags/other/SpecialTags.java index cc7b29d..c6b49bb 100644 --- a/src/me/rockyhawk/commandpanels/commandtags/tags/other/SpecialTags.java +++ b/src/me/rockyhawk/commandpanels/commandtags/tags/other/SpecialTags.java @@ -42,7 +42,7 @@ public class SpecialTags implements Listener { //do not change the placeholder String placeholder = contents.substring(0,contents.indexOf(':')); //only convert placeholders for the value - String value = plugin.tex.papi(e.panel,e.p,contents.substring(contents.indexOf(':')+1)); + String value = plugin.tex.placeholders(e.panel,e.p,contents.substring(contents.indexOf(':')+1)); openPanel.placeholders.addPlaceholder(placeholder,value); i = i+contents.length()-1; } diff --git a/src/me/rockyhawk/commandpanels/commandtags/tags/standard/BasicTags.java b/src/me/rockyhawk/commandpanels/commandtags/tags/standard/BasicTags.java index 7284ccb..f7d2308 100644 --- a/src/me/rockyhawk/commandpanels/commandtags/tags/standard/BasicTags.java +++ b/src/me/rockyhawk/commandpanels/commandtags/tags/standard/BasicTags.java @@ -58,7 +58,7 @@ public class BasicTags implements Listener { } catch (Exception exc) { e.p.setOp(isop); plugin.debug(exc,e.p); - e.p.sendMessage(plugin.tag + plugin.tex.papi( plugin.config.getString("config.format.error") + " op=: Error in op command!")); + e.p.sendMessage(plugin.tag + plugin.tex.colour( plugin.config.getString("config.format.error") + " op=: Error in op command!")); } return; } diff --git a/src/me/rockyhawk/commandpanels/generatepanels/Commandpanelsgenerate.java b/src/me/rockyhawk/commandpanels/generatepanels/Commandpanelsgenerate.java index e5e020f..6a11074 100644 --- a/src/me/rockyhawk/commandpanels/generatepanels/Commandpanelsgenerate.java +++ b/src/me/rockyhawk/commandpanels/generatepanels/Commandpanelsgenerate.java @@ -18,7 +18,7 @@ public class Commandpanelsgenerate implements CommandExecutor { @EventHandler public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { if(!(sender instanceof Player)) { - sender.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.RED + "Please execute command as a Player!")); + sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Please execute command as a Player!")); return true; } Player p = (Player) sender; @@ -31,30 +31,30 @@ public class Commandpanelsgenerate implements CommandExecutor { Inventory i = Bukkit.createInventory(null, Integer.parseInt(args[0]) * 9, "Generate New Panel"); p.openInventory(i); } else { - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.RED + "Please use integer from 1-6.")); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "Please use integer from 1-6.")); } }catch(Exception exc){ - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.RED + "Please use integer from 1-6.")); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "Please use integer from 1-6.")); } return true; }else if (args.length == 0) { if (this.plugin.generateMode.contains(p)) { this.plugin.generateMode.remove(p); - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Generate Mode Disabled!")); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Generate Mode Disabled!")); } else { this.plugin.generateMode.add(p); - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Generate Mode Enabled!")); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Generate Mode Enabled!")); } return true; } - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.RED + "Usage: /cpg [rows]")); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "Usage: /cpg [rows]")); return true; }else{ - p.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.perms"))); + p.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms"))); return true; } } - p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.RED + "Usage: /cpg [rows]")); + p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Usage: /cpg [rows]")); return true; } } \ No newline at end of file diff --git a/src/me/rockyhawk/commandpanels/generatepanels/GenUtils.java b/src/me/rockyhawk/commandpanels/generatepanels/GenUtils.java index 706a669..61cff7e 100644 --- a/src/me/rockyhawk/commandpanels/generatepanels/GenUtils.java +++ b/src/me/rockyhawk/commandpanels/generatepanels/GenUtils.java @@ -79,7 +79,7 @@ public class GenUtils implements Listener { } if(!foundItem){ //panels don't need items but I cancel on generate with no items because then players have the option to cancel if they need to - p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.RED + "Cancelled Panel!")); + p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Cancelled Panel!")); return; } YamlConfiguration file; @@ -111,9 +111,9 @@ public class GenUtils implements Listener { try { file.save(new File(plugin.panelsf + File.separator + date + ".yml")); - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Saved Generated File To: " + date + ".yml")); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Saved Generated File To: " + date + ".yml")); } catch (IOException var16) { - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.RED + "Could Not Save Generated Panel!")); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "Could Not Save Generated Panel!")); } plugin.reloadPanelFiles(); } diff --git a/src/me/rockyhawk/commandpanels/ingameeditor/CpIngameEditCommand.java b/src/me/rockyhawk/commandpanels/ingameeditor/CpIngameEditCommand.java index 7d04542..b80470e 100644 --- a/src/me/rockyhawk/commandpanels/ingameeditor/CpIngameEditCommand.java +++ b/src/me/rockyhawk/commandpanels/ingameeditor/CpIngameEditCommand.java @@ -21,16 +21,16 @@ public class CpIngameEditCommand implements CommandExecutor { @EventHandler public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { if(!sender.hasPermission("commandpanel.edit")){ - sender.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.perms"))); + sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms"))); return true; } if(Objects.requireNonNull(plugin.config.getString("config.ingame-editor")).equalsIgnoreCase("false")){ //this will cancel every /cpe command if ingame-editor is set to false - sender.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.RED + "Editor disabled!")); + sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Editor disabled!")); return true; } if(!(sender instanceof Player)) { - sender.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.RED + "Please execute command as a Player!")); + sender.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "Please execute command as a Player!")); return true; } Player p = (Player)sender; @@ -48,7 +48,7 @@ public class CpIngameEditCommand implements CommandExecutor { plugin.editorGuis.openEditorGui(p,0); return true; } - sender.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.RED + "Usage: /cpe ")); + sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Usage: /cpe ")); return true; } } diff --git a/src/me/rockyhawk/commandpanels/ingameeditor/EditorUserInput.java b/src/me/rockyhawk/commandpanels/ingameeditor/EditorUserInput.java index 075fcee..376d408 100644 --- a/src/me/rockyhawk/commandpanels/ingameeditor/EditorUserInput.java +++ b/src/me/rockyhawk/commandpanels/ingameeditor/EditorUserInput.java @@ -43,7 +43,7 @@ public class EditorUserInput implements Listener { cf = panel.getConfig(); cfile = YamlConfiguration.loadConfiguration(panel.getFile()); panelFile = panel.getFile(); - panelTitle = plugin.tex.papi(cf.getString("title")); + panelTitle = plugin.tex.colour(cf.getString("title")); break; } } @@ -56,7 +56,7 @@ public class EditorUserInput implements Listener { if(e.getMessage().equalsIgnoreCase(plugin.config.getString("config.input-cancel"))){ plugin.editorInputStrings.remove(temp); plugin.reloadPanelFiles(); - e.getPlayer().sendMessage(plugin.tex.papi( Objects.requireNonNull(plugin.config.getString("config.input-cancelled")))); + e.getPlayer().sendMessage(plugin.tex.colour( Objects.requireNonNull(plugin.config.getString("config.input-cancelled")))); return; } plugin.editorInputStrings.remove(temp); @@ -121,101 +121,101 @@ public class EditorUserInput implements Listener { if(Objects.requireNonNull(cfile.getConfigurationSection("panels")).getKeys(false).size() != 1){ //if the file has more than one panel in it if(savePanelFile(null, cfile, panelName, panelFile)){ - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Deleted Panel!")); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Deleted Panel!")); }else{ - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.RED + "Could Not Delete Panel!")); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "Could Not Delete Panel!")); } }else { //if the file only has one panel in it if (panelFile.delete()) { - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Deleted Panel!")); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Deleted Panel!")); }else{ - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.RED + "Could Not Delete Panel!")); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "Could Not Delete Panel!")); } } } break; case "panel.perm": if(e.getMessage().contains(" ")){ - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.RED + "Permission cannot contain spaces!")); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "Permission cannot contain spaces!")); break; } cf.set("perm", e.getMessage()); savePanelFile(cf, cfile, panelName, panelFile); - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Permission required is now " + "commandpanel.panel." + e.getMessage())); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Permission required is now " + "commandpanel.panel." + e.getMessage())); break; case "panel.rows": try { int rows = Integer.parseInt(e.getMessage()); if (rows >= 7 || rows <= 0) { //if the number isn't between 1-6 - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Choose an integer between 1 to 6!")); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Choose an integer between 1 to 6!")); return; } cf.set("rows", rows); savePanelFile(cf, cfile, panelName, panelFile); - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Set Panel to " + rows + " rows!")); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Set Panel to " + rows + " rows!")); } catch (Exception io) { plugin.debug(io,p); } break; case "panel.title": - if(panelTitle.equals(plugin.tex.papi(e.getMessage()))){ - p.sendMessage(plugin.tex.papi(plugin.tag + e.getMessage() + ChatColor.RED + " is in use from another panel!")); + if(panelTitle.equals(plugin.tex.colour(e.getMessage()))){ + p.sendMessage(plugin.tex.colour(plugin.tag + e.getMessage() + ChatColor.RED + " is in use from another panel!")); break; } cf.set("title", e.getMessage()); savePanelFile(cf, cfile, panelName, panelFile); - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Set new Title to " + ChatColor.WHITE + e.getMessage())); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Set new Title to " + ChatColor.WHITE + e.getMessage())); break; case "panel.name": if(e.getMessage().contains(" ")){ - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.RED + "Panel name cannot contain spaces!")); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "Panel name cannot contain spaces!")); break; } if(panelName.equals(e.getMessage())){ - p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.RED + e.getMessage() + " is in use from another panel!")); + p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + e.getMessage() + " is in use from another panel!")); break; } cfile.set("panels." + e.getMessage(), cfile.get("panels." + panelName)); //I have put null there instead of cf because that will replicate cp = null to delete it savePanelFile(null, cfile, panelName, panelFile); - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Set new Name to " + e.getMessage())); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Set new Name to " + e.getMessage())); break; case "panel.empty": if(e.getMessage().trim().equalsIgnoreCase("remove")){ cf.set("empty", null); savePanelFile(cf, cfile, panelName, panelFile); - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Empty materials have been removed.")); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Empty materials have been removed.")); break; } String materialTemp = null; try { materialTemp = Objects.requireNonNull(Material.matchMaterial(e.getMessage())).toString(); }catch(NullPointerException ex){ - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.RED + e.getMessage() + " is not a valid Material!")); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + e.getMessage() + " is not a valid Material!")); } cf.set("empty", materialTemp); savePanelFile(cf, cfile, panelName, panelFile); - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Set Empty material to " + materialTemp)); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Set Empty material to " + materialTemp)); break; case "panel.sound-on-open": if(e.getMessage().trim().equalsIgnoreCase("remove")){ cf.set("sound-on-open", null); savePanelFile(cf, cfile, panelName, panelFile); - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Sounds have been removed.")); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Sounds have been removed.")); break; } String tempSound; try { tempSound = Sound.valueOf(e.getMessage()).toString(); }catch(Exception ex){ - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.RED + e.getMessage() + " is not a valid Sound!")); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + e.getMessage() + " is not a valid Sound!")); return; } cf.set("sound-on-open", tempSound); savePanelFile(cf, cfile, panelName, panelFile); - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Sound when opening is now " + tempSound)); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Sound when opening is now " + tempSound)); break; case "panel.panelType.add": List typeAdd = new ArrayList<>(); @@ -225,20 +225,20 @@ public class EditorUserInput implements Listener { typeAdd.add(e.getMessage().toLowerCase()); cf.set("panelType", typeAdd); savePanelFile(cf, cfile, panelName, panelFile); - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Added new panel type: " + e.getMessage().toLowerCase())); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Added new panel type: " + e.getMessage().toLowerCase())); break; case "panel.panelType.remove": List typeRemove; if(cf.contains("panelType")){ typeRemove = cf.getStringList("panelType"); }else{ - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.RED + "No types found to remove!")); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "No types found to remove!")); break; } try { typeRemove.remove(Integer.parseInt(e.getMessage())-1); }catch (Exception ex){ - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.RED + "Could not find type!")); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "Could not find type!")); break; } if(typeRemove.size() == 0){ @@ -247,7 +247,7 @@ public class EditorUserInput implements Listener { cf.set("panelType", typeRemove); } savePanelFile(cf, cfile, panelName, panelFile); - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Removed panel type " + e.getMessage())); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Removed panel type " + e.getMessage())); break; case "panel.commands.add": List commandsAdd = new ArrayList<>(); @@ -257,20 +257,20 @@ public class EditorUserInput implements Listener { commandsAdd.add(e.getMessage()); cf.set("commands", commandsAdd); savePanelFile(cf, cfile, panelName, panelFile); - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Added new command: " + e.getMessage())); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Added new command: " + e.getMessage())); break; case "panel.commands.remove": List commandsRemove; if(cf.contains("commands")){ commandsRemove = cf.getStringList("commands"); }else{ - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.RED + "No commands found to remove!")); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "No commands found to remove!")); break; } try { commandsRemove.remove(Integer.parseInt(e.getMessage())-1); }catch (Exception ex){ - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.RED + "Could not find command!")); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "Could not find command!")); break; } if(commandsRemove.size() == 0){ @@ -279,7 +279,7 @@ public class EditorUserInput implements Listener { cf.set("commands", commandsRemove); } savePanelFile(cf, cfile, panelName, panelFile); - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Removed command line " + e.getMessage())); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Removed command line " + e.getMessage())); break; case "panel.commands-on-open.add": List commandsOnOpenAdd = new ArrayList<>(); @@ -289,20 +289,20 @@ public class EditorUserInput implements Listener { commandsOnOpenAdd.add(e.getMessage()); cf.set("commands-on-open", commandsOnOpenAdd); savePanelFile(cf, cfile, panelName, panelFile); - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Added new command: " + e.getMessage())); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Added new command: " + e.getMessage())); break; case "panel.commands-on-open.remove": List commandsOnOpenRemove; if(cf.contains("commands-on-open")){ commandsOnOpenRemove = cf.getStringList("commands-on-open"); }else{ - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.RED + "No commands found to remove!")); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "No commands found to remove!")); break; } try { commandsOnOpenRemove.remove(Integer.parseInt(e.getMessage())-1); }catch (Exception ex){ - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.RED + "Could not find command!")); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "Could not find command!")); break; } if(commandsOnOpenRemove.size() == 0){ @@ -311,7 +311,7 @@ public class EditorUserInput implements Listener { cf.set("commands-on-open", commandsOnOpenRemove); } savePanelFile(cf, cfile, panelName, panelFile); - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Removed command line " + e.getMessage())); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Removed command line " + e.getMessage())); break; case "panel.disabled-worlds.add": List disabledWorldsAdd = new ArrayList<>(); @@ -321,20 +321,20 @@ public class EditorUserInput implements Listener { disabledWorldsAdd.add(e.getMessage()); cf.set("disabled-worlds", disabledWorldsAdd); savePanelFile(cf, cfile, panelName, panelFile); - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Added new World: " + e.getMessage())); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Added new World: " + e.getMessage())); break; case "panel.disabled-worlds.remove": List disabledWorldsRemove; if(cf.contains("disabled-worlds")){ disabledWorldsRemove = cf.getStringList("disabled-worlds"); }else{ - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.RED + "No Worlds found to remove!")); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "No Worlds found to remove!")); break; } try { disabledWorldsRemove.remove(Integer.parseInt(e.getMessage())-1); }catch (Exception ex){ - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.RED + "Could not find World!")); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "Could not find World!")); break; } if(disabledWorldsRemove.size() == 0){ @@ -343,13 +343,13 @@ public class EditorUserInput implements Listener { cf.set("disabled-worlds", disabledWorldsRemove); } savePanelFile(cf, cfile, panelName, panelFile); - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Removed World line " + e.getMessage())); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Removed World line " + e.getMessage())); break; case "panel.hotbar.material": if(e.getMessage().trim().equalsIgnoreCase("remove")){ cf.set("open-with-item", null); savePanelFile(cf, cfile, panelName, panelFile); - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Hotbar item have been removed.")); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Hotbar item have been removed.")); //after an open-with-item has been altered, reload after changes plugin.reloadPanelFiles(); break; @@ -359,7 +359,7 @@ public class EditorUserInput implements Listener { cf.set("open-with-item.name", panelName + " Item"); } savePanelFile(cf, cfile, panelName, panelFile); - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Set new Material to " + ChatColor.WHITE + e.getMessage())); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Set new Material to " + ChatColor.WHITE + e.getMessage())); //after an open-with-item has been altered, reload after changes plugin.reloadPanelFiles(); break; @@ -367,17 +367,17 @@ public class EditorUserInput implements Listener { if(e.getMessage().trim().equalsIgnoreCase("remove")){ cf.set("open-with-item.stationary", null); savePanelFile(cf, cfile, panelName, panelFile); - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Hotbar item can now be moved.")); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Hotbar item can now be moved.")); break; } try { int loc = Integer.parseInt(e.getMessage()); if (loc >= 34 || loc <= -1) { //if the number isn't between 1-9 - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Choose an integer between 0 to 33!")); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Choose an integer between 0 to 33!")); return; } - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Set Hotbar Location to " + loc + "!")); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Set Hotbar Location to " + loc + "!")); //because it needs to convert 1-9 to 0-8 for in the panel loc -= 1; cf.set("open-with-item.stationary", loc); @@ -389,7 +389,7 @@ public class EditorUserInput implements Listener { case "panel.hotbar.name": cf.set("open-with-item.name",e.getMessage()); savePanelFile(cf, cfile, panelName, panelFile); - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Set new Name to " + ChatColor.WHITE + e.getMessage())); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Set new Name to " + ChatColor.WHITE + e.getMessage())); break; case "panel.hotbar.lore.add": List loreAdd = new ArrayList<>(); @@ -399,20 +399,20 @@ public class EditorUserInput implements Listener { loreAdd.add(e.getMessage()); cf.set("open-with-item.lore", loreAdd); savePanelFile(cf, cfile, panelName, panelFile); - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Added new lore: " + e.getMessage())); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Added new lore: " + e.getMessage())); break; case "panel.hotbar.lore.remove": List loreRemove; if(cf.contains("open-with-item.lore")){ loreRemove = cf.getStringList("open-with-item.lore"); }else{ - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.RED + "No lore found to remove!")); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "No lore found to remove!")); break; } try { loreRemove.remove(Integer.parseInt(e.getMessage())-1); }catch (Exception ex){ - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.RED + "Could not find lore!")); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "Could not find lore!")); break; } if(loreRemove.size() == 0){ @@ -421,7 +421,7 @@ public class EditorUserInput implements Listener { cf.set("open-with-item.lore", loreRemove); } savePanelFile(cf, cfile, panelName, panelFile); - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Removed lore line " + e.getMessage())); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Removed lore line " + e.getMessage())); break; case "panel.hotbar.commands.add": List commandAdd = new ArrayList<>(); @@ -431,20 +431,20 @@ public class EditorUserInput implements Listener { commandAdd.add(e.getMessage()); cf.set("open-with-item.commands", commandAdd); savePanelFile(cf, cfile, panelName, panelFile); - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Added new command: " + e.getMessage())); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Added new command: " + e.getMessage())); break; case "panel.hotbar.commands.remove": List commandRemove; if(cf.contains("open-with-item.commands")){ commandRemove = cf.getStringList("open-with-item.commands"); }else{ - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.RED + "No commands found to remove!")); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "No commands found to remove!")); break; } try { commandRemove.remove(Integer.parseInt(e.getMessage())-1); }catch (Exception ex){ - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.RED + "Could not find command!")); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "Could not find command!")); break; } if(commandRemove.size() == 0){ @@ -453,7 +453,7 @@ public class EditorUserInput implements Listener { cf.set("open-with-item.commands", commandRemove); } savePanelFile(cf, cfile, panelName, panelFile); - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Removed command line " + e.getMessage())); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Removed command line " + e.getMessage())); break; } } @@ -472,41 +472,41 @@ public class EditorUserInput implements Listener { if(e.getMessage().trim().equalsIgnoreCase("remove")){ cf.set("item." + itemSlot + ".name", ""); savePanelFile(cf, cfile, panelName, panelFile); - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Name is now default.")); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Name is now default.")); break; } cf.set("item." + itemSlot + ".name", e.getMessage()); savePanelFile(cf, cfile, panelName, panelFile); - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Set new name to " + ChatColor.WHITE + e.getMessage())); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Set new name to " + ChatColor.WHITE + e.getMessage())); break; case "head": if(e.getMessage().trim().equalsIgnoreCase("remove")){ cf.set("item." + itemSlot + ".material", plugin.getHeads.playerHeadString()); savePanelFile(cf, cfile, panelName, panelFile); - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Material is now default.")); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Material is now default.")); break; } cf.set("item." + itemSlot + ".material", e.getMessage()); savePanelFile(cf, cfile, panelName, panelFile); - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Set Material value to " + ChatColor.WHITE + e.getMessage())); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Set Material value to " + ChatColor.WHITE + e.getMessage())); break; case "stack": if(e.getMessage().trim().equalsIgnoreCase("remove")){ cf.set("item." + itemSlot + ".stack", null); savePanelFile(cf, cfile, panelName, panelFile); - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Item has been unstacked.")); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Item has been unstacked.")); break; } try { int rows = Integer.parseInt(e.getMessage()); if (rows >= 65 || rows <= 0) { //if the number isn't between 1-64 - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Choose an integer between 1 to 64!")); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Choose an integer between 1 to 64!")); return; } cf.set("item." + itemSlot + ".stack", rows); savePanelFile(cf, cfile, panelName, panelFile); - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Set stack to " + rows + "!")); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Set stack to " + rows + "!")); } catch (Exception io) { plugin.debug(io,p); } @@ -515,45 +515,45 @@ public class EditorUserInput implements Listener { if(e.getMessage().trim().equalsIgnoreCase("remove")){ cf.set("item." + itemSlot + ".enchanted", null); savePanelFile(cf, cfile, panelName, panelFile); - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Enchantments have been removed.")); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Enchantments have been removed.")); break; } cf.set("item." + itemSlot + ".enchanted", e.getMessage()); savePanelFile(cf, cfile, panelName, panelFile); - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Set new Enchantment to " + ChatColor.WHITE + e.getMessage())); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Set new Enchantment to " + ChatColor.WHITE + e.getMessage())); break; case "potion": if(e.getMessage().trim().equalsIgnoreCase("remove")){ cf.set("item." + itemSlot + ".potion", null); savePanelFile(cf, cfile, panelName, panelFile); - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Potion effects have been removed.")); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Potion effects have been removed.")); break; } cf.set("item." + itemSlot + ".potion", e.getMessage()); savePanelFile(cf, cfile, panelName, panelFile); - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Set new Potion to " + e.getMessage().toUpperCase())); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Set new Potion to " + e.getMessage().toUpperCase())); break; case "customdata": if(e.getMessage().trim().equalsIgnoreCase("remove")){ cf.set("item." + itemSlot + ".customdata", null); savePanelFile(cf, cfile, panelName, panelFile); - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Custom Model Data has been removed.")); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Custom Model Data has been removed.")); break; } cf.set("item." + itemSlot + ".customdata", e.getMessage()); savePanelFile(cf, cfile, panelName, panelFile); - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Custom Model Data set to " + e.getMessage())); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Custom Model Data set to " + e.getMessage())); break; case "leatherarmor": if(e.getMessage().trim().equalsIgnoreCase("remove")){ cf.set("item." + itemSlot + ".leatherarmor", null); savePanelFile(cf, cfile, panelName, panelFile); - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Leather armor colour has been removed.")); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Leather armor colour has been removed.")); break; } cf.set("item." + itemSlot + ".leatherarmor", e.getMessage()); savePanelFile(cf, cfile, panelName, panelFile); - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Leather armor colour set to " + e.getMessage())); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Leather armor colour set to " + e.getMessage())); break; case "commands:add": List commandsOnOpenAdd = new ArrayList<>(); @@ -563,20 +563,20 @@ public class EditorUserInput implements Listener { commandsOnOpenAdd.add(e.getMessage()); cf.set("item." + itemSlot + ".commands", commandsOnOpenAdd); savePanelFile(cf, cfile, panelName, panelFile); - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Added new command: " + e.getMessage())); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Added new command: " + e.getMessage())); break; case "commands:remove": List commandsOnOpenRemove; if(cf.contains("item." + itemSlot + ".commands")){ commandsOnOpenRemove = cf.getStringList("item." + itemSlot + ".commands"); }else{ - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.RED + "No commands found to remove!")); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "No commands found to remove!")); break; } try { commandsOnOpenRemove.remove(Integer.parseInt(e.getMessage())-1); }catch (Exception ex){ - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.RED + "Could not find command!")); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "Could not find command!")); plugin.debug(ex,p); break; } @@ -586,7 +586,7 @@ public class EditorUserInput implements Listener { cf.set("item." + itemSlot + ".commands", commandsOnOpenRemove); } savePanelFile(cf, cfile, panelName, panelFile); - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Removed command line " + e.getMessage())); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Removed command line " + e.getMessage())); break; case "lore:add": List loreOnOpenAdd = new ArrayList<>(); @@ -596,20 +596,20 @@ public class EditorUserInput implements Listener { loreOnOpenAdd.add(e.getMessage()); cf.set("item." + itemSlot + ".lore", loreOnOpenAdd); savePanelFile(cf, cfile, panelName, panelFile); - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Added new lore: " + e.getMessage())); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Added new lore: " + e.getMessage())); break; case "lore:remove": List loreOnOpenRemove; if(cf.contains("item." + itemSlot + ".lore")){ loreOnOpenRemove = cf.getStringList("item." + itemSlot + ".lore"); }else{ - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.RED + "No lore found to remove!")); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "No lore found to remove!")); break; } try { loreOnOpenRemove.remove(Integer.parseInt(e.getMessage())-1); }catch (Exception ex){ - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.RED + "Could not find lore!")); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "Could not find lore!")); plugin.debug(ex,p); break; } @@ -619,7 +619,7 @@ public class EditorUserInput implements Listener { cf.set("item." + itemSlot + ".lore", loreOnOpenRemove); } savePanelFile(cf, cfile, panelName, panelFile); - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Removed lore line " + e.getMessage())); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Removed lore line " + e.getMessage())); break; case "duplicate:add": if(cf.contains("item." + itemSlot + ".duplicate")){ @@ -628,7 +628,7 @@ public class EditorUserInput implements Listener { cf.set("item." + itemSlot + ".duplicate", e.getMessage()); } savePanelFile(cf, cfile, panelName, panelFile); - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Added new duplicate item/s: " + e.getMessage())); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Added new duplicate item/s: " + e.getMessage())); break; case "duplicate:remove": if(cf.contains("item." + itemSlot + ".duplicate")){ @@ -644,7 +644,7 @@ public class EditorUserInput implements Listener { } cf.set("item." + itemSlot + ".duplicate", items.toString()); } catch (Exception ex) { - p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.RED + "Could not delete or find item!")); + p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Could not delete or find item!")); plugin.debug(ex,p); break; } @@ -655,11 +655,11 @@ public class EditorUserInput implements Listener { cf.set("item." + itemSlot + ".duplicate", null); } }else{ - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.RED + "No items found to remove!")); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "No items found to remove!")); break; } savePanelFile(cf, cfile, panelName, panelFile); - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Removed duplicate item/s: " + e.getMessage())); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Removed duplicate item/s: " + e.getMessage())); break; } } @@ -682,19 +682,19 @@ public class EditorUserInput implements Listener { cf.set("item." + itemSection + "." + playerMessage + ".name", ""); savePanelFile(cf, cfile, panelName, panelFile); plugin.reloadPanelFiles(); - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Added Section " + ChatColor.WHITE + playerMessage)); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Added Section " + ChatColor.WHITE + playerMessage)); break; case "remove": cf.set("item." + itemSection + "." + playerMessage, null); savePanelFile(cf, cfile, panelName, panelFile); plugin.reloadPanelFiles(); - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Removed Section " + ChatColor.WHITE + playerMessage)); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Removed Section " + ChatColor.WHITE + playerMessage)); break; case "change": cf.set("item." + itemSection + "." + playerMessage.split(":")[0], playerMessage.split(":")[1]); savePanelFile(cf, cfile, panelName, panelFile); plugin.reloadPanelFiles(); - p.sendMessage(plugin.tex.papi( plugin.tag + ChatColor.GREEN + "Set " + playerMessage.split(":")[0] + " to " + ChatColor.WHITE + playerMessage.split(":")[1])); + p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Set " + playerMessage.split(":")[0] + " to " + ChatColor.WHITE + playerMessage.split(":")[1])); break; } } diff --git a/src/me/rockyhawk/commandpanels/ingameeditor/EditorUtils.java b/src/me/rockyhawk/commandpanels/ingameeditor/EditorUtils.java index 429ad67..049d24b 100644 --- a/src/me/rockyhawk/commandpanels/ingameeditor/EditorUtils.java +++ b/src/me/rockyhawk/commandpanels/ingameeditor/EditorUtils.java @@ -35,7 +35,7 @@ public class EditorUtils implements Listener { return; } }catch(NullPointerException nu){return;} - if(!p.getOpenInventory().getTitle().equals(ChatColor.stripColor(plugin.tex.papi("Command Panels Editor"))) || plugin.openPanels.hasPanelOpen(p.getName())){ + if(!p.getOpenInventory().getTitle().equals(ChatColor.stripColor(plugin.tex.colour("Command Panels Editor"))) || plugin.openPanels.hasPanelOpen(p.getName())){ return; } if(e.getClickedInventory() != e.getView().getTopInventory()){ @@ -47,8 +47,8 @@ public class EditorUtils implements Listener { ArrayList panelYaml = new ArrayList(); //all panels from ALL files (panel yaml files) try { for(Panel panel : plugin.panelList) { //will loop through all the files in folder - panelNames.add(plugin.tex.papi(panel.getName())); - panelTitles.add(plugin.tex.papi( Objects.requireNonNull(panel.getConfig().getString("title")))); + panelNames.add(plugin.tex.colour(panel.getName())); + panelTitles.add(plugin.tex.colour( Objects.requireNonNull(panel.getConfig().getString("title")))); panelYaml.add(panel.getConfig()); } }catch(Exception fail){ @@ -337,52 +337,52 @@ public class EditorUtils implements Listener { } if(e.getSlot() == 1){ plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.perm"}); - p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Enter New Permission")); + p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Permission")); p.closeInventory(); } if(e.getSlot() == 3){ plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.title"}); - p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Enter New Title")); + p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Title")); p.closeInventory(); } if(e.getSlot() == 5){ plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.sound-on-open"}); - p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Enter New Sound ID")); + p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Sound ID")); p.closeInventory(); } if(e.getSlot() == 7){ if(e.getClick().isLeftClick()) { plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "panel.commands.add"}); - p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Enter New Command")); + p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Command")); }else{ plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "panel.commands.remove"}); - p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Enter Command to remove (must be an integer)")); + p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter Command to remove (must be an integer)")); } p.closeInventory(); } if(e.getSlot() == 21){ plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.delete"}); - p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Are you sure? (yes/no)")); + p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Are you sure? (yes/no)")); p.closeInventory(); } if(e.getSlot() == 23){ plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.rows"}); - p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Enter Row Amount (1 to 6)")); + p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter Row Amount (1 to 6)")); p.closeInventory(); } if(e.getSlot() == 13){ plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.empty"}); - p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Enter New Material ID")); + p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Material ID")); p.closeInventory(); } if(e.getSlot() == 15){ //adds abilities to add and remove lines if(e.getClick().isLeftClick()) { plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "panel.commands-on-open.add"}); - p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Enter New Command")); + p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Command")); }else{ plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "panel.commands-on-open.remove"}); - p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Enter Command to remove (must be an integer)")); + p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter Command to remove (must be an integer)")); } p.closeInventory(); } @@ -390,10 +390,10 @@ public class EditorUtils implements Listener { //adds abilities to add and remove types if(e.getClick().isLeftClick()) { plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "panel.panelType.add"}); - p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Enter New Panel type")); + p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Panel type")); }else{ plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "panel.panelType.remove"}); - p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Enter Panel Type to remove (must be an integer)")); + p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter Panel Type to remove (must be an integer)")); } p.closeInventory(); } @@ -401,16 +401,16 @@ public class EditorUtils implements Listener { //adds abilities to add and remove lines if(e.getClick().isLeftClick()) { plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "panel.disabled-worlds.add"}); - p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Enter New World Name")); + p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New World Name")); }else{ plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "panel.disabled-worlds.remove"}); - p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Enter World line to remove (must be an integer)")); + p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter World line to remove (must be an integer)")); } p.closeInventory(); } if(e.getSlot() == 11){ plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.name"}); - p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Enter New Name")); + p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Name")); p.closeInventory(); } if(e.getSlot() == 18){ @@ -419,38 +419,38 @@ public class EditorUtils implements Listener { } if(e.getSlot() == 40){ plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.hotbar.material"}); - p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Enter New Material")); + p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Material")); p.closeInventory(); } if(e.getSlot() == 38 && hotbarItems){ plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.hotbar.name"}); - p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Enter New Name")); + p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Name")); p.closeInventory(); } if(e.getSlot() == 36 && hotbarItems){ //adds abilities to add and remove lines if(e.getClick().isLeftClick()) { plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.hotbar.lore.add"}); - p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Enter New Item Lore")); + p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Item Lore")); }else{ plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.hotbar.lore.remove"}); - p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Enter lore line to remove (must be an integer)")); + p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter lore line to remove (must be an integer)")); } p.closeInventory(); } if(e.getSlot() == 42 && hotbarItems){ plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.hotbar.stationary"}); - p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Enter Location (1 to 9)")); + p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter Location (1 to 9)")); p.closeInventory(); } if(e.getSlot() == 44 && hotbarItems){ //adds abilities to add and remove lines if(e.getClick().isLeftClick()) { plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.hotbar.commands.add"}); - p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Enter New Item Command")); + p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Item Command")); }else{ plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.hotbar.commands.remove"}); - p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Enter command line to remove (must be an integer)")); + p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter command line to remove (must be an integer)")); } p.closeInventory(); } @@ -494,38 +494,38 @@ public class EditorUtils implements Listener { } if(e.getSlot() == 1){ plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"item:" + itemSlot + ":name"}); - p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Enter New Item Name")); + p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Item Name")); p.closeInventory(); } if(e.getSlot() == 3){ //adds abilities to add and remove lines if(e.getClick().isLeftClick()) { plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "item:" + itemSlot + ":commands:add"}); - p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Enter New Item Command")); + p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Item Command")); }else{ plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "item:" + itemSlot + ":commands:remove"}); - p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Enter command line to remove (must be an integer)")); + p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter command line to remove (must be an integer)")); } p.closeInventory(); } if(e.getSlot() == 5){ plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"item:" + itemSlot + ":enchanted"}); - p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Enter New Item Enchantment")); + p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Item Enchantment")); p.closeInventory(); } if(e.getSlot() == 7){ plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"item:" + itemSlot + ":potion"}); - p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Enter New Item Potion Effect")); + p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Item Potion Effect")); p.closeInventory(); } if(e.getSlot() == 13){ //adds abilities to add and remove items if(e.getClick().isLeftClick()) { plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "item:" + itemSlot + ":duplicate:add"}); - p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Enter Duplicate Item Location/s")); + p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter Duplicate Item Location/s")); }else{ plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "item:" + itemSlot + ":duplicate:remove"}); - p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Enter Duplicate Item/s to Remove (must be an integer)")); + p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter Duplicate Item/s to Remove (must be an integer)")); } p.closeInventory(); } @@ -533,26 +533,26 @@ public class EditorUtils implements Listener { //adds abilities to add and remove lines if(e.getClick().isLeftClick()) { plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "item:" + itemSlot + ":lore:add"}); - p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Enter New Item Lore")); + p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Item Lore")); }else{ plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "item:" + itemSlot + ":lore:remove"}); - p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Enter lore line to remove (must be an integer)")); + p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter lore line to remove (must be an integer)")); } p.closeInventory(); } if(e.getSlot() == 21){ plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"item:" + itemSlot + ":stack"}); - p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Enter New Item Stack (must be an integer)")); + p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Item Stack (must be an integer)")); p.closeInventory(); } if(e.getSlot() == 23){ plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"item:" + itemSlot + ":customdata"}); - p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Enter New Custom Model Data")); + p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Custom Model Data")); p.closeInventory(); } if(e.getSlot() == 25){ plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"item:" + itemSlot + ":leatherarmor"}); - p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Enter New Leather Armor Colour")); + p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Leather Armor Colour")); p.closeInventory(); } if(e.getSlot() == 31){ @@ -562,7 +562,7 @@ public class EditorUtils implements Listener { } if(e.getSlot() == 35){ plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"item:" + itemSlot + ":head"}); - p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Enter New Custom Material (eg. cps= self)")); + p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Custom Material (eg. cps= self)")); p.closeInventory(); } if(e.getSlot() == 27){ @@ -627,7 +627,7 @@ public class EditorUtils implements Listener { }else{ String itemNameSection = "." + ChatColor.stripColor(e.getInventory().getItem(e.getSlot()).getItemMeta().getDisplayName()); plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"section.change." + section + itemNameSection}); - p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Enter Setting to change, eg, value:500")); + p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter Setting to change, eg, value:500")); p.closeInventory(); } } @@ -635,13 +635,13 @@ public class EditorUtils implements Listener { if(e.getSlot() == 38){ plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"section.remove." + section}); - p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Enter Section name to remove, eg, hasperm or hasperm0")); + p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter Section name to remove, eg, hasperm or hasperm0")); p.closeInventory(); } if(e.getSlot() == 42){ plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"section.add." + section}); - p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + "Enter Section name to add, eg, hasperm or hasperm0")); + p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter Section name to add, eg, hasperm or hasperm0")); p.closeInventory(); } @@ -720,9 +720,9 @@ public class EditorUtils implements Listener { config = plugin.itemCreate.generatePanelFile(panelName,inv,config); try { config.save(file); - p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.GREEN + "Saved Changes!")); + p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.GREEN + "Saved Changes!")); } catch (IOException s) { - p.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.RED + "Could Not Save Changes!")); + p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Could Not Save Changes!")); plugin.debug(s,p); } plugin.reloadPanelFiles(); diff --git a/src/me/rockyhawk/commandpanels/interactives/CommandpanelUserInput.java b/src/me/rockyhawk/commandpanels/interactives/CommandpanelUserInput.java index 9367d28..9a898d9 100644 --- a/src/me/rockyhawk/commandpanels/interactives/CommandpanelUserInput.java +++ b/src/me/rockyhawk/commandpanels/interactives/CommandpanelUserInput.java @@ -19,7 +19,7 @@ public class CommandpanelUserInput implements Listener { if(plugin.userInputStrings.get(o)[0].equals(e.getPlayer().getName())){ if(e.getMessage().equalsIgnoreCase(plugin.config.getString("config.input-cancel"))){ e.setCancelled(true); - e.getPlayer().sendMessage(plugin.tex.papi( Objects.requireNonNull(plugin.config.getString("config.input-cancelled")))); + e.getPlayer().sendMessage(plugin.tex.colour( Objects.requireNonNull(plugin.config.getString("config.input-cancelled")))); for(int i = 0; plugin.userInputStrings.size() > i; i++){ if(plugin.userInputStrings.get(i)[0].equals(e.getPlayer().getName())){ plugin.userInputStrings.remove(i); diff --git a/src/me/rockyhawk/commandpanels/interactives/Commandpanelrefresher.java b/src/me/rockyhawk/commandpanels/interactives/Commandpanelrefresher.java index 59d51c3..52cf18b 100644 --- a/src/me/rockyhawk/commandpanels/interactives/Commandpanelrefresher.java +++ b/src/me/rockyhawk/commandpanels/interactives/Commandpanelrefresher.java @@ -3,7 +3,6 @@ package me.rockyhawk.commandpanels.interactives; import me.rockyhawk.commandpanels.CommandPanels; import me.rockyhawk.commandpanels.api.Panel; import me.rockyhawk.commandpanels.api.PanelOpenedEvent; -import me.rockyhawk.commandpanels.ioclasses.nbt.NBT_1_13; import org.bukkit.Bukkit; import org.bukkit.Sound; import org.bukkit.configuration.file.YamlConfiguration; @@ -22,13 +21,13 @@ public class Commandpanelrefresher implements Listener { } @EventHandler public void onPanelOpen(PanelOpenedEvent e){ //Handles when Players open inventory - //I have to convert HumanEntity to a player if (plugin.config.contains("config.refresh-panels")) { if (Objects.requireNonNull(plugin.config.getString("config.refresh-panels")).trim().equalsIgnoreCase("false")) { return; } } + //I have to convert HumanEntity to a player Player p = e.getPlayer(); Panel pn = e.getPanel(); diff --git a/src/me/rockyhawk/commandpanels/ioclasses/nbt/NBTManager.java b/src/me/rockyhawk/commandpanels/ioclasses/nbt/NBTManager.java index b3f4023..daa57c0 100644 --- a/src/me/rockyhawk/commandpanels/ioclasses/nbt/NBTManager.java +++ b/src/me/rockyhawk/commandpanels/ioclasses/nbt/NBTManager.java @@ -10,11 +10,12 @@ public class NBTManager { this.plugin = pl; } + //commandpanel item NBT public boolean hasNBT(ItemStack item){ if(plugin.legacy.LOCAL_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_13)){ return new NBT_1_13().contains(item, "CommandPanelsItem"); }else{ - return new NBT_1_14(plugin).hasNBT(item); + return new NBT_1_14(plugin).hasNBT(item,"CommandPanelsItem"); } } @@ -22,7 +23,28 @@ public class NBTManager { if(plugin.legacy.LOCAL_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_13)){ return new NBT_1_13().set(item,1,"CommandPanelsItem"); }else{ - return new NBT_1_14(plugin).addNBT(item); + return new NBT_1_14(plugin).addNBT(item,"CommandPanelsItem","1"); + } + } + + //custom key NBT + public String getNBT(ItemStack item, String key){ + String output = ""; + if(plugin.legacy.LOCAL_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_13)){ + try{ + output = new NBT_1_13().getString(item, key); + }catch(NullPointerException ignore){} + }else{ + output = new NBT_1_14(plugin).getNBT(item, key); + } + return output; + } + + public ItemStack setNBT(ItemStack item, String key, String value){ + if(plugin.legacy.LOCAL_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_13)){ + return new NBT_1_13().set(item,value,key); + }else{ + return new NBT_1_14(plugin).addNBT(item,key,value); } } } diff --git a/src/me/rockyhawk/commandpanels/ioclasses/nbt/NBT_1_14.java b/src/me/rockyhawk/commandpanels/ioclasses/nbt/NBT_1_14.java index a64f3f2..134b2bb 100644 --- a/src/me/rockyhawk/commandpanels/ioclasses/nbt/NBT_1_14.java +++ b/src/me/rockyhawk/commandpanels/ioclasses/nbt/NBT_1_14.java @@ -13,17 +13,32 @@ public class NBT_1_14 { } //NBT class for Minecraft versions 1.14+ - public ItemStack addNBT(ItemStack item){ - NamespacedKey key = new NamespacedKey(plugin, "CommandPanelsItem"); + public ItemStack addNBT(ItemStack item, String key, String value){ + NamespacedKey ns_key = new NamespacedKey(plugin, key); ItemMeta itemMeta = item.getItemMeta(); - itemMeta.getPersistentDataContainer().set(key, PersistentDataType.INTEGER, 1); + itemMeta.getPersistentDataContainer().set(ns_key, PersistentDataType.STRING, value); item.setItemMeta(itemMeta); return item; } - public boolean hasNBT(ItemStack item){ - NamespacedKey key = new NamespacedKey(plugin, "CommandPanelsItem"); - ItemMeta itemMeta = item.getItemMeta(); - return itemMeta.getPersistentDataContainer().has(key, PersistentDataType.INTEGER); + public boolean hasNBT(ItemStack item, String key){ + NamespacedKey ns_key = new NamespacedKey(plugin, key); + try { + ItemMeta itemMeta = item.getItemMeta(); + return itemMeta.getPersistentDataContainer().has(ns_key, PersistentDataType.STRING); + }catch (Exception e){ + return false; + } + } + + public String getNBT(ItemStack item, String key){ + NamespacedKey ns_key = new NamespacedKey(plugin, key); + try { + ItemMeta itemMeta = item.getItemMeta(); + return itemMeta.getPersistentDataContainer().get(ns_key, PersistentDataType.STRING); + }catch (Exception e){ + plugin.debug(e,null); + return ""; + } } } diff --git a/src/me/rockyhawk/commandpanels/openpanelsmanager/OpenGUI.java b/src/me/rockyhawk/commandpanels/openpanelsmanager/OpenGUI.java index ad0adff..99aa6cf 100644 --- a/src/me/rockyhawk/commandpanels/openpanelsmanager/OpenGUI.java +++ b/src/me/rockyhawk/commandpanels/openpanelsmanager/OpenGUI.java @@ -2,7 +2,6 @@ package me.rockyhawk.commandpanels.openpanelsmanager; import me.rockyhawk.commandpanels.CommandPanels; import me.rockyhawk.commandpanels.api.Panel; -import me.rockyhawk.commandpanels.ioclasses.nbt.NBT_1_13; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.configuration.ConfigurationSection; @@ -28,7 +27,7 @@ public class OpenGUI { String title; if (onOpen != 3) { //regular inventory - title = plugin.tex.papi(panel,p,pconfig.getString("title")); + title = plugin.tex.placeholders(panel,p,pconfig.getString("title")); } else { //editor inventory title = "Editing Panel: " + panel.getName(); @@ -111,7 +110,7 @@ public class OpenGUI { } catch (ArrayIndexOutOfBoundsException var24) { plugin.debug(var24,p); if (plugin.debug.isEnabled(p)) { - p.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.error") + " item: One of the items does not fit in the Panel!")); + p.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.error") + " item: One of the items does not fit in the Panel!")); p.closeInventory(); plugin.openPanels.closePanelForLoader(p.getName()); } @@ -149,7 +148,7 @@ public class OpenGUI { } } catch (IllegalArgumentException | NullPointerException var26) { plugin.debug(var26,p); - p.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.error") + " empty: " + pconfig.getString("empty"))); + p.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.error") + " empty: " + pconfig.getString("empty"))); p.closeInventory(); plugin.openPanels.closePanelForLoader(p.getName()); return null; diff --git a/src/me/rockyhawk/commandpanels/openwithitem/HotbarItemLoader.java b/src/me/rockyhawk/commandpanels/openwithitem/HotbarItemLoader.java index a92ca82..d86326d 100644 --- a/src/me/rockyhawk/commandpanels/openwithitem/HotbarItemLoader.java +++ b/src/me/rockyhawk/commandpanels/openwithitem/HotbarItemLoader.java @@ -63,6 +63,9 @@ public class HotbarItemLoader { //return true if found public boolean itemCheckExecute(ItemStack invItem, Player p, boolean openPanel, boolean stationaryOnly){ + if(plugin.nbt.getNBT(invItem,"CommandPanelsHotbar") == null){ + return false; + } for(Panel panel : plugin.panelList) { if(stationaryOnly){ if(!panel.getConfig().contains("open-with-item.stationary")){ @@ -70,13 +73,7 @@ public class HotbarItemLoader { } } if(panel.hasHotbarItem()){ - ItemStack panelItem = panel.getHotbarItem(p); - if(invItem != null && panelItem != null) { - panelItem.setAmount(invItem.getAmount()); - }else{ - return false; - } - if(panelItem.isSimilar(invItem)){ + if(plugin.nbt.getNBT(invItem,"CommandPanelsHotbar").equals(panel.getName())){ if(openPanel) { //only open panel automatically if there are no commands and if world is not disabled if(!plugin.panelPerms.isPanelWorldEnabled(p,panel.getConfig())){ diff --git a/src/me/rockyhawk/commandpanels/openwithitem/UtilsOpenWithItem.java b/src/me/rockyhawk/commandpanels/openwithitem/UtilsOpenWithItem.java index 771c0b9..465714d 100644 --- a/src/me/rockyhawk/commandpanels/openwithitem/UtilsOpenWithItem.java +++ b/src/me/rockyhawk/commandpanels/openwithitem/UtilsOpenWithItem.java @@ -43,13 +43,8 @@ public class UtilsOpenWithItem implements Listener { if (plugin.hotbar.stationaryExecute(e.getSlot(), p, true)) { e.setCancelled(true); p.updateInventory(); - return; } } - if (plugin.hotbar.itemCheckExecute(e.getCurrentItem(), p, false,true) || plugin.hotbar.itemCheckExecute(e.getCursor(), p, false,true) || plugin.hotbar.stationaryExecute(e.getHotbarButton(), p, false)) { - e.setCancelled(true); - p.updateInventory(); - } } @EventHandler public void onPlayerUse(PlayerInteractEvent e){ diff --git a/src/me/rockyhawk/commandpanels/panelblocks/Commandpanelblocks.java b/src/me/rockyhawk/commandpanels/panelblocks/Commandpanelblocks.java index 3412ef0..4844b14 100644 --- a/src/me/rockyhawk/commandpanels/panelblocks/Commandpanelblocks.java +++ b/src/me/rockyhawk/commandpanels/panelblocks/Commandpanelblocks.java @@ -26,13 +26,13 @@ public class Commandpanelblocks implements CommandExecutor { if(args.length >= 2) { if (args[0].equalsIgnoreCase("add")) { if(!(sender instanceof Player)) { - sender.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.RED + "Please execute command as a Player!")); + sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Please execute command as a Player!")); return true; } Player p = (Player)sender; if(p.hasPermission("commandpanel.block.add")){ if(Objects.requireNonNull(plugin.config.getString("config.panel-blocks")).equalsIgnoreCase("false")){ - sender.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.RED + "Panel blocks disabled in config!")); + sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Panel blocks disabled in config!")); return true; } boolean foundPanel = false; @@ -43,12 +43,12 @@ public class Commandpanelblocks implements CommandExecutor { } } if(!foundPanel){ - sender.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.nopanel"))); + sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.nopanel"))); return true; } Block blockType = p.getTargetBlock(null, 5); if(blockType.getType() == Material.AIR){ - sender.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.RED + "Look at a block to add a panel!")); + sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Look at a block to add a panel!")); return true; } Location blockLocation = blockType.getLocation(); @@ -60,15 +60,15 @@ public class Commandpanelblocks implements CommandExecutor { plugin.blockConfig.save(new File(plugin.getDataFolder() + File.separator + "blocks.yml")); } catch (IOException e) { plugin.debug(e,p); - sender.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.RED + "Could not save to file!")); + sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Could not save to file!")); return true; } //make the material name look okay String materialNameFormatted = blockType.getType().toString().substring(0, 1).toUpperCase() + blockType.getType().toString().substring(1).toLowerCase(); materialNameFormatted = materialNameFormatted.replaceAll("_"," "); - sender.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.WHITE + args[1] + ChatColor.GREEN + " will now open when right clicking " + ChatColor.WHITE + materialNameFormatted)); + sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + args[1] + ChatColor.GREEN + " will now open when right clicking " + ChatColor.WHITE + materialNameFormatted)); }else{ - sender.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.perms"))); + sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms"))); } return true; } @@ -76,13 +76,13 @@ public class Commandpanelblocks implements CommandExecutor { if(args.length == 1){ if (args[0].equalsIgnoreCase("remove")) { if(!(sender instanceof Player)) { - sender.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.RED + "Please execute command as a Player!")); + sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Please execute command as a Player!")); return true; } Player p = (Player)sender; if(p.hasPermission("commandpanel.block.remove")){ if(Objects.requireNonNull(plugin.config.getString("config.panel-blocks")).equalsIgnoreCase("false")){ - sender.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.RED + "Panel blocks disabled in config!")); + sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Panel blocks disabled in config!")); return true; } Block blockType = p.getTargetBlock(null, 5); @@ -94,38 +94,38 @@ public class Commandpanelblocks implements CommandExecutor { plugin.blockConfig.save(new File(plugin.getDataFolder() + File.separator + "blocks.yml")); } catch (IOException e) { plugin.debug(e,p); - sender.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.RED + "Could not save to file!")); + sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Could not save to file!")); return true; } - sender.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.GREEN + "Panel has been removed from block.")); + sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.GREEN + "Panel has been removed from block.")); }else{ - sender.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.nopanel"))); + sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.nopanel"))); } }else{ - sender.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.perms"))); + sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms"))); } return true; } if (args[0].equalsIgnoreCase("list")) { if(sender.hasPermission("commandpanel.block.list")){ if(Objects.requireNonNull(plugin.config.getString("config.panel-blocks")).equalsIgnoreCase("false")){ - sender.sendMessage(plugin.tex.papi(plugin.tag + ChatColor.RED + "Panel blocks disabled in config!")); + sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Panel blocks disabled in config!")); return true; } if(plugin.blockConfig.contains("blocks")){ if(Objects.requireNonNull(plugin.blockConfig.getConfigurationSection("blocks")).getKeys(false).size() == 0){ - sender.sendMessage(plugin.tex.papi(plugin.tag) + ChatColor.RED + "No panel blocks found."); + sender.sendMessage(plugin.tex.colour(plugin.tag) + ChatColor.RED + "No panel blocks found."); return true; } - sender.sendMessage(plugin.tex.papi(plugin.tag) + ChatColor.DARK_AQUA + "Panel Block Locations:"); + sender.sendMessage(plugin.tex.colour(plugin.tag) + ChatColor.DARK_AQUA + "Panel Block Locations:"); for (String location : Objects.requireNonNull(plugin.blockConfig.getConfigurationSection("blocks")).getKeys(false)) { sender.sendMessage(ChatColor.GREEN + location.replaceAll("_"," ") + ": " + ChatColor.WHITE + plugin.blockConfig.getString("blocks." + location + ".panel")); } }else{ - sender.sendMessage(plugin.tex.papi(plugin.tag) + ChatColor.RED + "No panel blocks found."); + sender.sendMessage(plugin.tex.colour(plugin.tag) + ChatColor.RED + "No panel blocks found."); } }else{ - sender.sendMessage(plugin.tex.papi(plugin.tag + plugin.config.getString("config.format.perms"))); + sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms"))); } return true; }