- Fix players who've just recently joined a town/nation/alliance not

being included in the town/nation/alliance chats.
This commit is contained in:
Llm Dl committed 2021-04-17 08:17:49 -05:00
1 parent cc12304b2e
commit 047b14f6ac
3 files changed
+21 -18

No files matched your search

+2 -1
View File
@@ -372,4 +372,5 @@ v0.87:
- Fix ranged global channels' chat being forwarded to dynmap.
- Fix UnsupportedOperationException which was possible when leaving a channel.
v0.88:
- Replace deprecated Essentials call.
- Replace deprecated Essentials call.
- Fix players who've just recently joined a town/nation/alliance not being included in the town/nation/alliance chats.
@@ -241,30 +241,35 @@ public class StandardChannel extends Channel {
* Compile a list of valid recipients for this message.
*
* @param sender
* @param list
* @param playerList
* @return Set containing a list of players for this message.
*/
private Set<Player> findRecipients(Player sender, List<Player> list) {
private Set<Player> findRecipients(Player sender, List<Player> playerList) {
Set<Player> recipients = new HashSet<>();
boolean bEssentials = plugin.getTowny().isEssentials();
// Compile the list of recipients
for (Player test : list) {
for (Player player : playerList) {
/*
* Refresh the potential channels a player can see.
*/
plugin.getChannelsHandler().getChannel(getType().name()).forgetPlayer(player);
/*
* If the player has the correct permission node.
*/
if (TownyUniverse.getInstance().getPermissionSource().has(test, getPermission())) {
if (TownyUniverse.getInstance().getPermissionSource().has(player, getPermission())) {
/*
* If the player is within range for this channel.
*/
if (testDistance(sender, test, getRange())){
if (testDistance(sender, player, getRange())){
if (bEssentials) {
try {
User targetUser = plugin.getTowny().getEssentials().getUser(test);
User targetUser = plugin.getTowny().getEssentials().getUser(player);
User senderUser = plugin.getTowny().getEssentials().getUser(sender);
/*
* Don't send this message if the user is ignored
@@ -279,11 +284,11 @@ public class StandardChannel extends Channel {
// Spy's can leave channels and we'll respect that
if (absentPlayers != null) {
// Ignore players who have left this channel
if (absentPlayers.containsKey(test.getName())) {
if (absentPlayers.containsKey(player.getName())) {
continue;
}
}
recipients.add(test);
recipients.add(player);
}
}
}
@@ -13,7 +13,6 @@ import com.palmergames.bukkit.towny.exceptions.TownyException;
import com.palmergames.bukkit.towny.object.Resident;
import com.palmergames.bukkit.towny.object.Translation;
import com.palmergames.bukkit.towny.TownyUniverse;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
@@ -43,9 +42,7 @@ public class TownyChatPlayerListener implements Listener {
}
private void loginPlayer(Player player) {
for (Channel channel : plugin.getChannelsHandler().getAllChannels().values()) {
channel.forgetPlayer(player);
}
refreshPlayerChannels(player);
Channel channel = plugin.getChannelsHandler().getDefaultChannel();
if (channel != null && player.hasPermission(channel.getPermission())) {
@@ -57,11 +54,11 @@ public class TownyChatPlayerListener implements Listener {
@EventHandler(priority = EventPriority.LOW)
public void onPlayerQuit(final PlayerQuitEvent event) {
for (Channel channel : plugin.getChannelsHandler().getAllChannels().values()) {
// If the channel is auto join, they will be added
// If the channel is not auto join, they will marked as absent
channel.forgetPlayer(event.getPlayer());
}
refreshPlayerChannels(event.getPlayer());
}
private void refreshPlayerChannels(Player player) {
plugin.getChannelsHandler().getAllChannels().values().stream().forEach(channel -> channel.forgetPlayer(player));
}
@EventHandler