From 15dd55712a2eb5e578f1378a0d3309d646b0c200 Mon Sep 17 00:00:00 2001 From: Charlie Date: Tue, 29 Jul 2014 18:14:18 -0400 Subject: [PATCH] dense radius, fix off-by-one in /ds other --- .../java/ca/gibstick/discosheep/DiscoCommands.java | 11 +++++------ src/main/java/ca/gibstick/discosheep/DiscoSheep.java | 3 ++- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/ca/gibstick/discosheep/DiscoCommands.java b/src/main/java/ca/gibstick/discosheep/DiscoCommands.java index 35477b8..2e35987 100644 --- a/src/main/java/ca/gibstick/discosheep/DiscoCommands.java +++ b/src/main/java/ca/gibstick/discosheep/DiscoCommands.java @@ -50,16 +50,15 @@ public class DiscoCommands { private static void parsePartyFlags(DiscoParty party, final CommandContext args, CommandSender sender) throws IllegalArgumentException { party.setDuration(args.getFlagInteger('t', DiscoParty.defaultDuration)); party.setPeriod(args.getFlagInteger('p', DiscoParty.defaultPeriod)); - party.setRadius(args.getFlagInteger('r', DiscoParty.defaultRadius)); party.setSheep(args.getFlagInteger('n', DiscoParty.defaultSheep)); // handle the special case of radius flag arg "dense" - /*String radiusArg = args.getFlag('r'); + String radiusArg = args.getFlag('r', Integer.toString(DiscoParty.defaultRadius)); if ("dense".equals(radiusArg)) { - party.setDenseRadius(party.getSheep()); + party.setDenseRadius(party.getSheep()); } else { - party.setRadius(Integer.parseInt(radiusArg)); - }*/ + party.setRadius(Integer.parseInt(radiusArg)); + } if (sender.hasPermission(PERMISSION_FIREWORKS)) { party.setDoFireworks(args.hasFlag('f')); @@ -135,7 +134,7 @@ public class DiscoCommands { public static void partyOtherCommand(CommandContext args, CommandSender sender) { DiscoParty party = new DiscoParty(); Player p; - String players[] = args.getSlice(0); + String players[] = args.getSlice(1); parsePartyFlags(party, args, sender); diff --git a/src/main/java/ca/gibstick/discosheep/DiscoSheep.java b/src/main/java/ca/gibstick/discosheep/DiscoSheep.java index 82a64f2..0ac1b5b 100644 --- a/src/main/java/ca/gibstick/discosheep/DiscoSheep.java +++ b/src/main/java/ca/gibstick/discosheep/DiscoSheep.java @@ -60,6 +60,8 @@ public final class DiscoSheep extends JavaPlugin { } catch (WrappedCommandException e) { if (e.getCause() instanceof NumberFormatException) { sender.sendMessage(ChatColor.RED + "Number expected, string received instead."); + } else if (e.getCause() instanceof IllegalArgumentException) { + sender.sendMessage(ChatColor.RED + "Illegal argument (out of bounds or bad format)."); } else { sender.sendMessage(ChatColor.RED + "An error has occurred. See console."); e.printStackTrace(); @@ -69,7 +71,6 @@ public final class DiscoSheep extends JavaPlugin { } catch (com.sk89q.minecraft.util.commands.CommandException ex) { Logger.getLogger(DiscoSheep.class.getName()).log(Level.SEVERE, null, ex); } - return true; }