Skip to content

Commit

Permalink
Change how the admin key menu functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
ryderbelserion committed Mar 4, 2024
1 parent 98bcf0f commit ab9dad6
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 34 deletions.
2 changes: 2 additions & 0 deletions paper/build.gradle.kts
Expand Up @@ -9,6 +9,8 @@ dependencies {

implementation(libs.triumphcmds)

//implementation(libs.triumphgui)

implementation(libs.metrics)

implementation(libs.nbtapi)
Expand Down
Expand Up @@ -4,6 +4,7 @@
import com.badbones69.crazycrates.api.enums.Messages;
import com.badbones69.crazycrates.api.enums.Permissions;
import com.badbones69.crazycrates.api.objects.Crate;
import com.badbones69.crazycrates.api.objects.other.ItemBuilder;
import com.badbones69.crazycrates.tasks.crates.CrateManager;
import org.bukkit.Material;
import org.bukkit.entity.Player;
Expand All @@ -16,14 +17,10 @@
import org.bukkit.inventory.InventoryView;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import us.crazycrew.crazycrates.api.enums.types.CrateType;
import com.badbones69.crazycrates.api.builders.InventoryBuilder;
import us.crazycrew.crazycrates.api.enums.types.KeyType;
import us.crazycrew.crazycrates.api.users.UserManager;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class CrateAdminMenu extends InventoryBuilder {

Expand All @@ -35,8 +32,15 @@ public CrateAdminMenu(Player player, int size, String title) {
public InventoryBuilder build() {
Inventory inventory = getInventory();

inventory.setItem(49, new ItemBuilder().setMaterial(Material.CHEST)
.setName("&cWhat is this menu?")
.addLore("")
.addLore("&dA cheat cheat menu of all your available keys.")
.addLore("&7&lRight click to get virtual keys.")
.addLore("&7&lLeft click to get physical keys.").build());

for (Crate crate : this.plugin.getCrateManager().getUsableCrates()) {
if (inventory.firstEmpty() >= 0) inventory.setItem(inventory.firstEmpty(), crate.getAdminKey(getPlayer()));
if (inventory.firstEmpty() >= 0) inventory.setItem(inventory.firstEmpty(), crate.getKey(getPlayer()));
}

return this;
Expand Down
Expand Up @@ -42,7 +42,6 @@ public class Crate {
private final String keyName;
private final ItemBuilder keyBuilder;
private final ItemStack keyNoNBT;
private final ItemBuilder adminKey;
private int maxPage = 1;
private final int maxSlots;
private final String previewName;
Expand Down Expand Up @@ -91,11 +90,7 @@ public Crate(String name, String previewName, CrateType crateType, ItemStack key
this.keyBuilder = ItemBuilder.convertItemStack(key).setCrateName(name);
this.keyNoNBT = this.keyBuilder.build();
this.keyName = keyName;
this.adminKey = this.keyBuilder
.addLore("")
.addLore("&7&l(&6&l!&7&l) Left click for Physical Key")
.addLore("&7&l(&6&l!&7&l) Right click for Virtual Key")
.setCrateName(name);

this.file = file;
this.name = name;
this.tiers = tiers != null ? tiers : new ArrayList<>();
Expand Down Expand Up @@ -510,26 +505,6 @@ public ItemStack getKeyNoNBT(int amount) {
return key;
}

/**
* Get the key that shows in the /cc admin menu.
*
* @return the itemstack of the key shown in the /cc admin menu.
*/
public ItemStack getAdminKey() {
return this.adminKey.build();
}

/**
* Get the key that shows in the /cc admin menu.
*
* @param player The player getting the key.
*
* @return the itemstack of the key shown in the /cc admin menu.
*/
public ItemStack getAdminKey(Player player) {
return this.adminKey.setTarget(player).build();
}

/**
* @return the crates file.
*/
Expand Down
Expand Up @@ -19,8 +19,7 @@ public static void removeItem(ItemStack item, Player player) {

public static boolean isSimilar(ItemStack itemStack, Crate crate) {
NBTItem nbtItem = new NBTItem(itemStack);
return itemStack.isSimilar(crate.getKey()) || itemStack.isSimilar(crate.getKeyNoNBT()) ||
itemStack.isSimilar(crate.getAdminKey()) || stripNBT(itemStack).isSimilar(crate.getKeyNoNBT()) ||
return itemStack.isSimilar(crate.getKey()) || itemStack.isSimilar(crate.getKeyNoNBT()) || stripNBT(itemStack).isSimilar(crate.getKeyNoNBT()) ||
isSimilarCustom(crate.getKeyNoNBT(), itemStack) || (nbtItem.hasTag("CrazyCrates-Crate") && crate.getName().equals(nbtItem.getString("CrazyCrates-Crate")));
}

Expand Down
4 changes: 3 additions & 1 deletion settings.gradle.kts
Expand Up @@ -32,6 +32,8 @@ dependencyResolutionManagement {

library("placeholderapi", "me.clip", "placeholderapi").version("2.11.5")

library("triumphgui", "dev.triumphteam", "triumph-gui").version("3.1.7")

library("metrics", "org.bstats", "bstats-bukkit").version("3.0.2")

library("nbtapi", "de.tr7zw", "item-nbt-api").version("2.12.2")
Expand All @@ -47,5 +49,5 @@ rootProject.name = "CrazyCrates"

include("api")
include("paper")
include("fabric")
//include("fabric")
include("common")

0 comments on commit ab9dad6

Please sign in to comment.