diff options
Diffstat (limited to 'src/main/java/com/encrox/zombie/Commander.java')
-rwxr-xr-x | src/main/java/com/encrox/zombie/Commander.java | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/main/java/com/encrox/zombie/Commander.java b/src/main/java/com/encrox/zombie/Commander.java new file mode 100755 index 0000000..40e77eb --- /dev/null +++ b/src/main/java/com/encrox/zombie/Commander.java @@ -0,0 +1,56 @@ +package com.encrox.zombie;
+
+import org.bukkit.ChatColor;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandExecutor;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
+
+public class Commander implements CommandExecutor {
+
+ @Override
+ public boolean onCommand(CommandSender sender, Command arg1, String arg2, String[] args) {
+ try {
+ if(sender instanceof Player) {
+ Player player = (Player)sender;
+ switch(args[0]) {
+ case "lobby":
+ switch(args[1]) {
+ case "create":
+ if(player.hasPermission("zombie.create")) {
+ player.sendMessage(Zombie.createLobby(player, args[2], args[3]));
+ } else {
+ player.sendMessage(ChatColor.RED + Zombie.lang.getProperty("no_permission"));
+ }
+ break;
+ case "join":
+ if(player.hasPermission("zombie.join")) {
+ if(args.length == 3) {
+ player.sendMessage(Zombie.joinLobby(player, args[2]));
+ } else {
+ player.sendMessage(Zombie.listLobbies());
+ }
+ } else {
+ player.sendMessage(ChatColor.RED + Zombie.lang.getProperty("no_permission"));
+ }
+ break;
+ case "leave":
+ player.sendMessage(Zombie.removePlayer(player));
+ break;
+ case "start":
+ player.sendMessage(Zombie.start(player));
+ break;
+ }
+ break;
+ }
+ } else {
+ sender.sendMessage(Zombie.lang.getProperty("no_player"));
+ }
+ } catch(Exception e) {
+ e.printStackTrace();
+ return false;
+ }
+ return true;
+ }
+
+}
|