blob: a8dcf8ad4783148db7091e345adce96026ad48d4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
package com.earth2me.essentials.commands;
import com.earth2me.essentials.Essentials;
import com.earth2me.essentials.InventoryWorkaround;
import com.earth2me.essentials.ItemDb;
import com.earth2me.essentials.User;
import org.bukkit.ChatColor;
import org.bukkit.Server;
import org.bukkit.craftbukkit.inventory.CraftInventory;
import org.bukkit.inventory.ItemStack;
public class Commandunlimited extends EssentialsCommand
{
public Commandunlimited()
{
super("unlimited");
}
@Override
public void run(Server server, Essentials parent, User user, String commandLabel, String[] args) throws Exception
{
if (args.length < 1)
{
user.sendMessage("§cUsage: /" + commandLabel + " [item] <player>");
return;
}
ItemStack stack = ItemDb.get(args[0], 1);
if(!user.isAuthorized("essentials.infinite.whitelist.override") &&
Essentials.getSettings().getUnlimitedWhitelist().contains(stack.getTypeId()))
{
user.sendMessage(ChatColor.RED + "You are not allowed to spawn that item");
return;
}
User target = user;
if (args.length > 1 && user.isAuthorized("essentials.unlimited.others")) {
target = getPlayer(server, args, 1);
}
String itemName = stack.getType().name().toLowerCase().replace('_', ' ');
if (target.hasUnlimited(stack)) {
if (user != target) {
user.sendMessage("§7Disable unlimited placing of " + itemName + " for " + user.getDisplayName() + ".");
}
target.sendMessage("§7Disable unlimited placing of " + itemName + " for " + user.getDisplayName() + ".");
target.setUnlimited(stack, false);
return;
}
user.charge(this);
if (user != target) {
user.sendMessage("§7Giving unlimited amount of " + itemName + " to " + user.getDisplayName() + ".");
}
target.sendMessage("§7Giving unlimited amount of " + itemName + " to " + user.getDisplayName() + ".");
if (!InventoryWorkaround.containsItem((CraftInventory)target.getInventory(), true, stack)) {
target.getInventory().addItem(stack);
}
target.setUnlimited(stack, true);
}
}
|