解決済み エラー解析をお願いします!!

Suran2020

Well-known member
5月 4, 2020
74
45
18
MCBE FORUM
forum.mcbe.jp
製作中のプラグインでエラーが出ました.....
解析をお願いします!
PHP:
<?php

namespace chinahinata\SneakInv;

use pocketmine\plugin\PluginBase;
use pocketmine\event\Listener;
use pocketmine\event\player\PlayerToggleSneakEvent;
use pocketmine\entity\effect;

class Main extends PluginBase implements Listener {

  public function onEnable() {
    $this->getServer()->getPluginManager()->registerEvents($this, $this);
  }

  public function onSneakToggle(PlayerToggleSneakEvent $event) {
    $player = $event->getPlayer();
    $player->sendTip("OnSneak");
    $effect = Effect::get(INVISIBILITY);
    $effect->setDuration(20);
    $effect->setAmplifier(3);
    $effect->setVisible(false);
    $player->addEffect($effect);
  }
}
エラーメッセージ
Code:
[07:32:18] [Server thread/CRITICAL]: ArgumentCountError: "Too few arguments to function pocketmine\entity\Living::addEffect(), 0 passed in /data/plugins/SneakInv_v1.1.0/src/chinahinata/SneakInv/Main.php on line 19 and exactly 1 expected" (EXCEPTION) in "src/pocketmine/entity/Living" at line 267
[07:32:18] [Server thread/DEBUG]: #0 plugins/SneakInv_v1.1.0/src/chinahinata/SneakInv/Main(19): pocketmine\entity\Living->addEffect()
[07:32:18] [Server thread/DEBUG]: #1 src/pocketmine/plugin/MethodEventExecutor(42): chinahinata\SneakInv\Main->onSneakToggle(object pocketmine\event\player\PlayerToggleSneakEvent)
[07:32:18] [Server thread/DEBUG]: #2 src/pocketmine/plugin/RegisteredListener(80): pocketmine\plugin\MethodEventExecutor->execute(object chinahinata\SneakInv\Main, object pocketmine\event\player\PlayerToggleSneakEvent)
[07:32:18] [Server thread/DEBUG]: #3 src/pocketmine/event/Event(88): pocketmine\plugin\RegisteredListener->callEvent(object pocketmine\event\player\PlayerToggleSneakEvent)
[07:32:18] [Server thread/DEBUG]: #4 src/pocketmine/Player(2864): pocketmine\event\Event->call()
[07:32:18] [Server thread/DEBUG]: #5 src/pocketmine/Player(2822): pocketmine\Player->toggleSneak(boolean 1)
[07:32:18] [Server thread/DEBUG]: #6 src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter(174): pocketmine\Player->handlePlayerAction(object pocketmine\network\mcpe\protocol\PlayerActionPacket)
[07:32:18] [Server thread/DEBUG]: #7 src/pocketmine/network/mcpe/protocol/PlayerActionPacket(88): pocketmine\network\mcpe\PlayerNetworkSessionAdapter->handlePlayerAction(object pocketmine\network\mcpe\protocol\PlayerActionPacket)
[07:32:18] [Server thread/DEBUG]: #8 src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter(110): pocketmine\network\mcpe\protocol\PlayerActionPacket->handle(object pocketmine\network\mcpe\PlayerNetworkSessionAdapter)
[07:32:18] [Server thread/DEBUG]: #9 src/pocketmine/network/mcpe/protocol/BatchPacket(126): pocketmine\network\mcpe\PlayerNetworkSessionAdapter->handleDataPacket(object pocketmine\network\mcpe\protocol\PlayerActionPacket)
[07:32:18] [Server thread/DEBUG]: #10 src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter(110): pocketmine\network\mcpe\protocol\BatchPacket->handle(object pocketmine\network\mcpe\PlayerNetworkSessionAdapter)
[07:32:18] [Server thread/DEBUG]: #11 src/pocketmine/Player(3118): pocketmine\network\mcpe\PlayerNetworkSessionAdapter->handleDataPacket(object pocketmine\network\mcpe\protocol\BatchPacket)
[07:32:18] [Server thread/DEBUG]: #12 src/pocketmine/network/mcpe/RakLibInterface(169): pocketmine\Player->handleDataPacket(object pocketmine\network\mcpe\protocol\BatchPacket)
[07:32:18] [Server thread/DEBUG]: #13 vendor/pocketmine/raklib/src/server/ServerHandler(99): pocketmine\network\mcpe\RakLibInterface->handleEncapsulated(string[18] 192.168.11.7 60903, object raklib\protocol\EncapsulatedPacket, integer 0)
[07:32:18] [Server thread/DEBUG]: #14 src/pocketmine/network/mcpe/RakLibInterface(109): raklib\server\ServerHandler->handlePacket()
[07:32:18] [Server thread/DEBUG]: #15 src/pocketmine/network/mcpe/RakLibInterface(99): pocketmine\network\mcpe\RakLibInterface->process()
[07:32:18] [Server thread/DEBUG]: #16 vendor/pocketmine/snooze/src/SleeperHandler(123): pocketmine\network\mcpe\RakLibInterface->pocketmine\network\mcpe\{closure}()
[07:32:18] [Server thread/DEBUG]: #17 vendor/pocketmine/snooze/src/SleeperHandler(85): pocketmine\snooze\SleeperHandler->processNotifications()
[07:32:18] [Server thread/DEBUG]: #18 src/pocketmine/Server(2146): pocketmine\snooze\SleeperHandler->sleepUntil(double 1589009538.6324)
[07:32:18] [Server thread/DEBUG]: #19 src/pocketmine/Server(1990): pocketmine\Server->tickProcessor()
[07:32:18] [Server thread/DEBUG]: #20 src/pocketmine/Server(1584): pocketmine\Server->start()
[07:32:18] [Server thread/DEBUG]: #21 src/pocketmine/PocketMine(273): pocketmine\Server->__construct(object BaseClassLoader, object pocketmine\utils\MainLogger, string[6] /data/, string[14] /data/plugins/)
[07:32:18] [Server thread/DEBUG]: #22 src/pocketmine/PocketMine(296): pocketmine\server()
[07:32:18] [Server thread/DEBUG]: #23 (11): require(string[61] phar:///data/PocketMine-MP.phar/src/pocketmine/PocketMine.php)
 
  • Like
Reactions: DaisukeDaisuke

DaisukeDaisuke

Active member
1月 26, 2018
36
25
18
数年前にエフェクト関連の仕様変更を実施致しました為、現在ではエフェクトの仕様に関しましては、異なります、注意は必要にてございます...
use分
PHP:
use pocketmine\entity\Effect;
use pocketmine\entity\EffectInstance;
エフェクトの種類
PHP:
SPEED = 1;
SLOWNESS = 2;
HASTE = 3;
FATIGUE = 4, MINING_FATIGUE = 4;
STRENGTH = 5;
INSTANT_HEALTH = 6, HEALING = 6;
INSTANT_DAMAGE = 7, HARMING = 7;
JUMP_BOOST = 8, JUMP = 8;
NAUSEA = 9, CONFUSION = 9;
REGENERATION = 10;
RESISTANCE = 11, DAMAGE_RESISTANCE = 11;
FIRE_RESISTANCE = 12;
WATER_BREATHING = 13;
INVISIBILITY = 14;
BLINDNESS = 15;
NIGHT_VISION = 16;
HUNGER = 17;
WEAKNESS = 18;
POISON = 19;
WITHER = 20;
HEALTH_BOOST = 21;
ABSORPTION = 22;
SATURATION = 23;
LEVITATION = 24; //TODO(実装予定)
FATAL_POISON = 25;
CONDUIT_POWER = 26;
新しいエフェクトの仕様
PHP:
$effectInstance = new EffectInstance(Effect::getEffect(Effect::エフェクトのタイプ(英語)), エフェクトの効果時間, エフェクトの強さ, エフェクトのパーティクルの不可視設定);
$player->addEffect($effectInstance);
実際のコード
PHP:
$effectInstance = new EffectInstance(Effect::getEffect(Effect::INVISIBILITY), 20, 3, false);
$player->addEffect($effectInstance);
以下のコードをでも記述可能にてございます...
PHP:
$effectInstance = new EffectInstance(Effect::getEffect(Effect::INVISIBILITY));
$effectInstance->setDuration(20);
$effectInstance->setAmplifier(3);
$effectInstance->setVisible(false);
$player->addEffect($effectInstance);