SPMod
SPMod copied to clipboard
[WIP] Access manager
Description
Access manager
TODO:
- [ ] Attach system to commands
- [ ] Create interface?
Motivation and Context
How has this been tested?
#include <spmod>
public PluginInfo pluginInfo =
{
name = "test",
version = "0.0.0",
author = "author",
url = "https://github.com/Amaroq7/SPMod"
};
Group g;
public void OnPluginInit()
{
g = Group("test");
g.AttachPermission("one");
g.AttachPermission("two");
g.AttachPermission("three");
Command("^say /p1$", TestP1);
Command("^say /p2$", TestP2);
Command("^say /p3$", TestP3);
Command("^say /p4$", TestP4);
}
public PluginReturn TestP1(int client, Command cid)
{
Player p = view_as<Player>(client);
p.AttachGroup(g);
p.AttachPermission("four");
}
public PluginReturn TestP2(int client, Command cid)
{
Player p = view_as<Player>(client);
PrintToServer("client %d, has one[%d], two[%d], three[%d], four[%d]",
client,
p.HasAccess("one"),
p.HasAccess("two"),
p.HasAccess("three"),
p.HasAccess("four"))
}
public PluginReturn TestP3(int client, Command cid)
{
Player p = view_as<Player>(client);
p.RemovePermission("four");
}
public PluginReturn TestP4(int client, Command cid)
{
Player p = view_as<Player>(client);
p.RemoveGroup(g);
}
Screenshots (if appropriate):
Types of changes
- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
Checklist:
- [ ] My code follows the code style of this project.
- [x] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
I like the concept of groups and single permissions this gives us much more flexibility than flags.
I have a question, is there a possibility to exclude permissions for particular players? Let's say we have 2 players which belong to the same group f.e. admin
and we want one of them to have all permissions from the group except f.e. ban
.
I have a question, is there a possibility to exclude permissions for particular players? Let's say we have 2 players which belong to the same group f.e.
admin
and we want one of them to have all permissions from the group except f.e.ban
.
Yes, I try to do system based on sets. We can add member for exceptions and after union in PlayerRole::hasAccess
add complement with exceptions.
SonarCloud Quality Gate failed.
1 Bug
0 Vulnerabilities
0 Security Hotspots
163 Code Smells
No Coverage information
0.0% Duplication
Catch issues before they fail your Quality Gate with our IDE extension
SonarLint