mirror of
https://github.com/Aust1n46/VentureChat.git
synced 2025-05-23 10:39:05 +00:00
Tweaked how display names are passed and stored to work with other
nickname plugins.
This commit is contained in:
parent
fe4652fa7b
commit
8d913b6ce7
@ -703,6 +703,9 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener {
|
||||
String chat = msgin.readUTF();
|
||||
String consoleChat = format + chat;
|
||||
String globalJSON = msgin.readUTF();
|
||||
String primaryGroup = msgin.readUTF();
|
||||
String nickname = msgin.readUTF();
|
||||
System.out.println(nickname);
|
||||
|
||||
if(!ChatChannel.isChannel(chatchannel)) {
|
||||
return;
|
||||
@ -724,7 +727,7 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener {
|
||||
@Override
|
||||
public void run() {
|
||||
//Create VentureChatEvent
|
||||
VentureChatEvent ventureChatEvent = new VentureChatEvent(onlinePlayers.iterator().next(), chatChannelObject, recipients, format, chat, globalJSON, hash, false);
|
||||
VentureChatEvent ventureChatEvent = new VentureChatEvent(null, senderName, primaryGroup, chatChannelObject, recipients, format, chat, globalJSON, hash, false);
|
||||
//Fire event and wait for other plugin listeners to act on it
|
||||
Bukkit.getServer().getPluginManager().callEvent(ventureChatEvent);
|
||||
}
|
||||
|
@ -300,7 +300,7 @@ public class MineverseChatPlayer {
|
||||
}
|
||||
|
||||
public String getNickname() {
|
||||
return this.nickname;
|
||||
return this.online ? this.player.getDisplayName() : this.nickname;
|
||||
}
|
||||
|
||||
public void setNickname(String nick) {
|
||||
@ -326,7 +326,7 @@ public class MineverseChatPlayer {
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return online ? this.player : null;
|
||||
return this.online ? this.player : null;
|
||||
}
|
||||
|
||||
public boolean hasPlayed() {
|
||||
|
@ -18,6 +18,8 @@ import mineverse.Aust1n46.chat.channel.ChatChannel;
|
||||
public class VentureChatEvent extends Event {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private final MineverseChatPlayer mcp;
|
||||
private final String username;
|
||||
private final String playerPrimaryGroup;
|
||||
private final ChatChannel channel;
|
||||
private final Set<Player> recipients;
|
||||
private final String format;
|
||||
@ -26,21 +28,11 @@ public class VentureChatEvent extends Event {
|
||||
private final int hash;
|
||||
private final boolean bungee;
|
||||
|
||||
public VentureChatEvent(MineverseChatPlayer mcp, ChatChannel channel, Set<Player> recipients, String format, String chat, String globalJSON, int hash, 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) {
|
||||
super(MineverseChat.ASYNC);
|
||||
this.mcp = mcp;
|
||||
this.channel = channel;
|
||||
this.recipients = recipients;
|
||||
this.format = format;
|
||||
this.chat = chat;
|
||||
this.globalJSON = globalJSON;
|
||||
this.hash = hash;
|
||||
this.bungee = bungee;
|
||||
}
|
||||
|
||||
public VentureChatEvent(ChatChannel channel, Set<Player> recipients, String format, String chat, String globalJSON, int hash, boolean bungee) {
|
||||
super(MineverseChat.ASYNC);
|
||||
this.mcp = null;
|
||||
this.username = username;
|
||||
this.playerPrimaryGroup = playerPrimaryGroup;
|
||||
this.channel = channel;
|
||||
this.recipients = recipients;
|
||||
this.format = format;
|
||||
@ -54,6 +46,14 @@ public class VentureChatEvent extends Event {
|
||||
return this.mcp;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return this.username;
|
||||
}
|
||||
|
||||
public String getPlayerPrimaryGroup() {
|
||||
return this.playerPrimaryGroup;
|
||||
}
|
||||
|
||||
public ChatChannel getChannel() {
|
||||
return this.channel;
|
||||
}
|
||||
|
@ -160,6 +160,8 @@ public class MineverseChatBungee extends Plugin implements Listener {
|
||||
String format = in.readUTF();
|
||||
String chat = in.readUTF();
|
||||
String json = in.readUTF();
|
||||
String primaryGroup = in.readUTF();
|
||||
String nickname = in.readUTF();
|
||||
out.writeUTF("Chat");
|
||||
out.writeUTF(chatchannel);
|
||||
out.writeUTF(senderName);
|
||||
@ -168,6 +170,8 @@ public class MineverseChatBungee extends Plugin implements Listener {
|
||||
out.writeUTF(format);
|
||||
out.writeUTF(chat);
|
||||
out.writeUTF(json);
|
||||
out.writeUTF(primaryGroup);
|
||||
out.writeUTF(nickname);
|
||||
for(String send : getProxy().getServers().keySet()) {
|
||||
if(getProxy().getServers().get(send).getPlayers().size() > 0) {
|
||||
if(!bungeeToggle && !getProxy().getServers().get(send).getName().equalsIgnoreCase(ser.getInfo().getName())) {
|
||||
|
@ -456,7 +456,7 @@ public class ChatListener implements Listener {
|
||||
int hash = message.hashCode();
|
||||
|
||||
//Create VentureChatEvent
|
||||
VentureChatEvent ventureChatEvent = new VentureChatEvent(mcp, eventChannel, recipients, format, chat, globalJSON, hash, bungee);
|
||||
VentureChatEvent ventureChatEvent = new VentureChatEvent(mcp, mcp.getName(), MineverseChat.permission.getPrimaryGroup(mcp.getPlayer()), eventChannel, recipients, format, chat, globalJSON, hash, bungee);
|
||||
//Fire event and wait for other plugin listeners to act on it
|
||||
Bukkit.getServer().getPluginManager().callEvent(ventureChatEvent);
|
||||
//Call method to send the processed chat
|
||||
@ -522,6 +522,8 @@ public class ChatListener implements Listener {
|
||||
if(plugin.getConfig().getString("loglevel", "info").equals("debug")) {
|
||||
System.out.println(out.size() + " bytes size with json");
|
||||
}
|
||||
out.writeUTF(MineverseChat.permission.getPrimaryGroup(mcp.getPlayer()));
|
||||
out.writeUTF(mcp.getNickname());
|
||||
mcp.getPlayer().sendPluginMessage(plugin, MineverseChat.PLUGIN_MESSAGING_CHANNEL, byteOutStream.toByteArray());
|
||||
out.close();
|
||||
}
|
||||
|
@ -76,8 +76,8 @@ public class LoginListener implements Listener {
|
||||
mcp.setHasPlayed(false);
|
||||
MineverseChat.onlinePlayers.add(mcp);
|
||||
mcp.setJsonFormat();
|
||||
if(mcp.getNickname().equals(mcp.getName())) {
|
||||
mcp.setNickname(event.getPlayer().getName());
|
||||
if(!mcp.getPlayer().getDisplayName().equals(mcp.getName())) {
|
||||
mcp.setNickname(event.getPlayer().getDisplayName());
|
||||
}
|
||||
mcp.getPlayer().setDisplayName(Format.FormatStringAll(mcp.getNickname()));
|
||||
if(plugin.getConfig().getBoolean("nickname-in-tablist", false)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user