Overhauled permissions.

Overhauled permissions to use permission nodes, and separated some
permissions into smaller ones (such as cfg into tshock.cfg.maxspawns,
tshock.cfg.spawnrate, etc),
This commit is contained in:
MarioE 2013-09-23 18:53:36 -04:00
parent e0809427e0
commit e1531ab675
4 changed files with 228 additions and 143 deletions

View file

@ -165,7 +165,7 @@ namespace TShockAPI
add2(new Command(Permissions.rootonly, ManageUsers, "user") { DoLog = false });
add2(new Command(Permissions.canlogin, AttemptLogin, "login") { AllowServer = false, DoLog = false });
add2(new Command(Permissions.buff, Buff, "buff") { AllowServer = false });
add2(new Command(Permissions.cfg, SetSpawn, "setspawn") { AllowServer = false });
add2(new Command(Permissions.worldspawn, SetSpawn, "setspawn") { AllowServer = false });
add2(new Command(Permissions.grow, Grow, "grow") { AllowServer = false });
add2(new Command(Permissions.item, Item, "item", "i") { AllowServer = false });
add2(new Command(Permissions.home, Home, "home") { AllowServer = false });
@ -205,14 +205,14 @@ namespace TShockAPI
"additem", "additemgroup", "banitem", "delitem", "delitemgroup", "listitems", "listbanneditems", "unbanitem");
add(Permissions.manageregion, Region, "region");
add(Permissions.manageregion, DebugRegions, "debugreg");
add(Permissions.cfg, Reload, "reload");
add(Permissions.cfg, ServerPassword, "serverpassword");
add(Permissions.cfg, Save, "save");
add(Permissions.cfg, Settle, "settle");
add(Permissions.cfg, MaxSpawns, "maxspawns");
add(Permissions.cfg, SpawnRate, "spawnrate");
add(Permissions.cfgreload, Reload, "reload");
add(Permissions.cfgpassword, ServerPassword, "serverpassword");
add(Permissions.worldsave, Save, "save");
add(Permissions.worldsettle, Settle, "settle");
add(Permissions.cfgmaxspawns, MaxSpawns, "maxspawns");
add(Permissions.cfgspawnrate, SpawnRate, "spawnrate");
add(Permissions.time, Time, "time");
add(Permissions.pvpfun, Slap, "slap");
add(Permissions.slap, Slap, "slap");
add(Permissions.editspawn, ToggleAntiBuild, "antibuild");
add(Permissions.editspawn, ProtectSpawn, "protectspawn");
add(Permissions.maintenance, GetVersion, "version");
@ -225,7 +225,7 @@ namespace TShockAPI
add(Permissions.logs, DisplayLogs, "displaylogs");
add(Permissions.userinfo, GrabUserUserInfo, "userinfo", "ui");
add(Permissions.rootonly, AuthVerify, "auth-verify");
add(Permissions.cfg, Broadcast, "broadcast", "bc", "say");
add(Permissions.broadcast, Broadcast, "broadcast", "bc", "say");
add(Permissions.whisper, Whisper, "whisper", "w", "tell");
add(Permissions.whisper, Reply, "reply", "r");
add(Permissions.annoy, Annoy, "annoy");
@ -237,8 +237,8 @@ namespace TShockAPI
add(Permissions.buffplayer, GBuff, "gbuff", "buffplayer");
add(Permissions.hardmode, StartHardMode, "hardmode");
add(Permissions.hardmode, DisableHardMode, "stophardmode", "disablehardmode");
add(Permissions.cfg, ServerInfo, "stats");
add(Permissions.cfg, WorldInfo, "world");
add(Permissions.serverinfo, ServerInfo, "stats");
add(Permissions.worldinfo, WorldInfo, "world");
add(Permissions.savessi, SaveSSI, "savessi");
add(Permissions.savessi, OverrideSSI, "overridessi", "ossi");
add(Permissions.xmas, ForceXmas, "forcexmas");

View file

@ -65,12 +65,12 @@ namespace TShockAPI.DB
AddDefaultGroup("admin", "newadmin",
string.Join(",", Permissions.ban, Permissions.whitelist, Permissions.causeevents, Permissions.spawnboss,
Permissions.spawnmob, Permissions.managewarp, Permissions.time, Permissions.tp, Permissions.pvpfun,
Permissions.spawnmob, Permissions.managewarp, Permissions.time, Permissions.tp, Permissions.slap,
Permissions.kill, Permissions.logs,
Permissions.immunetokick, Permissions.tphere));
AddDefaultGroup("trustedadmin", "admin",
string.Join(",", Permissions.maintenance, Permissions.cfg, Permissions.butcher, Permissions.item,
string.Join(",", Permissions.maintenance, "tshock.cfg.*", "tshock.world.*", Permissions.butcher, Permissions.item,
Permissions.heal, Permissions.immunetoban, Permissions.usebanneditem));
AddDefaultGroup("vip", "default", string.Join(",", Permissions.reservedslot));

View file

@ -27,163 +27,253 @@ namespace TShockAPI
{
public static class Permissions
{
//Permissions with blank descriptions basically means its described by the commands it gives access to.
// tshock.account nodes
[Description("Allows player to get user info")] public static readonly string userinfo;
[Description("User can register account in game")]
public static readonly string canregister = "tshock.account.register";
[Description("")] public static readonly string causeevents;
[Description("User can login in game")]
public static readonly string canlogin = "tshock.account.login";
[Description("Required to be able to build (modify tiles and liquid)")] public static readonly string canbuild;
[Description("User can change password in game")]
public static readonly string canchangepassword = "tshock.account.changepassword";
[Description("")] public static readonly string kill;
// tshock.admin nodes
[Description("Allows you to use banned items")] public static readonly string usebanneditem;
[Description("Prevents you from being kicked.")]
public static readonly string immunetokick = "tshock.admin.nokick";
[Description("Allows you to edit the spawn")] public static readonly string editspawn;
[Description("Prevents you from being banned.")]
public static readonly string immunetoban = "tshock.admin.noban";
[Description("Prevents you from being kicked")] public static readonly string immunetokick;
[Description("Specific log messages are sent to users with this permission.")]
public static readonly string logs = "tshock.admin.viewlogs";
[Description("Prevents you from being banned")] public static readonly string immunetoban;
[Description("User can kick others.")]
public static readonly string kick = "tshock.admin.kick";
[Description("Prevents you from being reverted by kill tile abuse detection")] public static readonly string
ignorekilltiledetection;
[Description("User can ban others.")]
public static readonly string ban = "tshock.admin.ban";
[Description("Prevents you from being reverted by place tile abuse detection")] public static readonly string
ignoreplacetiledetection;
[Description("User can manage warps.")]
public static readonly string managewarp = "tshock.admin.warp";
[Description("Prevents you from being disabled by liquid set abuse detection")] public static readonly string
ignoreliquidsetdetection;
[Description("User can manage item bans.")]
public static readonly string manageitem = "tshock.admin.itemban";
[Description("Prevents you from being disabled by liquid set abuse detection")] public static readonly string
ignoreprojectiledetection;
[Description("User can manage groups.")]
public static readonly string managegroup = "tshock.admin.group";
[Description("Prevents you from being reverted by no clip detection")] public static readonly string
ignorenoclipdetection;
[Description("User can manage regions.")]
public static readonly string manageregion = "tshock.admin.region";
[Description("Prevents you from being disabled by stack hack detection")] public static readonly string
ignorestackhackdetection;
[Description("Prevents you from being kicked by hacked health detection")] public static readonly string
ignorestathackdetection;
[Description("Prevents your actions from being ignored if damage is too high")] public static readonly string
ignoredamagecap;
[Description("Specific log messages are sent to users with this permission")] public static readonly string logs;
[Description("Allows you to bypass the max slots for up to 5 slots above your max")] public static readonly string
reservedslot;
[Description("User is notified when an update is available, user can turn off / restart the server.")] public static readonly string maintenance;
[Description("User can kick others")] public static readonly string kick;
[Description("User can ban others")] public static readonly string ban;
[Description("User can modify the whitelist")] public static readonly string whitelist;
[Description("User can spawn bosses")] public static readonly string spawnboss;
[Description("User can spawn npcs")] public static readonly string spawnmob;
[Description("User can teleport")] public static readonly string tp;
[Description("User can teleport people to them")] public static readonly string tphere;
[Description("User can use warps")] public static readonly string warp;
[Description("User can manage warps")] public static readonly string managewarp;
[Description("User can manage item bans")] public static readonly string manageitem;
[Description("User can manage groups")] public static readonly string managegroup;
[Description("User can edit sevrer configurations")] public static readonly string cfg;
[Description("")] public static readonly string time;
[Description("")] public static readonly string pvpfun;
[Description("User can edit regions")] public static readonly string manageregion;
[Description("Meant for super admins only")] public static readonly string rootonly;
[Description("User can whisper to others")] public static readonly string whisper;
[Description("")] public static readonly string annoy;
[Description("User can kill all enemy npcs")] public static readonly string butcher;
[Description("User can spawn items")] public static readonly string item;
[Description("User can clear item drops.")] public static readonly string clearitems;
[Description("")] public static readonly string heal;
[Description("User can buff self")] public static readonly string buff;
[Description("User can buff other players")] public static readonly string buffplayer;
[Description("")] public static readonly string grow;
[Description("User can change hardmode state.")] public static readonly string hardmode;
[Description("User can change the homes of NPCs.")] public static readonly string movenpc;
[Description("Users can stop people from teleporting to them")] public static readonly string tpallow;
[Description("Users can tp to anyone")] public static readonly string tpall;
[Description("Users can tp to people without showing a notice")] public static readonly string tphide;
[Description("User can convert hallow into corruption and vice-versa")] public static readonly string converthardmode;
[Description("User can mute and unmute users")] public static readonly string mute;
[Description("User can register account in game")] public static readonly string canregister;
[Description("User can login in game")] public static readonly string canlogin;
[Description("User can change password in game")] public static readonly string canchangepassword;
[Description("User can use party chat in game")] public static readonly string canpartychat;
[Description("User can talk in third person")] public static readonly string cantalkinthird;
[Description("Bypass server side inventory checks")] public static readonly string bypassinventorychecks;
[Description("Allow unrestricted SendTileSquare usage, for client side world editing.")] public static readonly
string allowclientsideworldedit;
[Description("User can summon bosses using items")]
public static readonly string summonboss;
[Description("User can start invasions (Goblin/Snow Legion) using items")]
public static readonly string startinvasion;
[Description("User can mute and unmute users")]
public static readonly string mute = "tshock.admin.mute";
[Description("User can see the id of players with /who")]
public static readonly string seeids;
public static readonly string seeids = "tshock.admin.seeplayerids";
[Description("User can save all the players SSI state.")]
public static readonly string savessi;
public static readonly string savessi = "tshock.admin.savessi";
[Description("User can force the server to Christmas mode.")] public static readonly string xmas;
[Description("User can elevate other users' groups temporarily.")]
public static readonly string settempgroup = "tshock.admin.tempgroup";
[Description("User can use /home.")] public static readonly string home;
[Description("User can broadcast messages.")]
public static readonly string broadcast = "tshock.admin.broadcast";
[Description("User can use /spawn.")] public static readonly string spawn;
[Description("User can get other users' info.")]
public static readonly string userinfo = "tshock.admin.userinfo";
[Description("User can elevate other users' groups temporarily.")] public static readonly string settempgroup;
// tshock.buff nodes
[Description("User can download updates to plugins that are currently running.")] public static readonly string updateplugins;
[Description("User can buff self.")]
public static readonly string buff = "tshock.buff.self";
static Permissions()
{
foreach (var field in typeof (Permissions).GetFields())
{
field.SetValue(null, String.Format("tshock.{0}", field.Name));
}
}
[Description("User can buff other players.")]
public static readonly string buffplayer = "tshock.buff.others";
// tshock.cfg nodes
[Description("User is notified when an update is available, user can turn off / restart the server.")]
public static readonly string maintenance = "tshock.cfg.maintenance";
[Description("User can modify the whitelist.")]
public static readonly string whitelist = "tshock.cfg.whitelist";
[Description("User can edit the server password.")]
public static readonly string cfgpassword = "tshock.cfg.password";
[Description("User can reload the configurations file.")]
public static readonly string cfgreload = "tshock.cfg.reload";
[Description("User can edit the max spawns.")]
public static readonly string cfgmaxspawns = "tshock.cfg.maxspawns";
[Description("User can edit the spawnrate.")]
public static readonly string cfgspawnrate = "tshock.cfg.spawnrate";
[Description("User can download updates to plugins that are currently running.")]
public static readonly string updateplugins = "tshock.cfg.updateplugins";
// tshock.ignore nodes
[Description("Prevents you from being reverted by kill tile abuse detection.")]
public static readonly string ignorekilltiledetection = "tshock.ignore.removetile";
[Description("Prevents you from being reverted by place tile abuse detection.")]
public static readonly string ignoreplacetiledetection = "tshock.ignore.placetile";
[Description("Prevents you from being disabled by liquid set abuse detection.")]
public static readonly string ignoreliquidsetdetection = "tshock.ignore.liquid";
[Description("Prevents you from being disabled by projectile abuse detection.")]
public static readonly string ignoreprojectiledetection = "tshock.ignore.projectile";
[Description("Prevents you from being reverted by no clip detection.")]
public static readonly string ignorenoclipdetection = "tshock.ignore.noclip";
[Description("Prevents you from being disabled by stack hack detection.")]
public static readonly string ignorestackhackdetection = "tshock.ignore.itemstack";
[Description("Prevents you from being kicked by hacked health detection.")]
public static readonly string ignorestathackdetection = "tshock.ignore.stats";
[Description("Prevents your actions from being ignored if damage is too high.")]
public static readonly string ignoredamagecap = "tshock.ignore.damage";
[Description("Bypass server side inventory checks")]
public static readonly string bypassinventorychecks = "tshock.ignore.ssi";
[Description("Allow unrestricted SendTileSquare usage, for client side world editing.")]
public static readonly string allowclientsideworldedit = "tshock.ignore.sendtilesquare";
// tshock.item nodes
[Description("User can spawn items.")]
public static readonly string item = "tshock.item.spawn";
[Description("User can clear items.")]
public static readonly string clearitems = "tshock.item.clear";
[Description("Allows you to use banned items.")]
public static readonly string usebanneditem = "tshock.item.usebanned";
// tshock.npc nodes
[Description("User can spawn bosses.")]
public static readonly string spawnboss = "tshock.npc.spawnboss";
[Description("User can spawn npcs.")]
public static readonly string spawnmob = "tshock.npc.spawnmob";
[Description("User can kill all enemy npcs.")]
public static readonly string butcher = "tshock.npc.butcher";
[Description("User can summon bosses using items")]
public static readonly string summonboss = "tshock.npc.summonboss";
[Description("User can start invasions (Goblin/Snow Legion) using items")]
public static readonly string startinvasion = "tshock.npc.startinvasion";
// tshock.tp nodes
[Description("User can teleport to others.")]
public static readonly string tp = "tshock.tp.to";
[Description("User can teleport people to them.")]
public static readonly string tphere = "tshock.tp.others";
[Description("Users can stop people from teleporting to them")]
public static readonly string tpallow = "tshock.tp.block";
[Description("Users can tp to anyone")]
public static readonly string tpall = "tshock.tp.toall";
[Description("Users can tp to people without showing a notice")]
public static readonly string tphide = "tshock.tp.silent";
[Description("User can use /home.")]
public static readonly string home = "tshock.tp.home";
[Description("User can use /spawn.")]
public static readonly string spawn = "tshock.tp.spawn";
// tshock.world nodes
[Description("Allows you to edit the spawn.")]
public static readonly string editspawn = "tshock.world.editspawn";
[Description("User can set the time.")]
public static readonly string time = "tshock.world.settime";
[Description("User can grow plants.")]
public static readonly string grow = "tshock.world.grow";
[Description("User can change hardmode state.")]
public static readonly string hardmode = "tshock.world.hardmode";
[Description("User can change the homes of NPCs.")]
public static readonly string movenpc = "tshock.world.movenpc";
[Description("User can convert hallow into corruption and vice-versa")]
public static readonly string converthardmode = "tshock.world.converthardmode";
[Description("User can force the server to Christmas mode.")]
public static readonly string xmas = "tshock.world.setxmas";
[Description("User can save the world.")]
public static readonly string worldsave = "tshock.world.save";
[Description("User can settle liquids.")]
public static readonly string worldsettle = "tshock.world.settleliquids";
[Description("User can get the world info.")]
public static readonly string worldinfo = "tshock.world.info";
[Description("User can set the world spawn.")]
public static readonly string worldspawn = "tshock.world.setspawn";
[Description("User can cause some events.")]
public static readonly string causeevents = "tshock.world.causeevents";
[Description("User can modify the world.")]
public static readonly string canbuild = "tshock.world.modify";
// Non-grouped
[Description("User can kill others.")]
public static readonly string kill = "tshock.kill";
[Description("Allows you to bypass the max slots for up to 5 slots above your max.")]
public static readonly string reservedslot = "tshock.reservedslot";
[Description("User can use warps.")]
public static readonly string warp = "tshock.warp";
[Description("User can slap others.")]
public static readonly string slap = "tshock.slap";
[Description("Meant for super admins only.")]
public static readonly string rootonly = "tshock.rootonly";
[Description("User can whisper to others.")]
public static readonly string whisper = "tshock.whisper";
[Description("User can annoy others.")]
public static readonly string annoy = "tshock.annoy";
[Description("User can heal players.")]
public static readonly string heal = "tshock.heal";
[Description("User can use party chat in game")]
public static readonly string canpartychat = "tshock.partychat";
[Description("User can talk in third person")]
public static readonly string cantalkinthird = "tshock.thirdperson";
[Description("User can get the server info.")]
public static readonly string serverinfo = "tshock.info";
/// <summary>
/// Lists all commands associated with a given permission

View file

@ -22,71 +22,66 @@ namespace Rests
{
public static class RestPermissions
{
[Description("User can create REST tokens.")]
public static readonly string restapi;
[Description("User or REST user can destroy all REST tokens.")]
public static readonly string restmanage;
[Description("REST user can turn off / restart the server.")]
public static readonly string restmaintenance;
[Description("REST user can reload configurations, save the world and set auto save settings.")]
public static readonly string restcfg;
[Description("REST user can list and get detailed information about users.")]
public static readonly string restviewusers;
[Description("REST user can alter users.")]
public static readonly string restmanageusers;
// tshock.rest.bans nodes
[Description("REST user can list and get detailed information about bans.")]
public static readonly string restviewbans;
public static readonly string restviewbans = "tshock.rest.bans.view";
[Description("REST user can alter bans.")]
public static readonly string restmanagebans;
public static readonly string restmanagebans = "tshock.rest.bans.manage";
// tshock.rest.groups nodes
[Description("REST user can list and get detailed information about groups.")]
public static readonly string restviewgroups;
public static readonly string restviewgroups = "tshock.rest.groups.view";
[Description("REST user can alter groups.")]
public static readonly string restmanagegroups;
public static readonly string restmanagegroups = "tshock.rest.groups.manage";
// tshock.rest.users nodes
[Description("REST user can list and get detailed information about users.")]
public static readonly string restviewusers = "tshock.rest.users.view";
[Description("REST user can alter users.")]
public static readonly string restmanageusers = "tshock.rest.users.manage";
[Description("REST user can get user information.")]
public static readonly string restuserinfo;
public static readonly string restuserinfo = "tshock.rest.users.info";
// Non-grouped nodes
[Description("User can create REST tokens.")]
public static readonly string restapi = "tshock.rest.useapi";
[Description("User or REST user can destroy all REST tokens.")]
public static readonly string restmanage = "tshock.rest.manage";
[Description("REST user can turn off / restart the server.")]
public static readonly string restmaintenance = "tshock.rest.maintenance";
[Description("REST user can reload configurations, save the world and set auto save settings.")]
public static readonly string restcfg = "tshock.rest.cfg";
[Description("REST user can kick players.")]
public static readonly string restkick;
public static readonly string restkick = "tshock.rest.kick";
[Description("REST user can ban players.")]
public static readonly string restban;
public static readonly string restban = "tshock.rest.ban";
[Description("REST user can mute and unmute players.")]
public static readonly string restmute;
public static readonly string restmute = "tshock.rest.mute";
[Description("REST user can kill players.")]
public static readonly string restkill;
public static readonly string restkill = "tshock.rest.kill";
[Description("REST user can drop meteors or change bloodmoon.")]
public static readonly string restcauseevents;
public static readonly string restcauseevents = "tshock.rest.causeevents";
[Description("REST user can butcher npcs.")]
public static readonly string restbutcher;
public static readonly string restbutcher = "tshock.rest.butcher";
[Description("REST user can run raw TShock commands (the raw command permissions are also checked though).")]
public static readonly string restrawcommand;
static RestPermissions()
{
foreach (var field in typeof (RestPermissions).GetFields())
{
field.SetValue(null, field.Name);
}
}
public static readonly string restrawcommand = "tshock.rest.command";
}
}