Merge pull request #1312 from Simon311/general-devel
Add /accountinfo, fix offline bans exploit, fix #1309 more
This commit is contained in:
commit
78a4185152
3 changed files with 57 additions and 4 deletions
|
|
@ -244,6 +244,10 @@ namespace TShockAPI
|
|||
DoLog = false,
|
||||
HelpText = "Registers you an account."
|
||||
});
|
||||
add(new Command(Permissions.checkaccountinfo, ViewAccountInfo, "accountinfo", "ai")
|
||||
{
|
||||
HelpText = "Shows information about a user."
|
||||
});
|
||||
#endregion
|
||||
#region Admin Commands
|
||||
add(new Command(Permissions.ban, Ban, "ban")
|
||||
|
|
@ -300,7 +304,7 @@ namespace TShockAPI
|
|||
});
|
||||
add(new Command(Permissions.userinfo, GrabUserUserInfo, "userinfo", "ui")
|
||||
{
|
||||
HelpText = "Shows information about a user."
|
||||
HelpText = "Shows information about a player."
|
||||
});
|
||||
#endregion
|
||||
#region Annoy Commands
|
||||
|
|
@ -1205,6 +1209,43 @@ namespace TShockAPI
|
|||
}
|
||||
}
|
||||
|
||||
private static void ViewAccountInfo(CommandArgs args)
|
||||
{
|
||||
if (args.Parameters.Count < 1)
|
||||
{
|
||||
args.Player.SendErrorMessage("Invalid syntax! Proper syntax: {0}accountinfo <username>", Specifier);
|
||||
return;
|
||||
}
|
||||
|
||||
string username = String.Join(" ", args.Parameters);
|
||||
if (!string.IsNullOrWhiteSpace(username))
|
||||
{
|
||||
var user = TShock.Users.GetUserByName(username);
|
||||
if (user != null)
|
||||
{
|
||||
DateTime LastSeen = DateTime.Parse(user.LastAccessed).ToLocalTime();
|
||||
string Timezone = TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now).Hours.ToString("+#;-#");
|
||||
|
||||
args.Player.SendSuccessMessage("{0}'s last login occured {1} {2} UTC{3}.", user.Name, LastSeen.ToShortDateString(),
|
||||
LastSeen.ToShortTimeString(), Timezone);
|
||||
|
||||
if (args.Player.Group.HasPermission(Permissions.advaccountinfo))
|
||||
{
|
||||
List<string> KnownIps = JsonConvert.DeserializeObject<List<string>>(user.KnownIps);
|
||||
string ip = KnownIps[KnownIps.Count - 1];
|
||||
DateTime Registered = DateTime.Parse(user.Registered).ToLocalTime();
|
||||
|
||||
args.Player.SendSuccessMessage("{0}'s group is {1}.", user.Name, user.Group);
|
||||
args.Player.SendSuccessMessage("{0}'s last known IP is {1}.", user.Name, ip);
|
||||
args.Player.SendSuccessMessage("{0}'s register date is {1} {2} UTC{3}.", user.Name, Registered.ToShortDateString(), Registered.ToShortTimeString(), Timezone);
|
||||
}
|
||||
}
|
||||
else
|
||||
args.Player.SendErrorMessage("User {0} does not exist.", username);
|
||||
}
|
||||
else args.Player.SendErrorMessage("Invalid syntax! Proper syntax: {0}accountinfo <username>", Specifier);
|
||||
}
|
||||
|
||||
private static void Kick(CommandArgs args)
|
||||
{
|
||||
if (args.Parameters.Count < 1)
|
||||
|
|
|
|||
|
|
@ -388,6 +388,12 @@ namespace TShockAPI
|
|||
|
||||
[Description("Player can place banned tiles.")]
|
||||
public static readonly string canusebannedtiles = "tshock.tiles.usebanned";
|
||||
|
||||
[Description("Player can check if a username is registered and see its last login time.")]
|
||||
public static readonly string checkaccountinfo = "tshock.accountinfo.check";
|
||||
|
||||
[Description("Player can see advanced information about any user account.")]
|
||||
public static readonly string advaccountinfo = "tshock.accountinfo.details";
|
||||
/// <summary>
|
||||
/// Lists all commands associated with a given permission
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -412,8 +412,8 @@ namespace TShockAPI
|
|||
KnownIps = JsonConvert.DeserializeObject<List<String>>(args.Player.User.KnownIps);
|
||||
}
|
||||
|
||||
bool found = KnownIps.Any(s => s.Equals(args.Player.IP));
|
||||
if (!found)
|
||||
bool last = KnownIps.Last() == args.Player.IP;
|
||||
if (!last)
|
||||
{
|
||||
if (KnownIps.Count == 100)
|
||||
{
|
||||
|
|
@ -1467,9 +1467,15 @@ namespace TShockAPI
|
|||
/// <param name="args">The CommandEventArgs object</param>
|
||||
private void ServerHooks_OnCommand(CommandEventArgs args)
|
||||
{
|
||||
if (args.Handled || string.IsNullOrWhiteSpace(args.Command))
|
||||
if (args.Handled)
|
||||
return;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(args.Command))
|
||||
{
|
||||
args.Handled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
// Damn you ThreadStatic and Redigit
|
||||
if (Main.rand == null)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue