From 792b1c7af5361a940b3ee21c431c30f634af6466 Mon Sep 17 00:00:00 2001 From: snowleo Date: Mon, 4 Apr 2011 14:27:06 +0000 Subject: [PATCH] [trunk] Unlimited: List unlimited items with /unlimited list git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1119 e251c2fe-e539-e718-e476-b85c1f46cddb --- .../src/com/earth2me/essentials/User.java | 18 ++++++------- .../essentials/commands/Commandunlimited.java | 25 ++++++++++++++++--- Essentials/src/plugin.yml | 2 +- 3 files changed, 31 insertions(+), 14 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/User.java b/Essentials/src/com/earth2me/essentials/User.java index d90ae7c73..019b6e2c9 100644 --- a/Essentials/src/com/earth2me/essentials/User.java +++ b/Essentials/src/com/earth2me/essentials/User.java @@ -698,21 +698,21 @@ public class User extends PlayerExtension implements Comparable return !Essentials.getSettings().itemSpawnBlacklist().contains(itemId); } - public boolean hasUnlimited(ItemStack stack) { + @SuppressWarnings("unchecked") + public List getUnlimited() { if (!data.containsKey("unlimited")) { - return false; + return new ArrayList(); } - @SuppressWarnings("unchecked") - List items = (List)data.get("unlimited"); - return items.contains(stack.getTypeId()); + return (List)data.get("unlimited"); + } + + public boolean hasUnlimited(ItemStack stack) { + return getUnlimited().contains(stack.getTypeId()); } @SuppressWarnings("unchecked") public void setUnlimited(ItemStack stack, boolean state) { - List items = new ArrayList(); - if (data.containsKey("unlimited")) { - items = (List)data.get("unlimited"); - } + List items = getUnlimited(); if (items.contains(stack.getTypeId())) { items.remove(Integer.valueOf(stack.getTypeId())); } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandunlimited.java b/Essentials/src/com/earth2me/essentials/commands/Commandunlimited.java index a8e885763..8ea13a786 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandunlimited.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandunlimited.java @@ -22,16 +22,33 @@ public class Commandunlimited extends EssentialsCommand { if (args.length < 1) { - user.sendMessage("§cUsage: /" + commandLabel + " [item] "); + user.sendMessage("§cUsage: /" + commandLabel + " [list|item] "); return; } - ItemStack stack = ItemDb.get(args[0], 1); - + 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("Unlimited items: "); + boolean first = true; + for (Integer integer : target.getUnlimited()) { + if (!first) { + sb.append(", "); + first = true; + } + String matname = Material.getMaterial(integer).toString().toLowerCase().replace("_", "-"); + sb.append(matname); + } + user.sendMessage(sb.toString()); + return; + } + + ItemStack stack = ItemDb.get(args[0], 1); String itemname = stack.getType().toString().toLowerCase().replace("_", "-"); if (!user.isAuthorized("essentials.unlimited.item-add") && diff --git a/Essentials/src/plugin.yml b/Essentials/src/plugin.yml index 289a60aa9..e91caeb65 100644 --- a/Essentials/src/plugin.yml +++ b/Essentials/src/plugin.yml @@ -239,7 +239,7 @@ commands: aliases: pardonip unlimited: description: Allows the unlimited placing of items. - usage: / [item] + usage: / [list|item] warp: description: List all warps or warp to the specified location. usage: /