Fixed regions
Added /convert
This commit is contained in:
parent
92d6e7b9fb
commit
e1cd87f487
3 changed files with 59 additions and 3 deletions
|
|
@ -167,6 +167,7 @@ namespace TShockAPI
|
||||||
ChatCommands.Add(new Command("whisper", Whisper, "whisper", "w", "tell"));
|
ChatCommands.Add(new Command("whisper", Whisper, "whisper", "w", "tell"));
|
||||||
ChatCommands.Add(new Command("whisper", Reply, "reply", "r"));
|
ChatCommands.Add(new Command("whisper", Reply, "reply", "r"));
|
||||||
ChatCommands.Add(new Command("annoy", Annoy, "annoy"));
|
ChatCommands.Add(new Command("annoy", Annoy, "annoy"));
|
||||||
|
ChatCommands.Add(new Command("cfg", ConvertWaR, "convert"));
|
||||||
if (TShock.Config.DistributationAgent != "terraria-online")
|
if (TShock.Config.DistributationAgent != "terraria-online")
|
||||||
{
|
{
|
||||||
ChatCommands.Add(new Command("kill", Kill, "kill"));
|
ChatCommands.Add(new Command("kill", Kill, "kill"));
|
||||||
|
|
@ -718,6 +719,22 @@ namespace TShockAPI
|
||||||
|
|
||||||
#region Server Maintenence Commands
|
#region Server Maintenence Commands
|
||||||
|
|
||||||
|
public static void ConvertWaR(CommandArgs args)
|
||||||
|
{
|
||||||
|
if (args.Parameters.Count < 1)
|
||||||
|
{
|
||||||
|
args.Player.SendMessage("This command will dump all users from both Regions and Warps.");
|
||||||
|
args.Player.SendMessage("This command will also change all Worlds to reference this WorldID.");
|
||||||
|
args.Player.SendMessage("You must manually fix multi-world configurations.");
|
||||||
|
args.Player.SendMessage("To confirm this: /convert yes");
|
||||||
|
} else if (args.Parameters[0] == "yes")
|
||||||
|
{
|
||||||
|
TShock.Warps.ConvertDB();
|
||||||
|
TShock.Regions.ConvertDB();
|
||||||
|
args.Player.SendMessage("Convert complete. You need to re-allow users after they register.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static void Broadcast(CommandArgs args)
|
private static void Broadcast(CommandArgs args)
|
||||||
{
|
{
|
||||||
string message = "";
|
string message = "";
|
||||||
|
|
|
||||||
|
|
@ -151,7 +151,7 @@ namespace TShockAPI.DB
|
||||||
if (ipstr != "")
|
if (ipstr != "")
|
||||||
ipstr += ",";
|
ipstr += ",";
|
||||||
ipstr += TShock.Users.GetUserID(ips[i]);
|
ipstr += TShock.Users.GetUserID(ips[i]);
|
||||||
} catch (Exception e)
|
} catch (Exception)
|
||||||
{
|
{
|
||||||
Log.Error("An IP address failed to import. It wasn't a user in the new user system.");
|
Log.Error("An IP address failed to import. It wasn't a user in the new user system.");
|
||||||
}
|
}
|
||||||
|
|
@ -205,6 +205,28 @@ namespace TShockAPI.DB
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ConvertDB()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using (var com = database.CreateCommand())
|
||||||
|
{
|
||||||
|
com.CommandText = "UPDATE Regions SET WorldID=@worldid";
|
||||||
|
com.AddParameter("@worldid", Main.worldID.ToString());
|
||||||
|
com.ExecuteNonQuery();
|
||||||
|
com.Parameters.Clear();
|
||||||
|
com.CommandText = "UPDATE Regions SET UserIds=@UserIds";
|
||||||
|
com.AddParameter("@UserIds", "");
|
||||||
|
com.ExecuteNonQuery();
|
||||||
|
ReloadAllRegions();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Log.Error(ex.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void ReloadAllRegions()
|
public void ReloadAllRegions()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
@ -212,7 +234,7 @@ namespace TShockAPI.DB
|
||||||
using (var com = database.CreateCommand())
|
using (var com = database.CreateCommand())
|
||||||
{
|
{
|
||||||
com.CommandText = "SELECT * FROM Regions WHERE WorldID=@worldid";
|
com.CommandText = "SELECT * FROM Regions WHERE WorldID=@worldid";
|
||||||
com.AddParameter("@worldid", Main.worldName);
|
com.AddParameter("@worldid", Main.worldID.ToString());
|
||||||
using (var reader = com.ExecuteReader())
|
using (var reader = com.ExecuteReader())
|
||||||
{
|
{
|
||||||
Regions.Clear();
|
Regions.Clear();
|
||||||
|
|
@ -234,7 +256,7 @@ namespace TShockAPI.DB
|
||||||
{
|
{
|
||||||
for (int i = 0; i < SplitIDs.Length; i++)
|
for (int i = 0; i < SplitIDs.Length; i++)
|
||||||
{
|
{
|
||||||
if (SplitIDs.Length == 0)
|
if (SplitIDs.Length == 1 && SplitIDs[0].Equals(""))
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -130,6 +130,23 @@ namespace TShockAPI.DB
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ConvertDB()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using (var com = database.CreateCommand())
|
||||||
|
{
|
||||||
|
com.CommandText = "UPDATE Warps SET WorldID=@worldid";
|
||||||
|
com.AddParameter("@worldid", Main.worldID.ToString());
|
||||||
|
com.ExecuteNonQuery();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Log.Error(ex.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public bool AddWarp(int x, int y, string name, string worldid)
|
public bool AddWarp(int x, int y, string name, string worldid)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue