Request world name

Discussion in 'Plugin Development' started by buggermenot, Mar 30, 2012.

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

    buggermenot

    How can i request the actual world of a player. An simple example: Player X goes to the nether and now i want to have a message, that this player is now in the nether. Sorry for my bad english

    Code:
    public void playerChangedWorld(PlayerChangedWorldEvent event) {
     
    }
    does not seem to work
     
  2. Offline

    Sabersamus

    Code:java
    1.  
    2. @EventHandler
    3. public void onChange(PlayerChangedWorldEvent event){
    4. Player player = event.getPlayer();
    5. World world = event.getFrom();
    6. String newWorld = player.getWorld().getName();
    7. if(world.getName().equalsIgnoreCase(newWorld))return;
    8. player.sendMessage("You have gone to the world " + newWorld);
    9. }
     
  3. Offline

    surtic

    you can get this with the event PlayerTeleportEvent :) every World Change is a Teleport

    on the event you can make event.getPlayer().getWorld()

    Edit : Sabersamus : ah a new event :) never see this.
     
  4. Offline

    Sabersamus

    just make sure you do if(world.getName().equalsIgnoreCase(newWorld))return;

    cause for some reason it fires even when im teleporting back to spawn, from the same world D:
     
  5. Offline

    buggermenot

    Oh okay, now it's running
     
Thread Status:
Not open for further replies.

Share This Page