blob: 039badc80bf7ed1fd76c2225f84781fe9b04091b (
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
|
package com.earth2me.essentials.commands;
import com.earth2me.essentials.Console;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.entity.Player;
public class Commandkick extends EssentialsCommand
{
public Commandkick()
{
super("kick");
}
@Override
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
throw new NotEnoughArgumentsException();
}
final User user = getPlayer(server, args, 0);
if (user.isAuthorized("essentials.kick.exempt"))
{
throw new Exception(Util.i18n("kickExempt"));
}
final String kickReason = args.length > 1 ? getFinalArg(args, 1) : Util.i18n("kickDefault");
user.kickPlayer(kickReason);
final String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME;
for(Player onlinePlayer : server.getOnlinePlayers())
{
User player = ess.getUser(onlinePlayer);
if(player.isAuthorized("essentials.kick.notify"))
{
onlinePlayer.sendMessage(Util.format("playerKicked", senderName, user.getName(), kickReason));
}
}
}
}
|