Conversation
WalkthroughThis pull request introduces a framework for managing administrative permissions throughout the application. It adds a new Changes
Sequence Diagram(s)sequenceDiagram
participant GS as GameSession
participant CH as CommandHandler
participant CR as CommandRouter
GS->>CH: EnterServer calls RegisterCommands()
CH->>CR: Registers commands with permission checks
CR-->>CH: Returns allowed command list
sequenceDiagram
participant P as Player
participant CR as CommandRouter
participant APC as AdminPermissionCommand
P->>CR: Invoke command (e.g. set, remove, view permission)
CR->>P: Verify AdminPermissions
alt Sufficient Permission
CR->>APC: Execute subcommand logic
APC->>CR: Return result
CR->>P: Deliver confirmation message
else Insufficient Permission
CR->>P: Send unknown command notice
end
Possibly related PRs
Poem
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (8)
Maple2.Server.Game/Commands/DailyResetCommand.cs (1)
17-19: Consider adding error handling and feedbackThe command doesn't provide any feedback to the user when executed successfully, nor does it handle potential exceptions that might occur during the daily reset process.
Consider adding feedback and basic error handling:
private void Handle(InvocationContext ctx) { - session.DailyReset(); + try { + session.DailyReset(); + ctx.Console.WriteLine("Daily reset completed successfully."); + } catch (Exception ex) { + ctx.Console.WriteLine($"Error during daily reset: {ex.Message}"); + } }Maple2.Database/Model/Account.cs (1)
38-38: Consider adding a default value for Permissions.The
Permissionsproperty doesn't have a default value, which could potentially lead to null reference exceptions when converting to the model account.-public string Permissions { get; set; } +public string Permissions { get; set; } = AdminPermissions.None.ToString();Maple2.Model/Enum/Admin.cs (1)
81-81: Logical grouping of permissions for GameMaster role.The
GameMasterflag combines appropriate permissions for a game master:Warp,Ban,Alert,StringBoard,EventManagement, andPlayerCommands. This logical grouping simplifies permission assignment.Consider adding a comment explaining why these specific permissions are bundled together for the GameMaster role.
+// GameMaster role combines all permissions needed for in-game moderation and player assistance GameMaster = Warp | Ban | Alert | StringBoard | EventManagement | PlayerCommands,Maple2.Server.Game/Session/GameSession.cs (1)
177-177: Ensure re-registration logic is safe and idempotent.Re-registering commands after player initialization is a sound practice to synchronize permissions; however, consider verifying that repeated calls to
CommandHandler.RegisterCommands()won't cause performance degradation or potential concurrency conflicts if multiple sessions invoke or overlap this method.Maple2.Server.Game/Commands/CommandRouter.cs (2)
43-76: Streamline permission checks using patterns or attributes.The switch expression for permission checks here is helpful for readability. A few considerations:
_ => trueas a fallback might unintentionally allow new commands with no permissions set. Explicitly denying unknown commands might be safer.- Repeated “HasFlag” calls can be replaced with a dictionary-based or attribute-based approach if the list grows, potentially reducing duplication.
119-121: Optional: Provide feedback for empty command sets.Returning an empty string when no commands are available might be confusing for users. Consider returning a short “No commands are currently available.” message instead.
Maple2.Server.Game/Commands/AdminPermissionCommand.cs (2)
24-70: Refine permission-setting logic for broader scope.
- The
SetCommandonly searches the local field (session.Field.GetPlayers()), which might omit offline players or those in other fields. Confirm if the intent is to restrict admin changes only to currently active players in the same map.- After setting the flag, re-registering commands is apt, ensuring immediate effect.
173-190: Method for enumerating permission flags is clear.Skipping composite flags initially and then appending them at the bottom is a practical structure. Just ensure new composite flags remain excluded from the main loop.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (3)
Maple2.Server.World/Migrations/20250410190731_AdminPermissions.Designer.csis excluded by!Maple2.Server.World/Migrations/*Maple2.Server.World/Migrations/20250410190731_AdminPermissions.csis excluded by!Maple2.Server.World/Migrations/*Maple2.Server.World/Migrations/Ms2ContextModelSnapshot.csis excluded by!Maple2.Server.World/Migrations/*
📒 Files selected for processing (11)
Maple2.Database/Model/Account.cs(4 hunks)Maple2.Model/Enum/Admin.cs(2 hunks)Maple2.Model/Game/User/Account.cs(2 hunks)Maple2.Server.Game/Commands/AdminPermissionCommand.cs(1 hunks)Maple2.Server.Game/Commands/AlertCommand.cs(0 hunks)Maple2.Server.Game/Commands/CommandRouter.cs(3 hunks)Maple2.Server.Game/Commands/DailyResetCommand.cs(1 hunks)Maple2.Server.Game/Commands/PlayerCommand.cs(0 hunks)Maple2.Server.Game/Model/Field/Actor/FieldPlayer.cs(1 hunks)Maple2.Server.Game/Service/ChannelService.Admin.cs(1 hunks)Maple2.Server.Game/Session/GameSession.cs(1 hunks)
💤 Files with no reviewable changes (2)
- Maple2.Server.Game/Commands/AlertCommand.cs
- Maple2.Server.Game/Commands/PlayerCommand.cs
🧰 Additional context used
🧬 Code Graph Analysis (5)
Maple2.Server.Game/Commands/DailyResetCommand.cs (3)
Maple2.Server.Game/Session/GameSession.cs (4)
GameSession(37-805)GameSession(106-116)GameSession(698-698)DailyReset(602-618)Maple2.Server.Game/Commands/AlertCommand.cs (1)
Handle(33-56)Maple2.Server.Game/Commands/AdminPermissionCommand.cs (3)
Handle(39-69)Handle(87-121)Handle(136-170)
Maple2.Server.Game/Session/GameSession.cs (1)
Maple2.Server.Game/Commands/CommandRouter.cs (1)
RegisterCommands(39-81)
Maple2.Server.Game/Service/ChannelService.Admin.cs (2)
Maple2.Server.Core/Packets/NoticePacket.cs (1)
NoticePacket(9-77)Maple2.Server.Core/Network/Session.cs (1)
Disconnect(102-107)
Maple2.Model/Game/User/Account.cs (1)
Maple2.Database/Model/Account.cs (2)
Account(11-135)PrestigeMission(148-152)
Maple2.Server.Game/Commands/AdminPermissionCommand.cs (6)
Maple2.Server.Game/Session/GameSession.cs (3)
GameSession(37-805)GameSession(106-116)GameSession(698-698)Maple2.Server.Game/Model/Field/Actor/FieldPlayer.cs (2)
FieldPlayer(15-529)FieldPlayer(94-107)Maple2.Server.Game/Commands/CommandRouter.cs (1)
RegisterCommands(39-81)Maple2.Server.Core/Packets/NoticePacket.cs (1)
NoticePacket(9-77)Maple2.Database/Storage/Game/GameStorage.User.cs (1)
GetCharacterId(94-98)Maple2.Model/Game/User/Account.cs (2)
Account(5-40)Account(34-39)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: build
- GitHub Check: build
🔇 Additional comments (16)
Maple2.Server.Game/Service/ChannelService.Admin.cs (1)
32-39: Code block uses cleaner logical flow.This block correctly removes the Disconnect flag for sessions that meet the condition and sends a modified notice.
Maple2.Server.Game/Model/Field/Actor/FieldPlayer.cs (1)
87-90: Well-implemented permission property.The new
AdminPermissionsproperty provides a clean interface to access and modify admin permissions directly from theFieldPlayerclass. This follows good object-oriented design by delegating to the underlying Account object.Maple2.Database/Model/Account.cs (3)
3-3: Appropriate import for AdminPermissions enum.The added import is required for the enum type used in the conversion logic.
77-77: Proper string conversion from enum.This correctly stores the permissions as a string in the database model.
112-112: Robust parsing with fallback to None.The implementation correctly handles the conversion from string to enum with case-insensitive parsing and a fallback to
AdminPermissions.Noneif parsing fails, which is good defensive programming.Maple2.Model/Game/User/Account.cs (3)
1-2: Required enum import added correctly.The import is necessary for the new
AdminPermissionsproperty.
32-32: Good addition of AdminPermissions property.This property extends the Account model with admin permission capabilities, enabling role-based access control in the game.
38-38: Proper initialization to None by default.Setting the default value to
AdminPermissions.Noneensures that all accounts start with no special permissions, which is a security best practice.Maple2.Model/Enum/Admin.cs (1)
68-68: Adding None as the zero value is best practice.This follows the standard convention for flag enums to represent no flags being set.
Maple2.Server.Game/Commands/CommandRouter.cs (3)
7-9: Namespace imports are acceptable.These new namespace imports for
Maple2.Model.Enum,Maple2.Model.Game, andMaple2.Model.Metadataare logically correct given the permission checks and metadata references in the updated code.
103-107: Confirm restricting unknown commands to non-admin users aligns with intended design.The check prevents players without permissions from even seeing a “commands” listing. Confirm whether this is desired behavior or if you want to allow partial command disclosures for non-admin users.
108-111: Good approach for listing available commands.By displaying the command list here, you help admins discover command capabilities quickly. Ensure that unregistered or restricted commands do not appear in the output, which could mitigate confusion.
Maple2.Server.Game/Commands/AdminPermissionCommand.cs (4)
1-13: File-level overview.This new file introduces the
AdminPermissionCommandhierarchy for setting, removing, and viewing permissions. The namespaces and structure are consistent with the rest of the solution.
14-22: Constructor logic correctly aggregates subcommands.The constructor unifies "set", "remove", and "view" under the “perm” parent command. This is a clean approach to grouping admin-permission-related operations, improving discoverability.
72-122: Prevent partial removal of composite permissions.
- The inability to remove
AdminPermissions.Adminis enforced, but consider clarifying why “Admin” is treated as fully locked.- Similar to
SetCommand,RemoveCommandonly locates players in the current field, which might limit the command’s utility if you intend cross-field or offline modifications.
124-172: Database lookups for viewing permissions seem correct, but watch performance.Using
GetCharacterId()andGetOrFetch()fromGameStorageis logical; just ensure large-scale usage doesn’t cause performance bottlenecks. If frequent, consider caching or a unified approach for partial or offline lookups.
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (3)
Maple2.Server.Game/Commands/AdminPermissionCommand.cs (3)
65-69: Persist permission changes for future sessions.
Currently, permissions are updated in-memory only. If the intent is to persist changes, ensure that the modified permissions get saved in the underlying data store so that they remain across player re-logins or server restarts.
127-170: Consider restricting who can view other players’ permissions.
The “view” command exposes any player’s permissions without any guard. Ensure that only authorized users can retrieve this sensitive data if it’s intended to be confidential.
173-188: Improve composite flag handling inGetFlagsString.
Skipping composite flags in the main loop and appending them as an afterthought is workable, but consider a more descriptive approach—such as grouping base flags separately from combos—and clarifying any invariant that composite flags should never appear individually.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (3)
Maple2.Server.World/Migrations/20250404235104_RemoveSkillCooldown.csis excluded by!Maple2.Server.World/Migrations/*Maple2.Server.World/Migrations/20250406064924_DeathCount.csis excluded by!Maple2.Server.World/Migrations/*Maple2.Server.World/Migrations/20250410190731_AdminPermissions.csis excluded by!Maple2.Server.World/Migrations/*
📒 Files selected for processing (1)
Maple2.Server.Game/Commands/AdminPermissionCommand.cs(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
Maple2.Server.Game/Commands/AdminPermissionCommand.cs (5)
Maple2.Server.Game/Session/GameSession.cs (3)
GameSession(37-805)GameSession(106-116)GameSession(698-698)Maple2.Server.Game/Model/Field/Actor/FieldPlayer.cs (2)
FieldPlayer(15-529)FieldPlayer(94-107)Maple2.Server.Core/Packets/NoticePacket.cs (1)
NoticePacket(9-77)Maple2.Database/Storage/Game/GameStorage.User.cs (1)
GetCharacterId(94-98)Maple2.Model/Game/User/Account.cs (2)
Account(5-40)Account(34-39)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: build
- GitHub Check: build
There was a problem hiding this comment.
Actionable comments posted: 0
♻️ Duplicate comments (1)
Maple2.Server.Game/Commands/AdminPermissionCommand.cs (1)
73-122: Use bitwise checks for removing “Admin” permission.
You are comparingplayer.AdminPermissions == AdminPermissions.Adminat [114–117]. This is a known pitfall if the admin permission is combined with other flags.- if (player.AdminPermissions == AdminPermissions.Admin) { + if ((player.AdminPermissions & AdminPermissions.Admin) == AdminPermissions.Admin) { ctx.Console.Out.WriteLine($"Cannot remove admin permissions from {playerName}."); return; }
🧹 Nitpick comments (5)
Maple2.Server.Game/Commands/FindCommand.cs (1)
16-16: Consider renaming to avoid overshadowing the base field.
Definingpublic const AdminPermissions RequiredPermissioncan cause confusion because theGameCommandbase class also has aRequiredPermissionfield. To reduce ambiguity, consider using a unique constant name or removing the constant in favor of directly passing the enum value to the base constructor.- public const AdminPermissions RequiredPermission = AdminPermissions.Find; + private const AdminPermissions DefaultPermission = AdminPermissions.Find;Maple2.Server.Game/Commands/NpcCommand.cs (2)
17-17: Potential naming overlap with base.
Like inFindCommand, you might rename the constant to avoid overshadowing the base class’sRequiredPermissionfield.
61-61: Potential naming overlap.
Same caution regarding overshadowing the baseRequiredPermissionproperty.Maple2.Server.Game/Commands/AdminPermissionCommand.cs (1)
25-71: Setting permissions logic looks functional.
No major issues. However, be mindful that you’re retrieving the player only within the current field. If the target player is elsewhere or offline, this command won’t find them. That might be intended but worth confirming.Do you need help with handling offline or cross-field players?
Maple2.Server.Game/Commands/CommandRouter.cs (1)
108-113: Abstract GameCommand for permission-based commands is good.
Centralizing permissions inGameCommandis clean. However, be cautious about overshadowing theRequiredPermissionfield in derived classes with a same-named constant.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (22)
Maple2.Server.Game/Commands/AdminPermissionCommand.cs(1 hunks)Maple2.Server.Game/Commands/AlertCommand.cs(1 hunks)Maple2.Server.Game/Commands/BuffCommand.cs(1 hunks)Maple2.Server.Game/Commands/CommandRouter.cs(4 hunks)Maple2.Server.Game/Commands/CoordCommand.cs(1 hunks)Maple2.Server.Game/Commands/DailyResetCommand.cs(1 hunks)Maple2.Server.Game/Commands/DebugCommand.cs(1 hunks)Maple2.Server.Game/Commands/FieldCommand.cs(1 hunks)Maple2.Server.Game/Commands/FindCommand.cs(1 hunks)Maple2.Server.Game/Commands/FreeCamCommand.cs(1 hunks)Maple2.Server.Game/Commands/HomeCommand.cs(1 hunks)Maple2.Server.Game/Commands/ItemCommand.cs(1 hunks)Maple2.Server.Game/Commands/KillCommand.cs(1 hunks)Maple2.Server.Game/Commands/NpcCommand.cs(2 hunks)Maple2.Server.Game/Commands/PetCommand.cs(2 hunks)Maple2.Server.Game/Commands/PlayerCommand.cs(1 hunks)Maple2.Server.Game/Commands/QuestCommand.cs(1 hunks)Maple2.Server.Game/Commands/StringBoardCommand.cs(1 hunks)Maple2.Server.Game/Commands/TriggerCommand.cs(1 hunks)Maple2.Server.Game/Commands/TutorialCommand.cs(1 hunks)Maple2.Server.Game/Commands/WarpCommand.cs(2 hunks)Maple2.Server.Game/Program.cs(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- Maple2.Server.Game/Commands/DailyResetCommand.cs
🧰 Additional context used
🧬 Code Graph Analysis (14)
Maple2.Server.Game/Program.cs (1)
Maple2.Server.Game/Commands/CommandRouter.cs (2)
GameCommand(108-113)GameCommand(110-112)
Maple2.Server.Game/Commands/FieldCommand.cs (4)
Maple2.Server.Game/Commands/CommandRouter.cs (2)
GameCommand(108-113)GameCommand(110-112)Maple2.Server.Game/Session/GameSession.cs (3)
GameSession(37-805)GameSession(106-116)GameSession(698-698)Maple2.Server.Game/Session/GameSession.State.cs (1)
GameSession(12-60)Maple2.Database/Storage/Metadata/MapEntityStorage.cs (1)
MapEntityStorage(13-148)
Maple2.Server.Game/Commands/TutorialCommand.cs (3)
Maple2.Server.Game/Commands/CommandRouter.cs (2)
GameCommand(108-113)GameCommand(110-112)Maple2.Server.Game/Util/ItemStatsCalculator.cs (1)
ItemStatsCalculator(14-647)Maple2.Server.Game/Session/GameSession.cs (3)
GameSession(37-805)GameSession(106-116)GameSession(698-698)
Maple2.Server.Game/Commands/HomeCommand.cs (3)
Maple2.Server.Game/Commands/CommandRouter.cs (2)
GameCommand(108-113)GameCommand(110-112)Maple2.Server.Game/Session/GameSession.cs (3)
GameSession(37-805)GameSession(106-116)GameSession(698-698)Maple2.Database/Storage/Metadata/TableMetadataStorage.cs (2)
TableMetadataStorage(8-215)TableMetadataStorage(135-195)
Maple2.Server.Game/Commands/DebugCommand.cs (2)
Maple2.Server.Game/Commands/CommandRouter.cs (2)
GameCommand(108-113)GameCommand(110-112)Maple2.Server.Game/Session/GameSession.cs (3)
GameSession(37-805)GameSession(106-116)GameSession(698-698)
Maple2.Server.Game/Commands/CoordCommand.cs (2)
Maple2.Server.Game/Commands/CommandRouter.cs (2)
GameCommand(108-113)GameCommand(110-112)Maple2.Database/Storage/Metadata/MapMetadataStorage.cs (2)
MapMetadataStorage(12-95)MapMetadataStorage(19-26)
Maple2.Server.Game/Commands/AdminPermissionCommand.cs (6)
Maple2.Server.Game/Commands/CommandRouter.cs (2)
GameCommand(108-113)GameCommand(110-112)Maple2.Server.Game/Session/GameSession.cs (3)
GameSession(37-805)GameSession(106-116)GameSession(698-698)Maple2.Server.Game/Model/Field/Actor/FieldPlayer.cs (2)
FieldPlayer(15-529)FieldPlayer(94-107)Maple2.Server.Core/Packets/NoticePacket.cs (1)
NoticePacket(9-77)Maple2.Database/Storage/Game/GameStorage.User.cs (1)
GetCharacterId(94-98)Maple2.Model/Game/User/Account.cs (2)
Account(5-40)Account(34-39)
Maple2.Server.Game/Commands/FindCommand.cs (1)
Maple2.Server.Game/Commands/CommandRouter.cs (2)
GameCommand(108-113)GameCommand(110-112)
Maple2.Server.Game/Commands/NpcCommand.cs (3)
Maple2.Server.Game/Commands/CommandRouter.cs (2)
GameCommand(108-113)GameCommand(110-112)Maple2.Server.Game/Session/GameSession.cs (3)
GameSession(37-805)GameSession(106-116)GameSession(698-698)Maple2.Database/Storage/Metadata/NpcMetadataStorage.cs (2)
NpcMetadataStorage(11-90)NpcMetadataStorage(19-33)
Maple2.Server.Game/Commands/WarpCommand.cs (3)
Maple2.Server.Game/Commands/CommandRouter.cs (2)
GameCommand(108-113)GameCommand(110-112)Maple2.Server.Game/Session/GameSession.cs (3)
GameSession(37-805)GameSession(106-116)GameSession(698-698)Maple2.Database/Storage/Metadata/MapMetadataStorage.cs (2)
MapMetadataStorage(12-95)MapMetadataStorage(19-26)
Maple2.Server.Game/Commands/ItemCommand.cs (4)
Maple2.Database/Model/Item/Item.cs (1)
Maple2(99-145)Maple2.Server.Game/Commands/CommandRouter.cs (2)
GameCommand(108-113)GameCommand(110-112)Maple2.Server.Game/Session/GameSession.cs (3)
GameSession(37-805)GameSession(106-116)GameSession(698-698)Maple2.Database/Storage/Metadata/ItemMetadataStorage.cs (2)
ItemMetadataStorage(10-86)ItemMetadataStorage(16-22)
Maple2.Server.Game/Commands/PlayerCommand.cs (2)
Maple2.Server.Game/Commands/CommandRouter.cs (2)
GameCommand(108-113)GameCommand(110-112)Maple2.Server.Game/Session/GameSession.cs (3)
GameSession(37-805)GameSession(106-116)GameSession(698-698)
Maple2.Server.Game/Commands/BuffCommand.cs (3)
Maple2.Server.Game/Commands/CommandRouter.cs (2)
GameCommand(108-113)GameCommand(110-112)Maple2.Server.Game/Session/GameSession.cs (3)
GameSession(37-805)GameSession(106-116)GameSession(698-698)Maple2.Database/Storage/Metadata/SkillMetadataStorage.cs (2)
SkillMetadataStorage(11-81)SkillMetadataStorage(17-19)
Maple2.Server.Game/Commands/CommandRouter.cs (3)
Maple2.Server.Game/Session/GameSession.cs (3)
GameSession(37-805)GameSession(106-116)GameSession(698-698)Maple2.Server.Core/Packets/NoticePacket.cs (1)
NoticePacket(9-77)Maple2.Server.Game/Commands/GameConsole.cs (2)
Write(35-64)Write(68-75)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: build
- GitHub Check: build
🔇 Additional comments (68)
Maple2.Server.Game/Program.cs (1)
139-141: Command registration updated to useGameCommandwith permission handling.The modification changes the command registration to use
GameCommandinstead ofCommand, which aligns with the new admin permissions framework. The addition of!type.IsAbstractalso ensures that only concrete implementations are registered.This change correctly integrates with the
GameCommandabstract class (fromCommandRouter.cs) that now includes theRequiredPermissionproperty, enabling permission-based command execution. All commands inheriting from this class will now have proper permission checks.Maple2.Server.Game/Commands/KillCommand.cs (3)
15-15: Class inheritance updated to support permission systemThe class now inherits from
GameCommandinstead ofCommand, which enables the new admin permissions framework.
18-18: Clear permission requirement addedThe command now explicitly requires
AdminPermissions.GameMasterthrough a public constant. This improves security and establishes clear access control for the command.
20-20: Constructor updated to use permission systemThe constructor now passes the required permission to the base class constructor, completing the integration with the admin permissions framework.
Maple2.Server.Game/Commands/HomeCommand.cs (4)
4-4: Added required using directiveProper import for the
AdminPermissionsenum now that it's being used explicitly in this class.
11-11: Class inheritance updated to support permission systemThe class now inherits from
GameCommandinstead ofCommand, incorporating permission-based access control.
14-14: Debug permission requirement definedThe command now explicitly requires
AdminPermissions.Debug. This restricts access to users with debugging privileges only.
16-16: Constructor updated to use permission systemThe constructor now passes the required permission to the base class constructor, properly integrating with the admin permissions framework.
Maple2.Server.Game/Commands/AlertCommand.cs (3)
8-8: Class inheritance updated to support permission systemThe class now inherits from
GameCommandinstead ofCommand, enabling permission-based access control.
11-11: Alert permission requirement specifiedThe command now explicitly requires
AdminPermissions.Alert, creating a specific permission level for sending alerts to all users.
15-15: Constructor updated to use permission systemThe constructor now passes the required permission to the base class constructor, implementing the permission check.
Maple2.Server.Game/Commands/TutorialCommand.cs (4)
6-6: Added required using directiveProper import for the
AdminPermissionsenum that's now being used in this class.
14-14: Class inheritance updated to support permission systemThe class now inherits from
GameCommandinstead ofCommand, integrating with the permission framework.
17-17: Debug permission requirement specifiedThe command now requires
AdminPermissions.Debug, ensuring only users with debug privileges can access tutorial commands.
25-25: Constructor updated to use permission systemThe constructor now passes the required permission to the base class constructor, properly implementing the permission check.
Maple2.Server.Game/Commands/FieldCommand.cs (4)
5-5: Added necessary import for AdminPermissions enum.The addition of the Maple2.Model.Enum import is necessary to use the AdminPermissions enum, which supports the permission-based command framework.
12-12: Updated class inheritance to use GameCommand.The FieldCommand class now inherits from GameCommand instead of Command, which integrates it with the new permission management system.
15-15: Added required permission level for this command.This constant properly defines the permission level needed to execute the FieldCommand, setting it to Debug level which is appropriate for a command that displays field information.
21-21: Updated constructor to use the new permission parameter.The constructor now passes the required permission level to the GameCommand base class, ensuring proper permission checks during command execution.
Maple2.Server.Game/Commands/TriggerCommand.cs (4)
5-5: Added necessary import for AdminPermissions enum.The addition of the Maple2.Model.Enum import allows the use of the AdminPermissions enum, consistent with the new permission framework implementation.
13-13: Updated class inheritance to use GameCommand.TriggerCommand now inherits from GameCommand instead of Command, integrating it with the permission management system being implemented across command classes.
16-16: Added required permission level for this command.The RequiredPermission constant is set to AdminPermissions.Debug, which is appropriate for a command that manipulates map triggers and requires elevated privileges.
18-18: Updated constructor to use the new permission parameter.The constructor now properly passes the RequiredPermission constant to the GameCommand base class constructor, ensuring permission checks are applied when the command is executed.
Maple2.Server.Game/Commands/DebugCommand.cs (4)
13-13: Added necessary import for AdminPermissions enum.Added import for Maple2.Model.Enum namespace to access the AdminPermissions enum, ensuring consistent implementation of the permission system across command classes.
18-18: Updated class inheritance to use GameCommand.DebugCommand now inherits from GameCommand instead of Command, aligning with the new permission-based command framework being implemented.
21-21: Added required permission level for this command.The RequiredPermission constant is set to AdminPermissions.Debug, which is appropriate for a command that provides debug functionality and requires administrator privileges.
25-25: Updated constructor to use the new permission parameter.The constructor now passes the RequiredPermission constant to the GameCommand base class constructor, ensuring proper permission verification when the command is executed.
Maple2.Server.Game/Commands/PetCommand.cs (4)
6-6: Added necessary import for AdminPermissions enum.Added import for Maple2.Model.Enum namespace to access the AdminPermissions enum, consistent with the permission framework implementation.
15-15: Updated class inheritance to use GameCommand.PetCommand now inherits from GameCommand instead of Command, integrating it with the permission management system being implemented across the application.
18-18: Added appropriate permission level for this command.The RequiredPermission constant is set to AdminPermissions.SpawnItem, which is more specific than the Debug permission used in other commands and appropriate for a command that spawns in-game pets.
24-24: Updated constructor to use the new permission parameter.The constructor now passes the RequiredPermission constant to the GameCommand base class constructor, ensuring proper permission checks before allowing pet spawning.
Maple2.Server.Game/Commands/StringBoardCommand.cs (3)
11-11: Inheritance change looks good.The change from inheriting
CommandtoGameCommandaligns with the admin permissions framework being implemented.
14-14: Clear permission requirement definition.Good addition of the
RequiredPermissionconstant that explicitly defines the needed permission level for this command.
18-18: Constructor update properly implements permission checks.The base constructor call now correctly passes the required permission level as the first parameter.
Maple2.Server.Game/Commands/QuestCommand.cs (3)
12-12: Inheritance change looks good.Changing from
CommandtoGameCommandfollows the same pattern as other command classes in this PR.
15-15: Appropriate permission requirement.The
RequiredPermissionconstant is set toAdminPermissions.Quest, which makes sense for this command's functionality.
20-20: Constructor properly implements permission checks.The base constructor is now called with the required permission as the first parameter, consistent with other command changes.
Maple2.Server.Game/Commands/ItemCommand.cs (4)
6-6: Added necessary enum import.The import for
Maple2.Model.Enumis required for theAdminPermissionsenum.
14-14: Inheritance change follows permission framework pattern.The change from
CommandtoGameCommandis consistent with other command classes in this PR.
17-17: Appropriate permission requirement for item spawning.Setting
RequiredPermissiontoAdminPermissions.SpawnItemproperly restricts this powerful command.
25-25: Constructor updated to implement permission checks.The base constructor now receives the required permission as its first parameter, implementing the permission framework correctly.
Maple2.Server.Game/Commands/FreeCamCommand.cs (3)
10-10: Inheritance change follows permission framework pattern.The change from
CommandtoGameCommandis consistent with the other command classes in this PR.
13-13: Debug permission is appropriate for this feature.Setting
RequiredPermissiontoAdminPermissions.Debugis appropriate for a development/debugging tool like free camera.
17-17: Constructor properly implements permission checks.The base constructor now correctly receives the required permission as its first parameter.
Maple2.Server.Game/Commands/PlayerCommand.cs (1)
14-14: Well implemented permission framework forPlayerCommandThe code has been updated to use the new
GameCommandas the base class and correctly sets the required admin permission. This change aligns with the PR objective of introducing an admin permissions framework.Also applies to: 17-17, 19-19
Maple2.Server.Game/Commands/CoordCommand.cs (1)
7-7: Proper implementation of permission requirements forCoordCommandThe command has been updated to inherit from
GameCommandwith the appropriateAdminPermissions.Debugpermission level. The necessary import forMaple2.Model.Enumhas been added to access theAdminPermissionsenum.Also applies to: 14-14, 17-17, 22-22
Maple2.Server.Game/Commands/WarpCommand.cs (2)
21-21: Correctly implemented permissions forWarpCommandThe
WarpCommandclass now properly inherits fromGameCommandand requires theAdminPermissions.Warppermission level to execute, enhancing the security of map warping commands.Also applies to: 24-24, 29-29
61-61: Consistent permission implementation forGotoCommandThe
GotoCommandclass has been updated with the same permission level asWarpCommand, which is logical since both commands provide similar functionality. The implementation is consistent with the overall permission framework.Also applies to: 64-64, 66-66
Maple2.Server.Game/Commands/BuffCommand.cs (1)
5-5: Appropriate permission level forBuffCommandThe
BuffCommandclass now requiresAdminPermissions.GameMasterpermissions, which is a sensible choice given that adding buffs can significantly impact gameplay. The implementation follows the same pattern as other command classes in this PR.Also applies to: 13-13, 16-16, 21-21
Maple2.Server.Game/Commands/FindCommand.cs (3)
6-6: Import is appropriate.
The added importusing Maple2.Model.Enum;is necessary for referencingAdminPermissions.
13-13: Switch to GameCommand is consistent.
Inheriting fromGameCommandaligns with the new permission-based approach.
24-24: Base constructor usage looks good.
Passing the known permission, name, and description to theGameCommandconstructor is correct.Maple2.Server.Game/Commands/NpcCommand.cs (5)
6-6: Import is appropriate.
This import is required for theAdminPermissionsenum usage.
14-14: Transition to GameCommand is correct.
Aligns with the overall permission-based architecture.
22-22: Constructor signature is consistent.
Providing the permission constant first to theGameCommandbase constructor matches the project’s new standard.
58-58: Separate command for NPC animation is a good design.
Inheriting fromGameCommandensures this is also subject to permission checks.
66-66: Correct usage of base constructor.
This maintains consistency with the new permission requirements.Maple2.Server.Game/Commands/AdminPermissionCommand.cs (3)
14-23: Top-level command structure for admin permissions is effective.
The overall design to introduce subcommands for set, remove, and view is clean. However, ensure that separate subcommands don’t need distinct permission levels if narrower scoping is desired.
125-172: Viewing permissions works correctly.
This logic correctly shows the player’s stored permissions from the database. If future designs require checking whether the user is currently active, consider adding a presence check.
174-190: Flag listing is comprehensive.
Skipping composite permissions initially and adding them later is a neat approach.Maple2.Server.Game/Commands/CommandRouter.cs (8)
6-8: New using statements align with the updated permission model.
These references toMaple2.Model.Enum,Maple2.Model.Game, andMaple2.Server.Core.Packetsare essential for the new command structure.
15-16: Switching field types to GameCommand is consistent.
Replacing the oldCommandreferences withGameCommandensures that permission checks are centrally managed.
21-23: Collecting GameCommand instances is correct.
This properly resolves eachGameCommandvia dependency injection and aggregates them.
38-48: Registering commands based on flags is appropriate.
This filter ensures only commands matching the player’s admin flags are registered. If a user has multiple flags,HasFlagwill correctly allow any matching permission.
69-72: Command invocation is updated properly.
Switching toGameCommandand preserving arguments ensures no regression.
74-77: Validate partial or no permissions.
You’re checking forAdminPermissions.None, which suits a no-permission case. Additionally, limiting the “commands” listing to actual admin users (or a special case) prevents surfers from enumerating command usage.
79-81: Displaying command list only when appropriate.
If the user has zero permissions, you provide no command list. This meets the requirement that non-admins shouldn’t see restricted commands.
91-95: Defensive checks for empty command list.
This guard ensures the output remains clear if no commands are available for the user.
Summary by CodeRabbit