Merge remote branch 'upstream/general-devel' into general-devel

This commit is contained in:
k0rd 2012-05-30 01:05:21 -04:00
commit 65d0847f11
7 changed files with 977 additions and 939 deletions

File diff suppressed because it is too large Load diff

View file

@ -132,7 +132,7 @@ namespace TShockAPI
[Description("This will turn on a token requirement for the /status API endpoint.")] public bool
EnableTokenEndpointAuthentication;
[Description("This is used when the API endpoint /status is queried.")] public string ServerNickname = "TShock Server";
[Description("Deprecated. Use ServerName instead.")] public string ServerNickname = "TShock Server";
[Description("Enable/Disable the rest api.")] public bool RestApiEnabled;
@ -168,7 +168,7 @@ namespace TShockAPI
"Change ingame chat format, {0} = Group Name, {1} = Group Prefix, {2} = Player Name, {3} = Group Suffix, {4} = Chat Message"
)] public string ChatFormat = "{1}{2}{3}: {4}";
[Description("Change the chat format when using chat above heads. This begins with a player name wrapped in brackets, as per Terraria's formatting. Same formatting as ChatFormat.")] public string ChatAboveHeadsFormat = "{3}:";
[Description("Change the chat format when using chat above heads. This begins with a player name wrapped in brackets, as per Terraria's formatting. Same formatting as ChatFormat.")] public string ChatAboveHeadsFormat = "{4}";
[Description("Force the world time to be normal, day, or night")] public string ForceTime = "normal";
@ -239,6 +239,8 @@ namespace TShockAPI
[Description("Displays chat messages above players' heads, but will disable chat prefixes to compensate.")] public
bool EnableChatAboveHeads = false;
[Description("Hide stat tracker console messages.")] public bool HideStatTrackerDebugMessages = true;
/// <summary>
/// Reads a configuration file from a given path
/// </summary>

View file

@ -126,7 +126,7 @@ namespace TShockAPI
var activeplayers = Main.player.Where(p => null != p && p.active).ToList();
return new RestObject()
{
{"name", TShock.Config.ServerNickname},
{"name", TShock.Config.ServerName},
{"port", Convert.ToString(Netplay.serverPort)},
{"playercount", Convert.ToString(activeplayers.Count())},
{"players", string.Join(", ", activeplayers.Select(p => p.name))},
@ -140,7 +140,7 @@ namespace TShockAPI
var ret = new RestObject()
{
{"name", TShock.Config.ServerNickname},
{"name", TShock.Config.ServerName},
{"port", TShock.Config.ServerPort},
{"playercount", Main.player.Where(p => null != p && p.active).Count()},
{"maxplayers", TShock.Config.MaxSlots},

View file

@ -86,7 +86,8 @@ namespace TShockAPI
Environment.OSVersion + "&mono=" + Main.runningMono + "&port=" + Netplay.serverPort +
"&plcount=" + TShock.Utils.ActivePlayers());
}
Log.ConsoleInfo("Stat Tracker: " + response);
if (!TShock.Config.HideStatTrackerDebugMessages)
Log.ConsoleInfo("Stat Tracker: " + response);
}
catch (Exception e)
{

View file

@ -407,6 +407,26 @@ namespace TShockAPI
NetMessage.SendData((int) PacketTypes.ItemOwner, -1, -1, "", itemid, 0f, 0f, 0f);
}
public virtual void SendInformationalMessage(string msg)
{
SendMessage(msg, Color.Indigo);
}
public virtual void SendSuccessMessage(string msg)
{
SendMessage(msg, Color.Green);
}
public virtual void SendWarningMessage(string msg)
{
SendMessage(msg, Color.Yellow);
}
public virtual void SendErrorMessage(string msg)
{
SendMessage(msg, Color.Red);
}
public virtual void SendMessage(string msg)
{
SendMessage(msg, 0, 255, 0);

View file

@ -647,8 +647,10 @@ namespace TShockAPI
private void SetConsoleTitle()
{
Console.Title = string.Format("{0} - {1}/{2} @ {3}:{4} (TerrariaShock v{5})", Config.ServerName, Utils.ActivePlayers(),
Config.MaxSlots, Netplay.serverListenIP, Netplay.serverPort, Version);
Console.Title = string.Format("{0}{1}/{2} @ {3}:{4} (TerrariaShock v{5})",
!string.IsNullOrWhiteSpace(Config.ServerName) ? Config.ServerName + " - " : "",
Utils.ActivePlayers(),
Config.MaxSlots, Netplay.serverListenIP, Netplay.serverPort, Version);
}
private void OnHardUpdate( HardUpdateEventArgs args )
@ -1588,6 +1590,8 @@ namespace TShockAPI
RconHandler.ListenPort = file.RconPort;
Utils.HashAlgo = file.HashAlgorithm;
file.ServerName = file.ServerNickname;
}
}
}

View file

@ -64,6 +64,7 @@ namespace TShockAPI
/// Used for some places where a list of players might be used.
/// </summary>
/// <returns>String of players seperated by commas.</returns>
[Obsolete("Use GetPlayers and manually create strings. This should never have been kept as far as actual functions go.")]
public string GetPlayers()
{
var sb = new StringBuilder();
@ -81,10 +82,38 @@ namespace TShockAPI
return sb.ToString();
}
/// <summary>
/// Returns a list of current players on the server
/// </summary>
/// <param name="includeIDs">bool includeIDs - whether or not the string of each player name should include ID data</param>
/// <returns>List of strings with names</returns>
public List<string> GetPlayers(bool includeIDs)
{
var players = new List<string>();
foreach (TSPlayer ply in TShock.Players)
{
if (ply != null && ply.Active)
{
if (includeIDs)
{
players.Add(ply.Name + " (IX: " + ply.Index + ", ID: " + ply.UserID + ")");
}
else
{
players.Add(ply.Name);
}
}
}
return players;
}
/// <summary>
/// Used for some places where a list of players might be used.
/// </summary>
/// <returns>String of players and their id seperated by commas.</returns>
[Obsolete("Use GetPlayers and manually create strings. This should never have been kept as far as actual functions go.")]
public string GetPlayersWithIds()
{
var sb = new StringBuilder();
@ -669,7 +698,6 @@ namespace TShockAPI
/// </summary>
/// <param name="ply">int player</param>
/// <param name="file">string filename reletave to savedir</param>
//Todo: Fix this
public void ShowFileToUser(TSPlayer player, string file)
{
string foo = "";