All Downloads are FREE. Search and download functionalities are using the official Maven repository.

scripts.conditions.health.js Maven / Gradle / Ivy

There is a newer version: 1.6.7-beta-6
Show newest version
//@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