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 chat = msgin.readUTF();
|
||||||
String consoleChat = format + chat;
|
String consoleChat = format + chat;
|
||||||
String globalJSON = msgin.readUTF();
|
String globalJSON = msgin.readUTF();
|
||||||
|
String primaryGroup = msgin.readUTF();
|
||||||
|
String nickname = msgin.readUTF();
|
||||||
|
System.out.println(nickname);
|
||||||
|
|
||||||
if(!ChatChannel.isChannel(chatchannel)) {
|
if(!ChatChannel.isChannel(chatchannel)) {
|
||||||
return;
|
return;
|
||||||
@ -724,7 +727,7 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
//Create VentureChatEvent
|
//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
|
//Fire event and wait for other plugin listeners to act on it
|
||||||
Bukkit.getServer().getPluginManager().callEvent(ventureChatEvent);
|
Bukkit.getServer().getPluginManager().callEvent(ventureChatEvent);
|
||||||
}
|
}
|
||||||
|
@ -300,7 +300,7 @@ public class MineverseChatPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getNickname() {
|
public String getNickname() {
|
||||||
return this.nickname;
|
return this.online ? this.player.getDisplayName() : this.nickname;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNickname(String nick) {
|
public void setNickname(String nick) {
|
||||||
@ -326,7 +326,7 @@ public class MineverseChatPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Player getPlayer() {
|
public Player getPlayer() {
|
||||||
return online ? this.player : null;
|
return this.online ? this.player : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasPlayed() {
|
public boolean hasPlayed() {
|
||||||
|
@ -18,6 +18,8 @@ import mineverse.Aust1n46.chat.channel.ChatChannel;
|
|||||||
public class VentureChatEvent extends Event {
|
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 playerPrimaryGroup;
|
||||||
private final ChatChannel channel;
|
private final ChatChannel channel;
|
||||||
private final Set<Player> recipients;
|
private final Set<Player> recipients;
|
||||||
private final String format;
|
private final String format;
|
||||||
@ -26,21 +28,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, 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);
|
super(MineverseChat.ASYNC);
|
||||||
this.mcp = mcp;
|
this.mcp = mcp;
|
||||||
this.channel = channel;
|
this.username = username;
|
||||||
this.recipients = recipients;
|
this.playerPrimaryGroup = playerPrimaryGroup;
|
||||||
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.channel = channel;
|
this.channel = channel;
|
||||||
this.recipients = recipients;
|
this.recipients = recipients;
|
||||||
this.format = format;
|
this.format = format;
|
||||||
@ -54,6 +46,14 @@ public class VentureChatEvent extends Event {
|
|||||||
return this.mcp;
|
return this.mcp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getUsername() {
|
||||||
|
return this.username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPlayerPrimaryGroup() {
|
||||||
|
return this.playerPrimaryGroup;
|
||||||
|
}
|
||||||
|
|
||||||
public ChatChannel getChannel() {
|
public ChatChannel getChannel() {
|
||||||
return this.channel;
|
return this.channel;
|
||||||
}
|
}
|
||||||
|
@ -160,6 +160,8 @@ public class MineverseChatBungee extends Plugin implements Listener {
|
|||||||
String format = in.readUTF();
|
String format = in.readUTF();
|
||||||
String chat = in.readUTF();
|
String chat = in.readUTF();
|
||||||
String json = in.readUTF();
|
String json = in.readUTF();
|
||||||
|
String primaryGroup = in.readUTF();
|
||||||
|
String nickname = in.readUTF();
|
||||||
out.writeUTF("Chat");
|
out.writeUTF("Chat");
|
||||||
out.writeUTF(chatchannel);
|
out.writeUTF(chatchannel);
|
||||||
out.writeUTF(senderName);
|
out.writeUTF(senderName);
|
||||||
@ -168,6 +170,8 @@ public class MineverseChatBungee extends Plugin implements Listener {
|
|||||||
out.writeUTF(format);
|
out.writeUTF(format);
|
||||||
out.writeUTF(chat);
|
out.writeUTF(chat);
|
||||||
out.writeUTF(json);
|
out.writeUTF(json);
|
||||||
|
out.writeUTF(primaryGroup);
|
||||||
|
out.writeUTF(nickname);
|
||||||
for(String send : getProxy().getServers().keySet()) {
|
for(String send : getProxy().getServers().keySet()) {
|
||||||
if(getProxy().getServers().get(send).getPlayers().size() > 0) {
|
if(getProxy().getServers().get(send).getPlayers().size() > 0) {
|
||||||
if(!bungeeToggle && !getProxy().getServers().get(send).getName().equalsIgnoreCase(ser.getInfo().getName())) {
|
if(!bungeeToggle && !getProxy().getServers().get(send).getName().equalsIgnoreCase(ser.getInfo().getName())) {
|
||||||
|
@ -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, 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
|
//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
|
||||||
@ -522,6 +522,8 @@ public class ChatListener implements Listener {
|
|||||||
if(plugin.getConfig().getString("loglevel", "info").equals("debug")) {
|
if(plugin.getConfig().getString("loglevel", "info").equals("debug")) {
|
||||||
System.out.println(out.size() + " bytes size with json");
|
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());
|
mcp.getPlayer().sendPluginMessage(plugin, MineverseChat.PLUGIN_MESSAGING_CHANNEL, byteOutStream.toByteArray());
|
||||||
out.close();
|
out.close();
|
||||||
}
|
}
|
||||||
|
@ -76,8 +76,8 @@ public class LoginListener implements Listener {
|
|||||||
mcp.setHasPlayed(false);
|
mcp.setHasPlayed(false);
|
||||||
MineverseChat.onlinePlayers.add(mcp);
|
MineverseChat.onlinePlayers.add(mcp);
|
||||||
mcp.setJsonFormat();
|
mcp.setJsonFormat();
|
||||||
if(mcp.getNickname().equals(mcp.getName())) {
|
if(!mcp.getPlayer().getDisplayName().equals(mcp.getName())) {
|
||||||
mcp.setNickname(event.getPlayer().getName());
|
mcp.setNickname(event.getPlayer().getDisplayName());
|
||||||
}
|
}
|
||||||
mcp.getPlayer().setDisplayName(Format.FormatStringAll(mcp.getNickname()));
|
mcp.getPlayer().setDisplayName(Format.FormatStringAll(mcp.getNickname()));
|
||||||
if(plugin.getConfig().getBoolean("nickname-in-tablist", false)) {
|
if(plugin.getConfig().getBoolean("nickname-in-tablist", false)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user