From 638700c961052f3350588afd57f57b90c3fcb0a1 Mon Sep 17 00:00:00 2001 From: TheLonelyWolf1 <42873246+TheLonelyWolf1@users.noreply.github.com> Date: Mon, 15 Nov 2021 20:46:13 +0100 Subject: [PATCH 1/5] Fix bug with the delay-Tag This commit should fix the bug with the delay-tag not only deleting the first number. --- .../commandpanels/commandtags/tags/other/SpecialTags.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/me/rockyhawk/commandpanels/commandtags/tags/other/SpecialTags.java b/src/me/rockyhawk/commandpanels/commandtags/tags/other/SpecialTags.java index 499a6c1..4473b4b 100644 --- a/src/me/rockyhawk/commandpanels/commandtags/tags/other/SpecialTags.java +++ b/src/me/rockyhawk/commandpanels/commandtags/tags/other/SpecialTags.java @@ -105,7 +105,7 @@ public class SpecialTags implements Listener { e.commandTagUsed(); //if player uses op= it will perform command as op final int delayTicks = Integer.parseInt(e.args[0]); - String finalCommand = String.join(" ",e.args).replace(e.args[0],"").trim(); + String finalCommand = String.join(" ",e.args).replaceFirst(e.args[0],"").trim(); new BukkitRunnable() { @Override public void run() { From d5149ad961141466fb50a83adc02c0e748008f42 Mon Sep 17 00:00:00 2001 From: TheLonelyWolf1 <42873246+TheLonelyWolf1@users.noreply.github.com> Date: Sat, 20 Nov 2021 13:06:32 +0100 Subject: [PATCH 2/5] Custom No-Permission Messages Add the option to have panel-only no-permission messages --- .../classresources/ExecuteOpenVoids.java | 26 +++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/me/rockyhawk/commandpanels/classresources/ExecuteOpenVoids.java b/src/me/rockyhawk/commandpanels/classresources/ExecuteOpenVoids.java index cdf125d..4e3219a 100644 --- a/src/me/rockyhawk/commandpanels/classresources/ExecuteOpenVoids.java +++ b/src/me/rockyhawk/commandpanels/classresources/ExecuteOpenVoids.java @@ -36,15 +36,25 @@ public class ExecuteOpenVoids { panel.setConfig(YamlConfiguration.loadConfiguration(panel.getFile())); } if (!sender.hasPermission("commandpanel.panel." + panel.getConfig().getString("perm"))) { - sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms"))); - return; + if(!(panel.getConfig().getString("custom-messages.perms") == null)) { + sender.sendMessage(plugin.tex.colour(plugin.tag + panel.getConfig().getString("custom-messages.perms"))); + return; + }else { + 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.colour(plugin.tag + plugin.config.getString("config.format.perms"))); - return; + if(!(panel.getConfig().getString("custom-messages.perms") == null)) { + sender.sendMessage(plugin.tex.colour(plugin.tag + panel.getConfig().getString("custom-messages.perms"))); + return; + }else { + sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms"))); + return; + } } if(position != PanelPosition.Top && !plugin.openPanels.hasPanelOpen(p.getName(),PanelPosition.Top)){ @@ -101,7 +111,13 @@ public class ExecuteOpenVoids { p.closeInventory(); } }else{ - sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms"))); + if(!(panel.getConfig().getString("custom-messages.perms") == null)) { + sender.sendMessage(plugin.tex.colour(plugin.tag + panel.getConfig().getString("custom-messages.perms"))); + return; + }else { + sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms"))); + return; + } } } From 10c9825776e337afb5c306b90eb81b6a7e64c544 Mon Sep 17 00:00:00 2001 From: TheLonelyWolf1 <42873246+TheLonelyWolf1@users.noreply.github.com> Date: Sat, 20 Nov 2021 13:17:21 +0100 Subject: [PATCH 3/5] Fix failing checks Use opposite operator instead of negating the whole expression with a logic complement operator. --- .../commandpanels/classresources/ExecuteOpenVoids.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/me/rockyhawk/commandpanels/classresources/ExecuteOpenVoids.java b/src/me/rockyhawk/commandpanels/classresources/ExecuteOpenVoids.java index 4e3219a..63a9cdf 100644 --- a/src/me/rockyhawk/commandpanels/classresources/ExecuteOpenVoids.java +++ b/src/me/rockyhawk/commandpanels/classresources/ExecuteOpenVoids.java @@ -36,7 +36,7 @@ public class ExecuteOpenVoids { panel.setConfig(YamlConfiguration.loadConfiguration(panel.getFile())); } if (!sender.hasPermission("commandpanel.panel." + panel.getConfig().getString("perm"))) { - if(!(panel.getConfig().getString("custom-messages.perms") == null)) { + if(panel.getConfig().getString("custom-messages.perms") != null) { sender.sendMessage(plugin.tex.colour(plugin.tag + panel.getConfig().getString("custom-messages.perms"))); return; }else { @@ -48,7 +48,7 @@ public class ExecuteOpenVoids { if(sender.hasPermission("commandpanel.other") || !openForOtherUser) { //check for disabled worlds if(!plugin.panelPerms.isPanelWorldEnabled(p,panel.getConfig())){ - if(!(panel.getConfig().getString("custom-messages.perms") == null)) { + if(panel.getConfig().getString("custom-messages.perms") != null) { sender.sendMessage(plugin.tex.colour(plugin.tag + panel.getConfig().getString("custom-messages.perms"))); return; }else { @@ -111,7 +111,7 @@ public class ExecuteOpenVoids { p.closeInventory(); } }else{ - if(!(panel.getConfig().getString("custom-messages.perms") == null)) { + if(panel.getConfig().getString("custom-messages.perms") != null) { sender.sendMessage(plugin.tex.colour(plugin.tag + panel.getConfig().getString("custom-messages.perms"))); return; }else { From 39e505d8c8ea87415393c5537293243a9788731f Mon Sep 17 00:00:00 2001 From: TheLonelyWolf1 <42873246+TheLonelyWolf1@users.noreply.github.com> Date: Sat, 20 Nov 2021 15:20:11 +0100 Subject: [PATCH 4/5] Add Max.Character Input Add the option to limit the length of the Input given by the Player --- .../commandpanels/interactives/input/UserInputUtils.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/me/rockyhawk/commandpanels/interactives/input/UserInputUtils.java b/src/me/rockyhawk/commandpanels/interactives/input/UserInputUtils.java index 2c5f057..29eff7c 100644 --- a/src/me/rockyhawk/commandpanels/interactives/input/UserInputUtils.java +++ b/src/me/rockyhawk/commandpanels/interactives/input/UserInputUtils.java @@ -33,6 +33,14 @@ public class UserInputUtils implements Listener { } playerInput.get(e.getPlayer()).panel.placeholders.addPlaceholder("player-input",e.getMessage()); + + if((playerInput.get(e.getPlayer()).panel.getConfig().getString("max-input-length") != null) && (Integer.parseInt(playerInput.get(e.getPlayer()).panel.getConfig().getString("max-input-length")) != -1) && (e.getMessage().length() > Integer.parseInt(playerInput.get(e.getPlayer()).panel.getConfig().getString("max-input-length")))) { + e.getPlayer().sendMessage(plugin.tex.colour(plugin.tag + playerInput.get(e.getPlayer()).panel.getConfig().getString("custom-messages.input"))); + return; + }else if(e.getMessage().length() > Integer.parseInt(plugin.config.getString("input.max-input-length")) && (Integer.parseInt(plugin.config.getString("input.max-input-length")) != -1)) { + e.getPlayer().sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.input"))); + return; + } //get certain words from the input int c = 0; for(String message : e.getMessage().split("\\s")){ From ca2664c6e73a819be5a37b89a5ae9b14c9f5f465 Mon Sep 17 00:00:00 2001 From: TheLonelyWolf1 <42873246+TheLonelyWolf1@users.noreply.github.com> Date: Sat, 20 Nov 2021 15:22:04 +0100 Subject: [PATCH 5/5] Add Max.Character Message and Config Add the default Max.Character Message and the limit-config --- resource/config.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/resource/config.yml b/resource/config.yml index 47e8c8e..a1827a0 100644 --- a/resource/config.yml +++ b/resource/config.yml @@ -29,9 +29,11 @@ config: error: '&cError found in config.' offline: 'Offline' offlineHeadValue: 'eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNmU1Mjg2YzQ3MGY2NmZmYTFhMTgzMzFjYmZmYjlhM2MyYTQ0MjRhOGM3MjU5YzQ0MzZmZDJlMzU1ODJhNTIyIn19fQ==' + input: '&cYour Input is too long!' input: input-cancel: cancel input-cancelled: '&cCancelled!' + max-input-length: -1 input-message: - '%cp-tag%&aEnter Input for Command' - '&cType &4%cp-args% &cto Cancel the command'