mirror of
https://github.com/songoda/EpicVouchers.git
synced 2024-11-21 17:45:48 +01:00
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
This commit is contained in:
parent
c76cbe8de8
commit
70cc75b27f
@ -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()));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user