summaryrefslogtreecommitdiff
path: root/src/main/java/com/encrox/zombie/Commander.java
diff options
context:
space:
mode:
authorLeonard Kugis <leonard@kug.is>2022-04-25 18:50:36 +0200
committerLeonard Kugis <leonard@kug.is>2022-04-25 18:50:36 +0200
commit9e2ddeb55321b09086a5a27254197d783847e6e3 (patch)
tree620e4a7b326df2a77fff51aff390e0a6bef43631 /src/main/java/com/encrox/zombie/Commander.java
Initial commitHEADmaster
Diffstat (limited to 'src/main/java/com/encrox/zombie/Commander.java')
-rwxr-xr-xsrc/main/java/com/encrox/zombie/Commander.java56
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;
+ }
+
+}