-
Notifications
You must be signed in to change notification settings - Fork 104
fix: group(rank) and renaming of some properties #676
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…. 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
| set => ReferenceHub.serverRoles.Permissions = (ulong)value; | ||
| set | ||
| { | ||
| ReferenceHub.serverRoles.Permissions = (ulong)value; | ||
| Group.Permissions = (ulong)value; | ||
| ReferenceHub.serverRoles.FinalizeSetGroup(); | ||
| } |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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}");
}
}
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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 was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
EXILED/Exiled.API/Features/Player.cs
Outdated
| public void SetRank(string name, UserGroup group) | ||
| public void SetGroup(string name, UserGroup group) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not needed breaking change
…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.
|
that look good to me |
|
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? |
There was a problem hiding this 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
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. |

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)
Does this PR introduce a breaking change? (What changes might users need to make in their application due to this PR?)
Other information:
Types of changes
Submission checklist
Patches (if there are any changes related to Harmony patches)
Other