9
0
mirror of https://github.com/Xiao-MoMi/Custom-Crops.git synced 2025-12-27 02:49:11 +00:00
This commit is contained in:
XiaoMoMi
2024-04-13 17:06:21 +08:00
parent 6d5a379ceb
commit c7c6004300
9 changed files with 125 additions and 6 deletions

View File

@@ -586,6 +586,22 @@ public class RequirementManagerImpl implements RequirementManager {
}
private void registerNumberEqualRequirement() {
registerRequirement("=", (args, actions, advanced) -> {
if (args instanceof ConfigurationSection section) {
String v1 = section.getString("value1", "");
String v2 = section.getString("value2", "");
return state -> {
String p1 = v1.startsWith("%") ? ParseUtils.setPlaceholders(state.getPlayer(), v1) : v1;
String p2 = v2.startsWith("%") ? ParseUtils.setPlaceholders(state.getPlayer(), v2) : v2;
if (Double.parseDouble(p1) == Double.parseDouble(p2)) return true;
if (advanced) triggerActions(actions, state);
return false;
};
} else {
LogUtils.warn("Wrong value format found at = requirement.");
return EmptyRequirement.instance;
}
});
registerRequirement("==", (args, actions, advanced) -> {
if (args instanceof ConfigurationSection section) {
String v1 = section.getString("value1", "");
@@ -598,7 +614,7 @@ public class RequirementManagerImpl implements RequirementManager {
return false;
};
} else {
LogUtils.warn("Wrong value format found at !startsWith requirement.");
LogUtils.warn("Wrong value format found at == requirement.");
return EmptyRequirement.instance;
}
});
@@ -614,7 +630,7 @@ public class RequirementManagerImpl implements RequirementManager {
return false;
};
} else {
LogUtils.warn("Wrong value format found at !startsWith requirement.");
LogUtils.warn("Wrong value format found at != requirement.");
return EmptyRequirement.instance;
}
});
@@ -857,7 +873,7 @@ public class RequirementManagerImpl implements RequirementManager {
return false;
};
} else {
LogUtils.warn("Wrong value format found at in-list requirement.");
LogUtils.warn("Wrong value format found at !in-list requirement.");
return EmptyRequirement.instance;
}
});
@@ -946,7 +962,7 @@ public class RequirementManagerImpl implements RequirementManager {
private void registerPotionEffectRequirement() {
registerRequirement("potion-effect", (args, actions, advanced) -> {
String potions = (String) args;
String[] split = potions.split("(<=|>=|<|>|==)", 2);
String[] split = potions.split("(<=|>=|<|>|==|=)", 2);
PotionEffectType type = PotionEffectType.getByName(split[0]);
if (type == null) {
LogUtils.warn("Potion effect doesn't exist: " + split[0]);
@@ -969,7 +985,7 @@ public class RequirementManagerImpl implements RequirementManager {
case ">" -> {
if (level > required) result = true;
}
case "==" -> {
case "==", "=" -> {
if (level == required) result = true;
}
case "!=" -> {