diff --git a/src/com/massivecraft/mcore/cmd/MCommand.java b/src/com/massivecraft/mcore/cmd/MCommand.java index d45553eb..737f4636 100644 --- a/src/com/massivecraft/mcore/cmd/MCommand.java +++ b/src/com/massivecraft/mcore/cmd/MCommand.java @@ -73,6 +73,12 @@ public class MCommand public boolean isUsingTokenizer() { return this.usingTokenizer; } public void setUsingTokenizer(boolean usingTokenizer) { this.usingTokenizer = usingTokenizer; } + // FIELD: usingSmartQuotesRemoval + // Are "smart" quotes replaced with normal characters? + protected boolean usingSmartQuotesRemoval; + public boolean isUsingSmartQuotesRemoval() { return this.usingSmartQuotesRemoval; } + public void setUsingSmartQuotesRemoval(boolean usingSmartQuotesRemoval) { this.usingSmartQuotesRemoval = usingSmartQuotesRemoval; } + // FIELD: requirements // All these requirements must be met for the command to be executable; protected List requirements; @@ -184,6 +190,7 @@ public class MCommand this.errorOnToManyArgs = true; this.usingTokenizer = true; + this.usingSmartQuotesRemoval = true; this.desc = null; this.descPermission = null; diff --git a/src/com/massivecraft/mcore/cmd/MCoreBukkitCommand.java b/src/com/massivecraft/mcore/cmd/MCoreBukkitCommand.java index 15f9ee31..fcb7f6bf 100644 --- a/src/com/massivecraft/mcore/cmd/MCoreBukkitCommand.java +++ b/src/com/massivecraft/mcore/cmd/MCoreBukkitCommand.java @@ -82,6 +82,16 @@ public class MCoreBukkitCommand extends Command argList = new ArrayList(Arrays.asList(args)); } + if (this.mcommand.isUsingSmartQuotesRemoval()) + { + List oldArgList = argList; + argList = new ArrayList(); + for (String arg : oldArgList) + { + argList.add(Txt.removeSmartQuotes(arg)); + } + } + this.mcommand.execute(sender, argList); return true; diff --git a/src/com/massivecraft/mcore/util/Txt.java b/src/com/massivecraft/mcore/util/Txt.java index 5f110520..eb089e49 100644 --- a/src/com/massivecraft/mcore/util/Txt.java +++ b/src/com/massivecraft/mcore/util/Txt.java @@ -489,6 +489,42 @@ public class Txt return ret; } + // -------------------------------------------- // + // "SMART" QUOTES + // -------------------------------------------- // + // The quite stupid "Smart quotes" design idea means replacing normal characters with mutated UTF-8 alternatives. + // The normal characters look good in Minecraft. + // The UFT-8 "smart" alternatives look quite bad. + // http://www.fileformat.info/info/unicode/block/general_punctuation/list.htm + + public static String removeSmartQuotes(String string) + { + if (string == null) return null; + + // LEFT SINGLE QUOTATION MARK + string = string.replace("\u2018", "'"); + + // RIGHT SINGLE QUOTATION MARK + string = string.replace("\u2019", "'"); + + // LEFT DOUBLE QUOTATION MARK + string = string.replace("\u201C", "\""); + + // RIGHT DOUBLE QUOTATION MARK + string = string.replace("\u201D", "\""); + + // ONE DOT LEADER + string = string.replace("\u2024", "."); + + // TWO DOT LEADER + string = string.replace("\u2025", ".."); + + // HORIZONTAL ELLIPSIS + string = string.replace("\u2026", "..."); + + return string; + } + // -------------------------------------------- // // String comparison // -------------------------------------------- //