60 $sender->sendMessage(
new TranslationContainer(
"commands.generic.usage", [$this->usageMessage]));
64 $player = $sender->getServer()->getPlayer($args[0]);
67 $sender->sendMessage(
new TranslationContainer(
TextFormat::RED .
"%commands.generic.player.notFound"));
71 if($player->getName() != $sender->getName() && !$sender->hasPermission(
"pocketmine.command.effect.other")){
72 $sender->sendMessage(
"You don't have permission to give effect to other player .");
76 if(strtolower($args[1]) ===
"clear"){
77 foreach($player->getEffects() as $effect){
78 $player->removeEffect($effect->getId());
81 $sender->sendMessage(
new TranslationContainer(
"commands.effect.success.removed.all", [$player->getDisplayName()]));
92 $sender->sendMessage(
new TranslationContainer(
TextFormat::RED .
"%commands.effect.notFound", [(
string) $args[1]]));
99 if(count($args) >= 3){
100 $duration = (int) $args[2];
101 if(!($effect instanceof InstantEffect)){
104 }elseif($effect instanceof InstantEffect){
108 if(count($args) >= 4){
109 $amplification = (int) $args[3];
112 if(count($args) >= 5){
113 $v = strtolower($args[4]);
114 if($v ===
"on" or $v ===
"true" or $v ===
"t" or $v ===
"1"){
115 $effect->setVisible(
false);
120 if(!$player->hasEffect($effect->getId())){
121 if(count($player->getEffects()) === 0){
122 $sender->sendMessage(
new TranslationContainer(
"commands.effect.failure.notActive.all", [$player->getDisplayName()]));
124 $sender->sendMessage(
new TranslationContainer(
"commands.effect.failure.notActive", [$effect->getName(), $player->getDisplayName()]));
129 if($player->removeEffect($effect->getId())){
130 $sender->sendMessage(
new TranslationContainer(
"commands.effect.success.removed", [$effect->getName(), $player->getDisplayName()]));
133 $effect->setDuration($duration)->setAmplifier($amplification);
135 if($player->addEffect($effect)){
136 self::broadcastCommandMessage($sender,
new TranslationContainer(
"%commands.effect.success", [$effect->getName(), $effect->getId(), $effect->getAmplifier(), $player->getDisplayName(), $effect->getDuration() / 20]));