package net.simpvp.Misc;

import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;

/**
 * Don't announce name changes for ops.
 */
public class AdminNameChange implements Listener {
	@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled=true)
	public void onPlayerJoin(PlayerJoinEvent event) {
		if (!event.getPlayer().isOp()) {
			return;
		}

		if (!event.getJoinMessage().matches("^.* \\(formerly known as .*$")) {
			return;
		}

		Misc.instance.getLogger().info("Removing name change info from: " + event.getJoinMessage());
		event.setJoinMessage(event.getJoinMessage().replaceFirst(" \\(formerly known as \\S+\\) ", " "));
	}
}

@@ -452,21 +452,28 @@
 %0A%09%09%7D%0A%0A%09%09
-if (!
+String jm = 
 event.ge
@@ -486,16 +486,63 @@
 essage()
+;%0A%09%09if (jm == null) %7B%0A%09%09%09return;%0A%09%09%7D%0A%0A%09%09if (!jm
 .matches
@@ -663,38 +663,18 @@
 om: %22 + 
-event.getJoinMessage()
+jm
 );%0A%09%09eve
@@ -691,38 +691,18 @@
 Message(
-event.getJoinMessage()
+jm
 .replace

Fix exception on empty join messages