mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-22 18:55:17 +01:00
Made toLowerCase / toUpperCase use an explicit Locale
This avoids issues on some OS's. Put in Commodore (but commented out). Just checking it out.
This commit is contained in:
parent
bcb44c4cce
commit
203998d000
40
pom.xml
40
pom.xml
@ -51,6 +51,10 @@
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>luck-repo</id>
|
||||
<url>https://repo.lucko.me/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
@ -83,6 +87,12 @@
|
||||
<artifactId>mongodb-driver</artifactId>
|
||||
<version>3.8.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.lucko</groupId>
|
||||
<artifactId>commodore</artifactId>
|
||||
<version>1.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
@ -99,6 +109,33 @@
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.1.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<artifactSet>
|
||||
<includes>
|
||||
<include>me.lucko:commodore</include>
|
||||
</includes>
|
||||
</artifactSet>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>me.lucko.commodore</pattern>
|
||||
<!-- vvv Replace with the package of your plugin vvv -->
|
||||
<shadedPattern>com.yourdomain.yourplugin.commodore</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-clean-plugin</artifactId>
|
||||
@ -184,7 +221,8 @@
|
||||
<configuration>
|
||||
<append>true</append>
|
||||
<excludes>
|
||||
<!-- This is required to prevent Jacoco from adding synthetic fields to a JavaBean class (causes errors in testing) -->
|
||||
<!-- This is required to prevent Jacoco from adding synthetic fields
|
||||
to a JavaBean class (causes errors in testing) -->
|
||||
<exclude>**/*Names*</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
|
@ -5,6 +5,8 @@ import org.bukkit.World;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import me.lucko.commodore.Commodore;
|
||||
import me.lucko.commodore.CommodoreProvider;
|
||||
import world.bentobox.bentobox.api.configuration.Config;
|
||||
import world.bentobox.bentobox.api.configuration.WorldSettings;
|
||||
import world.bentobox.bentobox.api.events.BentoBoxReadyEvent;
|
||||
@ -63,8 +65,18 @@ public class BentoBox extends JavaPlugin {
|
||||
|
||||
private boolean isLoaded;
|
||||
|
||||
private Commodore commodore;
|
||||
|
||||
@Override
|
||||
public void onEnable(){
|
||||
// check if brigadier is supported
|
||||
if (CommodoreProvider.isSupported()) {
|
||||
// get a commodore instance
|
||||
commodore = CommodoreProvider.getCommodore(this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Not loaded
|
||||
isLoaded = false;
|
||||
@ -145,6 +157,13 @@ public class BentoBox extends JavaPlugin {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the commodore
|
||||
*/
|
||||
public Commodore getCommodore() {
|
||||
return commodore;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register listeners
|
||||
*/
|
||||
|
@ -17,10 +17,16 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.command.PluginIdentifiableCommand;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import com.mojang.brigadier.arguments.BoolArgumentType;
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import com.mojang.brigadier.builder.RequiredArgumentBuilder;
|
||||
|
||||
import me.lucko.commodore.Commodore;
|
||||
import world.bentobox.bentobox.BentoBox;
|
||||
import world.bentobox.bentobox.Settings;
|
||||
import world.bentobox.bentobox.api.addons.Addon;
|
||||
@ -126,6 +132,8 @@ public abstract class CompositeCommand extends Command implements PluginIdentifi
|
||||
// Register command if it is not already registered
|
||||
if (plugin.getCommand(label) == null) {
|
||||
plugin.getCommandsManager().registerCommand(this);
|
||||
// register your completions.
|
||||
//registerCompletions(plugin.getCommodore(), this);
|
||||
}
|
||||
// Default references to description and parameters
|
||||
setDescription("commands." + label + ".description");
|
||||
@ -134,8 +142,19 @@ public abstract class CompositeCommand extends Command implements PluginIdentifi
|
||||
if (!getSubCommand("help").isPresent() && !label.equals("help")) {
|
||||
new DefaultHelpCommand(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* This will eventually need to replace the tabComplete method
|
||||
private static void registerCompletions(Commodore commodore, CompositeCommand command) {
|
||||
commodore.register(command, LiteralArgumentBuilder.literal(command.getLabel())
|
||||
.then(RequiredArgumentBuilder.argument("some-argument", com.mojang.brigadier.arguments.StringArgumentType.string()))
|
||||
.then(RequiredArgumentBuilder.argument("some-other-argument", BoolArgumentType.bool()))
|
||||
);
|
||||
}
|
||||
*/
|
||||
/**
|
||||
* This is the top-level command constructor for commands that have no parent.
|
||||
* @param label - string for this command
|
||||
@ -352,7 +371,7 @@ public abstract class CompositeCommand extends Command implements PluginIdentifi
|
||||
* @return CompositeCommand or null if none found
|
||||
*/
|
||||
public Optional<CompositeCommand> getSubCommand(String label) {
|
||||
label = label.toLowerCase();
|
||||
label = label.toLowerCase(java.util.Locale.ENGLISH);
|
||||
if (subCommands.containsKey(label)) {
|
||||
return Optional.ofNullable(subCommands.get(label));
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ public class FlatFileDatabaseHandler<T> extends AbstractDatabaseHandler<T> {
|
||||
@Override
|
||||
public List<T> loadObjects() throws InstantiationException, IllegalAccessException, InvocationTargetException, ClassNotFoundException, IntrospectionException {
|
||||
List<T> list = new ArrayList<>();
|
||||
FilenameFilter ymlFilter = (dir, name) -> name.toLowerCase().endsWith(".yml");
|
||||
FilenameFilter ymlFilter = (dir, name) -> name.toLowerCase(java.util.Locale.ENGLISH).endsWith(".yml");
|
||||
String path = dataObject.getSimpleName();
|
||||
StoreAt storeAt = dataObject.getAnnotation(StoreAt.class);
|
||||
if (storeAt != null) {
|
||||
|
@ -37,7 +37,7 @@ public class BannedVisitorCommands implements Listener {
|
||||
return;
|
||||
}
|
||||
// Check banned commands
|
||||
String[] args = e.getMessage().substring(1).toLowerCase().split(" ");
|
||||
String[] args = e.getMessage().substring(1).toLowerCase(java.util.Locale.ENGLISH).split(" ");
|
||||
if (plugin.getIWM().getVisitorBannedCommands(e.getPlayer().getWorld()).contains(args[0])) {
|
||||
User user = User.getInstance(e.getPlayer());
|
||||
user.notify("protection.protected", TextVariables.DESCRIPTION, user.getTranslation("protection.command-is-banned"));
|
||||
|
@ -15,8 +15,7 @@ public class CommandsManager {
|
||||
|
||||
public void registerCommand(CompositeCommand command) {
|
||||
commands.put(command.getLabel(), command);
|
||||
// Use reflection to obtain the commandMap method in Bukkit's server. It used to be visible, but isn't anymore.
|
||||
|
||||
// Use reflection to obtain the commandMap method in Bukkit's server.
|
||||
try{
|
||||
Field commandMapField = Bukkit.getServer().getClass().getDeclaredField("commandMap");
|
||||
commandMapField.setAccessible(true);
|
||||
|
@ -62,7 +62,7 @@ public class LocalesManager {
|
||||
public void loadLocales(String parent) {
|
||||
// Describe the filter - we only want files that are correctly named
|
||||
// Files must be 9 chars long
|
||||
FilenameFilter ymlFilter = (dir, name) -> name.toLowerCase().endsWith(".yml") && name.length() == 9;
|
||||
FilenameFilter ymlFilter = (dir, name) -> name.toLowerCase(java.util.Locale.ENGLISH).endsWith(".yml") && name.length() == 9;
|
||||
|
||||
// Run through the files and store the locales
|
||||
File localeDir = new File(plugin.getDataFolder(), LOCALE_FOLDER + File.separator + parent);
|
||||
|
@ -39,7 +39,7 @@ public class FileLister{
|
||||
// Check if the folder exists
|
||||
File localeDir = new File(plugin.getDataFolder(), folderPath);
|
||||
if (localeDir.exists()) {
|
||||
FilenameFilter ymlFilter = (File dir, String name) -> name.toLowerCase().endsWith(".yml");
|
||||
FilenameFilter ymlFilter = (File dir, String name) -> name.toLowerCase(java.util.Locale.ENGLISH).endsWith(".yml");
|
||||
return Arrays.asList(Objects.requireNonNull(localeDir.list(ymlFilter)));
|
||||
} else if (checkJar) {
|
||||
// Else look in the JAR
|
||||
|
@ -52,7 +52,7 @@ public class ItemParser {
|
||||
return null;
|
||||
}
|
||||
|
||||
Material reqItem = Material.getMaterial(part[0].toUpperCase());
|
||||
Material reqItem = Material.getMaterial(part[0].toUpperCase(java.util.Locale.ENGLISH));
|
||||
if (reqItem == null) {
|
||||
return null;
|
||||
}
|
||||
@ -100,7 +100,7 @@ public class ItemParser {
|
||||
result = new ItemStack(Material.TIPPED_ARROW);
|
||||
}
|
||||
PotionMeta potionMeta = (PotionMeta)(result.getItemMeta());
|
||||
PotionType type = PotionType.valueOf(part[1].toUpperCase());
|
||||
PotionType type = PotionType.valueOf(part[1].toUpperCase(java.util.Locale.ENGLISH));
|
||||
boolean isUpgraded = !part[2].isEmpty() && !part[2].equalsIgnoreCase("1");
|
||||
boolean isExtended = part[3].equalsIgnoreCase("EXTENDED");
|
||||
PotionData data = new PotionData(type, isExtended, isUpgraded);
|
||||
|
@ -119,7 +119,7 @@ public class Util {
|
||||
*/
|
||||
public static String prettifyText(String ugly) {
|
||||
StringBuilder fin = new StringBuilder();
|
||||
ugly = ugly.toLowerCase();
|
||||
ugly = ugly.toLowerCase(java.util.Locale.ENGLISH);
|
||||
if (ugly.contains("_")) {
|
||||
String[] splt = ugly.split("_");
|
||||
int i = 0;
|
||||
@ -164,7 +164,7 @@ public class Util {
|
||||
if (s == null) {
|
||||
continue;
|
||||
}
|
||||
if (s.toLowerCase().startsWith(start.toLowerCase())) {
|
||||
if (s.toLowerCase(java.util.Locale.ENGLISH).startsWith(start.toLowerCase(java.util.Locale.ENGLISH))) {
|
||||
returned.add(s);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user