I have no idea why this won't work... Code (Text): @EventHandler public void onJoin(PlayerJoinEvent e) { Player p = e.getPlayer(); if (p.hasPermission("Quantum.newsletter")) { p.sendMessage("§8» &fThe &aApril &fnewletter is available to read. Use the command &a/newsletter&f to read!"); } }
check to see if event is actually firing (debug messages) once knowing event fires, make sure player has the permission specified
If you try to use /, java will read it as a special character. instead use // so it will ignore it *EDIT* sorry thats for \, ignore this
check if it's firing. Code (Java): @EventHandler public void onPlayerJoin(PlayerJoinEvent event) { System.out.println("event fired"); }
Well to add color to messages you need to either use the ChatColor enum or transalte the whole message to color using ChatColor.translateAlternateColor() (not sure about the exact name, but it takes a char as first parameter it beign the color code denominator & and then as second argument the String to translate)
register the event. ex: Code (Java): public class Main extends JavaPlugin { @Override public void onEnable() { getServer().getPluginManager().registerEvents(new ListenerClass(), this); } } public class ListenerClass implements Listener { @EventHandler public void onPlayerJoin(PlayerJoinEvent event) { Bukkit.getOnlinePlayers().stream().filter(Player::isOp).forEach(p -> p.sendMessage("you received a message since you were op!"); } }