public static function addAttribute($id, $name, $minValue, $maxValue, $defaultValue, $shouldSend = true)
{
if ($minValue > $maxValue or $defaultValue > $maxValue or $defaultValue < $minValue) {
throw new \InvalidArgumentException("Invalid ranges: min value: {$minValue}, max value: {$maxValue}, {$defaultValue}: {$defaultValue}");
}
return self::$attributes[(int) $id] = new Attribute($id, $name, $minValue, $maxValue, $defaultValue, $shouldSend);
}
public function __construct(Plugin $plugin) { $this->plugin = $plugin; $this->db = PluginData::getInstance(); $this->listenerloader = ListenerLoader::getInstance(); $this->server = Server::getInstance(); $this->attributeprovider = AttributeProvider::getInstance(); Attribute::addAttribute(3, "player.hunger", 0, 20, 20, true); $this->getServer()->getScheduler()->scheduleRepeatingTask(new HungerTask($this), 80); $this->getServer()->getPluginManager()->registerEvents($this, $plugin); }