Checking if a player is in a certain world

Discussion in 'Plugin Development' started by Harmings, Aug 9, 2013.

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

    Harmings

    I'm basically making a plugin that stops players from going above the y of 128 in the nether but I don't know how to check if the player is in the nether ;/
     
  2. Offline

    The_Doctor_123

    Code:
    @EventHandler
    public void onPlayerMove(PlayerMoveEvent event)
    {
    if (event.getPlayer().getLocation().getWorld().getName().endsWith("_nether")
    {
    if (event.getPlayer().getLocation().getY() > 128)
    {
    event.setCancelled(true);
    }
    }
    }
    
    Done. XD
     
  3. Offline

    Alex3543

    Code:
    if(player.getWorld().getName().equalsIgnoreCase("worldname)){
        //do sth
    }
     
    maxmar628 likes this.
  4. Offline

    Tarestudio

    The_Doctor_123
    More generic: player.getWorld().getEnvironment().equals(World.Environment.NETHER)
     
  5. Offline

    flaaghara

  6. Offline

    The_Doctor_123

    Ah, didn't know that existed. Learn something new every day with the Bukkit API. :p
     
  7. Offline

    Harmings

    Thank you all so much :D
     
  8. Offline

    Alex3543



    if(player.getWorld().getName().equalsIgnoreCase("worldname")){
    replace that with:
    if(player.getWorld().getName().equalsIgnoreCase("DeathWorld")){
     
Thread Status:
Not open for further replies.

Share This Page