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

Fix For Reset Map #5

Closed
ChaostixZix opened this issue Aug 3, 2020 · 0 comments
Closed

Fix For Reset Map #5

ChaostixZix opened this issue Aug 3, 2020 · 0 comments

Comments

@ChaostixZix
Copy link
Contributor

ChaostixZix commented Aug 3, 2020

Hi. I figured out that Pocketmine didnt save the world when the compression start.

Can you please add $level->save(true); to your code so the level is saved before comppresing

public function SetupArena(PlayerInteractEvent $e)
{
$p = $e->getPlayer();
$s = $p;
if (isset($this->setup[$p->getName()])) {
if ($this->setup[$s->getName()] == 1) {
$b = $e->getBlock();
$level = $p->getLevel()->getFolderName();
$this->cfg->set($level . "Spawn", array($b->getX(), $b->getY() + 1, $b->getZ()));
$this->cfg->save();

            $this->level = $s->getLevel()->getFolderName();
            if (!$this->cfg->get("arenas")) {

                $this->cfg->set("arenas", array($this->level));
                $this->cfg->save();
            } else {
                $array = $this->cfg->get("arenas");
                array_push($array, $this->level);
                $this->cfg->set("arenas", $array);
                $this->cfg->save();
            }
            $p->sendMessage($this->msg->get("touch_sign"));
            $p->teleport(new Position($this->getServer()->getDefaultLevel()->getSafeSpawn()->x, $this->getServer()->getDefaultLevel()->getSafeSpawn()->y, $this->getServer()->getDefaultLevel()->getSafeSpawn()->z, $this->getServer()->getDefaultLevel()));
            unset($this->setup[$s->getName()]);
            $this->setup[$s->getName()] = 2;
            return true;

        } elseif ($this->setup[$s->getName()] == 2) {

            $b = $e->getBlock();
            $tile = $p->getLevel()->getTile($b);
            if ($tile instanceof Sign) {
                $e->setCancelled();
                $p->sendMessage("Registering arena..... ");

                $level = $this->getServer()->getLevelByName($this->level);
                $level->save(true);
                $this->zipper($p, $this->level);


                $this->cfg->set($this->level . "Sign", array($b->getX(), $b->getY(), $b->getZ(), $this->level));
                $this->cfg->save();

                $tile->setText(TE::AQUA . "§7[ §fJoin §7]", TE::YELLOW . "0 / 12", "§f" . $this->level, $this->prefix);
                $p->sendMessage("Arena registered!");
                $this->game[$this->level] = false;
                unset($this->setup[$s->getName()]);
                $this->levels = $this->cfg->get("arenas");
                return true;
            }
        }
    }
    return true;
}
This was referenced Aug 16, 2020
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

1 participant