<?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
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
This is my main code
my setting code
My system details