mirror of
https://github.com/Xiao-MoMi/Custom-Crops.git
synced 2025-12-19 23:19:19 +00:00
Added regex support
This commit is contained in:
@@ -23,7 +23,6 @@ cloud_bukkit_version=2.0.0-beta.10
|
|||||||
cloud_paper_version=2.0.0-beta.10
|
cloud_paper_version=2.0.0-beta.10
|
||||||
cloud_minecraft_extras_version=2.0.0-beta.10
|
cloud_minecraft_extras_version=2.0.0-beta.10
|
||||||
boosted_yaml_version=1.3.7
|
boosted_yaml_version=1.3.7
|
||||||
byte_buddy_version=1.15.3
|
|
||||||
mojang_brigadier_version=1.0.18
|
mojang_brigadier_version=1.0.18
|
||||||
bstats_version=3.0.2
|
bstats_version=3.0.2
|
||||||
geantyref_version=1.3.16
|
geantyref_version=1.3.16
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ public class PlayerRequirementManager extends AbstractRequirementManager<Player>
|
|||||||
private void registerItemInHandRequirement() {
|
private void registerItemInHandRequirement() {
|
||||||
registerRequirement((args, actions, runActions) -> {
|
registerRequirement((args, actions, runActions) -> {
|
||||||
if (args instanceof Section section) {
|
if (args instanceof Section section) {
|
||||||
|
boolean regex = section.getBoolean("regex", false);
|
||||||
String hand = section.getString("hand","main");
|
String hand = section.getString("hand","main");
|
||||||
int mode;
|
int mode;
|
||||||
if (hand.equalsIgnoreCase("main")) {
|
if (hand.equalsIgnoreCase("main")) {
|
||||||
@@ -94,7 +95,15 @@ public class PlayerRequirementManager extends AbstractRequirementManager<Player>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
String id = plugin.getItemManager().id(itemStack);
|
String id = plugin.getItemManager().id(itemStack);
|
||||||
|
if (!regex) {
|
||||||
if (items.contains(id) && itemStack.getAmount() >= amount) return true;
|
if (items.contains(id) && itemStack.getAmount() >= amount) return true;
|
||||||
|
} else {
|
||||||
|
for (String itemRegex : items) {
|
||||||
|
if (id.matches(itemRegex) && itemStack.getAmount() >= amount) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (runActions) ActionManager.trigger(context, actions);
|
if (runActions) ActionManager.trigger(context, actions);
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
@@ -105,6 +114,7 @@ public class PlayerRequirementManager extends AbstractRequirementManager<Player>
|
|||||||
}, "item-in-hand");
|
}, "item-in-hand");
|
||||||
registerRequirement((args, actions, runActions) -> {
|
registerRequirement((args, actions, runActions) -> {
|
||||||
if (args instanceof Section section) {
|
if (args instanceof Section section) {
|
||||||
|
boolean regex = section.getBoolean("regex", false);
|
||||||
String hand = section.getString("hand","main");
|
String hand = section.getString("hand","main");
|
||||||
int mode;
|
int mode;
|
||||||
if (hand.equalsIgnoreCase("main")) {
|
if (hand.equalsIgnoreCase("main")) {
|
||||||
@@ -135,7 +145,15 @@ public class PlayerRequirementManager extends AbstractRequirementManager<Player>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
String id = itemStack.getType().name();
|
String id = itemStack.getType().name();
|
||||||
|
if (!regex) {
|
||||||
if (items.contains(id) && itemStack.getAmount() >= amount) return true;
|
if (items.contains(id) && itemStack.getAmount() >= amount) return true;
|
||||||
|
} else {
|
||||||
|
for (String itemRegex : items) {
|
||||||
|
if (id.matches(itemRegex) && itemStack.getAmount() >= amount) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (runActions) ActionManager.trigger(context, actions);
|
if (runActions) ActionManager.trigger(context, actions);
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user