A lot of tests, and some improvements
All checks were successful
EpicKnarvik97/Blacksmith/pipeline/head This commit looks good
All checks were successful
EpicKnarvik97/Blacksmith/pipeline/head This commit looks good
Adds a lot more tests for some utility classes Adds a new option to disable the hard-coded limitation "EnchantmentTarget.BREAKABLE" which can be useful for servers with custom items or similar. Makes enchantment name matching case-insensitive. Prevents an exception is enchantment name contains invalid characters. Makes invalid objects supplied to asStringList return null instead of throwing an exception. Uses isBlank instead of trim.isEmpty in the isEmpty method Re-uses the random generator if calculating salvage several times
This commit is contained in:
@ -21,7 +21,7 @@ public final class InputParsingHelper {
|
||||
*/
|
||||
public static boolean isEmpty(String input) {
|
||||
return input == null || input.equalsIgnoreCase("null") || input.equals("\"\"") ||
|
||||
input.trim().isEmpty() || input.equals("-1");
|
||||
input.isBlank() || input.equals("-1");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -41,7 +41,13 @@ public final class InputParsingHelper {
|
||||
* @return <p>The enchantment matching the string, or null if not found</p>
|
||||
*/
|
||||
public static Enchantment matchEnchantment(String input) {
|
||||
return Enchantment.getByKey(NamespacedKey.minecraft(input.replace("-", "_")));
|
||||
try {
|
||||
return Enchantment.getByKey(NamespacedKey.minecraft(
|
||||
input.replace("-", "_").replace(" ", "_").toLowerCase()));
|
||||
} catch (IllegalArgumentException exception) {
|
||||
//Invalid characters, such as : will normally throw an illegal argument exception
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user