Hello I having an issue in my skywars plugin which I kill an player and when I do I get an error (crash). This plugin is one I want to update. PHP: public function onDamage(EntityDamageEvent $event) { $player = $event->getEntity(); if (!$player instanceof Player) return; foreach (Arena::getArenas() as $arena) { if ($player->getLevel()->getFolderName() == Arena::getName($arena)) { if (Arena::getStatus($arena) == 'ingame') { switch ($event->getCause()) { case EntityDamageEvent::CAUSE_ENTITY_ATTACK: if ($event instanceof EntityDamageByEntityEvent) { $damager = $event->getDamager(); if ($damager instanceof Player) { if ($event->getFinalDamage() >= $player->getHealth()) { $event->setCancelled(true); PluginUtils::getEventDamage($player, $arena, 'He has been killed by', $damager); //Error is on here I check the crash dumps and got this Code: Error: Argument 1 passed to pocketmine\network\mcpe\NetworkBinaryStream::putString() must be of the type string, int given, called in phar:///home/container/PocketMine-MP.phar/src/pocketmine/network/mcpe/protocol/AddActorPacket.php on line 211 File: src/pocketmine/network/mcpe/NetworkBinaryStream Line: 62 Type: TypeError A PLUGIN WAS INVOLVED IN THIS CRASH BAD PLUGIN: SkyWarsMR v1.0.0 Code: [53] class NetworkBinaryStream extends BinaryStream{ [54] [55] private const DAMAGE_TAG = "Damage"; //TAG_Int [56] private const DAMAGE_TAG_CONFLICT_RESOLUTION = "___Damage_ProtocolCollisionResolution___"; [57] [58] public function getString() : string{ [59] return $this->get($this->getUnsignedVarInt()); [60] } [61] [62] public function putString(string $v) : void{ [63] $this->putUnsignedVarInt(strlen($v)); [64] ($this->buffer .= $v); [65] } Any reason why this is causing the error. This is the EventGetDamage code
Sure this is the getEventDamage PHP: public static function getEventDamage(Player $player, string $arena, string $cause, Player $damager = null) { $config = SkyWars::getConfigs('Arenas/' . $arena); $lobby = $config->get('lobbyspecters'); if (count(Arena::getPlayers($arena)) != 1) { if ($player->getGamemode() != 3) { if ($damager != false) { SkyWars::$data['kills'][Arena::getName($arena)][$damager->getName()] = SkyWars::$data['kills'][Arena::getName($arena)][$damager->getName()] + 1; $kills = SkyWars::getConfigs('kills'); $kills->set($damager->getName(), $kills->get($damager->getName()) + 1); $kills->save(); foreach ($damager->getLevel()->getPlayers() as $players) { $players->sendMessage(TextFormat::RED . $player->getName() . TextFormat::GRAY . ' ' . $cause . ' ' . TextFormat::GOLD . $damager->getName() . '.'); $remain = (count(Arena::getPlayers($arena)) - 1); if ($remain > 1) { $players->sendMessage(TextFormat::RED . $remain . ' players remain alive.'); } } $getcoins = SkyWars::getConfigs('Profiles/' . $player->getName()); if ($getcoins->get('coins') >= 0) { $getcoins->set('coins', $getcoins->get('coins') - 1); $getcoins->save(); $player->sendMessage(TextFormat::LIGHT_PURPLE . '-1 Coins.'); } $coins = SkyWars::getConfigs('Profiles/' . $damager->getName()); $coins->set('coins', $config->get('coins') + 2); $coins->save(); $damager->sendMessage(TextFormat::LIGHT_PURPLE . '+2 Coins.'); } else { foreach ($player->getLevel()->getPlayers() as $players) { $players->sendMessage(TextFormat::RED . $player->getName() . TextFormat::GRAY . ' ' . $cause . '.'); $remain = (count(Arena::getPlayers($arena)) - 1); if ($remain > 1) { $players->sendMessage(TextFormat::RED . $remain . ' players remain alive.'); } } } foreach ($player->getDrops() as $drops) { $player->getLevel()->dropItem($player, $drops); } self::addStrike(Server::getInstance()->getLevelByName($player->getLevel()->getFolderName())->getPlayers(), $player); $player->removeAllEffects(); $player->addEffect(new EffectInstance(Effect::getEffect(Effect::BLINDNESS), 20, 3)); switch (rand(1, 2)) { case 1: $player->addTitle(TextFormat::BOLD . TextFormat::RED . '¡You died!', TextFormat::YELLOW . 'You lost the game'); break; case 2: $player->addTitle(TextFormat::BOLD . TextFormat::RED . '¡You died!', TextFormat::YELLOW . 'Good luck next time'); break; } $player->teleport(new Vector3($lobby[0], $lobby[1], $lobby[2])); $player->setGamemode(3); $player->setHealth(20); $player->setFood(20); $player->getInventory()->clearAll(); $player->getArmorInventory()->clearAll(); $player->sendMessage(TextFormat::BOLD . TextFormat::GREEN . '» ' . TextFormat::RESET . TextFormat::YELLOW . 'The search for a new game will begin, cancel the wait using the remaining item of the players to continue watching.'); if (!in_array($player->getName(), SkyWars::$data['queue'])) { SkyWars::$data['queue'][] = $player->getName(); SkyWars::getInstance()->getScheduler()->scheduleRepeatingTask(new NewGame($player), 10); } $player->getInventory()->setItem(0, Item::get(381, 0, 1)->setCustomName(TextFormat::GOLD . "Players Reaming\n§r§fClick to select")); $player->getInventory()->setItem(4, Item::get(120, 0, 1)->setCustomName(TextFormat::LIGHT_PURPLE . "Random Game\n§r§fClick to select")); $player->getInventory()->setItem(8, Item::get(355, 14, 1)->setCustomName(TextFormat::RED . "Leave\n§r§fClick to select")); } else { $player->teleport(new Vector3($lobby[0], $lobby[1], $lobby[2])); } } else { $player->teleport(new Vector3($lobby[0], $lobby[1], $lobby[2])); } } public static function joinSolo(Player $player, int $id) { if ($player instanceof Player) { $world = Server::getInstance()->getLevelByName(Arena::getName('SW-' . $id)); if (Arena::getStatus('SW-' . $id) == 'waiting') { if (count(Arena::getPlayers('SW-' . $id)) < Arena::getSpawns('SW-' . $id)) { SkyWars::$data['skins'][$player->getName()] = $player->getSkin(); SkyWars::$data['damager'][$player->getName()] = 'string'; SkyWars::$data['kills'][Arena::getName('SW-' . $id)][$player->getName()] = 0; $player->getInventory()->clearAll(); $player->getArmorInventory()->clearAll(); $player->sendMessage(TextFormat::GREEN . TextFormat::BOLD . '» ' . TextFormat::RESET . TextFormat::GREEN . 'An available game has been found: ' . 'SW-' . $id); $config = SkyWars::getConfigs('Arenas/' . 'SW-' . $id); $lobby = $config->get('lobby'); $player->teleport(Server::getInstance()->getLevelByName(Arena::getName('SW-' . $id))->getSpawnLocation()); $player->teleport(new Vector3($lobby[0], $lobby[1], $lobby[2])); $player->setAllowFlight(false); $player->setFlying(false); $player->removeAllEffects(); $player->setGamemode(2); $player->setHealth(20); $player->setFood(20); $player->setScale(1); foreach ($world->getPlayers() as $players) { $players_array[] = $players->getName(); } $player->sendMessage(TextFormat::GOLD . join(TextFormat::GOLD . ', ' . TextFormat::GOLD, $players_array) . TextFormat::GOLD . '.'); $player->getLevel()->addSound(new EndermanTeleportSound($player)); foreach ($world->getPlayers() as $players) { $players->sendMessage(TextFormat::GREEN . TextFormat::BOLD . '» ' . TextFormat::RESET . TextFormat::DARK_GRAY . $player->getName() . ' ' . 'Joined the game.' . ' ' . TextFormat::DARK_GRAY . '[' . TextFormat::DARK_GRAY . count($world->getPlayers()) . TextFormat::DARK_GRAY . '/' . TextFormat::DARK_GRAY . Arena::getSpawns('SW-' . $id) . TextFormat::DARK_GRAY . ']'); $players->getLevel()->addSound(new EndermanTeleportSound($players)); } } } } } Can’t get the stack trace because my server node is down for now
My node is back and here the backtrace not sure if it is what ur lookin for PHP: Backtrace:#0 src/pocketmine/network/mcpe/protocol/AddActorPacket(211): pocketmine\network\mcpe\NetworkBinaryStream->putString(integer 93)#1 src/pocketmine/network/mcpe/protocol/DataPacket(127): pocketmine\network\mcpe\protocol\AddActorPacket->encodePayload()#2 src/pocketmine/network/mcpe/RakLibInterface(244): pocketmine\network\mcpe\protocol\DataPacket->encode()#3 src/pocketmine/Player(3303): pocketmine\network\mcpe\RakLibInterface->putPacket(object pocketmine\Player, object pocketmine\network\mcpe\protocol\AddActorPacket, boolean , boolean )#4 src/pocketmine/Player(3320): pocketmine\Player->sendDataPacket(object pocketmine\network\mcpe\protocol\AddActorPacket, boolean , boolean )#5 plugins/SkyWarsMR-master/src/MikeRangel/SkyWars/PluginUtils(124): pocketmine\Player->dataPacket(object pocketmine\network\mcpe\protocol\AddActorPacket)#6 plugins/SkyWarsMR-master/src/MikeRangel/SkyWars/PluginUtils(207): MikeRangel\SkyWars\PluginUtils::addStrike(array[2], object pocketmine\Player)#7 plugins/SkyWarsMR-master/src/MikeRangel/SkyWars/Events/GlobalEvents(551): MikeRangel\SkyWars\PluginUtils::getEventDamage(object pocketmine\Player, string[4] SW-1, string[24] Has fallen into the void)#8 src/pocketmine/plugin/MethodEventExecutor(42): MikeRangel\SkyWars\Events\GlobalEvents->onDamage(object pocketmine\event\entity\EntityDamageEvent)#9 src/pocketmine/plugin/RegisteredListener(80): pocketmine\plugin\MethodEventExecutor->execute(object MikeRangel\SkyWars\Events\GlobalEvents, object pocketmine\event\entity\EntityDamageEvent)#10 src/pocketmine/event/Event(88): pocketmine\plugin\RegisteredListener->callEvent(object pocketmine\event\entity\EntityDamageEvent)#11 src/pocketmine/entity/Entity(934): pocketmine\event\Event->call()#12 src/pocketmine/entity/Living(545): pocketmine\entity\Entity->attack(object pocketmine\event\entity\EntityDamageEvent)#13 src/pocketmine/Player(3873): pocketmine\entity\Living->attack(object pocketmine\event\entity\EntityDamageEvent)#14 src/pocketmine/entity/Entity(1034): pocketmine\Player->attack(object pocketmine\event\entity\EntityDamageEvent)#15 src/pocketmine/entity/Living(642): pocketmine\entity\Entity->entityBaseTick(integer 1)#16 src/pocketmine/entity/Human(627): pocketmine\entity\Living->entityBaseTick(integer 1)#17 src/pocketmine/Player(1785): pocketmine\entity\Human->entityBaseTick(integer 1)#18 src/pocketmine/level/Level(852): pocketmine\Player->onUpdate(integer 176495)#19 src/pocketmine/level/Level(785): pocketmine\level\Level->actuallyDoTick(integer 176495)#20 src/pocketmine/Server(2267): pocketmine\level\Level->doTick(integer 176495)#21 src/pocketmine/Server(2398): pocketmine\Server->checkTickUpdates(integer 176495, double 1603067511.9072)#22 src/pocketmine/Server(2154): pocketmine\Server->tick()#23 src/pocketmine/Server(1994): pocketmine\Server->tickProcessor()#24 src/pocketmine/Server(1588): pocketmine\Server->start()#25 src/pocketmine/PocketMine(273): pocketmine\Server->__construct(object BaseClassLoader, object pocketmine\utils\MainLogger, string[16] /home/container/, string[24] /home/container/plugins/)#26 src/pocketmine/PocketMine(304): pocketmine\server()#27 (11): require(string[71] phar:///home/container/PocketMine-MP.phar/src/pocketmine/PocketMine.php)
PHP: public static function addStrike(array $players, Player $deathPlayer) { $packet = new AddActorPacket(); $packet->type = 93; $packet->entityRuntimeId = Entity::$entityCount++; $packet->metadata = []; $packet->position = $deathPlayer->asVector3()->add(0, $height = 0); $packet->yaw = $deathPlayer->getYaw(); $packet->pitch = $deathPlayer->getPitch(); foreach ($players as $player) { $player->dataPacket($packet); self::playSound($player, 'ambient.weather.lightning.impact', 1, 1); } }
it is a bug with sound packages PHP: public static function addStrike(array $players, Player $deathPlayer) { $packet = new AddActorPacket(); $packet->type = 93; $packet->entityRuntimeId = Entity::$entityCount++; $packet->metadata = []; $packet->position = $deathPlayer->asVector3()->add(0, $height = 0); $packet->yaw = $deathPlayer->getYaw(); $packet->pitch = $deathPlayer->getPitch(); foreach ($players as $player) { $player->dataPacket($packet); self::playSound($player, 'ambient.weather.lightning.impact', 1, 1); } }
Change this line PHP: $packet->type = 93; to PHP: $packet->type = AddActorPacket::LEGACY_ID_MAP_BC[93];