Skip to content

Commit 64942cb

Browse files
committed
Make much of ProtocolLib locale independent
Fixes #242
1 parent 97430a8 commit 64942cb

File tree

5 files changed

+13
-8
lines changed

5 files changed

+13
-8
lines changed

modules/API/src/main/java/com/comphenix/protocol/PacketType.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import java.util.Arrays;
55
import java.util.Collection;
66
import java.util.List;
7+
import java.util.Locale;
78
import java.util.Map;
89
import java.util.UUID;
910
import java.util.concurrent.Callable;
@@ -542,7 +543,7 @@ public static Protocol fromVanilla(Enum<?> vanilla) {
542543
}
543544

544545
public String getPacketName() {
545-
return WordUtils.capitalize(name().toLowerCase());
546+
return WordUtils.capitalize(name().toLowerCase(Locale.ENGLISH));
546547
}
547548
}
548549

modules/API/src/main/java/com/comphenix/protocol/ProtocolConfig.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.io.IOException;
2121
import java.util.ArrayList;
2222
import java.util.List;
23+
import java.util.Locale;
2324

2425
import org.bukkit.configuration.Configuration;
2526
import org.bukkit.configuration.ConfigurationSection;
@@ -464,7 +465,7 @@ public PlayerInjectHooks getInjectionMethod() throws IllegalArgumentException {
464465
PlayerInjectHooks hook = getDefaultMethod();
465466

466467
if (text != null)
467-
hook = PlayerInjectHooks.valueOf(text.toUpperCase().replace(" ", "_"));
468+
hook = PlayerInjectHooks.valueOf(text.toUpperCase(Locale.ENGLISH).replace(" ", "_"));
468469
return hook;
469470
}
470471

modules/API/src/main/java/com/comphenix/protocol/wrappers/EnumWrappers.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.comphenix.protocol.wrappers;
22

33
import java.util.HashMap;
4+
import java.util.Locale;
45
import java.util.Map;
56

67
import org.bukkit.GameMode;
@@ -226,7 +227,7 @@ public enum Particle {
226227
BY_NAME = new HashMap<String, Particle>();
227228

228229
for (Particle particle : values()) {
229-
BY_NAME.put(particle.getName().toLowerCase(), particle);
230+
BY_NAME.put(particle.getName().toLowerCase(Locale.ENGLISH), particle);
230231
BY_ID.put(particle.getId(), particle);
231232
}
232233
}
@@ -264,7 +265,7 @@ public int getDataLength() {
264265
}
265266

266267
public static Particle getByName(String name) {
267-
return BY_NAME.get(name.toLowerCase());
268+
return BY_NAME.get(name.toLowerCase(Locale.ENGLISH));
268269
}
269270

270271
public static Particle getById(int id) {
@@ -302,7 +303,7 @@ public String getKey() {
302303
}
303304

304305
public static SoundCategory getByKey(String key) {
305-
return LOOKUP.get(key.toLowerCase());
306+
return LOOKUP.get(key.toLowerCase(Locale.ENGLISH));
306307
}
307308
}
308309

modules/API/src/main/java/com/comphenix/protocol/wrappers/MinecraftKey.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package com.comphenix.protocol.wrappers;
1818

1919
import java.lang.reflect.Constructor;
20+
import java.util.Locale;
2021

2122
import com.comphenix.protocol.reflect.EquivalentConverter;
2223
import com.comphenix.protocol.reflect.StructureModifier;
@@ -70,7 +71,7 @@ public static MinecraftKey fromHandle(Object handle) {
7071
* @return The resulting key
7172
*/
7273
public static MinecraftKey fromEnum(Enum<?> value) {
73-
return new MinecraftKey(value.name().toLowerCase().replace("_", "."));
74+
return new MinecraftKey(value.name().toLowerCase(Locale.ENGLISH).replace("_", "."));
7475
}
7576

7677
/**
@@ -104,7 +105,7 @@ public String getFullKey() {
104105
* @return The enum format
105106
*/
106107
public String getEnumFormat() {
107-
return key.toUpperCase().replace(".", "_");
108+
return key.toUpperCase(Locale.ENGLISH).replace(".", "_");
108109
}
109110

110111
private static Constructor<?> constructor = null;

modules/ProtocolLib/src/main/java/com/comphenix/protocol/PacketTypeParser.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import java.util.Deque;
55
import java.util.Iterator;
66
import java.util.List;
7+
import java.util.Locale;
78
import java.util.Set;
89

910
import com.comphenix.protocol.PacketType.Protocol;
@@ -53,7 +54,7 @@ public Set<PacketType> parseTypes(Deque<String> arguments, Range<Integer> defaul
5354
// And finally, parse packet names if we have a protocol
5455
if (protocol != null) {
5556
for (Iterator<String> it = arguments.iterator(); it.hasNext(); ) {
56-
String name = it.next().toUpperCase();
57+
String name = it.next().toUpperCase(Locale.ENGLISH);
5758
Collection<PacketType> names = PacketType.fromName(name);
5859

5960
for (PacketType type : names) {

0 commit comments

Comments
 (0)