Skip to content
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

[WIP] Access manager #47

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Conversation

Mistrick
Copy link
Collaborator

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):

image

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 not work as expected)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

@Amaroq7 Amaroq7 force-pushed the master branch 5 times, most recently from 477a2b1 to 43f5c4f Compare November 10, 2018 11:23
@Amaroq7 Amaroq7 force-pushed the master branch 2 times, most recently from cec1883 to cec02b1 Compare March 23, 2020 23:13
@Amaroq7
Copy link
Owner

Amaroq7 commented Mar 25, 2020

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.

@Mistrick
Copy link
Collaborator Author

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.

@Amaroq7 Amaroq7 force-pushed the master branch 5 times, most recently from 8ba0477 to 1765dad Compare October 24, 2020 22:38
@sonarcloud
Copy link

sonarcloud bot commented Oct 11, 2023

SonarCloud Quality Gate failed.    Quality Gate failed

Bug E 1 Bug
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell C 163 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

idea Catch issues before they fail your Quality Gate with our IDE extension sonarlint SonarLint

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants