PlayerJoinEvent

Discussion in 'Plugin Development' started by QuecksilberHD, Jul 9, 2014.

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

    QuecksilberHD

    Hey com,

    If I use this code :

    Code:
    @EventHandler
        public void onPlayerJoin(PlayerJoinEvent e) {
        
            e.setJoinMessage(ChatColor.GREEN + "Herzlich Willkommen");
            Bukkit.broadcastMessage(ChatColor.GREEN + "Es fehlen noch " + Main.playeranzahl + " Spieler um " + this.plugin.aep + " zu starten");
        }
    everybody will see "Herzlich Willkommen" and the Bukkit.broadcastMessage will be seeable
    before the e.setJoinMessage...Know someone why ... ?

    Thanks for everything :D
     
  2. Offline

    indyetoile

    QuecksilberHD
    Add a delay of a few ticks before you broadcast the message.
     
  3. Offline

    tommycake50

    Because you set the join message to run and immediately after you broadcast the message.
    So you change a variable in some class, the code moves to the next line, message is broadcast right there and then when the event fires(not necessarily after they join) and then bukkit realises it needs to send the join message so it does using the variable that you set by calling setJoinMessage.

    Hope that's clear enough for you.
     
Thread Status:
Not open for further replies.

Share This Page