Added the Registered property to REST's players/read endpoints

This commit is contained in:
ProfessorXZ 2016-08-30 09:16:01 +02:00
parent 66f5f9f540
commit 05a4e025f7
3 changed files with 272 additions and 262 deletions

View file

@ -6,6 +6,7 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin
* API: Fixed chat line breaks when using chat tags and long strings of text (@ProfessorXZ) * API: Fixed chat line breaks when using chat tags and long strings of text (@ProfessorXZ)
* API: Added ItemForceIntoChest hook (@WhiteXZ) * API: Added ItemForceIntoChest hook (@WhiteXZ)
* API: Included the player's registration date in REST's players/read endpoints (@ProfessorXZ)
* The setdungeon command correctly uses tshock.world.setdungeon as its permission (@OnsenManju) * The setdungeon command correctly uses tshock.world.setdungeon as its permission (@OnsenManju)
* Fixed clients being able to "Catch" and remove NPCs (@ProfessorXZ) * Fixed clients being able to "Catch" and remove NPCs (@ProfessorXZ)
* Fixed clients being able to remove other players' portals (@ProfessorXZ) * Fixed clients being able to remove other players' portals (@ProfessorXZ)

View file

@ -1808,7 +1808,8 @@ namespace TShockAPI
restUsersTokens.Select(ut => string.Format("{0} ({1} tokens)", ut.Key, ut.Value))); restUsersTokens.Select(ut => string.Format("{0} ({1} tokens)", ut.Key, ut.Value)));
PaginationTools.SendPage( PaginationTools.SendPage(
args.Player, pageNumber, PaginationTools.BuildLinesFromTerms(restUsers), new PaginationTools.Settings { args.Player, pageNumber, PaginationTools.BuildLinesFromTerms(restUsers), new PaginationTools.Settings
{
NothingToDisplayString = "There are currently no active REST users.", NothingToDisplayString = "There are currently no active REST users.",
HeaderFormat = "Active REST Users ({0}/{1}):", HeaderFormat = "Active REST Users ({0}/{1}):",
FooterFormat = "Type {0}rest listusers {{0}} for more.".SFormat(Specifier) FooterFormat = "Type {0}rest listusers {{0}} for more.".SFormat(Specifier)
@ -3681,7 +3682,8 @@ namespace TShockAPI
{ {
args.Player.SendInfoMessage("Changed the maximum spawns to 5."); args.Player.SendInfoMessage("Changed the maximum spawns to 5.");
} }
else { else
{
TSPlayer.All.SendInfoMessage("{0} changed the maximum spawns to 5.", args.Player.Name); TSPlayer.All.SendInfoMessage("{0} changed the maximum spawns to 5.", args.Player.Name);
} }
return; return;
@ -3699,7 +3701,8 @@ namespace TShockAPI
{ {
args.Player.SendInfoMessage("Changed the maximum spawns to {0}.", maxSpawns); args.Player.SendInfoMessage("Changed the maximum spawns to {0}.", maxSpawns);
} }
else { else
{
TSPlayer.All.SendInfoMessage("{0} changed the maximum spawns to {1}.", args.Player.Name, maxSpawns); TSPlayer.All.SendInfoMessage("{0} changed the maximum spawns to {1}.", args.Player.Name, maxSpawns);
} }
} }
@ -3719,7 +3722,8 @@ namespace TShockAPI
{ {
args.Player.SendInfoMessage("Changed the spawn rate to 600."); args.Player.SendInfoMessage("Changed the spawn rate to 600.");
} }
else { else
{
TSPlayer.All.SendInfoMessage("{0} changed the spawn rate to 600.", args.Player.Name); TSPlayer.All.SendInfoMessage("{0} changed the spawn rate to 600.", args.Player.Name);
} }
return; return;
@ -3736,7 +3740,8 @@ namespace TShockAPI
{ {
args.Player.SendInfoMessage("Changed the spawn rate to {0}.", spawnRate); args.Player.SendInfoMessage("Changed the spawn rate to {0}.", spawnRate);
} }
else { else
{
TSPlayer.All.SendInfoMessage("{0} changed the spawn rate to {1}.", args.Player.Name, spawnRate); TSPlayer.All.SendInfoMessage("{0} changed the spawn rate to {1}.", args.Player.Name, spawnRate);
} }
} }
@ -3911,8 +3916,8 @@ namespace TShockAPI
return; return;
} }
float speed; int speed;
if (!float.TryParse(args.Parameters[0], out speed)) if (!int.TryParse(args.Parameters[0], out speed))
{ {
args.Player.SendErrorMessage("Invalid wind speed!"); args.Player.SendErrorMessage("Invalid wind speed!");
return; return;
@ -4892,7 +4897,8 @@ namespace TShockAPI
} }
string givenCommandName = string.Join(" ", args.Parameters); string givenCommandName = string.Join(" ", args.Parameters);
if (string.IsNullOrWhiteSpace(givenCommandName)) { if (string.IsNullOrWhiteSpace(givenCommandName))
{
args.Player.SendErrorMessage("Please enter a proper command name or alias."); args.Player.SendErrorMessage("Please enter a proper command name or alias.");
return; return;
} }
@ -4904,7 +4910,8 @@ namespace TShockAPI
commandName = givenCommandName; commandName = givenCommandName;
bool didMatch = false; bool didMatch = false;
foreach (Command matchingCommand in ChatCommands.Where(cmd => cmd.Names.IndexOf(commandName) != -1)) { foreach (Command matchingCommand in ChatCommands.Where(cmd => cmd.Names.IndexOf(commandName) != -1))
{
if (matchingCommand.Names.Count > 1) if (matchingCommand.Names.Count > 1)
args.Player.SendInfoMessage( args.Player.SendInfoMessage(
"Aliases of {0}{1}: {0}{2}", Specifier, matchingCommand.Name, string.Join(", {0}".SFormat(Specifier), matchingCommand.Names.Skip(1))); "Aliases of {0}{1}: {0}{2}", Specifier, matchingCommand.Name, string.Join(", {0}".SFormat(Specifier), matchingCommand.Names.Skip(1)));

View file

@ -810,6 +810,7 @@ namespace TShockAPI
{"username", null == player.User ? "" : player.User.Name}, {"username", null == player.User ? "" : player.User.Name},
{"ip", player.IP}, {"ip", player.IP},
{"group", player.Group.Name}, {"group", player.Group.Name},
{"registered", null == player.User ? "" : player.User.Registered},
{"position", player.TileX + "," + player.TileY}, {"position", player.TileX + "," + player.TileY},
{"inventory", string.Join(", ", activeItems.Select(p => (p.name + ":" + p.stack)))}, {"inventory", string.Join(", ", activeItems.Select(p => (p.name + ":" + p.stack)))},
{"buffs", string.Join(", ", player.TPlayer.buffType)} {"buffs", string.Join(", ", player.TPlayer.buffType)}
@ -837,6 +838,7 @@ namespace TShockAPI
{"username", null == player.User ? "" : player.User.Name}, {"username", null == player.User ? "" : player.User.Name},
{"ip", player.IP}, {"ip", player.IP},
{"group", player.Group.Name}, {"group", player.Group.Name},
{"registered", null == player.User ? "" : player.User.Registered},
{"position", player.TileX + "," + player.TileY}, {"position", player.TileX + "," + player.TileY},
{"inventory", string.Join(", ", inventory.Select(p => (p.name + ":" + p.stack)))}, {"inventory", string.Join(", ", inventory.Select(p => (p.name + ":" + p.stack)))},
{"armor", string.Join(", ", equipment.Select(p => (p.netID + ":" + p.prefix)))}, {"armor", string.Join(", ", equipment.Select(p => (p.netID + ":" + p.prefix)))},