Merge branch 'general-devel' into newer-bans

This commit is contained in:
Lucas Nicodemus 2017-12-02 18:57:15 -07:00 committed by GitHub
commit a429d706fa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 65 additions and 25 deletions

View file

@ -16,6 +16,8 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin
* Added /region rename and OnRegionRenamed hook (@koneko-nyan, @deadsurgeon42)
* Rebuilt /ban add. New syntax is /ban add <target> [time] [reason] where target is the target online player, offline player, or IP; where time is the time format or 0 for permanent; and where [reason] is the reason. (@hakusaro)
* Removed /ban addip and /ban addtemp. Now covered under /ban add. (@hakusaro)
* 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
* Updated OpenTerraria API to 1.3.5.3 (@DeathCradle)

View file

@ -312,6 +312,14 @@ namespace TShockAPI
{
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")
{
HelpText = "Shows information about a player."
@ -686,6 +694,10 @@ namespace TShockAPI
{
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.");
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)
{
@ -1813,10 +1825,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
#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)
{
string message = string.Join(" ", args.Parameters);
@ -4841,10 +4891,10 @@ namespace TShockAPI
if (args.Player.Group.Name != "superadmin")
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("{0}user add <username> <password> superadmin", Specifier);
args.Player.SendInfoMessage("Creates: <username> with the password <password> as part of the superadmin group.");
args.Player.SendInfoMessage("{0}user add <username> <password> owner", Specifier);
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("If you understand, please {0}login <username> <password> now, and then type {0}auth.", Specifier);
return;

View file

@ -78,18 +78,6 @@ namespace TShockAPI
[Description("Disables any building / placing of blocks.")]
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>
[Description("Backup frequency in minutes. So, a value of 60 = 60 minutes. Backups are stored in the \\tshock\\backups folder.")]
public int BackupInterval;

View file

@ -77,6 +77,8 @@ namespace TShockAPI.DB
string.Join(",", Permissions.maintenance, "tshock.cfg.*", "tshock.world.*", Permissions.butcher, Permissions.item, Permissions.give,
Permissions.heal, Permissions.immunetoban, Permissions.usebanneditem));
AddDefaultGroup("owner", "trustedadmin", string.Join(",", Permissions.su));
AddDefaultGroup("vip", "default", string.Join(",", Permissions.reservedslot));
}

View file

@ -340,11 +340,11 @@ namespace TShockAPI
public SuperAdminGroup()
: base("superadmin")
{
R = (byte)TShock.Config.SuperAdminChatRGB[0];
G = (byte)TShock.Config.SuperAdminChatRGB[1];
B = (byte)TShock.Config.SuperAdminChatRGB[2];
Prefix = TShock.Config.SuperAdminChatPrefix;
Suffix = TShock.Config.SuperAdminChatSuffix;
R = (byte)255;
G = (byte)255;
B = (byte)255;
Prefix = "(Super Admin) ";
Suffix = "";
}
/// <summary>

View file

@ -221,6 +221,9 @@ namespace TShockAPI
[Description("Meant for super admins only.")]
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
[Description("User can teleport *everyone* to them.")]

View file

@ -549,11 +549,6 @@ namespace TShockAPI
get { return (int)(Y / 16); }
}
/// <summary>
/// Unused.
/// </summary>
public bool TpLock;
/// <summary>
/// Checks if the player has any inventory slots available.
/// </summary>