Merge pull request #1515 from Pryaxis/no-colors-for-superadmins
Discourage superadmin use
This commit is contained in:
commit
9c6c450751
7 changed files with 65 additions and 25 deletions
|
|
@ -14,6 +14,8 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin
|
||||||
* Added a warning notifying users of the minimum memory required to run TShock (@bartico6)
|
* Added a warning notifying users of the minimum memory required to run TShock (@bartico6)
|
||||||
* Added /group rename to allow changing group names (@ColinBohn, @ProfessorXZ)
|
* Added /group rename to allow changing group names (@ColinBohn, @ProfessorXZ)
|
||||||
* Added /region rename and OnRegionRenamed hook (@koneko-nyan, @deadsurgeon42)
|
* Added /region rename and OnRegionRenamed hook (@koneko-nyan, @deadsurgeon42)
|
||||||
|
* Added /su, which temporarily elevates players with the tshock.su permission to super admin. In addition added, a new group, owner, that is suggested for new users to setup TShock with as opposed to superadmin. Finally, /su is implemented such that a 10 minute timeout will occur preventing people from just camping with it on. (@hakusaro)
|
||||||
|
* Added /sudo, which runs a command as the superadmin group. If a user fails to execute a command but can sudo, they'll be told that they can override the permission check with sudo. Much better than just telling them to run /su and then re-run the command. (@hakusaro)
|
||||||
|
|
||||||
|
|
||||||
## TShock 4.3.24
|
## TShock 4.3.24
|
||||||
|
|
|
||||||
|
|
@ -311,6 +311,14 @@ namespace TShockAPI
|
||||||
{
|
{
|
||||||
HelpText = "Temporarily sets another player's group."
|
HelpText = "Temporarily sets another player's group."
|
||||||
});
|
});
|
||||||
|
add(new Command(Permissions.su, SubstituteUser, "su")
|
||||||
|
{
|
||||||
|
HelpText = "Temporarily elevates you to Super Admin."
|
||||||
|
});
|
||||||
|
add(new Command(Permissions.su, SubstituteUserDo, "sudo")
|
||||||
|
{
|
||||||
|
HelpText = "Executes a command as the super admin."
|
||||||
|
});
|
||||||
add(new Command(Permissions.userinfo, GrabUserUserInfo, "userinfo", "ui")
|
add(new Command(Permissions.userinfo, GrabUserUserInfo, "userinfo", "ui")
|
||||||
{
|
{
|
||||||
HelpText = "Shows information about a player."
|
HelpText = "Shows information about a player."
|
||||||
|
|
@ -685,6 +693,10 @@ namespace TShockAPI
|
||||||
{
|
{
|
||||||
TShock.Utils.SendLogs(string.Format("{0} tried to execute {1}{2}.", player.Name, Specifier, cmdText), Color.PaleVioletRed, player);
|
TShock.Utils.SendLogs(string.Format("{0} tried to execute {1}{2}.", player.Name, Specifier, cmdText), Color.PaleVioletRed, player);
|
||||||
player.SendErrorMessage("You do not have access to this command.");
|
player.SendErrorMessage("You do not have access to this command.");
|
||||||
|
if (player.HasPermission(Permissions.su))
|
||||||
|
{
|
||||||
|
player.SendInfoMessage("You can use '{0}sudo {0}{1}' to override this check.", Specifier, cmdText);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (!cmd.AllowServer && !player.RealPlayer)
|
else if (!cmd.AllowServer && !player.RealPlayer)
|
||||||
{
|
{
|
||||||
|
|
@ -1814,10 +1826,48 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void SubstituteUser(CommandArgs args)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (args.Player.tempGroup != null)
|
||||||
|
{
|
||||||
|
args.Player.tempGroup = null;
|
||||||
|
args.Player.tempGroupTimer.Stop();
|
||||||
|
args.Player.SendSuccessMessage("Your previous permission set has been restored.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
args.Player.tempGroup = new SuperAdminGroup();
|
||||||
|
args.Player.tempGroupTimer = new System.Timers.Timer(600 * 1000);
|
||||||
|
args.Player.tempGroupTimer.Elapsed += args.Player.TempGroupTimerElapsed;
|
||||||
|
args.Player.tempGroupTimer.Start();
|
||||||
|
args.Player.SendSuccessMessage("Your account has been elevated to Super Admin for 10 minutes.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endregion Player Management Commands
|
#endregion Player Management Commands
|
||||||
|
|
||||||
#region Server Maintenence Commands
|
#region Server Maintenence Commands
|
||||||
|
|
||||||
|
// Executes a command as a superuser if you have sudo rights.
|
||||||
|
private static void SubstituteUserDo(CommandArgs args)
|
||||||
|
{
|
||||||
|
if (args.Parameters.Count == 0)
|
||||||
|
{
|
||||||
|
args.Player.SendErrorMessage("Usage: /sudo [command].");
|
||||||
|
args.Player.SendErrorMessage("Example: /sudo /ban add Shank 2d Hacking.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
string replacementCommand = String.Join(" ", args.Parameters);
|
||||||
|
args.Player.tempGroup = new SuperAdminGroup();
|
||||||
|
HandleCommand(args.Player, replacementCommand);
|
||||||
|
args.Player.tempGroup = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
private static void Broadcast(CommandArgs args)
|
private static void Broadcast(CommandArgs args)
|
||||||
{
|
{
|
||||||
string message = string.Join(" ", args.Parameters);
|
string message = string.Join(" ", args.Parameters);
|
||||||
|
|
@ -4842,10 +4892,10 @@ namespace TShockAPI
|
||||||
if (args.Player.Group.Name != "superadmin")
|
if (args.Player.Group.Name != "superadmin")
|
||||||
args.Player.tempGroup = new SuperAdminGroup();
|
args.Player.tempGroup = new SuperAdminGroup();
|
||||||
|
|
||||||
args.Player.SendInfoMessage("Superadmin has been temporarily given to you. It will be removed on logout.");
|
args.Player.SendInfoMessage("Temporary system access has been given to you, so you can run one command.");
|
||||||
args.Player.SendInfoMessage("Please use the following to create a permanent account for you.");
|
args.Player.SendInfoMessage("Please use the following to create a permanent account for you.");
|
||||||
args.Player.SendInfoMessage("{0}user add <username> <password> superadmin", Specifier);
|
args.Player.SendInfoMessage("{0}user add <username> <password> owner", Specifier);
|
||||||
args.Player.SendInfoMessage("Creates: <username> with the password <password> as part of the superadmin group.");
|
args.Player.SendInfoMessage("Creates: <username> with the password <password> as part of the owner group.");
|
||||||
args.Player.SendInfoMessage("Please use {0}login <username> <password> after this process.", Specifier);
|
args.Player.SendInfoMessage("Please use {0}login <username> <password> after this process.", Specifier);
|
||||||
args.Player.SendInfoMessage("If you understand, please {0}login <username> <password> now, and then type {0}auth.", Specifier);
|
args.Player.SendInfoMessage("If you understand, please {0}login <username> <password> now, and then type {0}auth.", Specifier);
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -78,18 +78,6 @@ namespace TShockAPI
|
||||||
[Description("Disables any building / placing of blocks.")]
|
[Description("Disables any building / placing of blocks.")]
|
||||||
public bool DisableBuild;
|
public bool DisableBuild;
|
||||||
|
|
||||||
/// <summary>SuperAdminChatRGB - The chat color for the superadmin group.</summary>
|
|
||||||
[Description("#.#.# = Red/Blue/Green - RGB Colors for the Admin Chat Color. Max value: 255.")]
|
|
||||||
public int[] SuperAdminChatRGB = { 255, 0, 0 };
|
|
||||||
|
|
||||||
/// <summary>SuperAdminChatPrefix - The superadmin chat prefix.</summary>
|
|
||||||
[Description("Super admin group chat prefix.")]
|
|
||||||
public string SuperAdminChatPrefix = "(Admin) ";
|
|
||||||
|
|
||||||
/// <summary>SuperAdminChatSuffix - The superadmin chat suffix.</summary>
|
|
||||||
[Description("Super admin group chat suffix.")]
|
|
||||||
public string SuperAdminChatSuffix = "";
|
|
||||||
|
|
||||||
/// <summary>BackupInterval - The backup frequency in minutes.</summary>
|
/// <summary>BackupInterval - The backup frequency in minutes.</summary>
|
||||||
[Description("Backup frequency in minutes. So, a value of 60 = 60 minutes. Backups are stored in the \\tshock\\backups folder.")]
|
[Description("Backup frequency in minutes. So, a value of 60 = 60 minutes. Backups are stored in the \\tshock\\backups folder.")]
|
||||||
public int BackupInterval;
|
public int BackupInterval;
|
||||||
|
|
|
||||||
|
|
@ -77,6 +77,8 @@ namespace TShockAPI.DB
|
||||||
string.Join(",", Permissions.maintenance, "tshock.cfg.*", "tshock.world.*", Permissions.butcher, Permissions.item, Permissions.give,
|
string.Join(",", Permissions.maintenance, "tshock.cfg.*", "tshock.world.*", Permissions.butcher, Permissions.item, Permissions.give,
|
||||||
Permissions.heal, Permissions.immunetoban, Permissions.usebanneditem));
|
Permissions.heal, Permissions.immunetoban, Permissions.usebanneditem));
|
||||||
|
|
||||||
|
AddDefaultGroup("owner", "trustedadmin", string.Join(",", Permissions.su));
|
||||||
|
|
||||||
AddDefaultGroup("vip", "default", string.Join(",", Permissions.reservedslot));
|
AddDefaultGroup("vip", "default", string.Join(",", Permissions.reservedslot));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -340,11 +340,11 @@ namespace TShockAPI
|
||||||
public SuperAdminGroup()
|
public SuperAdminGroup()
|
||||||
: base("superadmin")
|
: base("superadmin")
|
||||||
{
|
{
|
||||||
R = (byte)TShock.Config.SuperAdminChatRGB[0];
|
R = (byte)255;
|
||||||
G = (byte)TShock.Config.SuperAdminChatRGB[1];
|
G = (byte)255;
|
||||||
B = (byte)TShock.Config.SuperAdminChatRGB[2];
|
B = (byte)255;
|
||||||
Prefix = TShock.Config.SuperAdminChatPrefix;
|
Prefix = "(Super Admin) ";
|
||||||
Suffix = TShock.Config.SuperAdminChatSuffix;
|
Suffix = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -221,6 +221,9 @@ namespace TShockAPI
|
||||||
[Description("Meant for super admins only.")]
|
[Description("Meant for super admins only.")]
|
||||||
public static readonly string user = "tshock.superadmin.user";
|
public static readonly string user = "tshock.superadmin.user";
|
||||||
|
|
||||||
|
[Description("Allows a user to elevate to superadmin for 10 minutes.")]
|
||||||
|
public static readonly string su = "tshock.su";
|
||||||
|
|
||||||
// tshock.tp nodes
|
// tshock.tp nodes
|
||||||
|
|
||||||
[Description("User can teleport *everyone* to them.")]
|
[Description("User can teleport *everyone* to them.")]
|
||||||
|
|
|
||||||
|
|
@ -549,11 +549,6 @@ namespace TShockAPI
|
||||||
get { return (int)(Y / 16); }
|
get { return (int)(Y / 16); }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Unused.
|
|
||||||
/// </summary>
|
|
||||||
public bool TpLock;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Checks if the player has any inventory slots available.
|
/// Checks if the player has any inventory slots available.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue