From 278590a9cb621deac22685e0119e4bbad7adc91e Mon Sep 17 00:00:00 2001 From: TheL0w3R Date: Sat, 10 Jan 2015 21:01:55 +0000 Subject: [PATCH 1/2] Trying to add a vote command Trying to add a vote command for the players to vote for night/day/rain etc.. --- .../minigamesapi/commands/CommandHandler.java | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/API/src/main/java/com/comze_instancelabs/minigamesapi/commands/CommandHandler.java b/API/src/main/java/com/comze_instancelabs/minigamesapi/commands/CommandHandler.java index 28022692..787ae427 100644 --- a/API/src/main/java/com/comze_instancelabs/minigamesapi/commands/CommandHandler.java +++ b/API/src/main/java/com/comze_instancelabs/minigamesapi/commands/CommandHandler.java @@ -71,6 +71,8 @@ public boolean handleArgs(JavaPlugin plugin, String uber_permission, String cmd, return this.joinArena(pli, sender, args, uber_permission, cmd, action, plugin, p); } else if (action.equalsIgnoreCase("leave")) { return this.leaveArena(pli, sender, args, uber_permission, cmd, action, plugin, p); + } else if (action.equalsIgnoreCase("vote")) { + return this.vote(pli, sender, args, uber_permission, cmd, action, plugin, p); } else if (action.equalsIgnoreCase("start")) { return this.startArena(pli, sender, args, uber_permission, cmd, action, plugin, p); } else if (action.equalsIgnoreCase("stop")) { @@ -479,7 +481,28 @@ public boolean leaveArena(PluginInstance pli, CommandSender sender, String[] arg } return true; } - + + public boolean vote(PluginInstance pli, CommandSender sender, String[] args, String uber_permission, String cmd, String action, JavaPlugin plugin, Player p) { + if (!sender.hasPermission(uber_permission + ".vote")) { + sender.sendMessage(pli.getMessagesConfig().no_perm); + return true; + } + if (args.length > 1) { + if(args.equals("night")) { + p.getWorld().setTime(18000); + } else if (args.equals("day")) { + p.getWorld().setTime(0); + } else if (args.equals("sunset")) { + p.getWorld().setTime(12550); + } else if (args.equals("rain")) { + p.getWorld().setStorm(true); + } else if (args.equals("clear")) { + p.getWorld().setStorm(false); + } + } + return true; + } + public boolean startArena(PluginInstance pli, CommandSender sender, String[] args, String uber_permission, String cmd, String action, JavaPlugin plugin, Player p) { if (!sender.hasPermission(uber_permission + ".start")) { sender.sendMessage(pli.getMessagesConfig().no_perm); From 220860e1770b3f3f849bcac5a5fcca88413103b8 Mon Sep 17 00:00:00 2001 From: TheL0w3R Date: Sun, 11 Jan 2015 21:46:04 +0000 Subject: [PATCH 2/2] Confusion with my last code. Changed "args.equals(String)" to "args.equalsIgnoreCase(String)" :) --- .../minigamesapi/commands/CommandHandler.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/API/src/main/java/com/comze_instancelabs/minigamesapi/commands/CommandHandler.java b/API/src/main/java/com/comze_instancelabs/minigamesapi/commands/CommandHandler.java index 787ae427..09ea350f 100644 --- a/API/src/main/java/com/comze_instancelabs/minigamesapi/commands/CommandHandler.java +++ b/API/src/main/java/com/comze_instancelabs/minigamesapi/commands/CommandHandler.java @@ -488,15 +488,15 @@ public boolean vote(PluginInstance pli, CommandSender sender, String[] args, Str return true; } if (args.length > 1) { - if(args.equals("night")) { + if(args.equalsIgnoreCase("night")) { p.getWorld().setTime(18000); - } else if (args.equals("day")) { + } else if (args.equalsIgnoreCase("day")) { p.getWorld().setTime(0); - } else if (args.equals("sunset")) { + } else if (args.equalsIgnoreCase("sunset")) { p.getWorld().setTime(12550); - } else if (args.equals("rain")) { + } else if (args.equalsIgnoreCase("rain")) { p.getWorld().setStorm(true); - } else if (args.equals("clear")) { + } else if (args.equalsIgnoreCase("clear")) { p.getWorld().setStorm(false); } }