From cab6de1bfc61472912667aa7bad510edb6a95936 Mon Sep 17 00:00:00 2001 From: Esophose Date: Sun, 6 Sep 2020 20:11:42 -0600 Subject: [PATCH] Finally fix the janky way of using /pp to open the gui. Fixed error msgs --- .../command/DefaultCommandModule.java | 3 ++- .../command/GUICommandModule.java | 16 ++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/main/java/dev/esophose/playerparticles/command/DefaultCommandModule.java b/src/main/java/dev/esophose/playerparticles/command/DefaultCommandModule.java index dd2fc98..34fd499 100644 --- a/src/main/java/dev/esophose/playerparticles/command/DefaultCommandModule.java +++ b/src/main/java/dev/esophose/playerparticles/command/DefaultCommandModule.java @@ -11,7 +11,8 @@ public class DefaultCommandModule implements CommandModule { public void onCommandExecute(PPlayer pplayer, String[] args) { // The default command just opens the GUI, execute the GUICommandModule - PlayerParticles.getInstance().getManager(CommandManager.class).findMatchingCommand("gui").onCommandExecute(pplayer, new String[] { "_byDefault_" }); + ((GUICommandModule) PlayerParticles.getInstance().getManager(CommandManager.class).findMatchingCommand("gui")) + .onCommandExecute(pplayer, false); } public List onTabComplete(PPlayer pplayer, String[] args) { diff --git a/src/main/java/dev/esophose/playerparticles/command/GUICommandModule.java b/src/main/java/dev/esophose/playerparticles/command/GUICommandModule.java index 30f0372..854fadd 100644 --- a/src/main/java/dev/esophose/playerparticles/command/GUICommandModule.java +++ b/src/main/java/dev/esophose/playerparticles/command/GUICommandModule.java @@ -13,6 +13,10 @@ import org.bukkit.Bukkit; public class GUICommandModule implements CommandModule { public void onCommandExecute(PPlayer pplayer, String[] args) { + this.onCommandExecute(pplayer, true); + } + + public void onCommandExecute(PPlayer pplayer, boolean openedFromGuiCommand) { PermissionManager permissionManager = PlayerParticles.getInstance().getManager(PermissionManager.class); LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class); GuiManager guiManager = PlayerParticles.getInstance().getManager(GuiManager.class); @@ -22,22 +26,18 @@ public class GUICommandModule implements CommandModule { return; } - boolean byDefault = false; - if (args.length > 0 && args[0].equals("_byDefault_")) // Why is this still the way I'm doing this smh - byDefault = true; - if (guiManager.isGuiDisabled()) { - if (byDefault) { - localeManager.sendMessage(pplayer, "command-error-unknown"); - } else { + if (openedFromGuiCommand) { localeManager.sendMessage(pplayer, "gui-disabled"); + } else { + localeManager.sendMessage(pplayer, "command-error-unknown"); } return; } boolean hasEffectsAndStyles = !permissionManager.getEffectsUserHasPermissionFor(pplayer).isEmpty() && !permissionManager.getStylesUserHasPermissionFor(pplayer).isEmpty(); if (!Setting.GUI_PRESETS_ONLY.getBoolean() && (Setting.GUI_REQUIRE_EFFECTS_AND_STYLES.getBoolean() && !hasEffectsAndStyles)) { - if (byDefault) { + if (openedFromGuiCommand) { localeManager.sendMessage(pplayer, "command-error-missing-effects-or-styles"); } else { localeManager.sendMessage(pplayer, "command-error-unknown");