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())); } } +