Hello, I'm attempting to send a message to the player when they log in using a separate class for sending messages. Eclipse nor the server give out errors; the message just doesn't send. Within my main class for the plugin: Code: @EventHandler public void onPlayerJoin(PlayerJoinEvent event) { Player newplayer = event.getPlayer(); new ChatMessages().joinMessage(newplayer); } Within my class "ChatMessages" dedicated to sending out chat messages: Code: public class ChatMessages { public void joinMessage(Player receiver) { receiver.sendMessage("Test!"); } } As always, your help is greatly appreciated. Thanks all
try this OnPlayer Code: @EventHandler public void onPlayerJoin(PlayerJoinEvent event) { Player GetPlayer = event.getPlayer(); ChatMessages.joinMessage(GetPlayer); } Removed the "new" ChatMessage Code: public class ChatMessages { public static void joinMessage(Player receiver) { receiver.sendMessage("Test!"); } } Needed to add the "static" flag
Yuck static, though you seem to at least use it a bit correct. MattKan You probably forgot Code: Bukkit.getPluginManager().registerEvents(this, this) in onEnable. Also, don't forget to put Code: implements Listener after Code: public class YourMainClass extends JavaPlugin