Skip to content

Commit 1fe3d84

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 1389868 commit 1fe3d84

7 files changed

Lines changed: 2087 additions & 570 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
@@ -39,6 +39,7 @@
3939
import dev.noah.perplayerkit.commands.share.ShareKitCommand;
4040
import dev.noah.perplayerkit.commands.shortcuts.ShortECCommand;
4141
import dev.noah.perplayerkit.commands.shortcuts.ShortKitCommand;
42+
import dev.noah.perplayerkit.gui.configurable.ConfigurableGuiService;
4243
import dev.noah.perplayerkit.listeners.*;
4344
import dev.noah.perplayerkit.listeners.antiexploit.CommandListener;
4445
import dev.noah.perplayerkit.listeners.antiexploit.ShulkerDropItemsListener;
@@ -87,6 +88,7 @@ public void onEnable() {
8788
new KitManager(this);
8889
new KitShareManager(this);
8990
new KitRoomDataManager(this);
91+
new ConfigurableGuiService(this);
9092

9193
loadPublicKitsIdsFromConfig();
9294
getLogger().info("Public Kit Configuration Loaded");
@@ -209,8 +211,6 @@ public void onEnable() {
209211
Bukkit.getPluginManager().registerEvents(new JoinListener(this, updateChecker), this);
210212
Bukkit.getPluginManager().registerEvents(new QuitListener(this), this);
211213
Bukkit.getPluginManager().registerEvents(new MenuFunctionListener(), this);
212-
Bukkit.getPluginManager().registerEvents(new KitMenuCloseListener(), this);
213-
Bukkit.getPluginManager().registerEvents(new KitRoomSaveListener(), this);
214214
Bukkit.getPluginManager().registerEvents(new AutoRekitListener(this), this);
215215
Bukkit.getPluginManager().registerEvents(new AboutCommandListener(), this);
216216

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

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,11 @@
1919
package dev.noah.perplayerkit.commands.kits;
2020

2121
import dev.noah.perplayerkit.commands.core.CommandGuards;
22-
import dev.noah.perplayerkit.gui.ItemUtil;
23-
import dev.noah.perplayerkit.util.StyleManager;
24-
import dev.noah.perplayerkit.util.SoundManager;
22+
import dev.noah.perplayerkit.gui.configurable.ConfigurableGuiService;
2523
import org.bukkit.command.Command;
2624
import org.bukkit.command.CommandExecutor;
2725
import org.bukkit.command.CommandSender;
2826
import org.bukkit.entity.Player;
29-
import org.bukkit.inventory.ItemStack;
30-
import org.ipvp.canvas.Menu;
31-
import org.ipvp.canvas.type.ChestMenu;
3227
import org.jetbrains.annotations.NotNull;
3328

3429
public class EnderchestCommand implements CommandExecutor {
@@ -44,24 +39,6 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command
4439
}
4540

4641
public void viewOnlyEC(Player player) {
47-
48-
ItemStack fill = ItemUtil.createGlassPane();
49-
50-
Menu menu = ChestMenu.builder(5).title(StyleManager.get().getPrimaryColor() + "View Only Enderchest").build();
51-
52-
53-
for (int i = 0; i < 9; i++) {
54-
menu.getSlot(i).setItem(fill);
55-
}
56-
for (int i = 36; i < 45; i++) {
57-
menu.getSlot(i).setItem(fill);
58-
}
59-
// set the items in the inventory to the items in the enderchest
60-
ItemStack[] items = player.getEnderChest().getContents();
61-
for (int i = 0; i < 27; i++) {
62-
menu.getSlot(i + 9).setItem(items[i]);
63-
}
64-
menu.open(player);
65-
SoundManager.playOpenGui(player);
42+
ConfigurableGuiService.get().openViewOnlyEnderchest(player);
6643
}
6744
}

0 commit comments

Comments
 (0)