Solved Player Join Message Help

Discussion in 'Plugin Development' started by tom_buscus, Nov 11, 2013.

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

    tom_buscus

    I have my plugin setup to tell the player a message when they join, as shown below:
    }

    public void onPlayerJoin(PlayerJoinEvent event) {
    Player player = event.getPlayer();
    event.setJoinMessage(ChatColor.GOLD + "Welcom to The Server!");
    }
    But when ever I or another player joins my server the message is not displayed. Does anyone know how to fix this problem?
     
  2. Offline

    AKMiner98

    Just do this:
    public void onPlayerJoin(PlayerJoinEvent event) {
    Player player = event.getPlayer();
    player.sendMessage(ChatColor.GOLD + "Welcome to The Server!");
    }

    or you can make the send message this:
    player.sendMessage(ChatColor.GOLD + getConfig().get("WelcomeMessage");
    Then make a config and add WelcomeMessage and you can set it from the server files.
    You can also from there make a command that can change it in game.
     
  3. Offline

    tom_buscus

    @AKAMiner98 ok thanks!
     
  4. Offline

    qlimax5000

    Did you register the event?
     
  5. Offline

    Sweatyyyy

    tom_buscus
    You seem to have forgotten
    Code:
    @EventHandler
     
    JPG2000 likes this.
  6. Offline

    tom_buscus

    Sweatyyyy
    No i just didn't copy it into the post

    qlimax5000
    No, I did not register the event.
    How do you register events?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 5, 2016
  7. Offline

    MayoDwarf

    Code:java
    1. this.getServer().getPluginManager().registerEvents(this, this);
    2. //^ Put this in your onEnable() method
     
  8. Offline

    tom_buscus

  9. Offline

    Meatiex

    You might want this, maybe not. It hides the join message from the player thats logging in to seam cleaner :D
    Code:java
    1. public void onPlayerJoin(PlayerJoinEvent event) {
    2. Player player = event.getPlayer();
    3. p.sendMessage(ChatColor.YELLOW + "Custom Message :D");
    4. event.setJoinMessage(null);
    5. for (Player p : Bukkit.getOnlinePlayers())
    6. if (p.getName() != player.getName()) {
    7. p.sendMessage(ChatColor.YELLOW + player.getName() + " Joined the game.");
    8. }


    If you'r done goto you'r first post and set this topic as [Solved] Thanks :D
     
  10. Offline

    tom_buscus

  11. Offline

    JPG2000

    tom_buscus MayoDwarf You may have confussed him. The this, this isn't the same for every event you register. If your registering an event in a different class, at the top implement Listener and then:
    ... (this, new ClassYouRegistered).

    For more about this, I made a thread on multiple classes, and it's link is in my signature.
     
  12. Offline

    MayoDwarf

    Yes, but his listening class is his main class. That is if he has a separate listening class or multiple listening classes.
     
  13. Offline

    JPG2000

  14. Offline

    MayoDwarf

    My bad mate
     
    JPG2000 likes this.
Thread Status:
Not open for further replies.

Share This Page