Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Creating And Reading Config.yml File Help

Comments in 'Plugin Development' started by Comedyman937, Mar 1, 2014.

Thread Status:
Not open for further replies.
  1. thebigsmileXD
    Offline

    thebigsmileXD Banned

    Joined:
    May 19, 2015
    Posts:
    845
    Plugins:
    1
    Minecraft User:
    XenialDan
    Just found this.. thats not hard, you don't even need a config.
    PHP:
    class Main implements Plugin{
    public 
    $swap=[];
    public function 
    swapPlayers(Player $player1Player $player2){
    $this->swap[$player1->getName()]=new Vector3($player1->getX(), $player1->getY(), $player1->getZ());
    $this->swap[$player1->getName()]["yaw"]=$player1->getYaw();
    $this->swap[$player1->getName()]["pitch"]=$player1->getPitch();
    $this->swap[$player2->getName()]=new Vector3($player2->getX(), $player2->getY(), $player2->getZ());
    $this->swap[$player2->getName()]["yaw"]=$player2->getYaw();
    $this->swap[$player2->getName()]["pitch"]=$player2->getPitch();
    $player1->teleport($this->swap[$player2->getName()], $this->swap[$player2->getName()]["yaw"], $this->swap[$player2->getName()]["pitch"]);
    $player2->teleport($this->swap[$player1->getName()], $this->swap[$player2->getName()]["yaw"], $this->swap[$player2->getName()]["pitch"]);
    unset(
    $this->swap[$player1->getName()]);
    unset(
    $this->swap[$player2->getName()]);
    }
    //to swap the players:
    $this->swapPlayers($player1$player2);
    This is alot faster and more relyable than a config file.

    EDIT: because you said EXACT position, i added yaw and pitch.
    --=+=--
    Tags for others to find this post:
    swap players, teleport players, 2 players, switch players, player positions
    Last edited: Sep 26, 2015
Thread Status:
Not open for further replies.

Share This Page

Advertisement