mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 00:07:30 +00:00
Effect: stop using hardcoded translation keys for names
This commit is contained in:
parent
8e58beef7f
commit
665f2473e1
@ -26,19 +26,20 @@ namespace pocketmine\entity\effect;
|
||||
use pocketmine\color\Color;
|
||||
use pocketmine\entity\Entity;
|
||||
use pocketmine\entity\Living;
|
||||
use pocketmine\lang\Translatable;
|
||||
|
||||
class Effect{
|
||||
|
||||
/**
|
||||
* @param int $internalRuntimeId Internal runtime ID, unique to this effect type. Used for comparisons.
|
||||
* @param string $name Translation key used for effect name
|
||||
* @param Color $color Color of bubbles given by this effect
|
||||
* @param bool $bad Whether the effect is harmful
|
||||
* @param bool $hasBubbles Whether the effect has potion bubbles. Some do not (e.g. Instant Damage has its own particles instead of bubbles)
|
||||
* @param int $internalRuntimeId Internal runtime ID, unique to this effect type. Used for comparisons.
|
||||
* @param Translatable|string $name Translation key used for effect name
|
||||
* @param Color $color Color of bubbles given by this effect
|
||||
* @param bool $bad Whether the effect is harmful
|
||||
* @param bool $hasBubbles Whether the effect has potion bubbles. Some do not (e.g. Instant Damage has its own particles instead of bubbles)
|
||||
*/
|
||||
public function __construct(
|
||||
protected int $internalRuntimeId,
|
||||
protected string $name,
|
||||
protected Translatable|string $name,
|
||||
protected Color $color,
|
||||
protected bool $bad = false,
|
||||
protected bool $hasBubbles = true
|
||||
@ -55,7 +56,7 @@ class Effect{
|
||||
/**
|
||||
* Returns the translation key used to translate this effect's name.
|
||||
*/
|
||||
public function getName() : string{
|
||||
public function getName() : Translatable|string{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
|
@ -27,13 +27,14 @@ use pocketmine\color\Color;
|
||||
use pocketmine\entity\Entity;
|
||||
use pocketmine\entity\Living;
|
||||
use pocketmine\event\entity\EntityDamageEvent;
|
||||
use pocketmine\lang\Translatable;
|
||||
|
||||
class PoisonEffect extends Effect{
|
||||
|
||||
/** @var bool */
|
||||
private $fatal;
|
||||
|
||||
public function __construct(int $internalRuntimeId, string $name, Color $color, bool $isBad = false, bool $hasBubbles = true, bool $fatal = false){
|
||||
public function __construct(int $internalRuntimeId, Translatable $name, Color $color, bool $isBad = false, bool $hasBubbles = true, bool $fatal = false){
|
||||
parent::__construct($internalRuntimeId, $name, $color, $isBad, $hasBubbles);
|
||||
$this->fatal = $fatal;
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
namespace pocketmine\entity\effect;
|
||||
|
||||
use pocketmine\color\Color;
|
||||
use pocketmine\lang\KnownTranslationFactory;
|
||||
use pocketmine\utils\RegistryTrait;
|
||||
use function assert;
|
||||
|
||||
@ -64,35 +65,35 @@ final class VanillaEffects{
|
||||
use RegistryTrait;
|
||||
|
||||
protected static function setup() : void{
|
||||
self::register("absorption", new AbsorptionEffect(22, "%potion.absorption", new Color(0x25, 0x52, 0xa5)));
|
||||
self::register("absorption", new AbsorptionEffect(22, KnownTranslationFactory::potion_absorption(), new Color(0x25, 0x52, 0xa5)));
|
||||
//TODO: bad_omen
|
||||
self::register("blindness", new Effect(15, "%potion.blindness", new Color(0x1f, 0x1f, 0x23), true));
|
||||
self::register("conduit_power", new Effect(26, "%potion.conduitPower", new Color(0x1d, 0xc2, 0xd1)));
|
||||
self::register("fatal_poison", new PoisonEffect(25, "%potion.poison", new Color(0x4e, 0x93, 0x31), true, true, true));
|
||||
self::register("fire_resistance", new Effect(12, "%potion.fireResistance", new Color(0xe4, 0x9a, 0x3a)));
|
||||
self::register("haste", new Effect(3, "%potion.digSpeed", new Color(0xd9, 0xc0, 0x43)));
|
||||
self::register("health_boost", new HealthBoostEffect(21, "%potion.healthBoost", new Color(0xf8, 0x7d, 0x23)));
|
||||
self::register("hunger", new HungerEffect(17, "%potion.hunger", new Color(0x58, 0x76, 0x53), true));
|
||||
self::register("instant_damage", new InstantDamageEffect(7, "%potion.harm", new Color(0x43, 0x0a, 0x09), true, false));
|
||||
self::register("instant_health", new InstantHealthEffect(6, "%potion.heal", new Color(0xf8, 0x24, 0x23), false, false));
|
||||
self::register("invisibility", new InvisibilityEffect(14, "%potion.invisibility", new Color(0x7f, 0x83, 0x92)));
|
||||
self::register("jump_boost", new Effect(8, "%potion.jump", new Color(0x22, 0xff, 0x4c)));
|
||||
self::register("levitation", new LevitationEffect(24, "%potion.levitation", new Color(0xce, 0xff, 0xff)));
|
||||
self::register("mining_fatigue", new Effect(4, "%potion.digSlowDown", new Color(0x4a, 0x42, 0x17), true));
|
||||
self::register("nausea", new Effect(9, "%potion.confusion", new Color(0x55, 0x1d, 0x4a), true));
|
||||
self::register("night_vision", new Effect(16, "%potion.nightVision", new Color(0x1f, 0x1f, 0xa1)));
|
||||
self::register("poison", new PoisonEffect(19, "%potion.poison", new Color(0x4e, 0x93, 0x31), true));
|
||||
self::register("regeneration", new RegenerationEffect(10, "%potion.regeneration", new Color(0xcd, 0x5c, 0xab)));
|
||||
self::register("resistance", new Effect(11, "%potion.resistance", new Color(0x99, 0x45, 0x3a)));
|
||||
self::register("saturation", new SaturationEffect(23, "%potion.saturation", new Color(0xf8, 0x24, 0x23), false));
|
||||
self::register("blindness", new Effect(15, KnownTranslationFactory::potion_blindness(), new Color(0x1f, 0x1f, 0x23), true));
|
||||
self::register("conduit_power", new Effect(26, KnownTranslationFactory::potion_conduitPower(), new Color(0x1d, 0xc2, 0xd1)));
|
||||
self::register("fatal_poison", new PoisonEffect(25, KnownTranslationFactory::potion_poison(), new Color(0x4e, 0x93, 0x31), true, true, true));
|
||||
self::register("fire_resistance", new Effect(12, KnownTranslationFactory::potion_fireResistance(), new Color(0xe4, 0x9a, 0x3a)));
|
||||
self::register("haste", new Effect(3, KnownTranslationFactory::potion_digSpeed(), new Color(0xd9, 0xc0, 0x43)));
|
||||
self::register("health_boost", new HealthBoostEffect(21, KnownTranslationFactory::potion_healthBoost(), new Color(0xf8, 0x7d, 0x23)));
|
||||
self::register("hunger", new HungerEffect(17, KnownTranslationFactory::potion_hunger(), new Color(0x58, 0x76, 0x53), true));
|
||||
self::register("instant_damage", new InstantDamageEffect(7, KnownTranslationFactory::potion_harm(), new Color(0x43, 0x0a, 0x09), true, false));
|
||||
self::register("instant_health", new InstantHealthEffect(6, KnownTranslationFactory::potion_heal(), new Color(0xf8, 0x24, 0x23), false, false));
|
||||
self::register("invisibility", new InvisibilityEffect(14, KnownTranslationFactory::potion_invisibility(), new Color(0x7f, 0x83, 0x92)));
|
||||
self::register("jump_boost", new Effect(8, KnownTranslationFactory::potion_jump(), new Color(0x22, 0xff, 0x4c)));
|
||||
self::register("levitation", new LevitationEffect(24, KnownTranslationFactory::potion_levitation(), new Color(0xce, 0xff, 0xff)));
|
||||
self::register("mining_fatigue", new Effect(4, KnownTranslationFactory::potion_digSlowDown(), new Color(0x4a, 0x42, 0x17), true));
|
||||
self::register("nausea", new Effect(9, KnownTranslationFactory::potion_confusion(), new Color(0x55, 0x1d, 0x4a), true));
|
||||
self::register("night_vision", new Effect(16, KnownTranslationFactory::potion_nightVision(), new Color(0x1f, 0x1f, 0xa1)));
|
||||
self::register("poison", new PoisonEffect(19, KnownTranslationFactory::potion_poison(), new Color(0x4e, 0x93, 0x31), true));
|
||||
self::register("regeneration", new RegenerationEffect(10, KnownTranslationFactory::potion_regeneration(), new Color(0xcd, 0x5c, 0xab)));
|
||||
self::register("resistance", new Effect(11, KnownTranslationFactory::potion_resistance(), new Color(0x99, 0x45, 0x3a)));
|
||||
self::register("saturation", new SaturationEffect(23, KnownTranslationFactory::potion_saturation(), new Color(0xf8, 0x24, 0x23), false));
|
||||
//TODO: slow_falling
|
||||
self::register("slowness", new SlownessEffect(2, "%potion.moveSlowdown", new Color(0x5a, 0x6c, 0x81), true));
|
||||
self::register("speed", new SpeedEffect(1, "%potion.moveSpeed", new Color(0x7c, 0xaf, 0xc6)));
|
||||
self::register("strength", new Effect(5, "%potion.damageBoost", new Color(0x93, 0x24, 0x23)));
|
||||
self::register("slowness", new SlownessEffect(2, KnownTranslationFactory::potion_moveSlowdown(), new Color(0x5a, 0x6c, 0x81), true));
|
||||
self::register("speed", new SpeedEffect(1, KnownTranslationFactory::potion_moveSpeed(), new Color(0x7c, 0xaf, 0xc6)));
|
||||
self::register("strength", new Effect(5, KnownTranslationFactory::potion_damageBoost(), new Color(0x93, 0x24, 0x23)));
|
||||
//TODO: village_hero
|
||||
self::register("water_breathing", new Effect(13, "%potion.waterBreathing", new Color(0x2e, 0x52, 0x99)));
|
||||
self::register("weakness", new Effect(18, "%potion.weakness", new Color(0x48, 0x4d, 0x48), true));
|
||||
self::register("wither", new WitherEffect(20, "%potion.wither", new Color(0x35, 0x2a, 0x27), true));
|
||||
self::register("water_breathing", new Effect(13, KnownTranslationFactory::potion_waterBreathing(), new Color(0x2e, 0x52, 0x99)));
|
||||
self::register("weakness", new Effect(18, KnownTranslationFactory::potion_weakness(), new Color(0x48, 0x4d, 0x48), true));
|
||||
self::register("wither", new WitherEffect(20, KnownTranslationFactory::potion_wither(), new Color(0x35, 0x2a, 0x27), true));
|
||||
}
|
||||
|
||||
protected static function register(string $name, Effect $member) : void{
|
||||
|
Loading…
x
Reference in New Issue
Block a user