pocketmine\entity\Attribute::addAttribute PHP Method

addAttribute() public static method

public static addAttribute ( integer $id, string $name, float $minValue, float $maxValue, float $defaultValue, boolean $shouldSend = true ) : Attribute
$id integer
$name string
$minValue float
$maxValue float
$defaultValue float
$shouldSend boolean
return Attribute
    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);
    }

Usage Example

コード例 #1
0
 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);
 }
All Usage Examples Of pocketmine\entity\Attribute::addAttribute