Idea:
Plugins using commands which depend on admin checks, currently don't have many options on working with admin functionality.
The Idea was to give Plugin developers more freedom on using admins by simplyfying that and extending the abilitys of the addon.dll.
General Features:
- Classes which derive from AdminPlugin get all features from the addon + the additional admin features
- seperated admin.cfg (autogenerated with admin-examples if the admin.cfg is missing)
Command Features:
- !admins (list the names of all admins)
- !addadmin <name> <xuid> (simply add a admin)
- !reloadadmins (if you edit the admin.cfg file while the server is still running, you can call this command to update the admin table)
Classes:
- ServerAdmin (Class which holds information of an admin, similar to ServerClient)
- Admin (Main Class holding the AdminPlugin Features)
ServerAdmin Functions:
- allowedToUse(command) Check if the admin is allowed to use the command
- isImmuneToCmd(command) Check if the admin is immun against the command
Admin Functions:
- LoadAdmins() loads the admin.cfg and initializes all admins
- GetAdmins() returns a list of ServerAdmins representing the admins defined in the admin.cfg
- GetAdminFromClient(ServerClient) returns the Admin-Information of the Client
- AddAdmin(name, xuid) add a new admin (which is also added in the admin.cfg)
- isAdmin(ServerClient) check if the client is a admin
- OnSayAfterAP(Message, ServerClient) this overrideable function is called after the AdminPlugin checked for admin related commands
- The OnSay Function is sealed inside the AdminPlugin to ensure that derived classes don't get the event before the AdminPlugin
Because i limit the usage of the AdminPlugin for derived classes only and sealing the OnSay Function, i ensure that AdminPlugin comes first regardless of the Plugin-Names.
Additional Information:
- the admin.cfg file is saved under admin\admin.cfg
- just make a derived project, start the server and run loadAdmins() to generate the default admin.cfg
Changelog:
- v0.1.1 Beta | initial release
Requirements:
- @Nukem's Server Addon v1.190+
Usage:
To Use the AdminPlugin, you have to set it as a reference in your Project.
This is a simple Example how to use my Plugin:
Plugins using commands which depend on admin checks, currently don't have many options on working with admin functionality.
The Idea was to give Plugin developers more freedom on using admins by simplyfying that and extending the abilitys of the addon.dll.
General Features:
- Classes which derive from AdminPlugin get all features from the addon + the additional admin features
- seperated admin.cfg (autogenerated with admin-examples if the admin.cfg is missing)
Command Features:
- !admins (list the names of all admins)
- !addadmin <name> <xuid> (simply add a admin)
- !reloadadmins (if you edit the admin.cfg file while the server is still running, you can call this command to update the admin table)
Classes:
- ServerAdmin (Class which holds information of an admin, similar to ServerClient)
- Admin (Main Class holding the AdminPlugin Features)
ServerAdmin Functions:
- allowedToUse(command) Check if the admin is allowed to use the command
- isImmuneToCmd(command) Check if the admin is immun against the command
Admin Functions:
- LoadAdmins() loads the admin.cfg and initializes all admins
- GetAdmins() returns a list of ServerAdmins representing the admins defined in the admin.cfg
- GetAdminFromClient(ServerClient) returns the Admin-Information of the Client
- AddAdmin(name, xuid) add a new admin (which is also added in the admin.cfg)
- isAdmin(ServerClient) check if the client is a admin
- OnSayAfterAP(Message, ServerClient) this overrideable function is called after the AdminPlugin checked for admin related commands
- The OnSay Function is sealed inside the AdminPlugin to ensure that derived classes don't get the event before the AdminPlugin
Because i limit the usage of the AdminPlugin for derived classes only and sealing the OnSay Function, i ensure that AdminPlugin comes first regardless of the Plugin-Names.
Additional Information:
- the admin.cfg file is saved under admin\admin.cfg
- just make a derived project, start the server and run loadAdmins() to generate the default admin.cfg
Changelog:
- v0.1.1 Beta | initial release
Requirements:
- @Nukem's Server Addon v1.190+
Usage:
To Use the AdminPlugin, you have to set it as a reference in your Project.
This is a simple Example how to use my Plugin:
Code:
using System;
using System.Collections.Generic;
using System.Text;
using AdminPlugin;
using Addon;
namespace TestPlugin
{
//Since the AdminPlugin derives from CPlugin,
//you only have to derive from AdminPlugin.Admin to call functions from both classes
public class Test : Admin
{
public override void OnServerLoad()
{
//Load the admin.cfg and initialize all admins
LoadAdmins();
ServerPrint("TestPlugin loaded.");
}
//This Function is called AFTER AdminPlugin checked the message for admin related commands
public override ChatType OnSayAfterAP(string Message, ServerClient Client)
{
//Check if the Message starts with an command and check if the client is a admin
if (Message.StartsWith("!") && isAdmin(Client))
{
//Get the ServerAdmin object representing the admin
ServerAdmin admin = GetAdminFromClient(Client);
//Simply check if the admin is allowed to use the command
if (admin.allowedToUse(Message.Split(' ')[0]))
{
TellClient(Client.ClientNum, "You are allowed to use this command.",true);
}
else
{
TellClient(Client.ClientNum, "You are not allowed to use this command.", true);
}
return ChatType.ChatNone;
}
else
return ChatType.ChatContinue;
}
}
}

