From da479b56b7f27cc75f431fc16c5e93602d5db1a1 Mon Sep 17 00:00:00 2001 From: Lee Date: Thu, 28 Sep 2023 00:54:16 -0700 Subject: [PATCH] menu wip --- .../java/lee/code/pets/database/cache/CachePets.java | 7 +++++++ src/main/java/lee/code/pets/lang/Lang.java | 3 ++- src/main/java/lee/code/pets/menus/menu/PetMenu.java | 9 +++++++++ .../java/lee/code/pets/menus/menu/PetOptionMenu.java | 2 +- .../code/pets/menus/menu/menudata/options/Option.java | 2 +- 5 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/main/java/lee/code/pets/database/cache/CachePets.java b/src/main/java/lee/code/pets/database/cache/CachePets.java index a1b98df..eb5b99d 100644 --- a/src/main/java/lee/code/pets/database/cache/CachePets.java +++ b/src/main/java/lee/code/pets/database/cache/CachePets.java @@ -54,4 +54,11 @@ public EntityType getPetEntityType(int id) { public String getPetName(int id) { return getPetTable(id).getData().split(",")[1]; } + + public void deletePet(int id) { + final PetTable petTable = getPetTable(id); + deletePetDatabase(petTable); + playerPetData.removePlayerPet(petTable.getOwner(), id); + petsCache.remove(id); + } } diff --git a/src/main/java/lee/code/pets/lang/Lang.java b/src/main/java/lee/code/pets/lang/Lang.java index 390ec55..436ae6e 100644 --- a/src/main/java/lee/code/pets/lang/Lang.java +++ b/src/main/java/lee/code/pets/lang/Lang.java @@ -10,7 +10,8 @@ public enum Lang { PREFIX("&d&lPets &6➔ "), MENU_PETS_TITLE("&5&lPets"), MENU_PET_OPTIONS_TITLE("&5&lPet Options"), - MENU_PET_ITEM_LORE("&6» &dRight-Click &7- &eEdit pet!\n&6» &dLeft-Click &7- &eSpawn pet!"), + MENU_DELETE_PET_SUCCESSFUL("&aYou successfully deleted pet &f{0}&a!"), + MENU_PET_ITEM_LORE("&6» &dRight-Click &7- &eEdit pet!\n&6» &dLeft-Click &7- &eSpawn pet!\n&6» &dShift-Click &7- &eDelete pet!"), CAPTURE_SUCCESSFUL("&aYou successfully captured a &3{0}&a!"), ERROR_NO_PERMISSION("&cYou do not have permission for this."), ERROR_ONE_COMMAND_AT_A_TIME("&cYou're currently processing another command, please wait for it to finish."), diff --git a/src/main/java/lee/code/pets/menus/menu/PetMenu.java b/src/main/java/lee/code/pets/menus/menu/PetMenu.java index ba7b059..52940c0 100644 --- a/src/main/java/lee/code/pets/menus/menu/PetMenu.java +++ b/src/main/java/lee/code/pets/menus/menu/PetMenu.java @@ -50,6 +50,15 @@ private MenuButton createPetButton(Player player, int petID) { final ItemStack item = PetItem.valueOf(entityType.name()).getHead(cachePets.getPetName(petID)); return new MenuButton().creator(p -> item) .consumer(e -> { + if (e.isShiftClick()) { + final String name = cachePets.getPetName(petID); + cachePets.deletePet(petID); + player.sendMessage(Lang.PREFIX.getComponent(null).append(Lang.MENU_DELETE_PET_SUCCESSFUL.getComponent(new String[]{name}))); + clearButtons(); + clearInventory(); + decorate(player); + return; + } if (e.isLeftClick()) { getMenuSoundManager().playClickSound(player); final PetManager petManager = pets.getPetManager(); diff --git a/src/main/java/lee/code/pets/menus/menu/PetOptionMenu.java b/src/main/java/lee/code/pets/menus/menu/PetOptionMenu.java index 68099e8..421a852 100644 --- a/src/main/java/lee/code/pets/menus/menu/PetOptionMenu.java +++ b/src/main/java/lee/code/pets/menus/menu/PetOptionMenu.java @@ -33,7 +33,7 @@ public PetOptionMenu(Pets pets, EntityType entityType, int petID) { @Override protected Inventory createInventory() { - return Bukkit.createInventory(null, 36, Lang.MENU_PETS_TITLE.getComponent(null)); + return Bukkit.createInventory(null, 36, Lang.MENU_PET_OPTIONS_TITLE.getComponent(null)); } @Override diff --git a/src/main/java/lee/code/pets/menus/menu/menudata/options/Option.java b/src/main/java/lee/code/pets/menus/menu/menudata/options/Option.java index 134f30a..7bc08e8 100644 --- a/src/main/java/lee/code/pets/menus/menu/menudata/options/Option.java +++ b/src/main/java/lee/code/pets/menus/menu/menudata/options/Option.java @@ -23,7 +23,7 @@ public enum Option { NECTAR(Material.BEEHIVE, "&e&lNectar"), STUNG(Material.HONEYCOMB, "&e&lStung"), PUMPKIN(Material.CARVED_PUMPKIN, "&e&lPumpkin"), - TYPE(Material.GRASS_BLOCK, "&e&lType"), + TYPE(Material.BELL, "&e&lType"), PROFESSION(Material.ANVIL, "&e&lProfession"), LEVEL(Material.EXPERIENCE_BOTTLE, "&e&lLevel"), COLLAR(Material.LEAD, "&e&lCollar"),