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

Void Teleportation

Comments in 'Plugin Development' started by MiguelBad9, Apr 1, 2015.

  1. MiguelBad9
    Offline

    MiguelBad9 New Member

    Joined:
    Sep 26, 2013
    Posts:
    4
    PHP:
    public function onVoidLoop(PlayerMoveEvent $event){
            if(
    $event->getTo()->getFloorY() < 2){
                
    $event->getPlayer()->teleport($this->getServer()->getDefaultLevel()->getSpawnLocation());
            }
        }
    }
    How do you get it to not teleport to the DefaultLevel? What can you put instead of getDefaultLevel. So, the problem is that every time someone falls down a void, they get teleported to the DEFAULT WORLD/LEVEL. But I want it to teleport to the current level/world that he/she is in. I don't know a lot about PHP.
  2. xFlare
    Offline

    xFlare Active Member Plugin Developer

    Joined:
    Sep 28, 2014
    Posts:
    199
    Plugins:
    1
    Minecraft User:
    xFlare
    1. This code is copied from github

    2.
    PHP:
    public function onVoidLoop(PlayerMoveEvent $event){
            if(
    $event->getTo()->getFloorY() < 2){
                
    $myworld $event->getPlayer()->getLevel();
                
    $event->getPlayer()->teleport($myworld->getSafeSpawn());
                
    $event->getPlayer()->teleport($this->getServer()->getDefaultLevel()->getSpawnLocation());
            }
        }
    }
    }
  3. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Why still keep the last meaningful line?
  4. MiguelBad9
    Offline

    MiguelBad9 New Member

    Joined:
    Sep 26, 2013
    Posts:
    4
    Yes, yes it is but it's just for personal use. Its not like I'm going to upload it. And thanks :)
    xFlare likes this.
  5. xFlare
    Offline

    xFlare Active Member Plugin Developer

    Joined:
    Sep 28, 2014
    Posts:
    199
    Plugins:
    1
    Minecraft User:
    xFlare
    That was a mistake xD
  6. aliuly
    Offline

    aliuly Notable Member Plugin Developer

    Joined:
    Feb 8, 2014
    Posts:
    1,086
    Plugins:
    17
    PHP:
    public function onVoidLoop(PlayerMoveEvent $event){
            if(
    $event->getTo()->getFloorY() < 2){
                
    $event->getPlayer()->teleport($event->getPlayer()->getLevel()->getSpawnLocation());
            }
        }
    }
    I would do this instead.
    PEMapModder likes this.

Share This Page

Advertisement