Pass player display name over Bungee

This commit is contained in:
Aust1n46 2020-03-14 22:57:29 -04:00
parent 8d913b6ce7
commit e44dfe9f07
3 changed files with 9 additions and 4 deletions

View File

@ -705,7 +705,6 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener {
String globalJSON = msgin.readUTF(); String globalJSON = msgin.readUTF();
String primaryGroup = msgin.readUTF(); String primaryGroup = msgin.readUTF();
String nickname = msgin.readUTF(); String nickname = msgin.readUTF();
System.out.println(nickname);
if(!ChatChannel.isChannel(chatchannel)) { if(!ChatChannel.isChannel(chatchannel)) {
return; return;
@ -727,7 +726,7 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener {
@Override @Override
public void run() { public void run() {
//Create VentureChatEvent //Create VentureChatEvent
VentureChatEvent ventureChatEvent = new VentureChatEvent(null, senderName, primaryGroup, chatChannelObject, recipients, format, chat, globalJSON, hash, false); VentureChatEvent ventureChatEvent = new VentureChatEvent(null, senderName, nickname, primaryGroup, chatChannelObject, recipients, format, chat, globalJSON, hash, false);
//Fire event and wait for other plugin listeners to act on it //Fire event and wait for other plugin listeners to act on it
Bukkit.getServer().getPluginManager().callEvent(ventureChatEvent); Bukkit.getServer().getPluginManager().callEvent(ventureChatEvent);
} }

View File

@ -19,6 +19,7 @@ public class VentureChatEvent extends Event {
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
private final MineverseChatPlayer mcp; private final MineverseChatPlayer mcp;
private final String username; private final String username;
private final String nickname;
private final String playerPrimaryGroup; private final String playerPrimaryGroup;
private final ChatChannel channel; private final ChatChannel channel;
private final Set<Player> recipients; private final Set<Player> recipients;
@ -28,10 +29,11 @@ public class VentureChatEvent extends Event {
private final int hash; private final int hash;
private final boolean bungee; private final boolean bungee;
public VentureChatEvent(MineverseChatPlayer mcp, String username, String playerPrimaryGroup, ChatChannel channel, Set<Player> recipients, String format, String chat, String globalJSON, int hash, boolean bungee) { public VentureChatEvent(MineverseChatPlayer mcp, String username, String nickname, String playerPrimaryGroup, ChatChannel channel, Set<Player> recipients, String format, String chat, String globalJSON, int hash, boolean bungee) {
super(MineverseChat.ASYNC); super(MineverseChat.ASYNC);
this.mcp = mcp; this.mcp = mcp;
this.username = username; this.username = username;
this.nickname = nickname;
this.playerPrimaryGroup = playerPrimaryGroup; this.playerPrimaryGroup = playerPrimaryGroup;
this.channel = channel; this.channel = channel;
this.recipients = recipients; this.recipients = recipients;
@ -50,6 +52,10 @@ public class VentureChatEvent extends Event {
return this.username; return this.username;
} }
public String getNickname() {
return this.nickname;
}
public String getPlayerPrimaryGroup() { public String getPlayerPrimaryGroup() {
return this.playerPrimaryGroup; return this.playerPrimaryGroup;
} }

View File

@ -456,7 +456,7 @@ public class ChatListener implements Listener {
int hash = message.hashCode(); int hash = message.hashCode();
//Create VentureChatEvent //Create VentureChatEvent
VentureChatEvent ventureChatEvent = new VentureChatEvent(mcp, mcp.getName(), MineverseChat.permission.getPrimaryGroup(mcp.getPlayer()), eventChannel, recipients, format, chat, globalJSON, hash, bungee); VentureChatEvent ventureChatEvent = new VentureChatEvent(mcp, mcp.getName(), mcp.getNickname(), MineverseChat.permission.getPrimaryGroup(mcp.getPlayer()), eventChannel, recipients, format, chat, globalJSON, hash, bungee);
//Fire event and wait for other plugin listeners to act on it //Fire event and wait for other plugin listeners to act on it
Bukkit.getServer().getPluginManager().callEvent(ventureChatEvent); Bukkit.getServer().getPluginManager().callEvent(ventureChatEvent);
//Call method to send the processed chat //Call method to send the processed chat