Skip to content

Commit

Permalink
Fix speak and listen channel nodes not working. (#61)
Browse files Browse the repository at this point in the history
Channels with speak and listen nodes were falling back to the normal
channel permission node.

Also prevent players that end up in the final channel limbo also need to
be able to speak in the default channel.
  • Loading branch information
LlmDl authored Jan 11, 2025
1 parent 5b27163 commit d3abc3f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<groupId>com.palmergames.bukkit</groupId>
<artifactId>TownyChat</artifactId>
<packaging>jar</packaging>
<version>0.117</version>
<version>0.118</version>

<licenses>
<license>
Expand Down
4 changes: 2 additions & 2 deletions src/com/palmergames/bukkit/TownyChat/channels/Channel.java
Original file line number Diff line number Diff line change
Expand Up @@ -497,13 +497,13 @@ public boolean hasPermission(Player player) {

public boolean hasSpeakPermission(Player player) {
if (!hasSpeakPermission())
return hasPermission(player);
return true;
return TownyUniverse.getInstance().getPermissionSource().testPermission(player, getSpeakPermissionNode());
}

public boolean hasListenPermission(Player player) {
if (!hasListenPermission())
return hasPermission(player);
return true;
return TownyUniverse.getInstance().getPermissionSource().testPermission(player, getListenPermissionNode());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,13 @@ private void handleChatEvent(AsyncPlayerChatEvent event) {
* We found no channels available so modify the chat (if enabled) and exit.
*/
if (ChatSettings.isModify_chat()) {
Channel channel = plugin.getChannelsHandler().getDefaultChannel();
if (channel.hasSpeakPermission() && !channel.hasSpeakPermission(player)) {
event.setCancelled(true);
TownyMessaging.sendMessage(player, ChatSettings.getUsingAloneMessageString());
return;
}

Resident resident = TownyAPI.getInstance().getResident(player);
if (resident == null)
return;
Expand Down

0 comments on commit d3abc3f

Please sign in to comment.