Skip to content

Conversation

@PUDGE133
Copy link

Description

Bug fixes and renaming of some properties to more understandable ones. We need to test this to make sure it doesn't cause problems, because God only knows how it all works internally.

What is the current behavior? (You can also link to an open issue here)

What is the new behavior? (if this is a feature change)

  • Now the SetGroup method of Player either finds an existing group and assigns it to the player, or creates a group based on UserGroup and also assigns it to the player. This method was also renamed to SetGroup.
  • The Player's RemoteAdminPermissions property now actually grants rights to the player and instantly determines access to the RA panel and permissions-related functionality.
  • Removed the useless setter for the GroupName property of Player.
  • Player's RankColor property has been renamed to BadgeColor.
  • Player's RankName property has been renamed to BadgeText.

Does this PR introduce a breaking change? (What changes might users need to make in their application due to this PR?)

  • Various renamings. One useless setter missing.

Other information:


Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentations

Submission checklist

  • I have checked the project can be compiled
  • I have tested my changes and it worked as expected

Patches (if there are any changes related to Harmony patches)

  • I have checked no IL patching errors in the console

Other

  • Still requires more testing

…. We need to test this to make sure it doesn't cause problems, because God only knows how it all works internally.

https://discord.com/channels/656673194693885975/1002713309876854924/1432873468285948055
@github-actions github-actions bot added the API label Oct 30, 2025
@PUDGE133 PUDGE133 changed the title Bug fixes with group(rank) and renaming of some properties fix: group(rank) and renaming of some properties Oct 30, 2025
Comment on lines 567 to 572
set => ReferenceHub.serverRoles.Permissions = (ulong)value;
set
{
ReferenceHub.serverRoles.Permissions = (ulong)value;
Group.Permissions = (ulong)value;
ReferenceHub.serverRoles.FinalizeSetGroup();
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would change the whole group permission not only the permissions for this player

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would change the whole group permission not only the permissions for this player

Yes, this does override the permissions for the entire group. But only if the player was assigned a group via "Player.SetRank." If we assign them a group via the "Player.Group" property, this problem doesn't occur. I spent three hours trying to reproduce this issue using the "Player.Group" property and various other manipulations, but I couldn't. However, the fact is: if you assign any permissions to a player using the current implementation of the "Player.RemoteAdminPermissions" property, they don't actually receive them. Access to the RA panel and other functionality are disabled.

Copy link
Author

@PUDGE133 PUDGE133 Oct 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked my code this way after your review. And I still couldn't figure out what was going on. Why does adding a group via a property work differently than via a method?

private void PlayerVerified(VerifiedEventArgs ev)
{
    //ev.Player.SetRank("free_tag", new UserGroup()
    //{
    //    Name = "free_tag",
    //    BadgeColor = "cyan",
    //    BadgeText = "adasda",
    //    Permissions = 0,
    //    Cover = true,
    //    HiddenByDefault = false,
    //    Shared = false,
    //    KickPower = 255,
    //    RequiredKickPower = 255,
    //});
    var group = new UserGroup()
    {
        Name = "free_tag",
        BadgeColor = "cyan",
        BadgeText = "adasda",
        Permissions = 0,
        Cover = true,
        HiddenByDefault = false,
        Shared = false,
        KickPower = 255,
        RequiredKickPower = 255,
    };
    ev.Player.Group = group;
    Log.Debug("");

    foreach (var e in ServerStatic.PermissionsHandler.Groups)
    {
        Log.Debug($"{e.Key} {e.Value.Name} {e.Value.BadgeColor} {e.Value.BadgeText} {e.Value.Permissions} {e.Value.Cover} {e.Value.HiddenByDefault} {e.Value.Shared} {e.Value.KickPower} {e.Value.RequiredKickPower}");
    }
    Log.Debug("");

    ev.Player.RemoteAdminPermissions = (PlayerPermissions)ulong.MaxValue;
    ev.Player.Group.Permissions = ulong.MaxValue;
    ev.Player.ReferenceHub.serverRoles.FinalizeSetGroup();

    foreach (var e in ServerStatic.PermissionsHandler.Groups)
    {
        Log.Debug($"{e.Key} {e.Value.Name} {e.Value.BadgeColor} {e.Value.BadgeText} {e.Value.Permissions} {e.Value.Cover} {e.Value.HiddenByDefault} {e.Value.Shared} {e.Value.KickPower} {e.Value.RequiredKickPower}");
    }
}
image

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe first try not having that event be async, while Exiled does support async events, that doesn’t mean your method will work, if anything in that method does anything with mirror somehow, it’ll probably kill the server or soft-dc the client. Also it can very easily cause other errors

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe first try not having that event be async, while Exiled does support async events, that doesn’t mean your method will work, if anything in that method does anything with mirror somehow, it’ll probably kill the server or soft-dc the client. Also it can very easily cause other errors

I don't really have a deep understanding of how this game works. If no one has any ideas on how to fix this, I might revert it back to its original state in the next commit.

public string GroupName
{
get => ServerStatic.PermissionsHandler.Members.TryGetValue(UserId, out string groupName) ? groupName : null;
set => ServerStatic.PermissionsHandler.Members[UserId] = value;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why removing this line ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why removing this line ?

There's no point in assigning anything to this dictionary. No functionality is called.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the setter doesn’t work then the getter won’t work. Is that not obvious? Also it’s a breaking change

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the setter doesn’t work then the getter won’t work. Is that not obvious? Also it’s a breaking change

The setter and getter functions work. This only makes sense if you want to retrieve the player's group name. Setting a value in this dictionary doesn't make sense because functionally nothing will change. The player's group will remain the same. This violates data integrity. You assign a group name to a player, but in fact, they don't have the properties of that group. This is literally the most obvious idea, immediately obvious.

Comment on lines 1922 to 1926
public void SetRank(string name, UserGroup group)
public void SetGroup(string name, UserGroup group)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed breaking change

PUDGE added 2 commits November 1, 2025 16:41
…ble ones. We need to test this to make sure it doesn't cause problems, because God only knows how it all works internally."

This reverts commit c72eabf.
@louis1706 louis1706 changed the base branch from master to dev November 1, 2025 17:17
@PUDGE133
Copy link
Author

PUDGE133 commented Nov 2, 2025

I wanted to create a new PR, but I messed something up and it ended up here. I was able to fix the "RemoteAdminPermissions" property. Now, when you assign new permissions to a player, they actually get them, and their group doesn't change globally.

private void PlayerVerified(VerifiedEventArgs ev)
{
    ev.Player.SetRank("free_tag", new UserGroup()
    {
        Name = "free_tag",
        BadgeColor = "cyan",
        BadgeText = "test",
        Permissions = 0,
        Cover = true,
        HiddenByDefault = false,
        Shared = false,
        KickPower = 255,
        RequiredKickPower = 255,
    });
    //ev.Player.Group = new UserGroup()
    //{
    //    Name = "free_tag",
    //    BadgeColor = "cyan",
    //    BadgeText = "test",
    //    Permissions = 0,
    //    Cover = true,
    //    HiddenByDefault = false,
    //    Shared = false,
    //    KickPower = 255,
    //    RequiredKickPower = 255,
    //};
    Log.Debug("");

    foreach (var e in ServerStatic.PermissionsHandler.Groups)
    {
        Log.Debug($"{e.Value.Name} {e.Value.Permissions}");
    }
    Log.Debug($"Player perms: {ev.Player.Group.Permissions}");
    Log.Debug("");

    ev.Player.RemoteAdminPermissions = (PlayerPermissions)ulong.MaxValue;
    // This line was causing the problem
    //ev.Player.Group.Permissions = ulong.MaxValue;
    ev.Player.ReferenceHub.serverRoles.FinalizeSetGroup();

    foreach (var e in ServerStatic.PermissionsHandler.Groups)
    {
        Log.Debug($"{e.Value.Name} {e.Value.Permissions}");
    }
    Log.Debug($"Player perms: {ev.Player.Group.Permissions}");
}
Снимок экрана 2025-11-02 031621

@louis1706
Copy link

louis1706 commented Nov 2, 2025

that look good to me

@Someone-193
Copy link
Collaborator

Maybe we could add null check so ppl can go SetRank("owner", null) for instance? And if there was no owner group the method would just return?

Copy link
Collaborator

@Someone-193 Someone-193 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ServerRoles::SetGroup does a null check so ignore my earlier comment

@PUDGE133
Copy link
Author

PUDGE133 commented Nov 2, 2025

ServerRoles::SetGroup does a null check so ignore my earlier comment

In general, it's better to check for Null before entering the SetGroup method. Firstly, we make the server's job a little easier. Secondly, we avoid calling PlayerEvents.OnGroupChanging when it's not necessary.

@louis1706 louis1706 merged commit 204b1cd into ExMod-Team:dev Nov 2, 2025
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants