Skip to content

Commit

Permalink
refactor: change how to handle command args and custom channels
Browse files Browse the repository at this point in the history
  • Loading branch information
Boy0000 committed Jun 8, 2024
1 parent 725c733 commit d648d1e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ data class ChattyChannel(

ChannelType.PERMISSION -> audiences.addAll(onlinePlayers.filter { p -> p.hasPermission(permission) })
// Intended for Guilds etc., want to consider finding a non-permission way for this
ChannelType.PRIVATE -> audiences.add(player)
ChannelType.CUSTOM -> audiences.add(player)
}

// Add spying players
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,16 @@ object ChattyBrigadierCommands {
}
"channel" {
val channel by ChattyChannelArgument().suggests {
suggest(chatty.config.channels.entries
.filter {
it.value.permission.isEmpty() || context.source.sender.hasPermission(it.value.permission)
}.sortedBy {
suggest(chatty.config.channels.entries.asSequence()
.filter { it.value.channelType != ChannelType.CUSTOM }
.filter { it.value.permission.isEmpty() || context.source.sender.hasPermission(it.value.permission) }
.sortedBy {
it.key in setOf(defaultChannel().key, radiusChannel()?.key, adminChannel()?.key).filterNotNull()
}.map { it.key }
}.map { it.key }.toList()
)
}
playerExecutes {
swapChannel(player, channel())
if (channel()?.channelType != ChannelType.CUSTOM) swapChannel(player, channel())
}
}
"commandspy" {
Expand Down Expand Up @@ -258,7 +258,7 @@ object ChattyBrigadierCommands {
newChannel == null ->
player.sendFormattedMessage(chatty.messages.channels.noChannelWithName)

newChannel.permission.isNotBlank() && !player.hasPermission(newChannel.permission) ->
newChannel.channelType != ChannelType.CUSTOM && newChannel.permission.isNotBlank() && !player.hasPermission(newChannel.permission) ->
player.sendFormattedMessage(chatty.messages.channels.missingChannelPermission)

else -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ enum class ChannelType {
GLOBAL,
RADIUS,
PERMISSION,
PRIVATE
CUSTOM
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class ChattyProxyListener : PluginMessageListener {
ChannelType.GLOBAL -> onlinePlayers
ChannelType.RADIUS -> canSpy
ChannelType.PERMISSION -> onlinePlayers.filter { it.hasPermission(channel.permission) || it in canSpy }
ChannelType.PRIVATE -> onlinePlayers.filter {
ChannelType.CUSTOM -> onlinePlayers.filter {
it.toGeary().get<ChannelData>()?.withChannelVerified()?.channel == channel || it in canSpy
}
}.forEach { it.sendMessage(message) }
Expand Down

0 comments on commit d648d1e

Please sign in to comment.