Solved Setting the join message doesn't work?

Discussion in 'Plugin Development' started by Astrophylite, Feb 13, 2016.

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

    Astrophylite

    Hello,

    I'm trying to make it so there is no join message and it just keeps saying "<name> joined the game."
    Any ideas?

    CODE (open)

    Code:java
    1.  
    2. @EventHandler
    3. public void onPlayerJoin(PlayerJoinEvent e) {
    4. e.setJoinMessage(null);
    5.  
    6. Utils.sendHeaderAndFooter(e.getPlayer());
    7.  
    8. Player p = e.getPlayer();
    9. UUID uuid = p.getUniqueId();
    10. try {
    11. ResultSet rs = MySQLHandler.returnStatement().executeQuery("SELECT * FROM login WHERE uuid = '" + uuid.toString() + "'");
    12. if(!rs.next()) {
    13. MessageManager.broadcastMessage("&7Welcome &5&l" + p.getName() + " &7to the server!");
    14. String sql = "INSERT INTO login(username, uuid, lastlogin) VALUES ('" + p.getName() + "', '" + p.getUniqueId() + "', '" + System.currentTimeMillis() + "')";
    15. MySQLHandler.returnStatement().executeUpdate(sql);
    16. } else {
    17. MySQLHandler.returnStatement().executeUpdate("UPDATE login SET username = '" + p.getName() + "', lastlogin = " + System.currentTimeMillis() + " WHERE uuid = '" + uuid.toString() + "'");
    18. }
    19. } catch (SQLException ex) {
    20. ex.printStackTrace();
    21. }
    22. }
    23.  

     
  2. Offline

    DoggyCode™

    e.setJoinMessage("");

    ?
     
  3. Offline

    Astrophylite

    That was just something I was trying because e.setJoinMessage(null) doesn't work...

    EDIT: Changing "" to null doesn't fix it ;-;
     
  4. Offline

    aTmAggies

    Try this:
    Code:
    import org.bukkit.ChatColor;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerJoinEvent;
    
    public class EventPlayerJoin implements Listener
    {
        @EventHandler
        public void onPlayerJoin(PlayerJoinEvent e)
        {
            Player p = e.getPlayer();
          
            e.setJoinMessage("Hi!");
        }
    }
     
    Last edited by a moderator: Feb 13, 2016
  5. Offline

    teej107

    @_zircon_ Did you register the event?
    Did you run your SQL queries off the main thread? No you did not :p
     
  6. Offline

    mcdorli

    Signature, 1st sentence

    BTW.: I'm amazed, how many times I can use this
     
    dart2112 likes this.
  7. Offline

    Astrophylite

    Yes, and there is no problem with the SQL queries. They work perfectly fine.

    I hate it when people spoonfeed...

    @aTmAggies The code doesn't work, it still says "IntristicMC joined the game" and I changed e.setJoinMessage(null) to e.setJoinMessage("Hi!") and removed the EventPriority..
     
  8. Offline

    teej107

    The problem isn't with the SQL queries. It's the thread where you are running statements. You should run SQL code in a separate thread. Show us the code where you registered the event.
     
  9. Offline

    Astrophylite

    Code:java
    1.  
    2. public void onEnable() {
    3. // Create and clear the replyMap
    4. HashMap<String, String> replyMap = new HashMap<String, String>();
    5. replyMap.clear();
    6.  
    7. // Connect to the database
    8. MySQLHandler.connect();
    9.  
    10. // Register the commands
    11. getCommand("ban").setExecutor(new CMDBan());
    12. getCommand("chatmode").setExecutor(new CMDChatMode());
    13. getCommand("clearchat").setExecutor(new CMDClearChat());
    14. getCommand("fly").setExecutor(new CMDFly());
    15. getCommand("history").setExecutor(new CMDHistory());
    16. getCommand("kick").setExecutor(new CMDKick());
    17. getCommand("maintenance").setExecutor(new CMDMaintenance());
    18. getCommand("message").setExecutor(new CMDMessage());
    19. getCommand("mute").setExecutor(new CMDMute());
    20. getCommand("nickname").setExecutor(new CMDNickname());
    21. getCommand("ping").setExecutor(new CMDPing());
    22. getCommand("report").setExecutor(new CMDReport());
    23. getCommand("staff").setExecutor(new CMDStaff());
    24. getCommand("tempban").setExecutor(new CMDTempBan());
    25. getCommand("tempmute").setExecutor(new CMDTempMute());
    26. getCommand("unban").setExecutor(new CMDUnBan());
    27. getCommand("unmute").setExecutor(new CMDUnMute());
    28.  
    29. // Register the events
    30. Bukkit.getServer().getPluginManager().registerEvents(new EVENTPlayerJoin(), this);
    31. Bukkit.getServer().getPluginManager().registerEvents(new EVENTPlayerCommandPreprocess(), this);
    32. }
    33.  
     
  10. Offline

    teej107

    @_zircon_ are you running other plugins?
     
  11. Offline

    Astrophylite

    Yeah, open the spoiler for a list :)
    Plugin List (open)

    ChromaCore*, WorldEdit, Essentials, EssentialsGeoIP, EssentialsChat, EssentialsAntiBuild, PermissionsEx, ChromaTags*, Vault, EssentialsSpawn, WorldGuard, ProtocolLib, MassiveCore, WhatIsIt, Factions, EssentialsProtect, floAuction, TabAPI

    * = Custom-coded plugin.
     
  12. Offline

    teej107

    @_zircon_ Remove all except for the one you are making and then test it.
     
  13. Offline

    Astrophylite

    I just moved them all into a "disabled" folder, then did /reload. The only plugin in the list is "ChromaCore" (the one I am making) and logged out and logged in, still doesn't work ;(
     
  14. Offline

    teej107

    @_zircon_ any errors? What are you packaging in your plugin jar?
     
  15. Offline

    Astrophylite

    I added the packaged plugins (ProtocolLib, TabAPI and PermissionsEx) but still not working...

    EDIT: Checked console and there is no errors either... In /plugins everything is enabled and present.
     
  16. Offline

    teej107

    @_zircon_
    1. You should only package in your plugin files.
    2. Are you sure you are putting the plugin in the right directory and reloading/restarting?
     
  17. Offline

    Astrophylite

    1. I need to access TabAPI and PermissionsEx though?
    2. Yes, I am.
     
  18. Offline

    mcdorli

    Get it from the plugins list
     
  19. Offline

    Astrophylite

    Can you tell me how you would go about doing this?
     
  20. Offline

    teej107

    It depends on the IDE you are using but you can import jars so you can reference them while developing but you don't have to (and you shouldn't in this case) package them in the jar.
     
  21. Offline

    aTmAggies

    Make sure to do this in your main class if your onPlayerJoinEvent class is separate:
    This is what I personally use!

    http://pastebin.com/htTkdTwq

    And

    http://pastebin.com/cBfJMDAR
     
    Last edited: Feb 14, 2016
  22. Offline

    teej107

    Yeah the only thing you done right was registering the event.
     
  23. Offline

    Astrophylite

    Oh, nevermind, I do only reference them..

    You even replied to my post where I said, "I hate it when people spoonfeed." ;-;

    @teej107 If he's done that wrong and that's the way I do it, can you tell me what you think I should do?
     
  24. Offline

    MaTaMoR_

    The event is running ?
     
  25. Offline

    Astrophylite

    Nope. I just added a message to send the player their UUID but it doesn't get sent.. I've registered the event correctly so I don't know anymore ;-;
     
  26. Offline

    Xerox262

    @_zircon_ Your plugin actually enabling? Are there any errors when you join the server (Assuming the plugin loaded, else are there any errors about your plugin enabling)? Have you tried sending a message when the event runs to see if it's actually firing? Have you tried removing everything except for e.setJoinMessage(null); and testing like that then adding everything back when it works?
     
  27. Offline

    Astrophylite

    My plugin is enabling and there are no errors when I join the server. There are no errors at all. I've tried sending a message to the player with their UUID but it doesn't work. I am going to try to remove everything and add it all back 1 by 1.. I'll edit the post with the updates.

    EDIT: Nope, nothing worked ;-;
     
    Last edited: Feb 15, 2016
  28. Offline

    MaTaMoR_

    Try adding @Override on onEnable
     
    aTmAggies likes this.
  29. @MaTaMoR_
    Does @Override do anything? I've never used it before, but it doesn't seem to make a difference.
     
  30. Offline

    teej107

    It doesn't make a difference but it's still good to use incase you misspell the method or something.

    @_zircon_ Show us what you have packaged in your jar.
     
Thread Status:
Not open for further replies.

Share This Page