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
|
package com.earth2me.essentials.spawn;
import java.util.logging.*;
import com.earth2me.essentials.*;
import com.earth2me.essentials.commands.IEssentialsCommand;
import org.bukkit.command.*;
public class EssentialsSpawnWorker
{
private static final Logger logger = Logger.getLogger("Minecraft");
@SuppressWarnings(
{
"LoggerStringConcat", "CallToThreadDumpStack"
})
public static boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args)
{
User user = User.get(sender);
IEssentialsCommand cmd;
try
{
cmd = (IEssentialsCommand)EssentialsSpawn.class.getClassLoader().loadClass("com.earth2me.essentials.spawn.Command" + command.getName()).newInstance();
}
catch (Exception ex)
{
sender.sendMessage("§cThat command is improperly loaded.");
ex.printStackTrace();
return true;
}
// Check authorization
if (user != null && !user.isAuthorized(cmd))
{
logger.warning(user.getName() + " was denied access to command.");
user.sendMessage("§cYou do not have access to that command.");
return true;
}
// Run the command
try
{
if (user == null)
cmd.run(Essentials.getStatic().getServer(), Essentials.getStatic(), sender, commandLabel, command, args);
else
cmd.run(Essentials.getStatic().getServer(), Essentials.getStatic(), user, commandLabel, command, args);
return true;
}
catch (Exception ex)
{
sender.sendMessage((user == null ? "" : "§c") + "Error: " + ex.getMessage());
return true;
}
}
}
|