mirror of
https://github.com/Xiao-MoMi/Custom-Crops.git
synced 2025-12-21 16:09:21 +00:00
added alias
This commit is contained in:
@@ -542,7 +542,7 @@ public abstract class AbstractRequirementManager<T> implements RequirementManage
|
|||||||
plugin.getPluginLogger().warn("Invalid value type: " + args.getClass().getSimpleName() + " found at == requirement which is expected be `Section`");
|
plugin.getPluginLogger().warn("Invalid value type: " + args.getClass().getSimpleName() + " found at == requirement which is expected be `Section`");
|
||||||
return Requirement.empty();
|
return Requirement.empty();
|
||||||
}
|
}
|
||||||
}, "==");
|
}, "==", "=");
|
||||||
registerRequirement((args, actions, runActions) -> {
|
registerRequirement((args, actions, runActions) -> {
|
||||||
if (args instanceof Section section) {
|
if (args instanceof Section section) {
|
||||||
MathValue<T> v1 = MathValue.auto(section.get("value1"));
|
MathValue<T> v1 = MathValue.auto(section.get("value1"));
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
before_install:
|
before_install:
|
||||||
- sdk install java 17.0.9-oracle
|
- sdk install java 17.0.11-oracle
|
||||||
- sdk install java 21.0.2-oracle
|
- sdk install java 21.0.3-oracle
|
||||||
- sdk use java 17.0.9-oracle
|
- sdk use java 17.0.11-oracle
|
||||||
@@ -103,6 +103,47 @@ public class PlayerRequirementManager extends AbstractRequirementManager<Player>
|
|||||||
return Requirement.empty();
|
return Requirement.empty();
|
||||||
}
|
}
|
||||||
}, "item-in-hand");
|
}, "item-in-hand");
|
||||||
|
registerRequirement((args, actions, runActions) -> {
|
||||||
|
if (args instanceof Section section) {
|
||||||
|
String hand = section.getString("hand","main");
|
||||||
|
int mode;
|
||||||
|
if (hand.equalsIgnoreCase("main")) {
|
||||||
|
mode = 1;
|
||||||
|
} else if (hand.equalsIgnoreCase("off")) {
|
||||||
|
mode = 2;
|
||||||
|
} else if (hand.equalsIgnoreCase("other")) {
|
||||||
|
mode = 3;
|
||||||
|
} else {
|
||||||
|
mode = 0;
|
||||||
|
plugin.getPluginLogger().warn("Invalid hand argument: " + hand + " which is expected to be main/off/other");
|
||||||
|
return Requirement.empty();
|
||||||
|
}
|
||||||
|
int amount = section.getInt("amount", 0);
|
||||||
|
List<String> items = ListUtils.toList(section.get("material"));
|
||||||
|
return context -> {
|
||||||
|
Player player = context.holder();
|
||||||
|
if (player == null) return true;
|
||||||
|
EquipmentSlot slot = context.arg(ContextKeys.SLOT);
|
||||||
|
ItemStack itemStack;
|
||||||
|
if (slot == null) {
|
||||||
|
itemStack = mode == 1 ? player.getInventory().getItemInMainHand() : player.getInventory().getItemInOffHand();
|
||||||
|
} else {
|
||||||
|
if (mode == 3) {
|
||||||
|
itemStack = player.getInventory().getItem(slot == EquipmentSlot.HAND ? EquipmentSlot.OFF_HAND : EquipmentSlot.HAND);
|
||||||
|
} else {
|
||||||
|
itemStack = player.getInventory().getItem(slot);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String id = itemStack.getType().name();
|
||||||
|
if (items.contains(id) && itemStack.getAmount() >= amount) return true;
|
||||||
|
if (runActions) ActionManager.trigger(context, actions);
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
plugin.getPluginLogger().warn("Invalid value type: " + args.getClass().getSimpleName() + " found at material-in-hand requirement which is expected be `Section`");
|
||||||
|
return Requirement.empty();
|
||||||
|
}
|
||||||
|
}, "material-in-hand");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerPluginLevelRequirement() {
|
private void registerPluginLevelRequirement() {
|
||||||
|
|||||||
Reference in New Issue
Block a user