From 9a2cdffcb78c7312a593dddceae585cafbeb389e Mon Sep 17 00:00:00 2001 From: xsmeths Date: Sun, 14 Apr 2024 22:27:16 +0100 Subject: [PATCH 1/7] include nms packages --- pom.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pom.xml b/pom.xml index 8678c3d..8c55f77 100644 --- a/pom.xml +++ b/pom.xml @@ -62,6 +62,9 @@ com.craftaro:CraftaroCore false + + **/nms/v*/** + **/third_party/org/apache/** **/third_party/net/kyori/** From 5c29ac1850e52c99dcf96fffe55323b4720c2f4f Mon Sep 17 00:00:00 2001 From: xsmeths Date: Sun, 14 Apr 2024 22:28:47 +0100 Subject: [PATCH 2/7] fix editor command --- .../java/com/craftaro/epicvouchers/commands/CommandEditor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/craftaro/epicvouchers/commands/CommandEditor.java b/src/main/java/com/craftaro/epicvouchers/commands/CommandEditor.java index 26d63ec..57f5d1e 100644 --- a/src/main/java/com/craftaro/epicvouchers/commands/CommandEditor.java +++ b/src/main/java/com/craftaro/epicvouchers/commands/CommandEditor.java @@ -12,7 +12,7 @@ public class CommandEditor extends AbstractCommand { final EpicVouchers instance; public CommandEditor(EpicVouchers instance) { - super(CommandType.PLAYER_ONLY, "EpicVouchers"); + super(CommandType.PLAYER_ONLY, "editor"); this.instance = instance; } From ea3445280e294869bafe1f589501a64a273a2d6f Mon Sep 17 00:00:00 2001 From: xsmeths Date: Mon, 15 Apr 2024 00:06:09 +0100 Subject: [PATCH 3/7] Correctly show voucher item names in editor main menu --- .../com/craftaro/epicvouchers/menus/VoucherMenu.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/craftaro/epicvouchers/menus/VoucherMenu.java b/src/main/java/com/craftaro/epicvouchers/menus/VoucherMenu.java index 787c74c..f02cb84 100644 --- a/src/main/java/com/craftaro/epicvouchers/menus/VoucherMenu.java +++ b/src/main/java/com/craftaro/epicvouchers/menus/VoucherMenu.java @@ -8,9 +8,11 @@ import com.craftaro.epicvouchers.libraries.ItemBuilder; import com.craftaro.epicvouchers.libraries.inventory.IconInv; import com.craftaro.epicvouchers.libraries.inventory.icons.Icon; import com.craftaro.epicvouchers.voucher.Voucher; +import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; import static org.bukkit.Material.PAPER; @@ -25,7 +27,12 @@ public class VoucherMenu extends IconInv { for (Voucher voucher : instance.getVoucherManager().getVouchers()) { if (getInventory().firstEmpty() != -1) { - addIcon(getInventory().firstEmpty(), voucher.toItemStack(), event -> new OptionMenu(instance, voucher).open(event.getPlayer())); + ItemStack voucherr = voucher.toItemStack(); + ItemMeta vouchermeta = voucherr.getItemMeta(); + vouchermeta.setDisplayName(voucher.getName()); + Bukkit.broadcastMessage(voucher.getName()); + voucherr.setItemMeta(vouchermeta); + addIcon(getInventory().firstEmpty(), voucherr, event -> new OptionMenu(instance, voucher).open(event.getPlayer())); } } From 2a74183821560f912f45e9871ea33b1242773a17 Mon Sep 17 00:00:00 2001 From: xsmeths Date: Mon, 15 Apr 2024 00:09:42 +0100 Subject: [PATCH 4/7] remove a debug line --- src/main/java/com/craftaro/epicvouchers/menus/VoucherMenu.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/craftaro/epicvouchers/menus/VoucherMenu.java b/src/main/java/com/craftaro/epicvouchers/menus/VoucherMenu.java index f02cb84..647cda0 100644 --- a/src/main/java/com/craftaro/epicvouchers/menus/VoucherMenu.java +++ b/src/main/java/com/craftaro/epicvouchers/menus/VoucherMenu.java @@ -30,7 +30,6 @@ public class VoucherMenu extends IconInv { ItemStack voucherr = voucher.toItemStack(); ItemMeta vouchermeta = voucherr.getItemMeta(); vouchermeta.setDisplayName(voucher.getName()); - Bukkit.broadcastMessage(voucher.getName()); voucherr.setItemMeta(vouchermeta); addIcon(getInventory().firstEmpty(), voucherr, event -> new OptionMenu(instance, voucher).open(event.getPlayer())); } From fc0e3ef7c038f2daac2741b2a3a26eba3a563183 Mon Sep 17 00:00:00 2001 From: xsmeths Date: Mon, 15 Apr 2024 00:18:00 +0100 Subject: [PATCH 5/7] translate colors for editor menu items that were just created --- src/main/java/com/craftaro/epicvouchers/menus/VoucherMenu.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/craftaro/epicvouchers/menus/VoucherMenu.java b/src/main/java/com/craftaro/epicvouchers/menus/VoucherMenu.java index 647cda0..d032bb5 100644 --- a/src/main/java/com/craftaro/epicvouchers/menus/VoucherMenu.java +++ b/src/main/java/com/craftaro/epicvouchers/menus/VoucherMenu.java @@ -29,7 +29,7 @@ public class VoucherMenu extends IconInv { if (getInventory().firstEmpty() != -1) { ItemStack voucherr = voucher.toItemStack(); ItemMeta vouchermeta = voucherr.getItemMeta(); - vouchermeta.setDisplayName(voucher.getName()); + vouchermeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', voucher.getName())); voucherr.setItemMeta(vouchermeta); addIcon(getInventory().firstEmpty(), voucherr, event -> new OptionMenu(instance, voucher).open(event.getPlayer())); } From c76cbe8de844381c042b31935c7a9aef94efc94d Mon Sep 17 00:00:00 2001 From: xsmeths Date: Mon, 15 Apr 2024 02:59:07 +0100 Subject: [PATCH 6/7] less horrible naming --- .../com/craftaro/epicvouchers/menus/VoucherMenu.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/craftaro/epicvouchers/menus/VoucherMenu.java b/src/main/java/com/craftaro/epicvouchers/menus/VoucherMenu.java index d032bb5..25ef9d6 100644 --- a/src/main/java/com/craftaro/epicvouchers/menus/VoucherMenu.java +++ b/src/main/java/com/craftaro/epicvouchers/menus/VoucherMenu.java @@ -27,11 +27,11 @@ public class VoucherMenu extends IconInv { for (Voucher voucher : instance.getVoucherManager().getVouchers()) { if (getInventory().firstEmpty() != -1) { - ItemStack voucherr = voucher.toItemStack(); - ItemMeta vouchermeta = voucherr.getItemMeta(); - vouchermeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', voucher.getName())); - voucherr.setItemMeta(vouchermeta); - addIcon(getInventory().firstEmpty(), voucherr, event -> new OptionMenu(instance, voucher).open(event.getPlayer())); + ItemStack voucherItemStack = voucher.toItemStack(); + ItemMeta voucherItemMeta = voucherItemStack.getItemMeta(); + voucherItemMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', voucher.getName())); + voucherItemStack.setItemMeta(voucherItemMeta); + addIcon(getInventory().firstEmpty(), voucherItemStack, event -> new OptionMenu(instance, voucher).open(event.getPlayer())); } } From 70cc75b27f6c3839eeea5c4a376f8f594ae3c871 Mon Sep 17 00:00:00 2001 From: xsmeths Date: Mon, 15 Apr 2024 06:05:08 +0100 Subject: [PATCH 7/7] more menu fixes stop people making vouchers with no id make it so the anvil gui logic updates your exp back to what it was after using it TextUtils for formatting --- .../epicvouchers/menus/VoucherMenu.java | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/craftaro/epicvouchers/menus/VoucherMenu.java b/src/main/java/com/craftaro/epicvouchers/menus/VoucherMenu.java index 25ef9d6..c2ff76d 100644 --- a/src/main/java/com/craftaro/epicvouchers/menus/VoucherMenu.java +++ b/src/main/java/com/craftaro/epicvouchers/menus/VoucherMenu.java @@ -29,7 +29,7 @@ public class VoucherMenu extends IconInv { if (getInventory().firstEmpty() != -1) { ItemStack voucherItemStack = voucher.toItemStack(); ItemMeta voucherItemMeta = voucherItemStack.getItemMeta(); - voucherItemMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', voucher.getName())); + voucherItemMeta.setDisplayName(TextUtils.formatText(voucher.getName())); voucherItemStack.setItemMeta(voucherItemMeta); addIcon(getInventory().firstEmpty(), voucherItemStack, event -> new OptionMenu(instance, voucher).open(event.getPlayer())); } @@ -42,19 +42,23 @@ public class VoucherMenu extends IconInv { gui.setTitle("Insert id"); gui.setAction(aEvent -> { final String msg = gui.getInputText().trim(); + aEvent.player.setLevel(aEvent.player.getLevel()+1); + aEvent.player.updateInventory(); + aEvent.player.setLevel(aEvent.player.getLevel()-1); + aEvent.player.updateInventory(); if (instance.getVoucherManager().getVoucher(msg) != null) { event.getPlayer().sendMessage(TextUtils.formatText("&cAlready a voucher registered with the id: " + msg)); new VoucherMenu(instance).open(event.getPlayer()); return; } - - Voucher voucher = new Voucher(msg, instance); - voucher.setMaterial(PAPER); - voucher.setName("&f" + msg); - voucher.setTexture(""); - - instance.getVoucherManager().addVoucher(voucher); - event.getPlayer().sendMessage(TextUtils.formatText("&7Successfully created voucher with id &r" + msg + "&7.")); + if (!msg.isEmpty()) { + Voucher voucher = new Voucher(msg, instance); + voucher.setMaterial(PAPER); + voucher.setName("&f" + msg); + voucher.setTexture(""); + instance.getVoucherManager().addVoucher(voucher); + event.getPlayer().sendMessage(TextUtils.formatText("&7Successfully created voucher with id &r" + msg + "&7.")); + } new VoucherMenu(instance).open(event.getPlayer()); }); instance.getGuiManager().showGUI(event.getPlayer(), gui); @@ -65,3 +69,4 @@ public class VoucherMenu extends IconInv { new ItemStack(Material.valueOf("STAINED_GLASS_PANE"), 1, (short) 7)).name(ChatColor.RESET.toString()).build())); } } +