Merge branch 'general-devel'

This commit is contained in:
Lucas Nicodemus 2015-03-15 15:02:29 -06:00
commit 298a314d0b
7 changed files with 55 additions and 59 deletions

View file

@ -3,3 +3,5 @@ solution: ./TShockAPI/TShockAPI.csproj
notifications: notifications:
hipchat: hipchat:
secure: hpRLWiHF2j6O2qJOVs++aqAmryN6G5kY0SF26/rKCpQ7klhMlDZIgI1V1dbkKqlculFtW1neS0EBJyV9lmcV5b26H+KhlZYGN0j7q1VcOTM3rvtU6wW0Ap22uRLl2RrnA4kEsgDAsNouPOkyLZ19hlHAISlsId6G4+Rfqg6k+zQ= secure: hpRLWiHF2j6O2qJOVs++aqAmryN6G5kY0SF26/rKCpQ7klhMlDZIgI1V1dbkKqlculFtW1neS0EBJyV9lmcV5b26H+KhlZYGN0j7q1VcOTM3rvtU6wW0Ap22uRLl2RrnA4kEsgDAsNouPOkyLZ19hlHAISlsId6G4+Rfqg6k+zQ=
slack:
secure: O4Nibe2fdaUa2ZxuETUg6WEoQKvNM2CotnfaIVgm3fjfe61dfE1P+EgTpbwDG8646jSmpTqMDw8Z6I/WJwGTlXV/ZQsbwu63Cps4MgOTvPHZ0Lsye5azySlJZs1iI4ItYSj2czXfcnJ+qAl1SOOkXJrjB5uyTMWtDpCrSCFB3MA=

View file

@ -1285,11 +1285,11 @@ namespace TShockAPI
{ {
if (args.Silent) if (args.Silent)
{ {
args.Player.SendInfoMessage("[broken name] was {1}banned for '{2}'.", force ? "force " : "", reason); args.Player.SendInfoMessage("[broken name] was {0}banned for '{1}'.", force ? "force " : "", reason);
} }
else else
{ {
TSPlayer.All.SendInfoMessage("{0} {1}banned [broken name] for '{3}'.", args.Player.Name, force ? "force " : "", reason); TSPlayer.All.SendInfoMessage("{0} {1}banned [broken name] for '{2}'.", args.Player.Name, force ? "force " : "", reason);
} }
} }
} }
@ -4449,7 +4449,7 @@ namespace TShockAPI
args.Player.SendSuccessMessage("Your new account has been verified, and the /auth system has been turned off."); args.Player.SendSuccessMessage("Your new account has been verified, and the /auth system has been turned off.");
args.Player.SendSuccessMessage("You can always use the /user command to manage players. Don't just delete the auth.lck."); args.Player.SendSuccessMessage("You can always use the /user command to manage players. Don't just delete the auth.lck.");
args.Player.SendSuccessMessage("Thank you for using TShock! http://tshock.co/ & http://github.com/TShock/TShock"); args.Player.SendSuccessMessage("Thank you for using TShock! https://tshock.co/ & https://github.com/TShock/TShock");
FileTools.CreateFile(Path.Combine(TShock.SavePath, "auth.lck")); FileTools.CreateFile(Path.Combine(TShock.SavePath, "auth.lck"));
File.Delete(Path.Combine(TShock.SavePath, "authcode.txt")); File.Delete(Path.Combine(TShock.SavePath, "authcode.txt"));
TShock.AuthToken = 0; TShock.AuthToken = 0;

View file

@ -110,6 +110,45 @@ namespace TShockAPI.DB
return 1 == ret.Count() ? ret.ElementAt(0) : null; return 1 == ret.Count() ? ret.ElementAt(0) : null;
} }
/// <summary>
/// Adds group with name and permissions if it does not exist.
/// </summary>
/// <param name="name">name of group</param>
/// <param name="parentname">parent of group</param>
/// <param name="permissions">permissions</param>
/// <param name="chatcolor">chatcolor</param>
public void AddGroup(String name, string parentname, String permissions, String chatcolor)
{
if (GroupExists(name))
{
throw new GroupExistsException(name);
}
var group = new Group(name, null, chatcolor);
group.Permissions = permissions;
if (!string.IsNullOrWhiteSpace(parentname))
{
var parent = groups.FirstOrDefault(gp => gp.Name == parentname);
if (parent == null || name == parentname)
{
var error = "Invalid parent {0} for group {1}".SFormat(parentname, group.Name);
TShock.Log.ConsoleError(error);
throw new GroupManagerException(error);
}
group.Parent = parent;
}
string query = (TShock.Config.StorageType.ToLower() == "sqlite")
? "INSERT OR IGNORE INTO GroupList (GroupName, Parent, Commands, ChatColor) VALUES (@0, @1, @2, @3);"
: "INSERT IGNORE INTO GroupList SET GroupName=@0, Parent=@1, Commands=@2, ChatColor=@3";
if (database.Query(query, name, parentname, permissions, chatcolor) == 1)
{
groups.Add(group);
}
else
throw new GroupManagerException("Failed to add group '" + name + ".'");
}
/// <summary> /// <summary>
/// Adds group with name and permissions if it does not exist. /// Adds group with name and permissions if it does not exist.
/// </summary> /// </summary>
@ -118,13 +157,14 @@ namespace TShockAPI.DB
/// <param name="permissions">permissions</param> /// <param name="permissions">permissions</param>
/// <param name="chatcolor">chatcolor</param> /// <param name="chatcolor">chatcolor</param>
/// <param name="exceptions">exceptions true indicates use exceptions for errors false otherwise</param> /// <param name="exceptions">exceptions true indicates use exceptions for errors false otherwise</param>
[Obsolete("Use AddGroup(name, parentname, permissions, chatcolor) instead.")]
public String AddGroup(String name, string parentname, String permissions, String chatcolor = Group.defaultChatColor, bool exceptions = false) public String AddGroup(String name, string parentname, String permissions, String chatcolor = Group.defaultChatColor, bool exceptions = false)
{ {
if (GroupExists(name)) if (GroupExists(name))
{ {
if (exceptions) if (exceptions)
throw new GroupExistsException(name); throw new GroupExistsException(name);
return "Error: Group already exists. Use /modgroup to change permissions."; return "Error: Group already exists; unable to add group.";
} }
var group = new Group(name, null, chatcolor); var group = new Group(name, null, chatcolor);

View file

@ -76,7 +76,7 @@ namespace TShockAPI.DB
/// Ensures a table exists and that its structure is correct /// Ensures a table exists and that its structure is correct
/// </summary> /// </summary>
/// <param name="table">The table name</param> /// <param name="table">The table name</param>
[Obsolete("This method will be replaced by EnsureTableExists.")] [Obsolete("This method will be replaced by EnsureTableStructure.")]
public void EnsureExists(SqlTable table) public void EnsureExists(SqlTable table)
{ {
EnsureTableStructure(table); EnsureTableStructure(table);

View file

@ -53,5 +53,5 @@ using System.Runtime.InteropServices;
// Also, be sure to release on github with the exact assembly version tag as below // Also, be sure to release on github with the exact assembly version tag as below
// so that the update manager works correctly (via the Github releases api and mimic) // so that the update manager works correctly (via the Github releases api and mimic)
[assembly: AssemblyVersion("4.2.7")] [assembly: AssemblyVersion("4.2.8")]
[assembly: AssemblyFileVersion("4.2.7")] [assembly: AssemblyFileVersion("4.2.8")]

View file

@ -483,7 +483,7 @@ namespace TShockAPI
if (path.IndexOfAny(Path.GetInvalidPathChars()) == -1) if (path.IndexOfAny(Path.GetInvalidPathChars()) == -1)
{ {
SavePath = path; SavePath = path;
Log.ConsoleInfo("Config path has been set to " + path); ServerApi.LogWriter.PluginWriteLine(this, "Config path has been set to " + path, TraceLevel.Info);
} }
break; break;
@ -492,7 +492,7 @@ namespace TShockAPI
if (path.IndexOfAny(Path.GetInvalidPathChars()) == -1) if (path.IndexOfAny(Path.GetInvalidPathChars()) == -1)
{ {
Main.WorldPath = path; Main.WorldPath = path;
Log.ConsoleInfo("World path has been set to " + path); ServerApi.LogWriter.PluginWriteLine(this, "World path has been set to " + path, TraceLevel.Info);
} }
break; break;
@ -501,7 +501,7 @@ namespace TShockAPI
if (path.IndexOfAny(Path.GetInvalidPathChars()) == -1) if (path.IndexOfAny(Path.GetInvalidPathChars()) == -1)
{ {
LogPath = path; LogPath = path;
Log.ConsoleInfo("Log path has been set to " + path); ServerApi.LogWriter.PluginWriteLine(this, "Log path has been set to " + path, TraceLevel.Info);
} }
break; break;
@ -1229,7 +1229,7 @@ namespace TShockAPI
if (Main.ServerSideCharacter) if (Main.ServerSideCharacter)
{ {
player.SendErrorMessage( player.SendErrorMessage(
player.IgnoreActionsForInventory = "Server side characters is enabled! Please {0}register or {0}login to play!", Commands.Specifier); player.IgnoreActionsForInventory = String.Format("Server side characters is enabled! Please {0}register or {0}login to play!", Commands.Specifier));
player.LoginHarassed = true; player.LoginHarassed = true;
} }
else if (Config.RequireLogin) else if (Config.RequireLogin)

View file

@ -63,28 +63,6 @@ namespace TShockAPI
return mess.Split(':')[0]; return mess.Split(':')[0];
} }
/// <summary>
/// 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();
foreach (TSPlayer player in TShock.Players)
{
if (player != null && player.Active)
{
if (sb.Length != 0)
{
sb.Append(", ");
}
sb.Append(player.Name);
}
}
return sb.ToString();
}
/// <summary> /// <summary>
/// Returns a list of current players on the server /// Returns a list of current players on the server
/// </summary> /// </summary>
@ -112,30 +90,6 @@ namespace TShockAPI
return players; 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();
foreach (TSPlayer player in TShock.Players)
{
if (player != null && player.Active)
{
if (sb.Length != 0)
{
sb.Append(", ");
}
sb.Append(player.Name);
string id = "(ID: " + Convert.ToString(TShock.Users.GetUserID(player.UserAccountName)) + ", IX:" + player.Index + ")";
sb.Append(id);
}
}
return sb.ToString();
}
/// <summary> /// <summary>
/// Finds a player and gets IP as string /// Finds a player and gets IP as string
/// </summary> /// </summary>
@ -697,7 +651,7 @@ namespace TShockAPI
} }
foo = foo.Replace("%map%", Main.worldName); foo = foo.Replace("%map%", Main.worldName);
foo = foo.Replace("%players%", GetPlayers()); foo = foo.Replace("%players%", String.Join(",", GetPlayers(false)));
Regex reg = new Regex("%\\s*(?<r>\\d{1,3})\\s*,\\s*(?<g>\\d{1,3})\\s*,\\s*(?<b>\\d{1,3})\\s*%"); Regex reg = new Regex("%\\s*(?<r>\\d{1,3})\\s*,\\s*(?<g>\\d{1,3})\\s*,\\s*(?<b>\\d{1,3})\\s*%");
var matches = reg.Matches(foo); var matches = reg.Matches(foo);
Color c = Color.White; Color c = Color.White;