From 35a87dc3fcd0d33712a81e7a91affea592141c8a Mon Sep 17 00:00:00 2001 From: Sho Sakuma Date: Tue, 27 Jan 2026 18:52:51 +0900 Subject: refactor: Rename exception --- .../dev/m1sk9/lunaticChat/engine/chat/channel/Channel.kt | 5 +++++ .../engine/exception/ChannelCannotInviteSelfException.kt | 7 +++++++ .../exception/ChannelPlayerAlreadyBannedException.kt | 8 ++++++++ .../engine/exception/ChannelPlayerBannedException.kt | 8 ++++++++ .../engine/exception/ChannelPlayerBypassBanException.kt | 8 ++++++++ .../engine/exception/ChannelPlayerBypassKickException.kt | 8 ++++++++ .../ChannelPlayerMembershipLimitExceededException.kt | 10 ++++++++++ .../engine/exception/ChannelPlayerNotBannedException.kt | 8 ++++++++ .../exception/ChannelPrivateRequiresInvitationException.kt | 8 ++++++++ .../exception/PlayerChannelLimitExceededException.kt | 10 ---------- .../engine/permission/LunaticChatPermissionNode.kt | 14 +++++++++++++- 11 files changed, 83 insertions(+), 11 deletions(-) create mode 100644 engine/src/main/kotlin/dev/m1sk9/lunaticChat/engine/exception/ChannelCannotInviteSelfException.kt create mode 100644 engine/src/main/kotlin/dev/m1sk9/lunaticChat/engine/exception/ChannelPlayerAlreadyBannedException.kt create mode 100644 engine/src/main/kotlin/dev/m1sk9/lunaticChat/engine/exception/ChannelPlayerBannedException.kt create mode 100644 engine/src/main/kotlin/dev/m1sk9/lunaticChat/engine/exception/ChannelPlayerBypassBanException.kt create mode 100644 engine/src/main/kotlin/dev/m1sk9/lunaticChat/engine/exception/ChannelPlayerBypassKickException.kt create mode 100644 engine/src/main/kotlin/dev/m1sk9/lunaticChat/engine/exception/ChannelPlayerMembershipLimitExceededException.kt create mode 100644 engine/src/main/kotlin/dev/m1sk9/lunaticChat/engine/exception/ChannelPlayerNotBannedException.kt create mode 100644 engine/src/main/kotlin/dev/m1sk9/lunaticChat/engine/exception/ChannelPrivateRequiresInvitationException.kt delete mode 100644 engine/src/main/kotlin/dev/m1sk9/lunaticChat/engine/exception/PlayerChannelLimitExceededException.kt (limited to 'engine') diff --git a/engine/src/main/kotlin/dev/m1sk9/lunaticChat/engine/chat/channel/Channel.kt b/engine/src/main/kotlin/dev/m1sk9/lunaticChat/engine/chat/channel/Channel.kt index cc1f743..568839a 100644 --- a/engine/src/main/kotlin/dev/m1sk9/lunaticChat/engine/chat/channel/Channel.kt +++ b/engine/src/main/kotlin/dev/m1sk9/lunaticChat/engine/chat/channel/Channel.kt @@ -13,6 +13,7 @@ import java.util.UUID * @property isPrivate Indicates whether the channel is private or public. * @property ownerId UUID of the user who owns the channel. * @property createdAt Timestamp of when the channel was created. + * @property bannedPlayers Set of UUIDs of players who are banned from the channel. */ @Serializable data class Channel( @@ -23,6 +24,10 @@ data class Channel( @Serializable(with = UUIDSerializer::class) val ownerId: UUID, val createdAt: Long = System.currentTimeMillis(), + val bannedPlayers: Set< + @Serializable(with = UUIDSerializer::class) + UUID, + > = emptySet(), ) { init { require(id.matches(CHANNEL_ID_PATTERN)) { diff --git a/engine/src/main/kotlin/dev/m1sk9/lunaticChat/engine/exception/ChannelCannotInviteSelfException.kt b/engine/src/main/kotlin/dev/m1sk9/lunaticChat/engine/exception/ChannelCannotInviteSelfException.kt new file mode 100644 index 0000000..5d1be73 --- /dev/null +++ b/engine/src/main/kotlin/dev/m1sk9/lunaticChat/engine/exception/ChannelCannotInviteSelfException.kt @@ -0,0 +1,7 @@ +package dev.m1sk9.lunaticChat.engine.exception + +import java.util.UUID + +class ChannelCannotInviteSelfException( + playerId: UUID, +) : Exception("Player $playerId cannot invite themselves") diff --git a/engine/src/main/kotlin/dev/m1sk9/lunaticChat/engine/exception/ChannelPlayerAlreadyBannedException.kt b/engine/src/main/kotlin/dev/m1sk9/lunaticChat/engine/exception/ChannelPlayerAlreadyBannedException.kt new file mode 100644 index 0000000..ce905f0 --- /dev/null +++ b/engine/src/main/kotlin/dev/m1sk9/lunaticChat/engine/exception/ChannelPlayerAlreadyBannedException.kt @@ -0,0 +1,8 @@ +package dev.m1sk9.lunaticChat.engine.exception + +import java.util.UUID + +class ChannelPlayerAlreadyBannedException( + val playerId: UUID, + val channelId: String, +) : Exception("Player $playerId is already banned from channel $channelId") diff --git a/engine/src/main/kotlin/dev/m1sk9/lunaticChat/engine/exception/ChannelPlayerBannedException.kt b/engine/src/main/kotlin/dev/m1sk9/lunaticChat/engine/exception/ChannelPlayerBannedException.kt new file mode 100644 index 0000000..9a70c72 --- /dev/null +++ b/engine/src/main/kotlin/dev/m1sk9/lunaticChat/engine/exception/ChannelPlayerBannedException.kt @@ -0,0 +1,8 @@ +package dev.m1sk9.lunaticChat.engine.exception + +import java.util.UUID + +class ChannelPlayerBannedException( + playerId: UUID, + val channelId: String, +) : Exception("Player $playerId is banned from channel $channelId") diff --git a/engine/src/main/kotlin/dev/m1sk9/lunaticChat/engine/exception/ChannelPlayerBypassBanException.kt b/engine/src/main/kotlin/dev/m1sk9/lunaticChat/engine/exception/ChannelPlayerBypassBanException.kt new file mode 100644 index 0000000..529f590 --- /dev/null +++ b/engine/src/main/kotlin/dev/m1sk9/lunaticChat/engine/exception/ChannelPlayerBypassBanException.kt @@ -0,0 +1,8 @@ +package dev.m1sk9.lunaticChat.engine.exception + +import java.util.UUID + +class ChannelPlayerBypassBanException( + playerId: UUID, + val channelId: String, +) : Exception("Cannot ban player $playerId: player has bypass permission") diff --git a/engine/src/main/kotlin/dev/m1sk9/lunaticChat/engine/exception/ChannelPlayerBypassKickException.kt b/engine/src/main/kotlin/dev/m1sk9/lunaticChat/engine/exception/ChannelPlayerBypassKickException.kt new file mode 100644 index 0000000..e818657 --- /dev/null +++ b/engine/src/main/kotlin/dev/m1sk9/lunaticChat/engine/exception/ChannelPlayerBypassKickException.kt @@ -0,0 +1,8 @@ +package dev.m1sk9.lunaticChat.engine.exception + +import java.util.UUID + +class ChannelPlayerBypassKickException( + playerId: UUID, + val channelId: String, +) : Exception("Cannot kick player $playerId: player has bypass permission") diff --git a/engine/src/main/kotlin/dev/m1sk9/lunaticChat/engine/exception/ChannelPlayerMembershipLimitExceededException.kt b/engine/src/main/kotlin/dev/m1sk9/lunaticChat/engine/exception/ChannelPlayerMembershipLimitExceededException.kt new file mode 100644 index 0000000..afad6bf --- /dev/null +++ b/engine/src/main/kotlin/dev/m1sk9/lunaticChat/engine/exception/ChannelPlayerMembershipLimitExceededException.kt @@ -0,0 +1,10 @@ +package dev.m1sk9.lunaticChat.engine.exception + +import java.util.UUID + +class ChannelPlayerMembershipLimitExceededException( + val playerId: UUID, + val limit: Int, +) : Exception( + "Player $playerId has reached the maximum channel membership limit of $limit", + ) diff --git a/engine/src/main/kotlin/dev/m1sk9/lunaticChat/engine/exception/ChannelPlayerNotBannedException.kt b/engine/src/main/kotlin/dev/m1sk9/lunaticChat/engine/exception/ChannelPlayerNotBannedException.kt new file mode 100644 index 0000000..8dcc293 --- /dev/null +++ b/engine/src/main/kotlin/dev/m1sk9/lunaticChat/engine/exception/ChannelPlayerNotBannedException.kt @@ -0,0 +1,8 @@ +package dev.m1sk9.lunaticChat.engine.exception + +import java.util.UUID + +class ChannelPlayerNotBannedException( + playerId: UUID, + val channelId: String, +) : Exception("Player $playerId is not banned from channel $channelId") diff --git a/engine/src/main/kotlin/dev/m1sk9/lunaticChat/engine/exception/ChannelPrivateRequiresInvitationException.kt b/engine/src/main/kotlin/dev/m1sk9/lunaticChat/engine/exception/ChannelPrivateRequiresInvitationException.kt new file mode 100644 index 0000000..737a529 --- /dev/null +++ b/engine/src/main/kotlin/dev/m1sk9/lunaticChat/engine/exception/ChannelPrivateRequiresInvitationException.kt @@ -0,0 +1,8 @@ +package dev.m1sk9.lunaticChat.engine.exception + +import java.util.UUID + +class ChannelPrivateRequiresInvitationException( + val playerId: UUID, + val channelId: String, +) : Exception("Player $playerId cannot join private channel $channelId without invitation") diff --git a/engine/src/main/kotlin/dev/m1sk9/lunaticChat/engine/exception/PlayerChannelLimitExceededException.kt b/engine/src/main/kotlin/dev/m1sk9/lunaticChat/engine/exception/PlayerChannelLimitExceededException.kt deleted file mode 100644 index 0820d8c..0000000 --- a/engine/src/main/kotlin/dev/m1sk9/lunaticChat/engine/exception/PlayerChannelLimitExceededException.kt +++ /dev/null @@ -1,10 +0,0 @@ -package dev.m1sk9.lunaticChat.engine.exception - -import java.util.UUID - -class PlayerChannelLimitExceededException( - val playerId: UUID, - val limit: Int, -) : Exception( - "Player $playerId has reached the maximum channel membership limit of $limit", - ) diff --git a/engine/src/main/kotlin/dev/m1sk9/lunaticChat/engine/permission/LunaticChatPermissionNode.kt b/engine/src/main/kotlin/dev/m1sk9/lunaticChat/engine/permission/LunaticChatPermissionNode.kt index c20d636..9b6c3c6 100644 --- a/engine/src/main/kotlin/dev/m1sk9/lunaticChat/engine/permission/LunaticChatPermissionNode.kt +++ b/engine/src/main/kotlin/dev/m1sk9/lunaticChat/engine/permission/LunaticChatPermissionNode.kt @@ -31,6 +31,18 @@ sealed class LunaticChatPermissionNode( object ChannelDelete : LunaticChatPermissionNode("lunaticchat.command.lc.channel.delete") + object ChannelInvite : LunaticChatPermissionNode("lunaticchat.command.lc.channel.invite") + + object ChannelKick : LunaticChatPermissionNode("lunaticchat.command.lc.channel.kick") + + object ChannelBan : LunaticChatPermissionNode("lunaticchat.command.lc.channel.ban") + + object ChannelUnban : LunaticChatPermissionNode("lunaticchat.command.lc.channel.unban") + + object ChannelMod : LunaticChatPermissionNode("lunaticchat.command.lc.channel.mod") + + object ChannelOwnership : LunaticChatPermissionNode("lunaticchat.command.lc.channel.ownership") + object ChatMode : LunaticChatPermissionNode("lunaticchat.command.lc.chatmode") object ChatModeToggle : LunaticChatPermissionNode("lunaticchat.command.lc.chatmode.toggle") @@ -39,5 +51,5 @@ sealed class LunaticChatPermissionNode( object NoticeUpdate : LunaticChatPermissionNode("lunaticchat.noticeupdate") - object ChannelBypass: LunaticChatPermissionNode("lunaticchat.channelbypass") + object ChannelBypass : LunaticChatPermissionNode("lunaticchat.channelbypass") } -- cgit v1.2.1