Specify Locale with String.toLowerCase()

This commit is contained in:
filoghost 2021-08-20 18:33:56 +02:00
parent 41fb1bc347
commit b3d8aae193
4 changed files with 8 additions and 4 deletions

View File

@ -13,6 +13,7 @@ import org.jetbrains.annotations.NotNull;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
public abstract class HologramSubCommand implements SubCommand {
@ -29,7 +30,7 @@ public abstract class HologramSubCommand implements SubCommand {
protected HologramSubCommand(String name, String... aliases) {
this.name = name;
this.aliases = aliases != null ? Arrays.asList(aliases) : Collections.emptyList();
this.permission = Permissions.COMMAND_BASE + name.toLowerCase();
this.permission = Permissions.COMMAND_BASE + name.toLowerCase(Locale.ROOT);
this.showInHelpCommand = true;
}

View File

@ -105,7 +105,7 @@ public class InternalHologramEditor {
}
private static boolean isConfigFile(Path file) {
return Files.isRegularFile(file) && file.getFileName().toString().toLowerCase().endsWith(".yml");
return Files.isRegularFile(file) && FileUtils.hasFileExtension(file, "yml");
}
}

View File

@ -17,6 +17,8 @@ import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import java.util.Locale;
public class HologramLineParser {
private static final String ICON_PREFIX = "icon:";
@ -24,7 +26,7 @@ public class HologramLineParser {
public static InternalHologramLine parseLine(InternalHologram hologram, String serializedLine) throws HologramLoadException {
InternalHologramLine hologramLine;
if (serializedLine.toLowerCase().startsWith(ICON_PREFIX)) {
if (serializedLine.toLowerCase(Locale.ROOT).startsWith(ICON_PREFIX)) {
String serializedIcon = serializedLine.substring(ICON_PREFIX.length());
ItemStack icon = parseItemStack(serializedIcon);
hologramLine = hologram.createItemLine(icon, serializedLine);

View File

@ -15,6 +15,7 @@ import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import java.util.Locale;
import java.util.stream.Stream;
public class AnimationsLegacyUpgrade extends LegacyUpgrade {
@ -60,7 +61,7 @@ public class AnimationsLegacyUpgrade extends LegacyUpgrade {
// Remove the first line that only contains the speed
String firstLine = lines.remove(0).trim();
if (!firstLine.toLowerCase().startsWith(SPEED_PREFIX)) {
if (!firstLine.toLowerCase(Locale.ROOT).startsWith(SPEED_PREFIX)) {
return; // Not a valid animation
}