diff options
author | snowleo <snowleo@e251c2fe-e539-e718-e476-b85c1f46cddb> | 2011-03-19 22:39:51 +0000 |
---|---|---|
committer | snowleo <snowleo@e251c2fe-e539-e718-e476-b85c1f46cddb> | 2011-03-19 22:39:51 +0000 |
commit | 59d0415c7d7c1aa1a1720734d73f9aada9c38c89 (patch) | |
tree | 751109b805d814fb4d290ce5b03fb19dc52f11f2 /EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnWorker.java | |
parent | ea668bf9d0733ad1ec6dd0653b1d243b3d979a59 (diff) | |
download | Essentials-59d0415c7d7c1aa1a1720734d73f9aada9c38c89.tar Essentials-59d0415c7d7c1aa1a1720734d73f9aada9c38c89.tar.gz Essentials-59d0415c7d7c1aa1a1720734d73f9aada9c38c89.tar.lz Essentials-59d0415c7d7c1aa1a1720734d73f9aada9c38c89.tar.xz Essentials-59d0415c7d7c1aa1a1720734d73f9aada9c38c89.zip |
Moving all files to trunk.
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@969 e251c2fe-e539-e718-e476-b85c1f46cddb
Diffstat (limited to 'EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnWorker.java')
-rw-r--r-- | EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnWorker.java | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnWorker.java b/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnWorker.java new file mode 100644 index 000000000..d6e34db55 --- /dev/null +++ b/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnWorker.java @@ -0,0 +1,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; + } + } +} |