mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-12-23 09:37:50 +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);
|
return !Essentials.getSettings().itemSpawnBlacklist().contains(itemId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasUnlimited(ItemStack stack) {
|
@SuppressWarnings("unchecked")
|
||||||
|
public List<Integer> getUnlimited() {
|
||||||
if (!data.containsKey("unlimited")) {
|
if (!data.containsKey("unlimited")) {
|
||||||
return false;
|
return new ArrayList<Integer>();
|
||||||
}
|
}
|
||||||
@SuppressWarnings("unchecked")
|
return (List<Integer>)data.get("unlimited");
|
||||||
List<Integer> items = (List<Integer>)data.get("unlimited");
|
}
|
||||||
return items.contains(stack.getTypeId());
|
|
||||||
|
public boolean hasUnlimited(ItemStack stack) {
|
||||||
|
return getUnlimited().contains(stack.getTypeId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void setUnlimited(ItemStack stack, boolean state) {
|
public void setUnlimited(ItemStack stack, boolean state) {
|
||||||
List<Integer> items = new ArrayList<Integer>();
|
List<Integer> items = getUnlimited();
|
||||||
if (data.containsKey("unlimited")) {
|
|
||||||
items = (List<Integer>)data.get("unlimited");
|
|
||||||
}
|
|
||||||
if (items.contains(stack.getTypeId())) {
|
if (items.contains(stack.getTypeId())) {
|
||||||
items.remove(Integer.valueOf(stack.getTypeId()));
|
items.remove(Integer.valueOf(stack.getTypeId()));
|
||||||
}
|
}
|
||||||
|
@ -22,16 +22,33 @@ public class Commandunlimited extends EssentialsCommand
|
|||||||
{
|
{
|
||||||
if (args.length < 1)
|
if (args.length < 1)
|
||||||
{
|
{
|
||||||
user.sendMessage("§cUsage: /" + commandLabel + " [item] <player>");
|
user.sendMessage("§cUsage: /" + commandLabel + " [list|item] <player>");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ItemStack stack = ItemDb.get(args[0], 1);
|
|
||||||
|
|
||||||
User target = user;
|
User target = user;
|
||||||
|
|
||||||
if (args.length > 1 && user.isAuthorized("essentials.unlimited.others")) {
|
if (args.length > 1 && user.isAuthorized("essentials.unlimited.others")) {
|
||||||
target = getPlayer(server, args, 1);
|
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("_", "-");
|
String itemname = stack.getType().toString().toLowerCase().replace("_", "-");
|
||||||
if (!user.isAuthorized("essentials.unlimited.item-add") &&
|
if (!user.isAuthorized("essentials.unlimited.item-add") &&
|
||||||
|
@ -239,7 +239,7 @@ commands:
|
|||||||
aliases: pardonip
|
aliases: pardonip
|
||||||
unlimited:
|
unlimited:
|
||||||
description: Allows the unlimited placing of items.
|
description: Allows the unlimited placing of items.
|
||||||
usage: /<command> [item] <player>
|
usage: /<command> [list|item] <player>
|
||||||
warp:
|
warp:
|
||||||
description: List all warps or warp to the specified location.
|
description: List all warps or warp to the specified location.
|
||||||
usage: /<command> <warp>
|
usage: /<command> <warp>
|
||||||
|
Loading…
Reference in New Issue
Block a user