mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-23 20:53:40 -04:00
Use Backend.DeleteTable instead of hardcoding DROP TABLE everywhere.
This commit is contained in:
parent
f68ff9dfca
commit
5c8edae438
@ -70,14 +70,14 @@ namespace MCGalaxy.Commands {
|
|||||||
if (args.Length == 1) {
|
if (args.Length == 1) {
|
||||||
Player.SendChatFrom(who, who.ColoredName + " %Shad their color removed.", false);
|
Player.SendChatFrom(who, who.ColoredName + " %Shad their color removed.", false);
|
||||||
who.color = who.group.color;
|
who.color = who.group.color;
|
||||||
Database.Execute("UPDATE Players SET color = '' WHERE name = @0", who.name);
|
Database.Execute("UPDATE Players SET color = '' WHERE Name = @0", who.name);
|
||||||
} else {
|
} else {
|
||||||
string color = Colors.Parse(args[1]);
|
string color = Colors.Parse(args[1]);
|
||||||
if (color == "") { Player.Message(p, "There is no color \"" + args[1] + "\"."); return; }
|
if (color == "") { Player.Message(p, "There is no color \"" + args[1] + "\"."); return; }
|
||||||
else if (color == who.color) { Player.Message(p, who.DisplayName + " already has that color."); return; }
|
else if (color == who.color) { Player.Message(p, who.DisplayName + " already has that color."); return; }
|
||||||
Player.SendChatFrom(who, who.ColoredName + " %Shad their color changed to " + color + Colors.Name(color) + "%S.", false);
|
Player.SendChatFrom(who, who.ColoredName + " %Shad their color changed to " + color + Colors.Name(color) + "%S.", false);
|
||||||
who.color = color;
|
who.color = color;
|
||||||
Database.Execute("UPDATE Players SET color = @1 WHERE name = @0", who.name, color);
|
Database.Execute("UPDATE Players SET color = @1 WHERE Name = @0", who.name, color);
|
||||||
}
|
}
|
||||||
Entities.GlobalDespawn(who, true);
|
Entities.GlobalDespawn(who, true);
|
||||||
Entities.GlobalSpawn(who, true);
|
Entities.GlobalSpawn(who, true);
|
||||||
|
@ -58,5 +58,11 @@ namespace MCGalaxy.SQL {
|
|||||||
string syntax = "INSERT INTO `" + dstTable + "` SELECT * FROM `" + srcTable + "`";
|
string syntax = "INSERT INTO `" + dstTable + "` SELECT * FROM `" + srcTable + "`";
|
||||||
Database.Execute(syntax);
|
Database.Execute(syntax);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary> Completely removes the given table from the database. </summary>
|
||||||
|
public virtual void DeleteTable(string table) {
|
||||||
|
string syntax = "DROP TABLE `" + table + "`";
|
||||||
|
Database.Execute(syntax);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ PRIMARY KEY(player)
|
|||||||
Database.Execute("INSERT INTO Economy (player, money) SELECT Players.Name, Players.Money FROM Players");
|
Database.Execute("INSERT INTO Economy (player, money) SELECT Players.Name, Players.Money FROM Players");
|
||||||
} else {
|
} else {
|
||||||
//this will only be needed when the server shuts down while it was copying content (or some other error)
|
//this will only be needed when the server shuts down while it was copying content (or some other error)
|
||||||
Database.Execute("DROP TABLE Economy");
|
Database.Backend.DeleteTable("Economy");
|
||||||
goto retry;
|
goto retry;
|
||||||
}
|
}
|
||||||
players.Dispose(); eco.Dispose();
|
players.Dispose(); eco.Dispose();
|
||||||
|
@ -136,15 +136,18 @@ namespace MCGalaxy {
|
|||||||
BotsFile.DeleteBots(name);
|
BotsFile.DeleteBots(name);
|
||||||
|
|
||||||
//safe against SQL injections because the levelname (message) is first being checked if it exists
|
//safe against SQL injections because the levelname (message) is first being checked if it exists
|
||||||
Database.Execute("DROP TABLE `Block" + name + "`");
|
Database.Backend.DeleteTable("Block" + name);
|
||||||
object locker = ThreadSafeCache.DBCache.Get(name);
|
object locker = ThreadSafeCache.DBCache.Get(name);
|
||||||
lock (locker) {
|
lock (locker) {
|
||||||
if (Database.TableExists("Portals" + name))
|
if (Database.TableExists("Portals" + name)) {
|
||||||
Database.Execute("DROP TABLE `Portals" + name + "`");
|
Database.Backend.DeleteTable("Portals" + name);
|
||||||
if (Database.TableExists("Messages" + name))
|
}
|
||||||
Database.Execute("DROP TABLE `Messages" + name + "`");
|
if (Database.TableExists("Messages" + name)) {
|
||||||
if (Database.TableExists("Zone" + name))
|
Database.Backend.DeleteTable("Messages" + name);
|
||||||
Database.Execute("DROP TABLE `Zone" + name + "`");
|
}
|
||||||
|
if (Database.TableExists("Zone" + name)) {
|
||||||
|
Database.Backend.DeleteTable("Zone" + name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -202,8 +202,8 @@ namespace MCGalaxy {
|
|||||||
|
|
||||||
//Delete old
|
//Delete old
|
||||||
List<string> tables = GetTables();
|
List<string> tables = GetTables();
|
||||||
foreach (string name in tables)
|
foreach (string table in tables)
|
||||||
Database.Execute("DROP TABLE `" + name + "`");
|
Database.Backend.DeleteTable(table);
|
||||||
|
|
||||||
// Import data
|
// Import data
|
||||||
using (StreamReader reader = new StreamReader(stream))
|
using (StreamReader reader = new StreamReader(stream))
|
||||||
|
@ -80,7 +80,7 @@ SELECT Time, Name, Cmd, Cmdmsg FROM Playercmds WHERE {0};";
|
|||||||
foreach (string cmd in Server.Opstats)
|
foreach (string cmd in Server.Opstats)
|
||||||
Database.Execute(string.Format(insertSyntax, "cmd = '" + cmd + "'"));
|
Database.Execute(string.Format(insertSyntax, "cmd = '" + cmd + "'"));
|
||||||
Database.Execute(string.Format(insertSyntax, "cmd = 'review' AND cmdmsg = 'next'"));
|
Database.Execute(string.Format(insertSyntax, "cmd = 'review' AND cmdmsg = 'next'"));
|
||||||
Database.Execute("DROP TABLE Playercmds");
|
Database.Backend.DeleteTable("Playercmds");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Here, since SQLite is a NEW thing from 5.3.0.0, we do not have to check for existing tables in SQLite.
|
// Here, since SQLite is a NEW thing from 5.3.0.0, we do not have to check for existing tables in SQLite.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user