@Listener(order = Order.PRE)
public void nick(MessageChannelEvent.Chat event) {
String plain = event.getRawMessage().toPlain();
Player player = event.getCause().first(Player.class).get();
if (plain.equals("NICK1")) {
DisplayNameData data = player.getDisplayNameData();
data.displayName().set(Text.of("TESTNICK"));
player.offer(data);
player.sendMessage(Text.of("Successfully set nick!"));
} else if (plain.equals("NICK2")) {
player.offer(Keys.DISPLAY_NAME, Text.of("TESTNICK2"));
player.sendMessage(Text.of("Successfully set nick!2"));
}
}
I got messages (when typing “NICK1” or “NICK2” to chat), but my display name not changed…
} else if (plain.equals("NICK2")) {
player.offer(Keys.DISPLAY_NAME, Text.of("TESTNICK2"));
player.sendMessage(Text.of("Successfully set nick!2"));
}
I got message, but display name do not changes…
Yes, I want change nickname over the head.
I joined the server from two accounts, in one account writed “NICK1” got message “Successfully set nick!” and checked my nickname over the head from second account, nothing changes. Same when I writed “NICK2”.
(Sorry for my bad English :-()
Setting name over head isn’t implemented yet because it isn’t something the server can’t do naturally. Sponge would need to do a “hack” (for lack of a better word) to make this work.