From 9e2ddeb55321b09086a5a27254197d783847e6e3 Mon Sep 17 00:00:00 2001 From: Leonard Kugis Date: Mon, 25 Apr 2022 18:50:36 +0200 Subject: Initial commit --- src/main/java/com/encrox/zombie/Commander.java | 56 ++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100755 src/main/java/com/encrox/zombie/Commander.java (limited to 'src/main/java/com/encrox/zombie/Commander.java') 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; + } + +} -- cgit v1.2.1