Skip to content
This repository has been archived by the owner on Jul 20, 2021. It is now read-only.

Error when game started #15

Open
raayyann opened this issue Jul 20, 2021 · 1 comment
Open

Error when game started #15

raayyann opened this issue Jul 20, 2021 · 1 comment

Comments

@raayyann
Copy link

When I enter the arena, the timer works normally, but when the timer runs out i get kicked from the server and the console says this error

#0 pmsrc/src/pocketmine/network/mcpe/NetworkBinaryStream(714): pocketmine\utils\Utils::errorExceptionHandler(integer 8, string[19] Undefined offset: 2, string[105] phar://D:/Minecraft Server/GameAPI/PocketMine-MP.phar/src/pocketmine/network/mcp, integer 714, array[3])
#1 pmsrc/src/pocketmine/network/mcpe/protocol/GameRulesChangedPacket(44): pocketmine\network\mcpe\NetworkBinaryStream->putGameRules(array[1])
#2 pmsrc/src/pocketmine/network/mcpe/protocol/DataPacket(127): pocketmine\network\mcpe\protocol\GameRulesChangedPacket->encodePayload()
#3 pmsrc/src/pocketmine/network/mcpe/protocol/BatchPacket(86): pocketmine\network\mcpe\protocol\DataPacket->encode()
#4 pmsrc/src/pocketmine/Server(1729): pocketmine\network\mcpe\protocol\BatchPacket->addPacket(object pocketmine\network\mcpe\protocol\GameRulesChangedPacket)
#5 pmsrc/src/pocketmine/level/Level(914): pocketmine\Server->batchPackets(array[2], array[1])
#6 pmsrc/src/pocketmine/level/Level(787): pocketmine\level\Level->actuallyDoTick(integer 5376)
#7 pmsrc/src/pocketmine/Server(2265): pocketmine\level\Level->doTick(integer 5376)
#8 pmsrc/src/pocketmine/Server(2396): pocketmine\Server->checkTickUpdates(integer 5376, double 1626766357.5761)
#9 pmsrc/src/pocketmine/Server(2152): pocketmine\Server->tick()
#10 pmsrc/src/pocketmine/Server(1992): pocketmine\Server->tickProcessor()
#11 pmsrc/src/pocketmine/Server(1586): pocketmine\Server->start()
#12 pmsrc/src/pocketmine/PocketMine(291): pocketmine\Server->__construct(object BaseClassLoader, object pocketmine\utils\MainLogger, string[28] D:\Minecraft Server\GameAPI\, string[36] D:\Minecraft Server\GameAPI\plugins\)
#13 pmsrc/src/pocketmine/PocketMine(321): pocketmine\server()
#14 pmsrc(11): require(string[83] phar://D:/Minecraft Server/GameAPI/PocketMine-MP.phar/src/pocketmine/PocketMine.)

This is my main code

<?php

namespace EmangGek\OneVsOne;

use pocketmine\Server;
use pocketmine\Player;
use pocketmine\entity\Entity;
use pocketmine\utils\TextFormat;
use pocketmine\command\CommandSender;
use pocketmine\command\Command;
use xenialdan\gameapi\API;
use xenialdan\gameapi\Arena;
use xenialdan\gameapi\Game;
use xenialdan\gameapi\Team;
use jojoe77777\FormAPI\SimpleForm;

class Main extends Game
{
    public function onEnable()
    {
        // $this->getServer()->getPluginManager()->registerEvents($this, $this);
        API::registerGame($this);
        foreach (glob($this->getDataFolder() . "*.json") as $v) {
            $this->addArena($this->getNewArena($v));
        }
    }

    public function onCommand(CommandSender $sender, Command $cmd, string $label, array $args): bool
    {
        if ($cmd->getName() === "onevsonesetup") {
            if (!$sender->hasPermission("onevsone.setup")) {
                $sender->sendMessage(TextFormat::RED . "You don't have permission to execute this command");
                return false;
            }
            if (!$sender instanceof Player) {
                $sender->sendMessage(TextFormat::RED . "Only players can execute this command");
                return false;
            }
            $this->setupArena($sender);
            return true;
        }
        if ($cmd->getName() === "onevsone") {
            if (!$sender->hasPermission("onevsone.play")) {
                $sender->sendMessage(TextFormat::RED . "You don't have permission to execute this command");
                return false;
            }
            if (!$sender instanceof Player) {
                $sender->sendMessage(TextFormat::RED . "Only players can execute this command");
                return false;
            }
            if (count($args) !== 1) {
                $sender->sendMessage(TextFormat::RED . 'Usage: /onevsone <arena>');
                return false;
            }
            if (!isset($this->getArenas()[$args[0]])) {
                $sender->sendMessage(TextFormat::RED . 'Arena not found');
                return false;
            }
            $arena = $this->getArenas()[$args[0]];
            if (!$arena->joinTeam($sender)) {
                $sender->sendMessage(TextFormat::RED . 'Error joining');
            }
            return true;
        }
        return false;
    }

    public function getNewArena(string $settingsPath): Arena
    {
        $settings = new OneVsOneSettings($settingsPath);
        $levelname = basename($settingsPath, ".json");
        $arena = new Arena($levelname, $this, $settings);
        $team = new Team(TextFormat::RESET, "Players");
        $team->setMinPlayers(2);
        $team->setMaxPlayers(2);
        $arena->addTeam($team);
        return $arena;
    }

    public function startArena(Arena $arena): void
    {
    }

    public function stopArena(Arena $arena): void
    {
    }

    public function onPlayerJoinTeam(Player $player): void
    {
    }

    public function removeEntityOnArenaReset(Entity $entity): bool
    {
        return true;
    }

    public function setupArena(Player $player): void
    {
        $worlds = API::getAllWorlds();
        $form = new SimpleForm(function(Player $player, int $result = null) use ($worlds)
        {
            if ($result === null) {
                return;
            }
            $name = $worlds[$result];
            $this->getServer()->loadLevel($name);
            new OneVsOneSettings($this->getDataFolder() . $name . ".json");
            $this->addArena($this->getNewArena($this->getDataFolder() . $name . ".json"));
            $player->sendMessage(TextFormat::GOLD . TextFormat::BOLD . "Arena Setup Done!");
        });
        $form->setTitle("OneVsOne Arena Setup");
        $form->setContent("Select world you want to be an arena");
        foreach ($worlds as $world) {
            $form->addButton($world);
        }
        $form->sendToPlayer($player);
    }
}

my setting code

<?php

namespace EmangGek\OneVsOne;

use xenialdan\gameapi\DefaultSettings;

class OneVsOneSettings extends DefaultSettings
{
    public $noDamageTeam = false;
    public $noFallDamage = true;
    public $noInventoryEditing = true;
}

My system details

PocketMine-MP version: 3.22.0 [Protocol 448]
Git commit: c32c21464c30cd7059a4cbfb0a7d7e493238a561
uname -a: Windows NT 10.0 build 19042 (Windows 10) AMD64
PHP Version: 7.4.20
Zend version: 3.4.0
OS : WINNT, win

Loaded plugins:
DEVirion 1.2.7 by poggit, SOFe for API(s) 3.0.0
DevTools 1.14.2 by PocketMine Team for API(s) 3.13.0
MultiWorld 1.6.0-beta2 by CzechPMDevs, VixikCZ, fuyutsuki, kaliiks for API(s) 3.20.0
OneVsOne 1.0.0 by EmangGek for API(s) 3.22.0
@inxomnyaa
Copy link
Owner

Support on this is discontinued

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants