Skip to content

Commit 270a08f

Browse files
committed
Add configurable GUI system and route menus through service
- introduce `ConfigurableGuiService`, `GuiConfigManager`, and `GuiContext` - move GUI behavior to config-backed definitions in `guis.yml` - update existing GUI entry points and `/enderchest` view to delegate to the new service - initialize the new GUI service during plugin startup and remove legacy GUI listeners
1 parent df1040e commit 270a08f

7 files changed

Lines changed: 2087 additions & 676 deletions

File tree

src/main/java/dev/noah/perplayerkit/PerPlayerKit.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import dev.noah.perplayerkit.commands.extracommands.RepairCommand;
2424
import dev.noah.perplayerkit.commands.tabcompleters.ECSlotTabCompleter;
2525
import dev.noah.perplayerkit.commands.tabcompleters.KitSlotTabCompleter;
26+
import dev.noah.perplayerkit.gui.configurable.ConfigurableGuiService;
2627
import dev.noah.perplayerkit.listeners.*;
2728
import dev.noah.perplayerkit.listeners.antiexploit.CommandListener;
2829
import dev.noah.perplayerkit.listeners.antiexploit.ShulkerDropItemsListener;
@@ -71,6 +72,7 @@ public void onEnable() {
7172
new KitManager(this);
7273
new KitShareManager(this);
7374
new KitRoomDataManager(this);
75+
new ConfigurableGuiService(this);
7476

7577
loadPublicKitsIdsFromConfig();
7678
getLogger().info("Public Kit Configuration Loaded");
@@ -193,8 +195,6 @@ public void onEnable() {
193195
Bukkit.getPluginManager().registerEvents(new JoinListener(this, updateChecker), this);
194196
Bukkit.getPluginManager().registerEvents(new QuitListener(this), this);
195197
Bukkit.getPluginManager().registerEvents(new MenuFunctionListener(), this);
196-
Bukkit.getPluginManager().registerEvents(new KitMenuCloseListener(), this);
197-
Bukkit.getPluginManager().registerEvents(new KitRoomSaveListener(), this);
198198
Bukkit.getPluginManager().registerEvents(new AutoRekitListener(this), this);
199199
Bukkit.getPluginManager().registerEvents(new AboutCommandListener(), this);
200200

src/main/java/dev/noah/perplayerkit/commands/EnderchestCommand.java

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,13 @@
1818
*/
1919
package dev.noah.perplayerkit.commands;
2020

21-
import dev.noah.perplayerkit.gui.ItemUtil;
21+
import dev.noah.perplayerkit.gui.configurable.ConfigurableGuiService;
2222
import dev.noah.perplayerkit.util.DisabledCommand;
23-
import dev.noah.perplayerkit.util.StyleManager;
2423
import org.bukkit.command.Command;
2524
import org.bukkit.command.CommandExecutor;
2625
import org.bukkit.command.CommandSender;
2726
import org.bukkit.entity.Player;
2827
import dev.noah.perplayerkit.util.SoundManager;
29-
import org.bukkit.inventory.ItemStack;
30-
import org.ipvp.canvas.Menu;
31-
import org.ipvp.canvas.type.ChestMenu;
3228
import org.jetbrains.annotations.NotNull;
3329

3430
public class EnderchestCommand implements CommandExecutor {
@@ -49,26 +45,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command
4945
}
5046

5147
public void viewOnlyEC(Player p) {
52-
53-
ItemStack fill = ItemUtil.createGlassPane();
54-
55-
Menu menu = ChestMenu.builder(5).title(StyleManager.get().getPrimaryColor() + "View Only Enderchest").build();
56-
57-
58-
for (int i = 0; i < 9; i++) {
59-
menu.getSlot(i).setItem(fill);
60-
}
61-
for (int i = 36; i < 45; i++) {
62-
menu.getSlot(i).setItem(fill);
63-
}
64-
// set the items in the inventory to the items in the enderchest
65-
ItemStack[] items = p.getEnderChest().getContents();
66-
for (int i = 0; i < 27; i++) {
67-
menu.getSlot(i + 9).setItem(items[i]);
68-
}
69-
menu.open(p);
70-
SoundManager.playOpenGui(p);
48+
ConfigurableGuiService.get().openViewOnlyEnderchest(p);
7149
}
7250
}
7351

74-

0 commit comments

Comments
 (0)