diff --git a/resource/plugin.yml b/resource/plugin.yml index 0fda631..06bca92 100644 --- a/resource/plugin.yml +++ b/resource/plugin.yml @@ -1,4 +1,4 @@ -version: 3.9.1 +version: 3.9.2 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 c9d700b..f5d62fe 100644 --- a/src/me/rockyhawk/commandPanels/commandpanels.java +++ b/src/me/rockyhawk/commandPanels/commandpanels.java @@ -995,7 +995,6 @@ public class commandpanels extends JavaPlugin { //look through all files in all folders public void fileNamesFromDirectory(File directory) { - int count = 0; for (String fileName : Objects.requireNonNull(directory.list())) { if(new File(directory + File.separator + fileName).isDirectory()){ fileNamesFromDirectory(new File(directory + File.separator + fileName)); @@ -1012,33 +1011,20 @@ public class commandpanels extends JavaPlugin { } panelFiles.add((directory + File.separator + fileName).replace(panelsf.toString() + File.separator,"")); for (String tempName : Objects.requireNonNull(YamlConfiguration.loadConfiguration(new File(directory + File.separator + fileName)).getConfigurationSection("panels")).getKeys(false)) { - panelNames.add(new String[]{tempName, Integer.toString(count)}); + panelNames.add(new String[]{tempName, Integer.toString(panelFiles.size()-1)}); + if(YamlConfiguration.loadConfiguration(new File(directory + File.separator + fileName)).contains("panels." + tempName + ".open-with-item")) { + openWithItem = true; + } } - count += 1; } } public void reloadPanelFiles() { panelFiles.clear(); panelNames.clear(); + openWithItem = false; //load panel files fileNamesFromDirectory(panelsf); - //this bit will set openWithItem to false/true upson reload - YamlConfiguration tempFile; - String tempName; - openWithItem = false; - for(String[] panelName : panelNames){ - tempFile = YamlConfiguration.loadConfiguration(new File(panelsf + File.separator + panelFiles.get(Integer.parseInt(panelName[1])))); - if(!checkPanels(tempFile)){ - this.getServer().getConsoleSender().sendMessage("[CommandPanels] Error in: " + panelFiles.get(Integer.parseInt(panelName[1]))); - continue; - } - tempName = panelName[0]; - if(tempFile.contains("panels." + tempName + ".open-with-item")) { - openWithItem = true; - break; - } - } } public void debug(Exception e) { diff --git a/src/me/rockyhawk/commandPanels/openWithItem/utilsOpenWithItem.java b/src/me/rockyhawk/commandPanels/openWithItem/utilsOpenWithItem.java index fdd5d7e..069a0a7 100644 --- a/src/me/rockyhawk/commandPanels/openWithItem/utilsOpenWithItem.java +++ b/src/me/rockyhawk/commandPanels/openWithItem/utilsOpenWithItem.java @@ -1,7 +1,6 @@ package me.rockyhawk.commandPanels.openWithItem; import me.rockyhawk.commandPanels.commandpanels; -import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.Player; @@ -92,7 +91,7 @@ public class utilsOpenWithItem implements Listener { try{ assert clicked != null; if (clicked.getType() == new ItemStack(Objects.requireNonNull(plugin.makeItemFromConfig(Objects.requireNonNull(tempFile.getConfigurationSection("panels." + tempName + ".open-with-item")), p, false, true).getType()), 1).getType()) { - if ((plugin.papi( Objects.requireNonNull(clicked.getItemMeta()).getDisplayName()).equals(plugin.papi( Objects.requireNonNull(tempFile.getString("panels." + tempName + ".open-with-item.name")))))) { + if ((plugin.papi( Objects.requireNonNull(clicked.getItemMeta()).getDisplayName()).equals(plugin.papi(Objects.requireNonNull(tempFile.getString("panels." + tempName + ".open-with-item.name")))))) { //cancel the click item event if (tempFile.contains("panels." + tempName + ".open-with-item.stationary")) { if (p.getInventory().getHeldItemSlot() != Integer.parseInt(Objects.requireNonNull(tempFile.getString("panels." + tempName + ".open-with-item.stationary")))) { @@ -177,7 +176,6 @@ 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 for(String fileName : plugin.panelFiles) { //will loop through all the files in folder YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName)); @@ -210,7 +208,7 @@ public class utilsOpenWithItem implements Listener { //if none of the panels have open-with-item return; } - Player p = (Player)e.getEntity(); + Player p = e.getEntity(); try { if (plugin.panelFiles == null) { return; @@ -218,7 +216,6 @@ 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 for(String fileName : plugin.panelFiles) { //will loop through all the files in folder YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName)); @@ -245,7 +242,6 @@ public class utilsOpenWithItem implements Listener { return; } Player p = e.getPlayer(); - String tag = plugin.config.getString("config.format.tag") + " "; try { if (plugin.panelFiles == null) { return;