From 01c5ccab7d9ffc1bcf8dd1fbaada49383cd6e30d Mon Sep 17 00:00:00 2001 From: Brettflan Date: Wed, 27 Jul 2011 22:25:16 -0500 Subject: [PATCH] When using commands, world name can now be specified in quotation marks if it has a space in it (example: /wb "you world name" set 4000 0 0); also made new "whoosh" knockback effect default to disabled so that it's opt-in, since it could potentially be considered annoying --- src/com/wimbli/WorldBorder/Config.java | 4 +-- src/com/wimbli/WorldBorder/WBCommand.java | 35 +++++++++++++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/src/com/wimbli/WorldBorder/Config.java b/src/com/wimbli/WorldBorder/Config.java index 781c24a..2ec0a23 100644 --- a/src/com/wimbli/WorldBorder/Config.java +++ b/src/com/wimbli/WorldBorder/Config.java @@ -46,7 +46,7 @@ public class Config private static boolean DEBUG = false; private static double knockBack = 3.0; private static int timerTicks = 4; - private static boolean whooshEffect = true; + private static boolean whooshEffect = false; // for monitoring plugin efficiency // public static long timeUsed = 0; @@ -334,7 +334,7 @@ public class Config message = cfg.getString("message"); shapeRound = cfg.getBoolean("round-border", false); DEBUG = cfg.getBoolean("debug-mode", false); - whooshEffect = cfg.getBoolean("whoosh-effect", true); + whooshEffect = cfg.getBoolean("whoosh-effect", false); knockBack = cfg.getDouble("knock-back-dist", 3.0); timerTicks = cfg.getInt("timer-delay-ticks", 5); LogConfig("Using " + (shapeRound ? "round" : "square") + " border, knockback of " + knockBack + " blocks, and timer delay of " + timerTicks + "."); diff --git a/src/com/wimbli/WorldBorder/WBCommand.java b/src/com/wimbli/WorldBorder/WBCommand.java index 3dfa795..ad50f70 100644 --- a/src/com/wimbli/WorldBorder/WBCommand.java +++ b/src/com/wimbli/WorldBorder/WBCommand.java @@ -1,6 +1,8 @@ package com.wimbli.WorldBorder; +import java.util.ArrayList; import java.util.Iterator; +import java.util.List; import java.util.Set; import org.bukkit.ChatColor; @@ -34,6 +36,39 @@ public class WBCommand implements CommandExecutor String cmd = clrCmd + ((player == null) ? "wb" : "/wb"); String cmdW = clrCmd + ((player == null) ? "wb " + clrReq + "" : "/wb " + clrOpt + "[world]") + clrCmd; + // if world name is passed inside quotation marks, handle that + if (split.length > 2 && split[0].startsWith("\"")) + { + if (split[0].endsWith("\"")) + { + split[0] = split[0].substring(1, split[0].length() - 1); + } + else + { + List args = new ArrayList(); + String quote = split[0]; + int loop; + for (loop = 1; loop < split.length; loop++) + { + quote += " " + split[loop]; + if (split[loop].endsWith("\"")) + break; + } + + if (loop < split.length || !split[loop].endsWith("\"")) + { + args.add(quote.substring(1, quote.length() - 1)); + loop++; + while (loop < split.length) + { + args.add(split[loop]); + loop++; + } + split = args.toArray(new String[0]); + } + } + } + // "set" command from player or console, world specified if (split.length == 5 && split[1].equalsIgnoreCase("set")) {