1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-20 03:35:51 +00:00

fix: Unable to limit enchantment level

optimize: set default and max level to Short.MAX_VALUE
This commit is contained in:
StarWishsama 2021-02-02 12:49:02 +08:00
parent ffb063e2d8
commit f308c60bd1
2 changed files with 4 additions and 4 deletions

View File

@ -39,7 +39,7 @@ import java.util.Map;
*/ */
public class AutoDisenchanter extends AContainer { public class AutoDisenchanter extends AContainer {
private final IntRangeSetting enchantLevelLimit = new IntRangeSetting("enchant-level-limit", 0, 5, 12); private final IntRangeSetting enchantLevelLimit = new IntRangeSetting("enchant-level-limit", 0, Short.MAX_VALUE, Short.MAX_VALUE);
@ParametersAreNonnullByDefault @ParametersAreNonnullByDefault
public AutoDisenchanter(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { public AutoDisenchanter(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
@ -78,7 +78,7 @@ public class AutoDisenchanter extends AContainer {
int amount = 0; int amount = 0;
for (Map.Entry<Enchantment, Integer> entry : item.getEnchantments().entrySet()) { for (Map.Entry<Enchantment, Integer> entry : item.getEnchantments().entrySet()) {
if (enchantLevelLimit.validateInput(entry.getValue())) { if (enchantLevelLimit.getValue() >= entry.getValue()) {
enchantments.put(entry.getKey(), entry.getValue()); enchantments.put(entry.getKey(), entry.getValue());
amount++; amount++;
} else if (!menu.toInventory().getViewers().isEmpty()) { } else if (!menu.toInventory().getViewers().isEmpty()) {

View File

@ -22,7 +22,7 @@ import java.util.Map;
public class AutoEnchanter extends AContainer { public class AutoEnchanter extends AContainer {
private final IntRangeSetting enchantLevelLimit = new IntRangeSetting("enchant-level-limit", 0, 5, 12); private final IntRangeSetting enchantLevelLimit = new IntRangeSetting("enchant-level-limit", 0, Short.MAX_VALUE, Short.MAX_VALUE);
@ParametersAreNonnullByDefault @ParametersAreNonnullByDefault
public AutoEnchanter(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { public AutoEnchanter(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
@ -55,7 +55,7 @@ public class AutoEnchanter extends AContainer {
for (Map.Entry<Enchantment, Integer> e : meta.getStoredEnchants().entrySet()) { for (Map.Entry<Enchantment, Integer> e : meta.getStoredEnchants().entrySet()) {
if (e.getKey().canEnchantItem(target)) { if (e.getKey().canEnchantItem(target)) {
if (enchantLevelLimit.validateInput(e.getValue())) { if (enchantLevelLimit.getValue() >= e.getValue()) {
amount++; amount++;
enchantments.put(e.getKey(), e.getValue()); enchantments.put(e.getKey(), e.getValue());
} else if (!menu.toInventory().getViewers().isEmpty()) { } else if (!menu.toInventory().getViewers().isEmpty()) {