Skip to content

Commit

Permalink
Make /listchatchannels and joining a channel via match pattern proper…
Browse files Browse the repository at this point in the history
…ly check listeners, closes #387
  • Loading branch information
renbinden committed May 25, 2020
1 parent afbb436 commit f9b5208
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2017 Ross Binden
* Copyright 2020 Ren Binden
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -84,7 +84,8 @@ class ListChatChannelsCommand(private val plugin: RPKChatBukkit): CommandExecuto
}
messageComponents.add(chatChannelComponent)
} else if (matcher.group() == "\$mute") {
if (chatChannel.listenerMinecraftProfiles.contains(minecraftProfile)) {
if (chatChannel.listenerMinecraftProfiles.any { listenerMinecraftProfile ->
listenerMinecraftProfile.id == minecraftProfile.id }) {
val muteComponent = TextComponent("Mute")
muteComponent.clickEvent = ClickEvent(ClickEvent.Action.RUN_COMMAND, "/mute ${chatChannel.name}")
muteComponent.hoverEvent = HoverEvent(HoverEvent.Action.SHOW_TEXT, arrayOf(TextComponent("Click to mute ${chatChannel.name}")))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ class AsyncPlayerChatListener(private val plugin: RPKChatBukkit): Listener {
message = matcher.group(1)
}
}
if (!chatChannel.listenerMinecraftProfiles.contains(minecraftProfile)) {
if (!chatChannel.listenerMinecraftProfiles.any { listenerMinecraftProfile ->
listenerMinecraftProfile.id == minecraftProfile.id }) {
chatChannel.addListener(minecraftProfile, event.isAsynchronous)
chatChannelProvider.updateChatChannel(chatChannel, event.isAsynchronous)
}
Expand Down

0 comments on commit f9b5208

Please sign in to comment.