From 8a84ceac339fb61d677cddc6a63861f025bd4c4c Mon Sep 17 00:00:00 2001 From: rockyhawk64 Date: Fri, 16 Oct 2020 16:05:33 +1100 Subject: [PATCH] 3.12.4 Fixes --- resource/config.yml | 1 + resource/example.yml | 45 ++++++++-------- resource/exampleLegacy.yml | 3 +- resource/plugin.yml | 2 +- .../commandpanels/CommandPanels.java | 7 ++- .../classresources/ItemCreation.java | 8 +-- .../classresources/OpenEditorGuis.java | 14 +++-- .../commands/Commandpanelsreload.java | 4 +- .../Commandpanelcustom.java | 15 +++++- .../ingameeditor/EditorUserInput.java | 52 +++++++++++++------ .../ingameeditor/EditorUtils.java | 11 ++-- .../openwithitem/UtilsOpenWithItem.java | 50 ++++++++---------- 12 files changed, 131 insertions(+), 81 deletions(-) rename src/me/rockyhawk/commandpanels/{commands => customcommands}/Commandpanelcustom.java (65%) diff --git a/resource/config.yml b/resource/config.yml index f4677a9..b2e76b3 100644 --- a/resource/config.yml +++ b/resource/config.yml @@ -8,6 +8,7 @@ config: panel-blocks: true ingame-editor: true hotbar-items: true + custom-commands: true refresh-delay: 4 server-ping-timeout: 10 stop-sound: true diff --git a/resource/example.yml b/resource/example.yml index e6f7df8..0d9d0b2 100644 --- a/resource/example.yml +++ b/resource/example.yml @@ -9,16 +9,17 @@ panels: panelType: default rows: 4 title: '&6[&bExample Panel&6]&f Welcome!' - command: example + commands: + - "example" sound-on-open: BLOCK_NOTE_BLOCK_CHIME empty: BLACK_STAINED_GLASS_PANE disabled-worlds: - - 'world_nether' + - 'world_nether' open-with-item: material: CLOCK name: '&6[&bExample Panel&6]' lore: - - '&3Click me to open the panel!' + - '&3Click me to open the panel!' stationary: 4 item: '0': @@ -76,7 +77,7 @@ panels: material: RED_WOOL name: '&cYour nickname is not ''RockyHawk''' commands: - - 'msg= &cNot RockyHawk' + - 'msg= &cNot RockyHawk' hasvalue: output: true value: RockyHawk @@ -84,7 +85,7 @@ panels: material: LIME_WOOL name: '&aYour username is ''RockyHawk''' commands: - - 'msg= &aWelcome my master!' + - 'msg= &aWelcome my master!' '27': material: LEATHER_BOOTS name: '&e&lYELLOW' @@ -96,38 +97,38 @@ panels: enchanted: true name: '&cClick Me' lore: - - '&fI will teleport you home!' + - '&fI will teleport you home!' commands: - - home - - commandpanels:commandpanelclose - - console= title %cp-player-name% times 20 60 20 - - console= title %cp-player-name% subtitle {"text":"%cp-player-displayname%","color":"green"} - - console= title %cp-player-name% title {"text":"Welcome Home"} + - home + - commandpanels:commandpanelclose + - console= title %cp-player-name% times 20 60 20 + - console= title %cp-player-name% subtitle {"text":"%cp-player-displayname%","color":"green"} + - console= title %cp-player-name% title {"text":"Welcome Home"} '30': material: POTION name: '&5&lInstant Health II' potion: INSTANT_HEAL commands: - - heal - - commandpanels:commandpanelclose + - heal + - commandpanels:commandpanelclose '34': material: REDSTONE_BLOCK name: '&cNo Permission' lore: - - '&4You cannot change to' - - '&4creative looking like that!' + - '&4You cannot change to' + - '&4creative looking like that!' hasperm: perm: essentials.gamemode output: true material: EMERALD_BLOCK name: '&aClick Me' lore: - - '&2I will change you' - - '&2to creative mode!' + - '&2I will change you' + - '&2to creative mode!' commands: - - gamemode creative - - commandpanels:commandpanelclose - - console= title %cp-player-name% times 20 60 20 - - console= title %cp-player-name% subtitle {"text":"You are now in creative + - gamemode creative + - commandpanels:commandpanelclose + - console= title %cp-player-name% times 20 60 20 + - console= title %cp-player-name% subtitle {"text":"You are now in creative mode!","color":"green"} - - console= title %cp-player-name% title {"text":"Awesome %cp-player-displayname%"} + - console= title %cp-player-name% title {"text":"Awesome %cp-player-displayname%"} diff --git a/resource/exampleLegacy.yml b/resource/exampleLegacy.yml index 9698ac5..1418c31 100644 --- a/resource/exampleLegacy.yml +++ b/resource/exampleLegacy.yml @@ -9,7 +9,8 @@ panels: panelType: default rows: 4 title: '&6[&bExample Panel&6]&f Welcome!' - command: example + commands: + - "example" empty: STAINED_GLASS_PANE emptyID: 15 disabled-worlds: diff --git a/resource/plugin.yml b/resource/plugin.yml index 7c14eb2..f562f2c 100644 --- a/resource/plugin.yml +++ b/resource/plugin.yml @@ -1,4 +1,4 @@ -version: 3.12.3 +version: 3.12.4 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 a4026d6..6bfdca6 100644 --- a/src/me/rockyhawk/commandpanels/CommandPanels.java +++ b/src/me/rockyhawk/commandpanels/CommandPanels.java @@ -14,6 +14,7 @@ import me.realized.tokenmanager.api.TokenManager; import me.rockyhawk.commandpanels.classresources.*; import me.rockyhawk.commandpanels.commands.*; import me.rockyhawk.commandpanels.completetabs.CpTabComplete; +import me.rockyhawk.commandpanels.customcommands.Commandpanelcustom; import me.rockyhawk.commandpanels.generatepanels.Commandpanelsgenerate; import me.rockyhawk.commandpanels.generatepanels.GenUtils; import me.rockyhawk.commandpanels.generatepanels.TabCompleteGenerate; @@ -127,7 +128,6 @@ public class CommandPanels extends JavaPlugin { this.getServer().getPluginManager().registerEvents(new Utils(this), this); this.getServer().getPluginManager().registerEvents(new UtilsPanelsLoader(this), this); this.getServer().getPluginManager().registerEvents(new GenUtils(this), this); - this.getServer().getPluginManager().registerEvents(new Commandpanelcustom(this), this); this.getServer().getPluginManager().registerEvents(new CommandpanelUserInput(this), this); //if refresh-panels set to false, don't load this @@ -135,6 +135,11 @@ public class CommandPanels extends JavaPlugin { this.getServer().getPluginManager().registerEvents(new Commandpanelrefresher(this), this); } + //if custom-commands set to false, don't load this + if(Objects.requireNonNull(config.getString("config.custom-commands")).equalsIgnoreCase("true")){ + this.getServer().getPluginManager().registerEvents(new Commandpanelcustom(this), this); + } + //if hotbar-items set to false, don't load this if(Objects.requireNonNull(config.getString("config.hotbar-items")).equalsIgnoreCase("true")){ this.getServer().getPluginManager().registerEvents(new UtilsOpenWithItem(this), this); diff --git a/src/me/rockyhawk/commandpanels/classresources/ItemCreation.java b/src/me/rockyhawk/commandpanels/classresources/ItemCreation.java index 7c1f4dc..5041282 100644 --- a/src/me/rockyhawk/commandpanels/classresources/ItemCreation.java +++ b/src/me/rockyhawk/commandpanels/classresources/ItemCreation.java @@ -304,7 +304,7 @@ public class ItemCreation { //if output is true, and values match it will be this item, vice versa outputValue = cf.getBoolean("hasvalue.output"); } - String value = cf.getString("hasvalue.value"); + String value = ChatColor.stripColor(plugin.papi(p,plugin.setCpPlaceholders(p,cf.getString("hasvalue.value")))); String compare = ChatColor.stripColor(plugin.papi(p,plugin.setCpPlaceholders(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 @@ -321,7 +321,7 @@ public class ItemCreation { //if output is true, and values match it will be this item, vice versa outputValue = cf.getBoolean("hasvalue" + count + ".output"); } - value = cf.getString("hasvalue" + count + ".value"); + value = ChatColor.stripColor(plugin.papi(p,plugin.setCpPlaceholders(p,cf.getString("hasvalue" + count + ".value")))); compare = ChatColor.stripColor(plugin.papi(p,plugin.setCpPlaceholders(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 @@ -340,7 +340,7 @@ public class ItemCreation { //if output is true, and values match it will be this item, vice versa outputValue = cf.getBoolean("hasgreater.output"); } - int value = cf.getInt("hasgreater.value"); + int value = Integer.parseInt(ChatColor.stripColor(plugin.papi(p,plugin.setCpPlaceholders(p,cf.getString("hasgreater.value"))))); double compare = Double.parseDouble(ChatColor.stripColor(plugin.papi(p,plugin.setCpPlaceholders(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 @@ -356,7 +356,7 @@ public class ItemCreation { //if output is true, and values match it will be this item, vice versa outputValue = cf.getBoolean("hasgreater" + count + ".output"); } - value = cf.getInt("hasgreater" + count + ".value"); + value = Integer.parseInt(ChatColor.stripColor(plugin.papi(p,plugin.setCpPlaceholders(p,cf.getString("hasgreater" + count + ".value"))))); compare = Double.parseDouble(ChatColor.stripColor(plugin.papi(p,plugin.setCpPlaceholders(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 diff --git a/src/me/rockyhawk/commandpanels/classresources/OpenEditorGuis.java b/src/me/rockyhawk/commandpanels/classresources/OpenEditorGuis.java index 8118432..ea99577 100644 --- a/src/me/rockyhawk/commandpanels/classresources/OpenEditorGuis.java +++ b/src/me/rockyhawk/commandpanels/classresources/OpenEditorGuis.java @@ -155,10 +155,16 @@ public class OpenEditorGuis { temp = new ItemStack(Material.IRON_DOOR, 1); lore.clear(); - lore.add(ChatColor.GRAY + "Custom command to open panel"); - if (cf.contains("command")) { - lore.add(ChatColor.WHITE + "----------------------------"); - lore.add(ChatColor.WHITE + cf.getString("command")); + lore.add(ChatColor.GRAY + "Custom commands to open panel"); + lore.add(ChatColor.GRAY + "- Left click to add command"); + lore.add(ChatColor.GRAY + "- Right click to remove command"); + if (cf.contains("commands")) { + lore.add(ChatColor.WHITE + "-----------------------------"); + int count = 1; + for (String tempLore : cf.getStringList("commands")) { + lore.add(ChatColor.WHITE + Integer.toString(count) + ") " + tempLore); + count += 1; + } } plugin.setName(temp, ChatColor.WHITE + "Panel Command", lore, p,true, true); i.setItem(7, temp); diff --git a/src/me/rockyhawk/commandpanels/commands/Commandpanelsreload.java b/src/me/rockyhawk/commandpanels/commands/Commandpanelsreload.java index ff9c7ce..8ce6ea2 100644 --- a/src/me/rockyhawk/commandpanels/commands/Commandpanelsreload.java +++ b/src/me/rockyhawk/commandpanels/commands/Commandpanelsreload.java @@ -1,6 +1,7 @@ package me.rockyhawk.commandpanels.commands; import me.rockyhawk.commandpanels.CommandPanels; +import me.rockyhawk.commandpanels.customcommands.Commandpanelcustom; import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -9,7 +10,6 @@ import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.event.EventHandler; import java.io.File; -import java.io.IOException; public class Commandpanelsreload implements CommandExecutor { CommandPanels plugin; @@ -25,8 +25,10 @@ public class Commandpanelsreload implements CommandExecutor { //empty } plugin.config = YamlConfiguration.loadConfiguration(new File(plugin.getDataFolder() + File.separator + "config.yml")); + //check for duplicates plugin.checkDuplicatePanel(sender); + tag = plugin.config.getString("config.format.tag") + " "; sender.sendMessage(plugin.papi(tag + plugin.config.getString("config.format.reload"))); return true; diff --git a/src/me/rockyhawk/commandpanels/commands/Commandpanelcustom.java b/src/me/rockyhawk/commandpanels/customcommands/Commandpanelcustom.java similarity index 65% rename from src/me/rockyhawk/commandpanels/commands/Commandpanelcustom.java rename to src/me/rockyhawk/commandpanels/customcommands/Commandpanelcustom.java index df39e8c..967c33f 100644 --- a/src/me/rockyhawk/commandpanels/commands/Commandpanelcustom.java +++ b/src/me/rockyhawk/commandpanels/customcommands/Commandpanelcustom.java @@ -1,6 +1,7 @@ -package me.rockyhawk.commandpanels.commands; +package me.rockyhawk.commandpanels.customcommands; import me.rockyhawk.commandpanels.CommandPanels; +import org.bukkit.ChatColor; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.event.EventHandler; @@ -28,11 +29,23 @@ public class Commandpanelcustom implements Listener { for(String[] panelName : plugin.panelNames){ tempFile = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + plugin.panelFiles.get(Integer.parseInt(panelName[1])))).getConfigurationSection("panels." + panelName[0]); + if(tempFile.contains("commands")) { + List panelCommands = tempFile.getStringList("commands"); + if(panelCommands.contains(e.getMessage().replace("/",""))){ + e.setCancelled(true); + plugin.openVoids.openCommandPanel(e.getPlayer(),e.getPlayer(),panelName[0],tempFile,false); + return; + } + } + + //this will be deleted next update if(tempFile.contains("command")) { List panelCommands = Arrays.asList(tempFile.getString("command").split("\\s")); if(panelCommands.contains(e.getMessage().replace("/",""))){ e.setCancelled(true); + plugin.getServer().getConsoleSender().sendMessage(ChatColor.RED + "[CommandPanels] Using command: for custom commands will soon be deprecated. Please use commands: as shown in the wiki instead!"); plugin.openVoids.openCommandPanel(e.getPlayer(),e.getPlayer(),panelName[0],tempFile,false); + return; } } } diff --git a/src/me/rockyhawk/commandpanels/ingameeditor/EditorUserInput.java b/src/me/rockyhawk/commandpanels/ingameeditor/EditorUserInput.java index d2986a3..84efb18 100644 --- a/src/me/rockyhawk/commandpanels/ingameeditor/EditorUserInput.java +++ b/src/me/rockyhawk/commandpanels/ingameeditor/EditorUserInput.java @@ -122,10 +122,9 @@ public class EditorUserInput implements Listener { switch (section) { case "panel.delete": if (e.getMessage().contains("y")) { - if(Objects.requireNonNull(cf.getConfigurationSection("panels")).getKeys(false).size() != 1){ + if(Objects.requireNonNull(cfile.getConfigurationSection("panels")).getKeys(false).size() != 1){ //if the file has more than one panel in it - cf.set("panels." + panelName, null); - if(savePanelFile(cf, cfile, panelName, panelFile)){ + if(savePanelFile(null, cfile, panelName, panelFile)){ p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Deleted Panel!")); }else{ p.sendMessage(plugin.papi( tag + ChatColor.RED + "Could Not Delete Panel!")); @@ -182,9 +181,9 @@ public class EditorUserInput implements Listener { p.sendMessage(plugin.papi(tag + ChatColor.RED + e.getMessage() + " is in use from another panel!")); break; } - cf.set("panels." + e.getMessage(), cf.get("panels." + panelName)); - cf.set("panels." + panelName, null); - savePanelFile(cf, cfile, panelName, panelFile); + 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.papi( tag + ChatColor.GREEN + "Set new Name to " + e.getMessage())); break; case "panel.empty": @@ -222,16 +221,37 @@ public class EditorUserInput implements Listener { savePanelFile(cf, cfile, panelName, panelFile); p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Sound when opening is now " + tempSound)); break; - case "panel.command": - if(e.getMessage().trim().equalsIgnoreCase("remove")){ - cf.set("command", null); - savePanelFile(cf, cfile, panelName, panelFile); - p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Custom commands have been removed.")); + case "panel.commands.add": + List commandsAdd = new ArrayList<>(); + if(cf.contains("commands")){ + commandsAdd = cf.getStringList("commands"); + } + commandsAdd.add(e.getMessage()); + cf.set("commands", commandsAdd); + savePanelFile(cf, cfile, panelName, panelFile); + p.sendMessage(plugin.papi( 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.papi( tag + ChatColor.RED + "No commands found to remove!")); break; } - cf.set("command", e.getMessage()); + try { + commandsRemove.remove(Integer.parseInt(e.getMessage())-1); + }catch (Exception ex){ + p.sendMessage(plugin.papi( tag + ChatColor.RED + "Could not find command!")); + break; + } + if(commandsRemove.size() == 0){ + cf.set("commands", null); + }else{ + cf.set("commands", commandsRemove); + } savePanelFile(cf, cfile, panelName, panelFile); - p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Set new custom commands to " + ChatColor.WHITE + "/" + e.getMessage().trim().replace(" ", " /"))); + p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Removed command line " + e.getMessage())); break; case "panel.commands-on-open.add": List commandsOnOpenAdd = new ArrayList<>(); @@ -386,7 +406,7 @@ public class EditorUserInput implements Listener { everything else */ String tag = plugin.config.getString("config.format.tag") + " "; - String itemSlot = section.split("\\:")[1]; + String itemSlot = section.split(":")[1]; String sectionChange = section.replace("item:" + itemSlot + ":",""); switch (sectionChange) { case "name": @@ -571,10 +591,10 @@ public class EditorUserInput implements Listener { p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Removed Section " + ChatColor.WHITE + playerMessage)); break; case "change": - cf.set("item." + itemSection + "." + playerMessage.split("\\:")[0], playerMessage.split("\\:")[1]); + cf.set("item." + itemSection + "." + playerMessage.split(":")[0], playerMessage.split(":")[1]); savePanelFile(cf, cfile, panelName, panelFile); plugin.reloadPanelFiles(); - p.sendMessage(plugin.papi( tag + ChatColor.GREEN + "Set " + playerMessage.split("\\:")[0] + " to " + ChatColor.WHITE + playerMessage.split("\\:")[1])); + p.sendMessage(plugin.papi( 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 ef216d9..cec7d53 100644 --- a/src/me/rockyhawk/commandpanels/ingameeditor/EditorUtils.java +++ b/src/me/rockyhawk/commandpanels/ingameeditor/EditorUtils.java @@ -393,8 +393,13 @@ public class EditorUtils implements Listener { p.closeInventory(); } if(e.getSlot() == 7){ - plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.command"}); - p.sendMessage(plugin.papi(tag + ChatColor.WHITE + "Enter New Command")); + if(e.getClick().isLeftClick()) { + plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "panel.commands.add"}); + p.sendMessage(plugin.papi(tag + ChatColor.WHITE + "Enter New Command")); + }else{ + plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "panel.commands.remove"}); + p.sendMessage(plugin.papi(tag + ChatColor.WHITE + "Enter Command to remove (must be an integer)")); + } p.closeInventory(); } if(e.getSlot() == 21){ @@ -419,7 +424,7 @@ public class EditorUtils implements Listener { p.sendMessage(plugin.papi(tag + ChatColor.WHITE + "Enter New Command")); }else{ plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "panel.commands-on-open.remove"}); - p.sendMessage(plugin.papi(tag + ChatColor.WHITE + "Enter Command line to remove (must be an integer)")); + p.sendMessage(plugin.papi(tag + ChatColor.WHITE + "Enter Command to remove (must be an integer)")); } p.closeInventory(); } diff --git a/src/me/rockyhawk/commandpanels/openwithitem/UtilsOpenWithItem.java b/src/me/rockyhawk/commandpanels/openwithitem/UtilsOpenWithItem.java index 5220d93..689e858 100644 --- a/src/me/rockyhawk/commandpanels/openwithitem/UtilsOpenWithItem.java +++ b/src/me/rockyhawk/commandpanels/openwithitem/UtilsOpenWithItem.java @@ -339,7 +339,7 @@ public class UtilsOpenWithItem implements Listener { return; } //cancel everything if holding item (item frames eg) - Player p = (Player)e.getPlayer(); + Player p = e.getPlayer(); try { if (plugin.panelFiles == null) { return; @@ -347,37 +347,33 @@ public class UtilsOpenWithItem implements Listener { }catch(Exception b){ return; } - YamlConfiguration cf; //this is the file to use for any panel.* requests - String tpanels; //tpanels is the temp to check through the files ItemStack clicked = e.getPlayer().getInventory().getItemInMainHand(); - for(String fileName : plugin.panelFiles) { //will loop through all the files in folder - YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName)); - String key; - tpanels = ""; - if(!plugin.checkPanels(temp)){ - continue; - } - for (Iterator var10 = Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false).iterator(); var10.hasNext(); tpanels = tpanels + key + " ") { - key = (String) var10.next(); - if (temp.contains("panels." + key + ".open-with-item")) { - if (clicked.getType() != Material.AIR) { - //if loop has material first to stop 1.12.2 from spitting errors - //try and catch loop to stop errors with the same material type but different name - try { - if (clicked.getType() == new ItemStack(Objects.requireNonNull(Material.matchMaterial(Objects.requireNonNull(temp.getString("panels." + key + ".open-with-item.material")))), 1).getType()) { - if ((plugin.papi( Objects.requireNonNull(clicked.getItemMeta()).getDisplayName()).equals(plugin.papi( Objects.requireNonNull(temp.getString("panels." + key + ".open-with-item.name")))))) { - //cancel the click item event - if (temp.contains("panels." + key + ".open-with-item.stationary")) { - if (p.getInventory().getHeldItemSlot() == Integer.parseInt(Objects.requireNonNull(temp.getString("panels." + key + ".open-with-item.stationary")))) { - e.setCancelled(true); - } + String tempName; + ConfigurationSection tempFile; + for(String[] panelName : plugin.panelNames){ + tempName = panelName[0]; + tempFile = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + plugin.panelFiles.get(Integer.parseInt(panelName[1])))).getConfigurationSection("panels." + tempName); + + if (tempFile.contains("open-with-item")) { + if (clicked.getType() != Material.AIR) { + //if loop has material first to stop 1.12.2 from spitting errors + //try and catch loop to stop errors with the same material type but different name + try { + if (clicked.getType() == new ItemStack(Objects.requireNonNull(Material.matchMaterial(Objects.requireNonNull(tempFile.getString("open-with-item.material")))), 1).getType()) { + if ((plugin.papi( Objects.requireNonNull(clicked.getItemMeta()).getDisplayName()).equals(plugin.papi( Objects.requireNonNull(tempFile.getString("open-with-item.name")))))) { + //cancel the click item event + if (tempFile.contains("open-with-item.stationary")) { + if (p.getInventory().getHeldItemSlot() == Integer.parseInt(Objects.requireNonNull(tempFile.getString("open-with-item.stationary")))) { + e.setCancelled(true); + p.updateInventory(); + plugin.openVoids.openCommandPanel(p,p,tempName,tempFile,false); } - return; } + return; } - } catch (NullPointerException | IllegalArgumentException n) { - plugin.debug(n); } + } catch (NullPointerException | IllegalArgumentException n) { + plugin.debug(n); } } }