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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
package com.earth2me.essentials.commands;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.inventory.ItemStack;
public class Commandpowertool extends EssentialsCommand
{
public Commandpowertool()
{
super("powertool");
}
@Override
protected void run(Server server, User user, String commandLabel, String[] args) throws Exception
{
ItemStack is = user.getItemInHand();
List<String> powertools = user.getPowertool(is);
if (is == null || is.getType() == Material.AIR)
{
user.sendMessage(Util.i18n("powerToolAir"));
return;
}
String itemName = is.getType().toString().toLowerCase().replaceAll("_", " ");
String command = getFinalArg(args, 0);
if (command != null && !command.isEmpty())
{
if (command.equalsIgnoreCase("l:"))
{
if (powertools == null || powertools.isEmpty())
{
user.sendMessage(Util.format("powerToolListEmpty", itemName));
}
else
{
user.sendMessage(Util.format("powerToolList", Util.joinList(powertools), itemName));
}
return;
}
if (command.startsWith("r:"))
{
try
{
command = command.substring(2);
if (!powertools.contains(command))
{
user.sendMessage(Util.format("powerToolNoSuchCommandAssigned", command, itemName));
return;
}
powertools.remove(command);
user.sendMessage(Util.format("powerToolRemove", command, itemName));
}
catch (Exception e)
{
user.sendMessage(e.getMessage());
return;
}
}
else
{
if (command.startsWith("a:"))
{
command = command.substring(2);
if(powertools.contains(command))
{
user.sendMessage(Util.format("powerToolAlreadySet", command, itemName));
return;
}
}
else if (powertools != null && !powertools.isEmpty())
{
// Replace all commands with this one
powertools.clear();
}
else
{
powertools = new ArrayList<String>();
}
powertools.add(command);
user.sendMessage(Util.format("powerToolAttach", Util.joinList(powertools), itemName));
}
}
else
{
powertools.clear();
user.sendMessage(Util.format("powerToolRemoveAll", itemName));
}
charge(user);
user.setPowertool(is, powertools);
}
}
|