From cf754c4ef654160dca946889c11941634c5db3d5 Mon Sep 17 00:00:00 2001 From: "slicedlime (Mikael Hedberg)" Date: Thu, 18 Mar 2021 15:32:47 +0100 Subject: [PATCH] Use rootian locale for case conversion. --- src/main/java/com/mojang/brigadier/CommandDispatcher.java | 3 ++- .../com/mojang/brigadier/suggestion/SuggestionsBuilder.java | 3 ++- .../java/com/mojang/brigadier/tree/LiteralCommandNode.java | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/mojang/brigadier/CommandDispatcher.java b/src/main/java/com/mojang/brigadier/CommandDispatcher.java index f67a95d..ca24830 100644 --- a/src/main/java/com/mojang/brigadier/CommandDispatcher.java +++ b/src/main/java/com/mojang/brigadier/CommandDispatcher.java @@ -20,6 +20,7 @@ import java.util.Collections; import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Set; import java.util.concurrent.CompletableFuture; @@ -588,7 +589,7 @@ public class CommandDispatcher { final String fullInput = parse.getReader().getString(); final String truncatedInput = fullInput.substring(0, cursor); - final String truncatedInputLowerCase = truncatedInput.toLowerCase(); + final String truncatedInputLowerCase = truncatedInput.toLowerCase(Locale.ROOT); @SuppressWarnings("unchecked") final CompletableFuture[] futures = new CompletableFuture[parent.getChildren().size()]; int i = 0; for (final CommandNode node : parent.getChildren()) { diff --git a/src/main/java/com/mojang/brigadier/suggestion/SuggestionsBuilder.java b/src/main/java/com/mojang/brigadier/suggestion/SuggestionsBuilder.java index 3cc72b9..b61f85f 100644 --- a/src/main/java/com/mojang/brigadier/suggestion/SuggestionsBuilder.java +++ b/src/main/java/com/mojang/brigadier/suggestion/SuggestionsBuilder.java @@ -8,6 +8,7 @@ import com.mojang.brigadier.context.StringRange; import java.util.ArrayList; import java.util.List; +import java.util.Locale; import java.util.concurrent.CompletableFuture; public class SuggestionsBuilder { @@ -27,7 +28,7 @@ public class SuggestionsBuilder { } public SuggestionsBuilder(final String input, final int start) { - this(input, input.toLowerCase(), start); + this(input, input.toLowerCase(Locale.ROOT), start); } public String getInput() { diff --git a/src/main/java/com/mojang/brigadier/tree/LiteralCommandNode.java b/src/main/java/com/mojang/brigadier/tree/LiteralCommandNode.java index 90c0cbb..85a8904 100644 --- a/src/main/java/com/mojang/brigadier/tree/LiteralCommandNode.java +++ b/src/main/java/com/mojang/brigadier/tree/LiteralCommandNode.java @@ -16,6 +16,7 @@ import com.mojang.brigadier.suggestion.SuggestionsBuilder; import java.util.Collection; import java.util.Collections; +import java.util.Locale; import java.util.concurrent.CompletableFuture; import java.util.function.Predicate; @@ -26,7 +27,7 @@ public class LiteralCommandNode extends CommandNode { public LiteralCommandNode(final String literal, final Command command, final Predicate requirement, final CommandNode redirect, final RedirectModifier modifier, final boolean forks) { super(command, requirement, redirect, modifier, forks); this.literal = literal; - this.literalLowerCase = literal.toLowerCase(); + this.literalLowerCase = literal.toLowerCase(Locale.ROOT); } public String getLiteral() {