scripts.conditions.health.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of Pouvoir Show documentation
Show all versions of Pouvoir Show documentation
Bukkit Script Engine Plugin.
//@Condition()
Coerce = static("Coerce");
key = "health";
names = ["生命值需要: (?\\d+)-(?\\d+)", "生命值需要: (?\\d+)"];
function parameters(matcher, text) {
const min = Coerce.toDouble(matcher.group("min"));
let max = min;
try {
max = Coerce.toDouble(matcher.group("max"));
} catch (ignored) {}
return mapOf({ min: min, max: max });
}
function condition(entity, map) {
if (entity == null) return true;
const min = Coerce.toDouble(map.get("min"));
let max = min;
try {
max = Coerce.toDouble(map.get("max"));
} catch (ignored) {}
return entity.health >= min && entity.health <= max;
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy