blob: ef2502b9bbe21f12e7a94adb8393aab94af2161f (
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
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
|
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import java.util.List;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Commandclearinventory extends EssentialsCommand
{
public Commandclearinventory()
{
super("clearinventory");
}
//TODO: Cleanup
@Override
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
{
if (args.length > 0 && user.isAuthorized("essentials.clearinventory.others"))
{
//TODO: Fix fringe user match case.
if (args[0].length() >= 3)
{
List<Player> online = server.matchPlayer(args[0]);
if (!online.isEmpty())
{
for (Player p : online)
{
p.getInventory().clear();
user.sendMessage(_("inventoryClearedOthers", p.getDisplayName()));
}
return;
}
throw new Exception(_("playerNotFound"));
}
else
{
Player p = server.getPlayer(args[0]);
if (p != null)
{
p.getInventory().clear();
user.sendMessage(_("inventoryClearedOthers", p.getDisplayName()));
}
else
{
throw new Exception(_("playerNotFound"));
}
}
}
else
{
user.getInventory().clear();
user.sendMessage(_("inventoryCleared"));
}
}
@Override
protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
{
if (args.length < 1)
{
throw new NotEnoughArgumentsException();
}
if (args[0].length() >= 3)
{
List<Player> online = server.matchPlayer(args[0]);
if (!online.isEmpty())
{
for (Player p : online)
{
p.getInventory().clear();
sender.sendMessage(_("inventoryClearedOthers", p.getDisplayName()));
}
return;
}
throw new Exception(_("playerNotFound"));
}
else
{
Player u = server.getPlayer(args[0]);
if (u != null)
{
u.getInventory().clear();
sender.sendMessage(_("inventoryClearedOthers", u.getDisplayName()));
}
else
{
throw new Exception(_("playerNotFound"));
}
}
}
}
|