diff --git a/src/changelog.txt b/src/changelog.txt index 55f746e..813d730 100644 --- a/src/changelog.txt +++ b/src/changelog.txt @@ -81,4 +81,5 @@ v0.14: v0.15: - Updated for the new Bukkit Event system. v0.16: - - Lowered event priorities to HIGH to allow other plugins the chance to beat us to the event and cancel. \ No newline at end of file + - Lowered event priorities to HIGH to allow other plugins the chance to beat us to the event and cancel. + - Fixed Op's with no default mode set using local chat. It will now try global, then world, then local in it's search order. \ No newline at end of file diff --git a/src/com/palmergames/bukkit/TownyChat/channels/ChannelsHolder.java b/src/com/palmergames/bukkit/TownyChat/channels/ChannelsHolder.java index 6ed25a0..cfb8984 100644 --- a/src/com/palmergames/bukkit/TownyChat/channels/ChannelsHolder.java +++ b/src/com/palmergames/bukkit/TownyChat/channels/ChannelsHolder.java @@ -82,17 +82,44 @@ public class ChannelsHolder { return null; } + + /** + * Find a channel we are able to talk in, starting with the greatest range. + * + * @param player + * @param type + * @return channel or null if none. + */ public Channel getChannel(Player player, channelTypes type) { + Channel local = null; + Channel global = null; + Channel world = null; + for (Channel channel: channels.values()) { if (channel.getType().equals(type)) { if (!plugin.getTowny().isPermissions() || (plugin.getTowny().isPermissions() && ((TownyUniverse.getPermissionSource().hasPermission(player, channel.getPermission())) - || (channel.getPermission().isEmpty())))) - return channel; - + || (channel.getPermission().isEmpty())))) { + if (channel.getRange() == -1) + global = channel; + else if (channel.getRange() == 0) + world = channel; + else + local = channel; + } } } + + if (global != null) + return global; + + if (world != null) + return world; + + if (local != null) + return local; + return null; }