blob: f7740c96c061d22bcfd93565f4492dc9057ed6ce (
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
|
package net.ess3.commands;
import java.util.List;
import static net.ess3.I18n._;
import net.ess3.api.IUser;
import net.ess3.permissions.Permissions;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Commandclearinventory extends EssentialsCommand
{
@Override
public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
if (args.length > 0 && Permissions.CLEARINVENTORY_OTHERS.isAuthorized(user))
{
IUser p = ess.getUserMap().matchUser(args[0], false, false);
if (p != null)
{
p.getPlayer().getInventory().clear();
user.sendMessage(_("inventoryClearedOthers", p.getPlayer().getDisplayName()));
}
else
{
throw new Exception(_("playerNotFound"));
}
}
else
{
user.getPlayer().getInventory().clear();
user.sendMessage(_("inventoryCleared"));
}
}
@Override
protected void run(final CommandSender sender, final String commandLabel, final 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"));
}
}
}
}
|