mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-10-19 23:37:45 +00:00
Refactored effects handling, split up concerns of effect types and instances
Removed json insanity for effects Split up effect types and effect instances Saturation is an instant effect
This commit is contained in:
@@ -26,6 +26,7 @@ namespace pocketmine\command\defaults;
|
||||
use pocketmine\command\CommandSender;
|
||||
use pocketmine\command\utils\InvalidCommandSyntaxException;
|
||||
use pocketmine\entity\Effect;
|
||||
use pocketmine\entity\EffectInstance;
|
||||
use pocketmine\lang\TranslationContainer;
|
||||
use pocketmine\utils\TextFormat;
|
||||
|
||||
@@ -81,7 +82,7 @@ class EffectCommand extends VanillaCommand{
|
||||
if(count($args) >= 3){
|
||||
$duration = ((int) $args[2]) * 20; //ticks
|
||||
}else{
|
||||
$duration = $effect->getDefaultDuration();
|
||||
$duration = null;
|
||||
}
|
||||
|
||||
if(count($args) >= 4){
|
||||
@@ -95,10 +96,11 @@ class EffectCommand extends VanillaCommand{
|
||||
}
|
||||
}
|
||||
|
||||
$visible = true;
|
||||
if(count($args) >= 5){
|
||||
$v = strtolower($args[4]);
|
||||
if($v === "on" or $v === "true" or $v === "t" or $v === "1"){
|
||||
$effect->setVisible(false);
|
||||
$visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,10 +117,9 @@ class EffectCommand extends VanillaCommand{
|
||||
$player->removeEffect($effect->getId());
|
||||
$sender->sendMessage(new TranslationContainer("commands.effect.success.removed", [$effect->getName(), $player->getDisplayName()]));
|
||||
}else{
|
||||
$effect->setDuration($duration)->setAmplifier($amplification);
|
||||
|
||||
$player->addEffect($effect);
|
||||
self::broadcastCommandMessage($sender, new TranslationContainer("%commands.effect.success", [$effect->getName(), $effect->getAmplifier(), $player->getDisplayName(), $effect->getDuration() / 20, $effect->getId()]));
|
||||
$instance = new EffectInstance($effect, $duration, $amplification, $visible);
|
||||
$player->addEffect($instance);
|
||||
self::broadcastCommandMessage($sender, new TranslationContainer("%commands.effect.success", [$effect->getName(), $instance->getAmplifier(), $player->getDisplayName(), $instance->getDuration() / 20, $effect->getId()]));
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user