mirror of
https://github.com/darksaid98/TownyChat.git
synced 2026-12-04 22:21:52 +00:00
- 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:
1 parent
cc12304b2e
commit
047b14f6ac
3 files changed
+21
-18
No files matched your search
@@ -372,4 +372,5 @@ v0.87:
|
|||||||
- Fix ranged global channels' chat being forwarded to dynmap.
|
- Fix ranged global channels' chat being forwarded to dynmap.
|
||||||
- Fix UnsupportedOperationException which was possible when leaving a channel.
|
- Fix UnsupportedOperationException which was possible when leaving a channel.
|
||||||
v0.88:
|
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.
|
* Compile a list of valid recipients for this message.
|
||||||
*
|
*
|
||||||
* @param sender
|
* @param sender
|
||||||
* @param list
|
* @param playerList
|
||||||
* @return Set containing a list of players for this message.
|
* @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<>();
|
Set<Player> recipients = new HashSet<>();
|
||||||
boolean bEssentials = plugin.getTowny().isEssentials();
|
boolean bEssentials = plugin.getTowny().isEssentials();
|
||||||
|
|
||||||
// Compile the list of recipients
|
// 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 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 the player is within range for this channel.
|
||||||
*/
|
*/
|
||||||
if (testDistance(sender, test, getRange())){
|
if (testDistance(sender, player, getRange())){
|
||||||
|
|
||||||
if (bEssentials) {
|
if (bEssentials) {
|
||||||
try {
|
try {
|
||||||
User targetUser = plugin.getTowny().getEssentials().getUser(test);
|
User targetUser = plugin.getTowny().getEssentials().getUser(player);
|
||||||
User senderUser = plugin.getTowny().getEssentials().getUser(sender);
|
User senderUser = plugin.getTowny().getEssentials().getUser(sender);
|
||||||
/*
|
/*
|
||||||
* Don't send this message if the user is ignored
|
* 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
|
// Spy's can leave channels and we'll respect that
|
||||||
if (absentPlayers != null) {
|
if (absentPlayers != null) {
|
||||||
// Ignore players who have left this channel
|
// Ignore players who have left this channel
|
||||||
if (absentPlayers.containsKey(test.getName())) {
|
if (absentPlayers.containsKey(player.getName())) {
|
||||||
continue;
|
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.Resident;
|
||||||
import com.palmergames.bukkit.towny.object.Translation;
|
import com.palmergames.bukkit.towny.object.Translation;
|
||||||
import com.palmergames.bukkit.towny.TownyUniverse;
|
import com.palmergames.bukkit.towny.TownyUniverse;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@@ -43,9 +42,7 @@ public class TownyChatPlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void loginPlayer(Player player) {
|
private void loginPlayer(Player player) {
|
||||||
for (Channel channel : plugin.getChannelsHandler().getAllChannels().values()) {
|
refreshPlayerChannels(player);
|
||||||
channel.forgetPlayer(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
Channel channel = plugin.getChannelsHandler().getDefaultChannel();
|
Channel channel = plugin.getChannelsHandler().getDefaultChannel();
|
||||||
if (channel != null && player.hasPermission(channel.getPermission())) {
|
if (channel != null && player.hasPermission(channel.getPermission())) {
|
||||||
@@ -57,11 +54,11 @@ public class TownyChatPlayerListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOW)
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
public void onPlayerQuit(final PlayerQuitEvent event) {
|
public void onPlayerQuit(final PlayerQuitEvent event) {
|
||||||
for (Channel channel : plugin.getChannelsHandler().getAllChannels().values()) {
|
refreshPlayerChannels(event.getPlayer());
|
||||||
// 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());
|
private void refreshPlayerChannels(Player player) {
|
||||||
}
|
plugin.getChannelsHandler().getAllChannels().values().stream().forEach(channel -> channel.forgetPlayer(player));
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
|||||||
Reference in new issue
Block a user