Solved 2 times sendplayermessage?

Discussion in 'Plugin Development' started by kingsofbart, Oct 26, 2015.

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

    kingsofbart

    hi,

    I made a little script but if some one doesnt have the correct permission they will be teleported to the a location (spawn) and got a message, but the message will be send 2 times. how can i fix this?
    Code:
    FileConfiguration c = getConfig();
    @EventHandler
         public void onWorldChange(PlayerChangedWorldEvent event){
             Player p = event.getPlayer();
             String enter = event.getPlayer().getWorld().getName();
             if(p.hasPermission("worldchange."+enter)){
                 if(c.get("enter-message") == "none"){
                 p.updateInventory();
                 }else{
                     p.sendMessage((String) c.get("enter-message"));
                 }
                
             }else if(!p.hasPermission("worldchange."+enter)){
                 String kickmsg = c.getString("kick-message");
                 Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "pw spawn "+p.getPlayerListName());
                 if(c.get(kickmsg) == "none"){
                     p.updateInventory();
                     }else{
                         p.sendMessage(kickmsg);
                     }
             }
           }
     
  2. Offline

    Lolmewn

    Because you're teleporting them back to a different world, firing the event again?
     
  3. Offline

    kingsofbart

    Thanks!
    do you have any idea how to fix?
     
  4. Offline

    Lolmewn

    @kingsofbart Just use a Set, if they get kicked; add them to the set, when they join succesfully remove them from the set. If in the set when joining, don't send message.
     
  5. Offline

    kingsofbart

    thanks! ill check it out right now!
     
  6. Offline

    DoggyCode™

    This is not JavaScript? It's Java.
     
  7. Offline

    kingsofbart

    SOLVED :)
     
Thread Status:
Not open for further replies.

Share This Page