Skip to content

Commit

Permalink
menu wip
Browse files Browse the repository at this point in the history
  • Loading branch information
LeeTheTech committed Sep 28, 2023
1 parent 7a72da7 commit da479b5
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 3 deletions.
7 changes: 7 additions & 0 deletions src/main/java/lee/code/pets/database/cache/CachePets.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
3 changes: 2 additions & 1 deletion src/main/java/lee/code/pets/lang/Lang.java
Original file line number Diff line number Diff line change
Expand Up @@ -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."),
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/lee/code/pets/menus/menu/PetMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/lee/code/pets/menus/menu/PetOptionMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down

0 comments on commit da479b5

Please sign in to comment.