From d44c72a68bbd9cf352d752b07b62b110ff2adf48 Mon Sep 17 00:00:00 2001 From: rockyhawk64 Date: Tue, 27 Oct 2020 11:20:31 +1100 Subject: [PATCH] Fixes v3.12.6 --- resource/example.yml | 3 +- resource/exampleLegacy.yml | 3 +- resource/plugin.yml | 2 +- .../commandpanels/CommandPanels.java | 1 + .../customcommands/Commandpanelcustom.java | 39 +++++++++++-------- 5 files changed, 26 insertions(+), 22 deletions(-) diff --git a/resource/example.yml b/resource/example.yml index 0d9d0b2..d752d15 100644 --- a/resource/example.yml +++ b/resource/example.yml @@ -129,6 +129,5 @@ panels: - 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% subtitle {"text":"You are now in creative mode!","color":"green"} - console= title %cp-player-name% title {"text":"Awesome %cp-player-displayname%"} diff --git a/resource/exampleLegacy.yml b/resource/exampleLegacy.yml index 1418c31..ee59f36 100644 --- a/resource/exampleLegacy.yml +++ b/resource/exampleLegacy.yml @@ -131,6 +131,5 @@ panels: - 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% subtitle {"text":"You are now in creative mode!","color":"green"} - console= title %cp-player-name% title {"text":"Awesome %cp-player-displayname%"} diff --git a/resource/plugin.yml b/resource/plugin.yml index 3bf7afc..71bfe13 100644 --- a/resource/plugin.yml +++ b/resource/plugin.yml @@ -1,4 +1,4 @@ -version: 3.12.5 +version: 3.12.6 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 6bfdca6..6be3960 100644 --- a/src/me/rockyhawk/commandpanels/CommandPanels.java +++ b/src/me/rockyhawk/commandpanels/CommandPanels.java @@ -476,6 +476,7 @@ public class CommandPanels extends JavaPlugin { public void debug(Exception e) { if (debug) { + getServer().getConsoleSender().sendMessage(ChatColor.DARK_RED + "[CommandPanels] The plugin has generated a debug error, find the error below"); e.printStackTrace(); } } diff --git a/src/me/rockyhawk/commandpanels/customcommands/Commandpanelcustom.java b/src/me/rockyhawk/commandpanels/customcommands/Commandpanelcustom.java index 967c33f..c5afb81 100644 --- a/src/me/rockyhawk/commandpanels/customcommands/Commandpanelcustom.java +++ b/src/me/rockyhawk/commandpanels/customcommands/Commandpanelcustom.java @@ -27,27 +27,32 @@ public class Commandpanelcustom implements Listener { } ConfigurationSection tempFile; - 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; + try { + 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; + //this will be deleted in 3.13.x + 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; + } } } + }catch(NullPointerException exc){ + //this is placed to prevent null exceptions if the commandpanels reload command has file changes + plugin.debug(exc); } } }