Finally fix the janky way of using /pp to open the gui. Fixed error msgs

This commit is contained in:
Esophose 2020-09-06 20:11:42 -06:00
parent ca485e0825
commit cab6de1bfc
2 changed files with 10 additions and 9 deletions

View file

@ -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<String> onTabComplete(PPlayer pplayer, String[] args) {

View file

@ -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");