[Solved][Thanks Njol]Notive a PlayerChangedWorldEvent and cancel it

Discussion in 'Plugin Development' started by luke100, May 14, 2012.

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

    luke100

    Hi there, i want to block a player from a specific world if he is added to a file.
    I dont really know which event to use, either the PlayerChangedWorldEvent which isnt cancelable as far as i know and the PlayerTeleportEvent which doesnt work for me.
    Maybe you can help me

    PHP:
    @EventHandler
                   
    public void playerJoin(PlayerTeleportEvent event) {
           
                   if (
    event.getTo().getWorld().toString().equalsIgnoreCase(getConfig().getString("world"))){
                   
                   List<
    Stringdeaths getConfig().getStringList("dead");
                   
                   if(
    deaths.contains(event.getPlayer().toString().toLowerCase())) {
                   
    event.getPlayer().sendMessage("you are already dead");
                   
    event.setCancelled(true);
                   
                   
                   }
    Thanks for your help
    Scharnhorst
     
  2. Offline

    Njol

    You have to use world.getName(), not world.toString() to get a world's name. The same applies to players as well.
     
  3. Offline

    luke100

    Thanks Njol for helping me again=)
     
Thread Status:
Not open for further replies.

Share This Page