SmartlyDressedGames / Unturned-3.x-Community

Community portion of the Unturned-3.x repo. If you have access to the source code you can find it here:
https://github.com/SmartlyDressedGames/Unturned-3.x/
85 stars 18 forks source link

Request to join Rocket Get All Permissions Group #3339

Closed hksz closed 1 year ago

hksz commented 2 years ago

RocketPermissionsHelper Add public List GetAllGroup() { return this.permissions.Instance.Groups; }

RocketPermissionsManager Add public List GetAllGroup() { return helper.GetAllGroup(); }

IRocketPermissionsProvider Add List GetAllGroup();

QERT2002 commented 2 years ago

Rocket is open source project, you can edit source code and bundle you own rocketmod:/

hksz commented 2 years ago

Rocket is open source project, you can edit source code and bundle you own rocketmod:/

I know it can be edited, but I would prefer Nelson Sexton to add this feature

rube200 commented 2 years ago

First, this repository is for Unturned and not LDM so you should ask it in the correct repository. Second you can obtain it using reflection.

hksz commented 2 years ago

First, this repository is for Unturned and not LDM so you should ask it in the correct repository. Second you can obtain it using reflection.

I've already asked a question on Legally Distinct Missile, but no one is paying attention to me I don't know much about reflexes, but I do now, thanks for your help!

hksz commented 1 year ago

Solutions

XMLFileAsset permissions = new XMLFileAsset(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Permissions.config.xml")); List groups = permissions.Instance.Groups;

hksz commented 1 year ago

Code replaced by the system? Use line 15 in RocketPermissionsHelperTest 屏幕截图 2022-10-18 213520

GazziFX commented 1 year ago

Solutions

XMLFileAsset permissions = new XMLFileAsset(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Permissions.config.xml")); List groups = permissions.Instance.Groups;

Might not be good idea as it wont update on permissions reload

hksz commented 1 year ago

Solutions XMLFileAsset permissions = new XMLFileAsset(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Permissions.config.xml")); List groups = permissions.Instance.Groups;

Might not be good idea as it wont update on permissions reload

It can be updated on reload, it will read the file in real time, and parsing XML may report an error if your changes are not completed.

hksz commented 1 year ago

Correction, replace Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Permissions.config.xml") with System.IO.Directory.GetCurrentDirectory() + "\Permissions.config.xml"

hksz commented 1 year ago

屏幕截图 2022-10-18 232435

rube200 commented 1 year ago

Why would u do that instead of using reflection

hksz commented 1 year ago

reflection

Because I still haven't figured out how to use

GazziFX commented 1 year ago
var helperField = typeof(RocketPermissionsManager).GetField("helper", BindingFlags.Instance | BindingFlags.NonPublic);
var helper = fieldInfo.GetValue(R.Permissions);
var permissionsField = helper.GetType().GetField("permissions", BindingFlags.Instance | BindingFlags.NonPublic);
var permissions = (Asset<RocketPermissions>)permissionsField.GetValue(helper);
hksz commented 1 year ago
var helperField = typeof(RocketPermissionsManager).GetField("helper", BindingFlags.Instance | BindingFlags.NonPublic);
var helper = fieldInfo.GetValue(R.Permissions);
var permissionsField = helper.GetType().GetField("permissions", BindingFlags.Instance | BindingFlags.NonPublic);
var permissions = (Asset<RocketPermissions>)permissionsField.GetValue(helper);

This is very useful, thank you very much!