diff --git a/Commands/Chat/CmdColor.cs b/Commands/Chat/CmdColor.cs
index da712bc84..5880efb4b 100644
--- a/Commands/Chat/CmdColor.cs
+++ b/Commands/Chat/CmdColor.cs
@@ -70,14 +70,14 @@ namespace MCGalaxy.Commands {
if (args.Length == 1) {
Player.SendChatFrom(who, who.ColoredName + " %Shad their color removed.", false);
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 {
string color = Colors.Parse(args[1]);
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; }
Player.SendChatFrom(who, who.ColoredName + " %Shad their color changed to " + color + Colors.Name(color) + "%S.", false);
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.GlobalSpawn(who, true);
diff --git a/Database/IDatabaseBackend.cs b/Database/IDatabaseBackend.cs
index 356dbc5e3..db1949052 100644
--- a/Database/IDatabaseBackend.cs
+++ b/Database/IDatabaseBackend.cs
@@ -58,5 +58,11 @@ namespace MCGalaxy.SQL {
string syntax = "INSERT INTO `" + dstTable + "` SELECT * FROM `" + srcTable + "`";
Database.Execute(syntax);
}
+
+ /// Completely removes the given table from the database.
+ public virtual void DeleteTable(string table) {
+ string syntax = "DROP TABLE `" + table + "`";
+ Database.Execute(syntax);
+ }
}
}
diff --git a/Economy/Economy.cs b/Economy/Economy.cs
index a35c192b2..9b745c51d 100644
--- a/Economy/Economy.cs
+++ b/Economy/Economy.cs
@@ -65,7 +65,7 @@ PRIMARY KEY(player)
Database.Execute("INSERT INTO Economy (player, money) SELECT Players.Name, Players.Money FROM Players");
} else {
//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;
}
players.Dispose(); eco.Dispose();
diff --git a/Levels/LevelActions.cs b/Levels/LevelActions.cs
index 4f69f994d..fcfbf8dd0 100644
--- a/Levels/LevelActions.cs
+++ b/Levels/LevelActions.cs
@@ -74,7 +74,7 @@ namespace MCGalaxy {
string updateSyntax = "UPDATE `Portals" + dst + "` SET ExitMap=@1 WHERE ExitMap=@0";
Database.Execute(updateSyntax, src, dst);
}
-
+
if (Database.TableExists("Messages" + src)) {
Database.Backend.RenameTable("Messages" + src, "Messages" + dst);
}
@@ -136,15 +136,18 @@ namespace MCGalaxy {
BotsFile.DeleteBots(name);
//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);
lock (locker) {
- if (Database.TableExists("Portals" + name))
- Database.Execute("DROP TABLE `Portals" + name + "`");
- if (Database.TableExists("Messages" + name))
- Database.Execute("DROP TABLE `Messages" + name + "`");
- if (Database.TableExists("Zone" + name))
- Database.Execute("DROP TABLE `Zone" + name + "`");
+ if (Database.TableExists("Portals" + name)) {
+ Database.Backend.DeleteTable("Portals" + name);
+ }
+ if (Database.TableExists("Messages" + name)) {
+ Database.Backend.DeleteTable("Messages" + name);
+ }
+ if (Database.TableExists("Zone" + name)) {
+ Database.Backend.DeleteTable("Zone" + name);
+ }
}
}
diff --git a/Server/BackupDB.cs b/Server/BackupDB.cs
index 338318206..2387387da 100644
--- a/Server/BackupDB.cs
+++ b/Server/BackupDB.cs
@@ -202,8 +202,8 @@ namespace MCGalaxy {
//Delete old
List tables = GetTables();
- foreach (string name in tables)
- Database.Execute("DROP TABLE `" + name + "`");
+ foreach (string table in tables)
+ Database.Backend.DeleteTable(table);
// Import data
using (StreamReader reader = new StreamReader(stream))
diff --git a/Server/Server.DB.cs b/Server/Server.DB.cs
index b35926faf..3e2ac18ba 100644
--- a/Server/Server.DB.cs
+++ b/Server/Server.DB.cs
@@ -80,7 +80,7 @@ SELECT Time, Name, Cmd, Cmdmsg FROM Playercmds WHERE {0};";
foreach (string cmd in Server.Opstats)
Database.Execute(string.Format(insertSyntax, "cmd = '" + cmd + "'"));
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.