Fixes some bugs
All checks were successful
EpicKnarvik97/Blacksmith/pipeline/head This commit looks good
All checks were successful
EpicKnarvik97/Blacksmith/pipeline/head This commit looks good
Fixes some config commands not being registered Bumps KnarLib version to include bug-fix Fixes and improves tab-completion for enchantment block-list
This commit is contained in:
@ -36,25 +36,11 @@ public final class TabCompleteValuesHelper {
|
||||
case PERCENTAGE -> getPercentages();
|
||||
case REFORGE_ABLE_ITEMS -> getReforgeAbleMaterials();
|
||||
case MATERIAL -> getAllReforgeAbleMaterialNames();
|
||||
case ENCHANTMENT -> getAllEnchantments();
|
||||
case STRING_LIST -> getExampleEnchantmentBlockLists();
|
||||
case ENCHANTMENT, ENCHANTMENT_LIST -> getAllEnchantments();
|
||||
case STRING_LIST -> List.of("*_SHOVEL,*_PICKAXE,*_AXE,*_HOE,*_SWORD:STICK,SMITHING_TABLE:*_PLANKS");
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets example enchantment block lists
|
||||
*
|
||||
* @return <p>Some example enchantment block lists</p>
|
||||
*/
|
||||
private static @NotNull List<String> getExampleEnchantmentBlockLists() {
|
||||
List<String> exampleBlockLists = new ArrayList<>();
|
||||
exampleBlockLists.add(Enchantment.VANISHING_CURSE.getKey().getKey() + "," +
|
||||
Enchantment.BINDING_CURSE.getKey().getKey() + "," + Enchantment.MENDING.getKey().getKey());
|
||||
exampleBlockLists.add(Enchantment.VANISHING_CURSE.getKey().getKey() + "," +
|
||||
Enchantment.BINDING_CURSE.getKey().getKey());
|
||||
return exampleBlockLists;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets a complete list of all reforge-able material names
|
||||
|
@ -37,9 +37,10 @@ public final class TypeValidationHelper {
|
||||
case POSITIVE_INTEGER -> isPositiveInteger(value, sender);
|
||||
case PERCENTAGE -> isPercentage(value, sender);
|
||||
case BOOLEAN -> true;
|
||||
case STRING_LIST, REFORGE_ABLE_ITEMS -> isStringList(value, sender);
|
||||
case REFORGE_ABLE_ITEMS, STRING_LIST -> isStringList(value, sender);
|
||||
case MATERIAL -> isMaterial(value, sender);
|
||||
case ENCHANTMENT -> isEnchantment(value, sender);
|
||||
case ENCHANTMENT_LIST -> isEnchantmentList(value, sender);
|
||||
};
|
||||
} catch (ClassCastException exception) {
|
||||
//This error signifies that an object is not a string, and of the wrong class
|
||||
@ -64,6 +65,34 @@ public final class TypeValidationHelper {
|
||||
return isMaterial;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the given value is a list of enchantments
|
||||
*
|
||||
* @param value <p>The value to check</p>
|
||||
* @param sender <p>The command sender to use for printing error messages</p>
|
||||
* @return <p>True if the value is an enchantment list</p>
|
||||
*/
|
||||
private static boolean isEnchantmentList(@Nullable Object value, @Nullable CommandSender sender) {
|
||||
// Check whether a string list is given
|
||||
if (!isStringList(value, sender)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Make sure the input can be converted to a string list
|
||||
List<String> strings = ConfigHelper.asStringList(value);
|
||||
if (strings == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Make sure each value is an enchantment
|
||||
for (String string : strings) {
|
||||
if (!isEnchantment(string, sender)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the given value is an enchantment
|
||||
*
|
||||
|
Reference in New Issue
Block a user