From 34ae6f19282a47f1e0052dd373f2324a870ddd14 Mon Sep 17 00:00:00 2001 From: Esophose Date: Wed, 30 Dec 2020 00:29:32 -0700 Subject: [PATCH] Allow directly opening two more gui pages --- .../command/GUICommandModule.java | 23 +++++++++++++++---- .../playerparticles/manager/GuiManager.java | 22 ++++++++++++++++++ 2 files changed, 40 insertions(+), 5 deletions(-) diff --git a/src/main/java/dev/esophose/playerparticles/command/GUICommandModule.java b/src/main/java/dev/esophose/playerparticles/command/GUICommandModule.java index a21495e..0bd0381 100644 --- a/src/main/java/dev/esophose/playerparticles/command/GUICommandModule.java +++ b/src/main/java/dev/esophose/playerparticles/command/GUICommandModule.java @@ -7,7 +7,7 @@ import dev.esophose.playerparticles.manager.LocaleManager; import dev.esophose.playerparticles.manager.PermissionManager; import dev.esophose.playerparticles.particles.PPlayer; import java.util.ArrayList; -import java.util.Collections; +import java.util.Arrays; import java.util.List; import org.bukkit.util.StringUtil; @@ -47,10 +47,23 @@ public class GUICommandModule implements CommandModule { return; } - if (args.length > 0 && args[0].equalsIgnoreCase("presets")) { - guiManager.openPresetGroups(pplayer); - } else { + if (args.length == 0) { guiManager.openDefault(pplayer); + } else { + switch (args[0].toLowerCase()) { + case "presets": + guiManager.openPresetGroups(pplayer); + break; + case "groups": + guiManager.openGroups(pplayer); + break; + case "particles": + guiManager.openParticles(pplayer); + break; + default: + guiManager.openDefault(pplayer); + break; + } } } @@ -58,7 +71,7 @@ public class GUICommandModule implements CommandModule { public List onTabComplete(PPlayer pplayer, String[] args) { List completions = new ArrayList<>(); if (args.length == 1) { - List possibilities = Collections.singletonList("presets"); + List possibilities = Arrays.asList("presets", "groups", "particles"); StringUtil.copyPartialMatches(args[0], possibilities, completions); } return completions; diff --git a/src/main/java/dev/esophose/playerparticles/manager/GuiManager.java b/src/main/java/dev/esophose/playerparticles/manager/GuiManager.java index 13840ec..51f0b07 100644 --- a/src/main/java/dev/esophose/playerparticles/manager/GuiManager.java +++ b/src/main/java/dev/esophose/playerparticles/manager/GuiManager.java @@ -4,6 +4,8 @@ import dev.esophose.playerparticles.PlayerParticles; import dev.esophose.playerparticles.gui.GuiInventory; import dev.esophose.playerparticles.gui.GuiInventoryDefault; import dev.esophose.playerparticles.gui.GuiInventoryLoadPresetGroups; +import dev.esophose.playerparticles.gui.GuiInventoryManageGroups; +import dev.esophose.playerparticles.gui.GuiInventoryManageParticles; import dev.esophose.playerparticles.manager.ConfigurationManager.Setting; import dev.esophose.playerparticles.particles.PPlayer; import java.util.ArrayList; @@ -128,6 +130,26 @@ public class GuiManager extends Manager implements Listener, Runnable { this.openGui(pplayer, new GuiInventoryLoadPresetGroups(pplayer, true, 1))); } + /** + * Opens the groups GUI screen for a player + * + * @param pplayer The PPlayer to open the GUI screen for + */ + public void openGroups(PPlayer pplayer) { + Bukkit.getScheduler().runTask(this.playerParticles, () -> + this.openGui(pplayer, new GuiInventoryManageGroups(pplayer, 1))); + } + + /** + * Opens the edit particles GUI screen for a player + * + * @param pplayer The PPlayer to open the GUI screen for + */ + public void openParticles(PPlayer pplayer) { + Bukkit.getScheduler().runTask(this.playerParticles, () -> + this.openGui(pplayer, new GuiInventoryManageParticles(pplayer))); + } + /** * Opens a GUI screen for a player *