Pleas help, stuppid questions, maybe..

Discussion in 'Plugin Development' started by Pystaon, Dec 8, 2019.

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

    Pystaon

    Hello! I am new in writing plugins, and don’t know much, but I’m learning a bit, in practice. Can you please answers for the next questions:

    1. Why does this class not work? (The game does not display a message, even if it is logged to me in the console, it does not appear).

    2. Is it possible to make the message appear only when the player first logs on to the server? Which event is responsible for this?

    Code:
    package joinplayers;
    
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.player.PlayerJoinEvent;
    import org.bukkit.event.player.PlayerQuitEvent;
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class Main extends JavaPlugin {
      
        /* Log for enable */
      
        public void onEnable() {
            getLogger().info("All god, plugin enabled. (^_^)");
        }
      
        /* Log for disable */
      
        public void onDisable() {
            getLogger().info("Plugin disabled. (~_~)");
          
        }
      
        /* Message for player join */
        @EventHandler
      
        public void onJoin(PlayerJoinEvent event) {
            event.setJoinMessage(event.getPlayer().getName() + ": Hello all!");
          
        }
      
        /* Message for player leave */
        @EventHandler
      
        public void onQuit(PlayerQuitEvent event) {
            event.setQuitMessage(event.getPlayer().getName() + ": Bye-bye all!");
        }
    
    }
    
    
     
    Last edited by a moderator: Dec 8, 2019
  2. Online

    timtower Administrator Administrator Moderator

    @Pystaon You did not register the class as listener.
    Player#hasPlayedBefore()
     
  3. Offline

    Strahan

    Also sending messages to indicate when a plugin is loaded or unloaded is not necessary; the server already does that so you are just cluttering the log. Plus it's all "good", not all "god" unless you mean to indicate your plugin is a deity ;)
     
    KarimAKL likes this.
Thread Status:
Not open for further replies.

Share This Page