Skip to content

Commit

Permalink
Fixed changing default lang to English (#1054)
Browse files Browse the repository at this point in the history
  • Loading branch information
OmerBenGera committed Apr 16, 2022
1 parent a907b40 commit 2cb142c
Show file tree
Hide file tree
Showing 69 changed files with 296 additions and 246 deletions.
@@ -1,6 +1,7 @@
package com.bgsoftware.superiorskyblock.api.enums;

import java.util.Arrays;
import java.util.Locale;

/**
* Used to determine what rating has a player given to an island.
Expand All @@ -20,8 +21,8 @@ public enum Rating {
*/
public static String getValuesString() {
StringBuilder stringBuilder = new StringBuilder();
Arrays.stream(values()).forEach(rating -> stringBuilder.append(", ").append(rating.toString().toLowerCase()));
return stringBuilder.toString().substring(2);
Arrays.stream(values()).forEach(rating -> stringBuilder.append(", ").append(rating.toString().toLowerCase(Locale.ENGLISH)));
return stringBuilder.substring(2);
}

/**
Expand Down
Expand Up @@ -4,6 +4,7 @@

import java.util.Collection;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;

public final class IslandFlag {
Expand All @@ -13,7 +14,7 @@ public final class IslandFlag {
private final String name;

private IslandFlag(String name) {
this.name = name.toUpperCase();
this.name = name.toUpperCase(Locale.ENGLISH);
}

/**
Expand All @@ -31,7 +32,7 @@ public static Collection<IslandFlag> values() {
public static IslandFlag getByName(String name) {
Preconditions.checkNotNull(name, "name parameter cannot be null.");

IslandFlag islandFlag = islandFlags.get(name.toUpperCase());
IslandFlag islandFlag = islandFlags.get(name.toUpperCase(Locale.ENGLISH));

Preconditions.checkNotNull(islandFlag, "Couldn't find an IslandFlag with the name " + name + ".");

Expand All @@ -46,7 +47,7 @@ public static IslandFlag getByName(String name) {
public static void register(String name) {
Preconditions.checkNotNull(name, "name parameter cannot be null.");

name = name.toUpperCase();
name = name.toUpperCase(Locale.ENGLISH);

Preconditions.checkState(!islandFlags.containsKey(name), "IslandFlag with the name " + name + " already exists.");

Expand Down
Expand Up @@ -4,6 +4,7 @@

import java.util.Collection;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;

public final class IslandPrivilege {
Expand All @@ -13,7 +14,7 @@ public final class IslandPrivilege {
private final String name;

private IslandPrivilege(String name) {
this.name = name.toUpperCase();
this.name = name.toUpperCase(Locale.ENGLISH);
}

/**
Expand All @@ -31,7 +32,7 @@ public static Collection<IslandPrivilege> values() {
public static IslandPrivilege getByName(String name) {
Preconditions.checkNotNull(name, "name parameter cannot be null.");

IslandPrivilege islandPrivilege = islandPrivileges.get(name.toUpperCase());
IslandPrivilege islandPrivilege = islandPrivileges.get(name.toUpperCase(Locale.ENGLISH));

Preconditions.checkNotNull(islandPrivilege, "Couldn't find an IslandPrivilege with the name " + name + ".");

Expand All @@ -46,7 +47,7 @@ public static IslandPrivilege getByName(String name) {
public static void register(String name) {
Preconditions.checkNotNull(name, "name parameter cannot be null.");

name = name.toUpperCase();
name = name.toUpperCase(Locale.ENGLISH);

Preconditions.checkState(!islandPrivileges.containsKey(name), "IslandPrivilege with the name " + name + " already exists.");

Expand Down
Expand Up @@ -16,6 +16,8 @@
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;

import java.util.Locale;

public final class SpawnersProvider_AdvancedSpawners implements SpawnersProvider_AutoDetect {

private static boolean registered = false;
Expand All @@ -32,13 +34,13 @@ public SpawnersProvider_AdvancedSpawners() {
public Pair<Integer, String> getSpawner(Location location) {
Preconditions.checkNotNull(location, "location parameter cannot be null.");
return !Bukkit.isPrimaryThread() ? new Pair<>(-1, null) :
new Pair<>(ASAPI.getSpawnerAmount(location), ASAPI.getSpawnerType(location).toUpperCase());
new Pair<>(ASAPI.getSpawnerAmount(location), ASAPI.getSpawnerType(location).toUpperCase(Locale.ENGLISH));
}

@Override
public String getSpawnerType(ItemStack itemStack) {
Preconditions.checkNotNull(itemStack, "itemStack parameter cannot be null.");
return ASAPI.getSpawnerType(itemStack).toUpperCase();
return ASAPI.getSpawnerType(itemStack).toUpperCase(Locale.ENGLISH);
}

@SuppressWarnings("unused")
Expand All @@ -53,14 +55,18 @@ public void onSpawnerStack(AdvancedSpawnerPlaceEvent e) {
Island island = plugin.getGrid().getIslandAt(location);

if (island != null)
island.handleBlockPlace(KeyImpl.of(Materials.SPAWNER.toBukkitType() + "", e.getEntityType().toUpperCase()), e.getCountPlaced());
island.handleBlockPlace(
KeyImpl.of(Materials.SPAWNER.toBukkitType() + "", e.getEntityType()),
e.getCountPlaced());
}

@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onSpawnerUnstack(AdvancedSpawnersBreakEvent e) {
Island island = plugin.getGrid().getIslandAt(e.getSpawner().getLocation());
if (island != null)
island.handleBlockBreak(KeyImpl.of(Materials.SPAWNER.toBukkitType() + "", e.getEntityType().toUpperCase()), e.getCountBroken());
island.handleBlockBreak(
KeyImpl.of(Materials.SPAWNER.toBukkitType() + "", e.getEntityType()),
e.getCountBroken());
}

}
Expand Down
Expand Up @@ -8,6 +8,8 @@
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;

import java.util.Locale;

@SuppressWarnings("unused")
public final class PermissionsProvider_LuckPerms implements PermissionsProvider {

Expand All @@ -30,7 +32,7 @@ public static boolean isCompatible() {
public boolean hasPermission(Player player, String permission) {
User user = luckPerms.getUserManager().getUser(player.getUniqueId());
return user != null && user.getCachedData().getPermissionData().getPermissionMap()
.getOrDefault(permission.toLowerCase(), false);
.getOrDefault(permission.toLowerCase(Locale.ENGLISH), false);
}

}
Expand Up @@ -94,7 +94,6 @@
import javax.annotation.Nullable;
import java.io.File;
import java.lang.reflect.Constructor;
import java.util.Locale;
import java.util.Optional;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
Expand Down Expand Up @@ -171,10 +170,6 @@ public static SuperiorSkyblockPlugin getPlugin() {
public void onLoad() {
plugin = this;

// Setting the default locale to English will fix issues related to using upper case in Turkish.
// https://stackoverflow.com/questions/11063102/using-locales-with-javas-tolowercase-and-touppercase
Locale.setDefault(Locale.ENGLISH);

new Metrics(this);

initCustomFilter();
Expand Down

0 comments on commit 2cb142c

Please sign in to comment.