forked from SteamWar/SteamWar
Read global chat on fight servers after /chat global join
This commit is contained in:
@@ -75,8 +75,8 @@ public class ChatManager extends BasicListener {
|
||||
private static final Map<UUID, ChatChannel> defaults = new ConcurrentHashMap<>();
|
||||
private static final Map<UUID, String> persisted = new ConcurrentHashMap<>();
|
||||
private static final Set<UUID> globalOnArena = ConcurrentHashMap.newKeySet();
|
||||
// Players who wrote into the global chat on their current fight server and read it until they leave the server
|
||||
private static final Set<UUID> globalAfterWriting = ConcurrentHashMap.newKeySet();
|
||||
// Players reading the global chat on their current fight server until they leave it (after /global <text> or /chat global join)
|
||||
private static final Set<UUID> globalOnServer = ConcurrentHashMap.newKeySet();
|
||||
private static final Set<UUID> announced = ConcurrentHashMap.newKeySet();
|
||||
private static final Map<UUID, Set<RegisteredServer>> spies = new ConcurrentHashMap<>();
|
||||
private static final Map<UUID, Boolean> allArenas = new ConcurrentHashMap<>();
|
||||
@@ -162,7 +162,7 @@ public class ChatManager extends BasicListener {
|
||||
|
||||
static boolean readsGlobal(Player player) {
|
||||
UUID uuid = player.getUniqueId();
|
||||
return !currentServer(player).map(ChatManager::isArena).orElse(false) || globalOnArena.contains(uuid) || globalAfterWriting.contains(uuid);
|
||||
return !currentServer(player).map(ChatManager::isArena).orElse(false) || globalOnArena.contains(uuid) || globalOnServer.contains(uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -172,7 +172,7 @@ public class ChatManager extends BasicListener {
|
||||
if (!currentServer(player.getPlayer()).map(ChatManager::isArena).orElse(false)) return;
|
||||
if (!reads(player, global.persistId())) return;
|
||||
|
||||
if (globalAfterWriting.add(player.user().getUUID())) {
|
||||
if (globalOnServer.add(player.user().getUUID())) {
|
||||
player.system("CHAT_GLOBAL_AFTER_WRITING", global.tag(player));
|
||||
}
|
||||
}
|
||||
@@ -277,6 +277,9 @@ public class ChatManager extends BasicListener {
|
||||
if (hidden(uuid).remove(channel.persistId())) {
|
||||
saveHidden(uuid);
|
||||
}
|
||||
if (channel == global && currentServer(player.getPlayer()).map(ChatManager::isArena).orElse(false)) {
|
||||
globalOnServer.add(uuid);
|
||||
}
|
||||
player.system("CHAT_CHANNEL_JOINED", channel.tag(player));
|
||||
}
|
||||
|
||||
@@ -298,8 +301,8 @@ public class ChatManager extends BasicListener {
|
||||
return;
|
||||
}
|
||||
|
||||
// Leaving the global chat read after writing into it only ends that, it does not leave the global chat everywhere
|
||||
if (channel == global && globalAfterWriting.remove(uuid)) {
|
||||
// On fight servers leaving only stops reading the global chat on this server, it does not leave the global chat everywhere
|
||||
if (channel == global && globalOnServer.remove(uuid)) {
|
||||
player.system("CHAT_CHANNEL_LEFT", channel.tag(player));
|
||||
return;
|
||||
}
|
||||
@@ -478,7 +481,7 @@ public class ChatManager extends BasicListener {
|
||||
|
||||
UUID uuid = player.getUniqueId();
|
||||
globalOnArena.remove(uuid);
|
||||
globalAfterWriting.remove(uuid);
|
||||
globalOnServer.remove(uuid);
|
||||
|
||||
ChatChannel current = defaults.get(uuid);
|
||||
ChatChannel next;
|
||||
@@ -499,7 +502,7 @@ public class ChatManager extends BasicListener {
|
||||
defaults.remove(uuid);
|
||||
persisted.remove(uuid);
|
||||
globalOnArena.remove(uuid);
|
||||
globalAfterWriting.remove(uuid);
|
||||
globalOnServer.remove(uuid);
|
||||
announced.remove(uuid);
|
||||
spies.remove(uuid);
|
||||
allArenas.remove(uuid);
|
||||
|
||||
Reference in New Issue
Block a user