Skip to content

Commit

Permalink
Improved Queue Menu
Browse files Browse the repository at this point in the history
  • Loading branch information
Devlrxxh committed Apr 1, 2024
1 parent f28208a commit 13c8e0c
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/main/java/me/lrxh/practice/kit/Kit.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public static void init() {
kit.getEditRules().getEditorItems().add(new ItemBuilder(Material.valueOf(
config.getString(path + ".edit-rules.items." + itemKey + ".material")))
.durability(config.getInt(path + ".edit-rules.items." + itemKey + ".durability"))
.amount(config.getInt(path + ".edit-rules.items." + itemKey + ".amount"))
.amount(config.getInt(path + ".edit-rules.items." + itemKey + ".amount"), false)
.build());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ private static class HealthButton extends Button {
public ItemStack getButtonItem(Player player) {
return new ItemBuilder(Material.MELON)
.name("&bHealth: &f" + health + "/10 &4" + StringEscapeUtils.unescapeJava("❤"))
.amount((int) (health == 0 ? 1 : health))
.amount((int) (health == 0 ? 1 : health), false)
.clearFlags()
.build();
}
Expand Down Expand Up @@ -131,7 +131,7 @@ private static class PotionsButton extends Button {
public ItemStack getButtonItem(Player player) {
return new ItemBuilder(Material.POTION)
.durability(16421)
.amount(potions == 0 ? 1 : potions)
.amount(potions == 0 ? 1 : potions, false)
.name("&bPotions")
.lore("&b" + name + " &fhad &b" + potions + " &fpotion" + (potions == 1 ? "" : "s") + " left.")
.clearFlags()
Expand Down Expand Up @@ -197,7 +197,7 @@ private class HungerButton extends Button {
public ItemStack getButtonItem(Player player) {
return new ItemBuilder(Material.COOKED_BEEF)
.name("&bHunger: &f" + hunger + "/20")
.amount(hunger == 0 ? 1 : hunger)
.amount(hunger == 0 ? 1 : hunger, false)
.clearFlags()
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ private static class HealthButton extends Button {
public ItemStack getButtonItem(Player player) {
return new ItemBuilder(Material.MELON)
.name("&eHealth: &d" + health + "/10 " + StringEscapeUtils.unescapeJava("\u2764"))
.amount(health == 0 ? 1 : health)
.amount(health == 0 ? 1 : health, false)
.clearFlags()
.build();
}
Expand All @@ -91,7 +91,7 @@ private static class HungerButton extends Button {
public ItemStack getButtonItem(Player player) {
return new ItemBuilder(Material.COOKED_BEEF)
.name("&eHunger: &d" + hunger + "/20")
.amount(hunger == 0 ? 1 : hunger)
.amount(hunger == 0 ? 1 : hunger, false)
.clearFlags()
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public ItemStack getButtonItem(Player player) {

return new ItemBuilder(Material.SKULL_ITEM)
.name("&6Party of &r" + party.getLeader().getName())
.amount(party.getPlayers().size())
.amount(party.getPlayers().size(), false)
.durability(3)
.lore(lore)
.clearFlags()
Expand Down
25 changes: 19 additions & 6 deletions src/main/java/me/lrxh/practice/queue/menu/QueueSelectKitMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import me.lrxh.practice.util.menu.Menu;
import me.lrxh.practice.util.menu.filters.Filters;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
Expand Down Expand Up @@ -111,12 +112,24 @@ public ItemStack getButtonItem(Player player) {
.replace("<kit>", queue.getKit().getName())
.replace("<type>", ranked ? "Unranked" : "Ranked");

return new ItemBuilder(queue.getKit().getDisplayIcon())
.name(kitName)
.lore(lore)
.clearEnchantments()
.clearFlags()
.build();
if(queue.getQueuing() > 0){
return new ItemBuilder(queue.getKit().getDisplayIcon())
.name(kitName)
.lore(lore)
.clearEnchantments()
.enchantment(Enchantment.DURABILITY)
.clearFlags()
.build();
}else{
return new ItemBuilder(queue.getKit().getDisplayIcon())
.name(kitName)
.lore(lore)
.clearEnchantments()
.amount(Match.getInFightsCount(queue), true)
.clearFlags()
.build();
}

}

private String replaceLeaderboardPlaceholders(String line, Queue queue) {
Expand Down
8 changes: 6 additions & 2 deletions src/main/java/me/lrxh/practice/util/ItemBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,12 @@ public ItemBuilder(ItemStack is) {
this.is = is;
}

public ItemBuilder amount(int amount) {
is.setAmount(amount);
public ItemBuilder amount(int amount, boolean fixed) {
if (!fixed) {
is.setAmount(Math.min(amount, 64));
} else {
is.setAmount(amount == 0 ? 1 : Math.min(amount, 64));
}
return this;
}

Expand Down

0 comments on commit 13c8e0c

Please sign in to comment.