summaryrefslogtreecommitdiffstats
path: root/Essentials/src/com/earth2me/essentials/commands/Commandkickall.java
blob: e73f57a00b791a5bf7e0ae1764f1ac524db8dc95 (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
package com.earth2me.essentials.commands;

import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.earth2me.essentials.Essentials;
import com.earth2me.essentials.User;

public class Commandkickall extends EssentialsCommand
{
	public Commandkickall()
	{
		super("kickall");
	}

	@Override
	public void run(Server server, Essentials parent, User user, String commandLabel, String[] args) throws Exception
	{
		if (args.length < 1)
		{
			user.sendMessage("§7Usage: /" + commandLabel + "<reason>");
			return;
		}


		for (Player p : server.getOnlinePlayers())
		{
			if (server.getOnlinePlayers().length == 1 && p.getName().equalsIgnoreCase(user.getName()))
			{
				user.sendMessage("§7Only you online...");
				return;
			}
			else
			{
				if (!p.getName().equalsIgnoreCase(user.getName()))
				{
					p.kickPlayer(args.length < 1 ? args[0] : "Kicked from server");
				}
			}
		}
	}

	@Override
	public void run(Server server, Essentials parent, CommandSender sender, String commandLabel, String[] args) throws Exception
	{
		if (args.length < 1)
		{
			sender.sendMessage("Usage: /" + commandLabel + "<reason>");
			return;
		}

		for (Player p : server.getOnlinePlayers())
			p.kickPlayer(args.length < 1 ? args[0] : "Kicked from server");
	}
}