1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

MapReset/Position ERROR

Discussion in 'Help' started by YunoSiwa, Feb 1, 2018.

  1. YunoSiwa

    YunoSiwa Spider

    Messages:
    9
    My problem is that in my 1vs1 plugin I use new Position (var1, var1, var3, level);

    I keep it in a variable and I send it to what would be the arena ...

    the problem comes when I want to do a map reset since one of the minigames will be BuildUhc and I need the map to be reset when they put blocks

    because resetting the world obviously in the new position will erase the world as the world is disabled


    How could you solve this?

    What alternatives do I have?

    What do you advise me?
     
  2. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    You could create a function that returns a Position instance than saving the position instance in a variable.
    PHP:
    public function getPosition() : Position{
        return new 
    Position(var1var2var3Server::getInstance()->getLevelByName(levelName));
    }
    Or you could rebuild the level in the position instance if you don't want to create a Position instance everytime and want to keep it all short and simple.

    PHP:

    /** @var Position */
    public $myPosition;//new Position(var1, var2, var3, level)

    /** @var string */
    public $myLevelName;//level->getName()

    public function getPosition() : Position{
        
    $pos $this->myPosition;
        if(
    $pos->level->isClosed()){
            
    $pos->setLevel(Server::getInstance()->getLevelByName($this->levelName));
        }
        return 
    $pos;
    }
    But the best solution would be to not unload and reload the Level every so often. Loading a level is a heavy process.
     
    Last edited: Feb 2, 2018
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.