diff --git a/src/main/java/ch/njol/skript/effects/EffReplace.java b/src/main/java/ch/njol/skript/effects/EffReplace.java index 90a4ae2dfa6..5d945b0b8fd 100644 --- a/src/main/java/ch/njol/skript/effects/EffReplace.java +++ b/src/main/java/ch/njol/skript/effects/EffReplace.java @@ -106,7 +106,7 @@ protected void execute(final Event e) { for (int x = 0; x < haystack.length; x++) for (final Object n : needles) { assert n != null; - haystack[x] = StringUtils.replace((String)haystack[x], (String)n, Matcher.quoteReplacement((String)replacement), caseSensitive); + haystack[x] = StringUtils.replace((String) haystack[x], (String) n, (String) replacement, caseSensitive); } } this.haystack.change(e, haystack, ChangeMode.SET); diff --git a/src/main/java/ch/njol/util/StringUtils.java b/src/main/java/ch/njol/util/StringUtils.java index fdd8769ab95..9776d00a1bd 100644 --- a/src/main/java/ch/njol/util/StringUtils.java +++ b/src/main/java/ch/njol/util/StringUtils.java @@ -402,7 +402,7 @@ public static boolean contains(final String haystack, final String needle, final public static String replace(final String haystack, final String needle, final String replacement, final boolean caseSensitive) { if (caseSensitive) return "" + haystack.replace(needle, replacement); - return "" + haystack.replaceAll("(?ui)" + Pattern.quote(needle), replacement); + return "" + haystack.replaceAll("(?ui)" + Pattern.quote(needle), Matcher.quoteReplacement(replacement)); } public static String replaceFirst(final String haystack, final String needle, final String replacement, final boolean caseSensitive) {