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

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

There is a newer version: 1.6.7-beta-6
Show newest version
//@Condition()

Coerce = static("Coerce");

Player = find("org.bukkit.entity.Player");
key = "weather";

names = ["需要天气: (?.*)", "需要不是天气: (?.*)"];

function parameters(matcher, text) {
  var weather = matcher.group("weather");
  if (weather.contains("晴")) {
    weather = "CLEAR";
  } else {
    weather = "DOWNFALL";
  }
  const isIn = !matcher.pattern().toString().contains("不");
  return mapOf({ weather: weather, status: isIn });
}

function condition(entity, map) {
  if (entity == null || !(entity instanceof Player)) return true;
  const weather = map.get("weather");
  const isIn = map.get("status");
  return (
    (isIn && entity.getPlayerWeather().name().equalsIgnoreCase(weather)) ||
    (!isIn && !entity.getPlayerWeather().name().equalsIgnoreCase(weather))
  );
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy