mirror of
https://github.com/Xiao-MoMi/Custom-Fishing.git
synced 2025-12-27 10:59:13 +00:00
in-list
This commit is contained in:
@@ -215,6 +215,7 @@ public class RequirementManagerImpl implements RequirementManager {
|
||||
this.registerSizeRequirement();
|
||||
this.registerHasStatsRequirement();
|
||||
this.registerLootTypeRequirement();
|
||||
this.registerInListRequirement();
|
||||
}
|
||||
|
||||
public HashMap<String, Double> getLootWithWeight(Condition condition) {
|
||||
@@ -937,6 +938,39 @@ public class RequirementManagerImpl implements RequirementManager {
|
||||
});
|
||||
}
|
||||
|
||||
private void registerInListRequirement() {
|
||||
registerRequirement("in-list", (args, actions, advanced) -> {
|
||||
if (args instanceof ConfigurationSection section) {
|
||||
String papi = section.getString("papi", "");
|
||||
List<String> values = ConfigUtils.stringListArgs(section.get("values"));
|
||||
return condition -> {
|
||||
String p1 = papi.startsWith("%") ? ParseUtils.setPlaceholders(condition.getPlayer(), papi) : papi;
|
||||
if (values.contains(p1)) return true;
|
||||
if (advanced) triggerActions(actions, condition);
|
||||
return false;
|
||||
};
|
||||
} else {
|
||||
LogUtils.warn("Wrong value format found at in-list requirement.");
|
||||
return EmptyRequirement.instance;
|
||||
}
|
||||
});
|
||||
registerRequirement("!in-list", (args, actions, advanced) -> {
|
||||
if (args instanceof ConfigurationSection section) {
|
||||
String papi = section.getString("papi", "");
|
||||
List<String> values = ConfigUtils.stringListArgs(section.get("values"));
|
||||
return condition -> {
|
||||
String p1 = papi.startsWith("%") ? ParseUtils.setPlaceholders(condition.getPlayer(), papi) : papi;
|
||||
if (!values.contains(p1)) return true;
|
||||
if (advanced) triggerActions(actions, condition);
|
||||
return false;
|
||||
};
|
||||
} else {
|
||||
LogUtils.warn("Wrong value format found at in-list requirement.");
|
||||
return EmptyRequirement.instance;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void registerEqualsRequirement() {
|
||||
registerRequirement("equals", (args, actions, advanced) -> {
|
||||
if (args instanceof ConfigurationSection section) {
|
||||
|
||||
Reference in New Issue
Block a user