mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-08-22 19:31:38 +00:00
This introduces static getters for every currently-known effect type. At some point in the near future, the magic number constants (which are really network IDs, by the way) will disappear. Migrating: - If you used constants (like any sensible person would): for the most part it's just a case of adding a () anywhere you used an Effect constant. - If you hardcoded magic numbers: ... well, have fun fixing your code, and I reserve the right to say "I told you so" :) This achieves multiple goals: 1) creating an EffectInstance for application is much less verbose (see diff for examples, especially the Potion class) 2) plugin devs cannot use magic numbers to apply effects anymore and are forced to use type-safe objects. :) This is a warning shot for plugin devs who use magic numbers. More changes like this are coming in the not-too-distant future.
44 lines
1.3 KiB
PHP
44 lines
1.3 KiB
PHP
<?php
|
|
|
|
/*
|
|
*
|
|
* ____ _ _ __ __ _ __ __ ____
|
|
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
|
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
|
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU Lesser General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* @author PocketMine Team
|
|
* @link http://www.pocketmine.net/
|
|
*
|
|
*
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace pocketmine\item;
|
|
|
|
use pocketmine\entity\effect\Effect;
|
|
use pocketmine\entity\effect\EffectInstance;
|
|
|
|
class GoldenAppleEnchanted extends GoldenApple{
|
|
|
|
public function __construct(){
|
|
Food::__construct(self::ENCHANTED_GOLDEN_APPLE, 0, "Enchanted Golden Apple"); //skip parent constructor
|
|
}
|
|
|
|
public function getAdditionalEffects() : array{
|
|
return [
|
|
new EffectInstance(Effect::REGENERATION(), 600, 4),
|
|
new EffectInstance(Effect::ABSORPTION(), 2400, 3),
|
|
new EffectInstance(Effect::RESISTANCE(), 6000),
|
|
new EffectInstance(Effect::FIRE_RESISTANCE(), 6000)
|
|
];
|
|
}
|
|
}
|