Fix ignore in private message

This commit is contained in:
destro174 2021-08-23 11:56:31 +02:00
parent 3fd7bbfece
commit 250aeb5d16
4 changed files with 19 additions and 12 deletions

View File

@ -42,8 +42,8 @@ public class ChatHandler {
}
public void privateMessage(Player player, String target, String message) {
ChatUser user = ChatUserManager.getChatUser(player.getUniqueId());
user.setReplyTarget(target);
// ChatUser user = ChatUserManager.getChatUser(player.getUniqueId());
// user.setReplyTarget(target);
String updatedMessage = RegexManager.replaceText(player.getName(), player.getUniqueId(), message); // todo a better way for this
if(updatedMessage == null) {
GalaxyUtility.sendBlockedNotification("DM Language", player, message, target);

View File

@ -40,16 +40,17 @@ public class ChatListener implements Listener, ChatRenderer {
+ " tried to say: "
+ PlainComponentSerializer.plain().serialize(event.message()) + "</red>");
Bukkit.getOnlinePlayers().forEach(a ->{
if (a.hasPermission("chat.alert-blocked")) {
a.sendMessage(blockedNotification);//TODO make configurable (along with all the messages)
}
});
Bukkit.broadcast(blockedNotification, "chat.alert-blocked");
// Bukkit.getOnlinePlayers().forEach(a ->{
// if (a.hasPermission("chat.alert-blocked")) {
// a.sendMessage(blockedNotification);//TODO make configurable (along with all the messages)
// }
// });
return;
}
Player player = event.getPlayer();
ChatUser user = ChatUserManager.getChatUser(player.getUniqueId());
// ChatUser user = ChatUserManager.getChatUser(player.getUniqueId());
event.viewers().removeIf(audience -> audience instanceof Player receiver
&& ChatUserManager.getChatUser(receiver.getUniqueId()).getIgnoredPlayers().contains(player.getUniqueId()));

View File

@ -38,10 +38,12 @@ public class PluginMessage implements PluginMessageListener {
UUID uuid = UUID.fromString(in.readUTF());
String target = in.readUTF();
Player p = Bukkit.getPlayer(uuid);
String message = in.readUTF();
UUID targetuuid = UUID.fromString(in.readUTF());
if (p != null) {
ChatUser chatUser = ChatUserManager.getChatUser(uuid);
if (!chatUser.getIgnoredPlayers().contains(uuid)) {
p.sendMessage(GsonComponentSerializer.gson().deserialize(in.readUTF()));
if (!chatUser.getIgnoredPlayers().contains(targetuuid)) {
p.sendMessage(GsonComponentSerializer.gson().deserialize(message));
p.playSound(p.getLocation(), Sound.BLOCK_NOTE_BLOCK_BASS, 1, 1); // todo load this from config
ChatUser user = ChatUserManager.getChatUser(uuid);
user.setReplyTarget(target);
@ -53,10 +55,12 @@ public class PluginMessage implements PluginMessageListener {
UUID uuid = UUID.fromString(in.readUTF());
String target = in.readUTF();
Player p = Bukkit.getPlayer(uuid);
String message = in.readUTF();
UUID targetuuid = UUID.fromString(in.readUTF());
if (p != null) {
ChatUser chatUser = ChatUserManager.getChatUser(uuid);
if (!chatUser.getIgnoredPlayers().contains(uuid)) {
p.sendMessage(GsonComponentSerializer.gson().deserialize(in.readUTF()));
if (!chatUser.getIgnoredPlayers().contains(targetuuid)) {
p.sendMessage(GsonComponentSerializer.gson().deserialize(message));
ChatUser user = ChatUserManager.getChatUser(uuid);
user.setReplyTarget(target);
}

View File

@ -57,6 +57,7 @@ public class ChatHandler {
buf.writeUTF(player.getUniqueId().toString());
buf.writeUTF(player2.getUsername());
buf.writeUTF(GsonComponentSerializer.gson().serialize(component));
buf.writeUTF(player2.getUniqueId().toString());
serverConnection.sendPluginMessage(VelocityChat.getPlugin().getChannelIdentifier(), buf.toByteArray());
//redirect to the receiver
@ -67,6 +68,7 @@ public class ChatHandler {
buf.writeUTF(player2.getUniqueId().toString());
buf.writeUTF(player.getUsername());
buf.writeUTF(GsonComponentSerializer.gson().serialize(component));
buf.writeUTF(player.getUniqueId().toString());
serverConnection.sendPluginMessage(VelocityChat.getPlugin().getChannelIdentifier(), buf.toByteArray());
}