mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-12-23 01:27:40 +01:00
[trunk] Unlimited: List unlimited items with /unlimited list <player>
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1119 e251c2fe-e539-e718-e476-b85c1f46cddb
This commit is contained in:
parent
2606e5d9ff
commit
792b1c7af5
@ -698,21 +698,21 @@ public class User extends PlayerExtension implements Comparable<User>
|
||||
return !Essentials.getSettings().itemSpawnBlacklist().contains(itemId);
|
||||
}
|
||||
|
||||
public boolean hasUnlimited(ItemStack stack) {
|
||||
if (!data.containsKey("unlimited")) {
|
||||
return false;
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Integer> items = (List<Integer>)data.get("unlimited");
|
||||
return items.contains(stack.getTypeId());
|
||||
public List<Integer> getUnlimited() {
|
||||
if (!data.containsKey("unlimited")) {
|
||||
return new ArrayList<Integer>();
|
||||
}
|
||||
return (List<Integer>)data.get("unlimited");
|
||||
}
|
||||
|
||||
public boolean hasUnlimited(ItemStack stack) {
|
||||
return getUnlimited().contains(stack.getTypeId());
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void setUnlimited(ItemStack stack, boolean state) {
|
||||
List<Integer> items = new ArrayList<Integer>();
|
||||
if (data.containsKey("unlimited")) {
|
||||
items = (List<Integer>)data.get("unlimited");
|
||||
}
|
||||
List<Integer> items = getUnlimited();
|
||||
if (items.contains(stack.getTypeId())) {
|
||||
items.remove(Integer.valueOf(stack.getTypeId()));
|
||||
}
|
||||
|
@ -22,10 +22,9 @@ public class Commandunlimited extends EssentialsCommand
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
user.sendMessage("§cUsage: /" + commandLabel + " [item] <player>");
|
||||
user.sendMessage("§cUsage: /" + commandLabel + " [list|item] <player>");
|
||||
return;
|
||||
}
|
||||
ItemStack stack = ItemDb.get(args[0], 1);
|
||||
|
||||
User target = user;
|
||||
|
||||
@ -33,6 +32,24 @@ public class Commandunlimited extends EssentialsCommand
|
||||
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") &&
|
||||
!user.isAuthorized("essentials.unlimited.item-"+itemname)
|
||||
|
@ -239,7 +239,7 @@ commands:
|
||||
aliases: pardonip
|
||||
unlimited:
|
||||
description: Allows the unlimited placing of items.
|
||||
usage: /<command> [item] <player>
|
||||
usage: /<command> [list|item] <player>
|
||||
warp:
|
||||
description: List all warps or warp to the specified location.
|
||||
usage: /<command> <warp>
|
||||
|
Loading…
Reference in New Issue
Block a user