From 15f5dcf860ccacbb423c39740d6ce85da0c1c312 Mon Sep 17 00:00:00 2001 From: GJ Date: Wed, 18 Sep 2013 09:57:28 -0400 Subject: [PATCH] Removed HudType references from the database. --- .../database/FlatfileDatabaseManager.java | 4 ++-- .../nossr50/database/SQLDatabaseManager.java | 19 +++++++++++-------- .../database/DatabaseUpdateType.java | 3 ++- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/database/FlatfileDatabaseManager.java b/src/main/java/com/gmail/nossr50/database/FlatfileDatabaseManager.java index 29f1ece1d..b82709cfb 100644 --- a/src/main/java/com/gmail/nossr50/database/FlatfileDatabaseManager.java +++ b/src/main/java/com/gmail/nossr50/database/FlatfileDatabaseManager.java @@ -346,7 +346,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager { out.append("0:"); // DATS out.append("0:"); // DATS out.append("0:"); // DATS - out.append("STANDARD").append(":"); // HUD + out.append(":"); out.append("0:"); // Fishing out.append("0:"); // FishingXp out.append("0:"); // Blast Mining @@ -609,7 +609,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager { // Introduction of HUDType // Version 1.1.06 // commit 78f79213cdd7190cd11ae54526f3b4ea42078e8a - newLine.append("STANDARD").append(":"); + newLine.append(":"); oldVersion = "1.1.06"; } if (character.length <= 35) { diff --git a/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java b/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java index 93bef8b3a..1f17ba547 100644 --- a/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java +++ b/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java @@ -130,6 +130,7 @@ public final class SQLDatabaseManager implements DatabaseManager { MobHealthbarType mobHealthbarType = profile.getMobHealthbarType(); saveLogin(userId, ((int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR))); + saveHuds(userId, (mobHealthbarType == null ? Config.getInstance().getMobHealthbarDefault().toString() : mobHealthbarType.toString())); saveLongs( "UPDATE " + tablePrefix + "cooldowns SET " + " mining = ?, woodcutting = ?, unarmed = ?" @@ -354,7 +355,7 @@ public final class SQLDatabaseManager implements DatabaseManager { + "s.taming, s.mining, s.repair, s.woodcutting, s.unarmed, s.herbalism, s.excavation, s.archery, s.swords, s.axes, s.acrobatics, s.fishing, " + "e.taming, e.mining, e.repair, e.woodcutting, e.unarmed, e.herbalism, e.excavation, e.archery, e.swords, e.axes, e.acrobatics, e.fishing, " + "c.taming, c.mining, c.repair, c.woodcutting, c.unarmed, c.herbalism, c.excavation, c.archery, c.swords, c.axes, c.acrobatics, c.blast_mining, " - + "h.hudtype, h.mobhealthbar " + + "h.mobhealthbar " + "FROM " + tablePrefix + "users u " + "JOIN " + tablePrefix + "skills s ON (u.id = s.user_id) " + "JOIN " + tablePrefix + "experience e ON (u.id = e.user_id) " @@ -422,7 +423,7 @@ public final class SQLDatabaseManager implements DatabaseManager { + "s.taming, s.mining, s.repair, s.woodcutting, s.unarmed, s.herbalism, s.excavation, s.archery, s.swords, s.axes, s.acrobatics, s.fishing, " + "e.taming, e.mining, e.repair, e.woodcutting, e.unarmed, e.herbalism, e.excavation, e.archery, e.swords, e.axes, e.acrobatics, e.fishing, " + "c.taming, c.mining, c.repair, c.woodcutting, c.unarmed, c.herbalism, c.excavation, c.archery, c.swords, c.axes, c.acrobatics, c.blast_mining, " - + "h.hudtype, h.mobhealthbar " + + "h.mobhealthbar " + "FROM " + tablePrefix + "users u " + "JOIN " + tablePrefix + "skills s ON (u.id = s.user_id) " + "JOIN " + tablePrefix + "experience e ON (u.id = e.user_id) " @@ -631,7 +632,6 @@ public final class SQLDatabaseManager implements DatabaseManager { + "UNIQUE KEY `user` (`user`)) DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;"); write("CREATE TABLE IF NOT EXISTS `" + tablePrefix + "huds` (" + "`user_id` int(10) unsigned NOT NULL," - + "`hudtype` varchar(50) NOT NULL DEFAULT 'STANDARD'," + "`mobhealthbar` varchar(50) NOT NULL DEFAULT '" + Config.getInstance().getMobHealthbarDefault() + "'," + "PRIMARY KEY (`user_id`)) " + "DEFAULT CHARSET=latin1;"); @@ -732,6 +732,10 @@ public final class SQLDatabaseManager implements DatabaseManager { write("ALTER TABLE `" + tablePrefix + "users` DROP COLUMN `party` ;"); return; + case DROPPED_SPOUT: + write("ALTER TABLE `" + tablePrefix + "huds` DROP COLUMN `hudtype` ;"); + return; + case KILL_ORPHANS: mcMMO.p.getLogger().info("Killing orphans"); write( @@ -1118,14 +1122,13 @@ public final class SQLDatabaseManager implements DatabaseManager { } } - private void saveHuds(int userId, String hudType, String mobHealthBar) { + private void saveHuds(int userId, String mobHealthBar) { PreparedStatement statement = null; try { - statement = connection.prepareStatement("UPDATE " + tablePrefix + "huds SET hudtype = ?, mobhealthbar = ? WHERE user_id = ?"); - statement.setString(1, hudType); - statement.setString(2, mobHealthBar); - statement.setInt(3, userId); + statement = connection.prepareStatement("UPDATE " + tablePrefix + "huds SET mobhealthbar = ? WHERE user_id = ?"); + statement.setString(1, mobHealthBar); + statement.setInt(2, userId); statement.execute(); } catch (SQLException ex) { diff --git a/src/main/java/com/gmail/nossr50/datatypes/database/DatabaseUpdateType.java b/src/main/java/com/gmail/nossr50/datatypes/database/DatabaseUpdateType.java index c47919501..2d2d2133c 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/database/DatabaseUpdateType.java +++ b/src/main/java/com/gmail/nossr50/datatypes/database/DatabaseUpdateType.java @@ -5,7 +5,8 @@ public enum DatabaseUpdateType { BLAST_MINING, INDEX, MOB_HEALTHBARS, - PARTY_NAMES, + PARTY_NAMES, KILL_ORPHANS, + DROPPED_SPOUT ; }