mirror of
https://github.com/darksaid98/TownyChat.git
synced 2026-12-02 06:28:58 +00:00
Make previous ! support also handle servers that have set their default
channel to local/limited range.
This commit is contained in:
1 parent
0b705e4742
commit
a35961367e
2 files changed
+19
-4
No files matched your search
@@ -82,6 +82,19 @@ public class ChannelsHolder {
|
||||
*/
|
||||
public Channel getActiveChannel(Player player, channelTypes type) {
|
||||
|
||||
return getActiveChannel(player, type, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find a channel we are able to talk in, and have not left, starting with the greatest range.
|
||||
*
|
||||
* @param player
|
||||
* @param type
|
||||
* @param unlimitedRange true when a channel has to have an unlimited range.
|
||||
* @return channel or null if none.
|
||||
*/
|
||||
public Channel getActiveChannel(Player player, channelTypes type, boolean unlimitedRange) {
|
||||
|
||||
Channel local = null;
|
||||
Channel global = null;
|
||||
Channel world = null;
|
||||
@@ -89,8 +102,10 @@ public class ChannelsHolder {
|
||||
String name = player.getName();
|
||||
|
||||
// Return the defaultChan if it is the correct type, and the player is present in that channel.
|
||||
if (getDefaultChannel() != null && getDefaultChannel().isPresent(name) && getDefaultChannel().getType().equals(type))
|
||||
return getDefaultChannel();
|
||||
if (getDefaultChannel() != null && getDefaultChannel().isPresent(name) && getDefaultChannel().getType().equals(type)) {
|
||||
if (!unlimitedRange || getDefaultChannel().getRange() < 1)
|
||||
return getDefaultChannel();
|
||||
}
|
||||
|
||||
for (Channel channel: channels.values()) {
|
||||
if (!channel.isPresent(name)) continue;
|
||||
@@ -100,7 +115,7 @@ public class ChannelsHolder {
|
||||
global = channel;
|
||||
} else if (channel.getRange() == 0) {
|
||||
world = channel;
|
||||
} else
|
||||
} else if (!unlimitedRange)
|
||||
local = channel;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ public class TownyChatPlayerListener implements Listener {
|
||||
/*
|
||||
* Find a global channel this player has permissions for.
|
||||
*/
|
||||
channel = plugin.getChannelsHandler().getActiveChannel(player, channelTypes.GLOBAL);
|
||||
channel = plugin.getChannelsHandler().getActiveChannel(player, channelTypes.GLOBAL, forceGlobal);
|
||||
if (channel != null) {
|
||||
if (isMutedOrSpam(event, channel, player))
|
||||
return;
|
||||
|
||||
Reference in new issue
Block a user