@Override public void onPlayerEggThrow(final PlayerEggThrowEvent event) { final User user = ess.getUser(event.getPlayer()); final ItemStack is = new ItemStack(Material.EGG, 1); if (user.hasUnlimited(is)) { user.getInventory().addItem(is); user.updateInventory(); } }
@Override public void onPlayerBucketEmpty(final PlayerBucketEmptyEvent event) { final User user = ess.getUser(event.getPlayer()); if (user.hasUnlimited(new ItemStack(event.getBucket()))) { event.getItemStack().setType(event.getBucket()); ess.scheduleSyncDelayedTask( new Runnable() { public void run() { user.updateInventory(); } }); } }
@Override public void run(Server server, User user, String commandLabel, String[] args) throws Exception { if (args.length < 1) { throw new NotEnoughArgumentsException(); } User target = user; if (args.length > 1 && user.isAuthorized("essentials.unlimited.others")) { target = getPlayer(server, args, 1); } if (args[0].equalsIgnoreCase("list")) { StringBuilder sb = new StringBuilder(); sb.append(Util.i18n("unlimitedItems")).append(" "); boolean first = true; List<Integer> items = target.getUnlimited(); if (items.isEmpty()) { sb.append(Util.i18n("none")); } for (Integer integer : items) { if (!first) { sb.append(", "); } first = false; String matname = Material.getMaterial(integer).toString().toLowerCase().replace("_", ""); sb.append(matname); } user.sendMessage(sb.toString()); return; } final ItemStack stack = ess.getItemDb().get(args[0], 1); stack.setAmount(Math.min(stack.getType().getMaxStackSize(), 2)); String itemname = stack.getType().toString().toLowerCase().replace("_", ""); if (!user.isAuthorized("essentials.unlimited.item-all") && !user.isAuthorized("essentials.unlimited.item-" + itemname) && !user.isAuthorized("essentials.unlimited.item-" + stack.getTypeId()) && !((stack.getType() == Material.WATER_BUCKET || stack.getType() == Material.LAVA_BUCKET) && user.isAuthorized("essentials.unlimited.item-bucket"))) { user.sendMessage(Util.format("unlimitedItemPermission", itemname)); return; } if (target.hasUnlimited(stack)) { if (user != target) { user.sendMessage(Util.format("disableUnlimited", itemname, target.getDisplayName())); } target.sendMessage(Util.format("disableUnlimited", itemname, target.getDisplayName())); target.setUnlimited(stack, false); return; } charge(user); if (user != target) { user.sendMessage(Util.format("enableUnlimited", itemname, target.getDisplayName())); } target.sendMessage(Util.format("enableUnlimited", itemname, target.getDisplayName())); if (!InventoryWorkaround.containsItem(target.getInventory(), true, stack)) { target.getInventory().addItem(stack); } target.setUnlimited(stack, true); }