diff --git a/src/Changelog.txt b/src/Changelog.txt index 184965543..5b187ef89 100644 --- a/src/Changelog.txt +++ b/src/Changelog.txt @@ -1,6 +1,10 @@ Changelog: #Versions without changelogs probably had very small misc fixes, like tweaks to the source code Version 1.2.03 +skills2 and experience2 will be removed from MySQL DB automagically when this version first runs +Fishing is now stored in skills and experience tables on the MySQL DB as it should have been +Fishing will now save properly for MySQL +Fishing will now work properly with mctop for those using MySQL Fixed problems with mmoedit and fishing Version 1.2.02 diff --git a/src/com/gmail/nossr50/Database.java b/src/com/gmail/nossr50/Database.java index 0a7f8fb1a..9db72945f 100644 --- a/src/com/gmail/nossr50/Database.java +++ b/src/com/gmail/nossr50/Database.java @@ -48,7 +48,6 @@ public class Database { } } //Create the DB structure - public void createStructure() { Write("CREATE TABLE IF NOT EXISTS `" + LoadProperties.MySQLtablePrefix + "huds` (`user_id` int(10) unsigned NOT NULL," + "`hudtype` varchar(50) NOT NULL DEFAULT ''," @@ -85,11 +84,6 @@ public class Database { + "`axes` int(10) unsigned NOT NULL DEFAULT '0'," + "`acrobatics` int(10) unsigned NOT NULL DEFAULT '0'," + "PRIMARY KEY (`user_id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1;"); - Write("CREATE TABLE IF NOT EXISTS `" + LoadProperties.MySQLtablePrefix + "skills2` (`user_id` int(10) unsigned NOT NULL," - + "`fishing` int(10) unsigned NOT NULL DEFAULT '0'," - + "`enchanting` int(10) unsigned NOT NULL DEFAULT '0'," - + "`alchemy` int(10) unsigned NOT NULL DEFAULT '0'," - + "PRIMARY KEY (`user_id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1;"); Write("CREATE TABLE IF NOT EXISTS `" + LoadProperties.MySQLtablePrefix + "experience` (`user_id` int(10) unsigned NOT NULL," + "`taming` int(10) unsigned NOT NULL DEFAULT '0'," + "`mining` int(10) unsigned NOT NULL DEFAULT '0'," @@ -103,19 +97,47 @@ public class Database { + "`axes` int(10) unsigned NOT NULL DEFAULT '0'," + "`acrobatics` int(10) unsigned NOT NULL DEFAULT '0'," + "PRIMARY KEY (`user_id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1;"); - Write("CREATE TABLE IF NOT EXISTS `" + LoadProperties.MySQLtablePrefix + "experience2` (`user_id` int(10) unsigned NOT NULL," - + "`fishing` int(10) unsigned NOT NULL DEFAULT '0'," - + "`enchanting` int(10) unsigned NOT NULL DEFAULT '0'," - + "`alchemy` int(10) unsigned NOT NULL DEFAULT '0'," - + "PRIMARY KEY (`user_id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1;"); Write("CREATE TABLE IF NOT EXISTS `" + LoadProperties.MySQLtablePrefix + "spawn` (`user_id` int(10) NOT NULL," + "`x` int(64) NOT NULL DEFAULT '0'," + "`y` int(64) NOT NULL DEFAULT '0'," + "`z` int(64) NOT NULL DEFAULT '0'," + "`world` varchar(50) NOT NULL DEFAULT ''," + "PRIMARY KEY (`user_id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1;"); + + Write("DROP TABLE IF EXISTS `"+LoadProperties.MySQLtablePrefix+"skills2`"); + Write("DROP TABLE IF EXISTS `"+LoadProperties.MySQLtablePrefix+"experience2`"); + + checkDatabaseStructure(); } + public void checkDatabaseStructure() + { + String sql = "SELECT * FROM `mcmmo_experience` ORDER BY `"+LoadProperties.MySQLtablePrefix+"experience`.`fishing` ASC LIMIT 0 , 30"; + + ResultSet rs = null; + HashMap> Rows = new HashMap>(); + try { + Connection conn = DriverManager.getConnection(connectionString); + PreparedStatement stmt = conn.prepareStatement(sql); + if (stmt.executeQuery() != null) { + stmt.executeQuery(); + rs = stmt.getResultSet(); + while (rs.next()) { + ArrayList Col = new ArrayList(); + for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) { + Col.add(rs.getString(i)); + } + Rows.put(rs.getRow(), Col); + } + } + conn.close(); + } catch (SQLException ex) { + System.out.println("Updating mcMMO MySQL tables..."); + Write("ALTER TABLE `"+LoadProperties.MySQLtablePrefix + "skills` ADD `fishing` int(10) NOT NULL DEFAULT '0' ;"); + Write("ALTER TABLE `"+LoadProperties.MySQLtablePrefix + "experience` ADD `fishing` int(10) NOT NULL DEFAULT '0' ;"); + } + } + // write query public boolean Write(String sql) { try { diff --git a/src/com/gmail/nossr50/command/Commands.java b/src/com/gmail/nossr50/command/Commands.java index 6a97f3a92..b248a16fb 100644 --- a/src/com/gmail/nossr50/command/Commands.java +++ b/src/com/gmail/nossr50/command/Commands.java @@ -743,7 +743,7 @@ public class Commands /* * MYSQL LEADERBOARDS */ - String powerlevel = "taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics"; + String powerlevel = "taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing"; if(split.length >= 2 && Skills.isSkill(split[1])){ /* * Create a nice consistent capitalized leaderboard name diff --git a/src/com/gmail/nossr50/datatypes/PlayerProfile.java b/src/com/gmail/nossr50/datatypes/PlayerProfile.java index 80e0ca230..acdbdf74c 100644 --- a/src/com/gmail/nossr50/datatypes/PlayerProfile.java +++ b/src/com/gmail/nossr50/datatypes/PlayerProfile.java @@ -33,6 +33,7 @@ import org.bukkit.Location; import org.bukkit.entity.Player; import com.gmail.nossr50.config.LoadProperties; import com.gmail.nossr50.party.Party; +import com.gmail.nossr50.Database; import com.gmail.nossr50.Users; import com.gmail.nossr50.m; import com.gmail.nossr50.mcMMO; @@ -164,7 +165,7 @@ public class PlayerProfile serratedStrikesDATS = Integer.valueOf(cooldowns.get(1).get(5)); skullSplitterDATS = Integer.valueOf(cooldowns.get(1).get(6)); } - HashMap> stats = mcMMO.database.Read("SELECT taming, mining, repair, woodcutting, unarmed, herbalism, excavation, archery, swords, axes, acrobatics FROM "+LoadProperties.MySQLtablePrefix+"skills WHERE user_id = " + id); + HashMap> stats = mcMMO.database.Read("SELECT taming, mining, repair, woodcutting, unarmed, herbalism, excavation, archery, swords, axes, acrobatics, fishing FROM "+LoadProperties.MySQLtablePrefix+"skills WHERE user_id = " + id); skills.put(SkillType.TAMING, Integer.valueOf(stats.get(1).get(0))); skills.put(SkillType.MINING, Integer.valueOf(stats.get(1).get(1))); skills.put(SkillType.REPAIR, Integer.valueOf(stats.get(1).get(2))); @@ -176,16 +177,8 @@ public class PlayerProfile skills.put(SkillType.SWORDS, Integer.valueOf(stats.get(1).get(8))); skills.put(SkillType.AXES, Integer.valueOf(stats.get(1).get(9))); skills.put(SkillType.ACROBATICS, Integer.valueOf(stats.get(1).get(10))); - HashMap> stats2 = mcMMO.database.Read("SELECT fishing, enchanting, alchemy FROM "+LoadProperties.MySQLtablePrefix+"skills2 WHERE user_id = " + id); - if(stats2.get(1) == null) - { - mcMMO.database.Write("INSERT INTO "+LoadProperties.MySQLtablePrefix+"skills2 (user_id) VALUES ("+id+")"); - } else { - skills.put(SkillType.FISHING, Integer.valueOf(stats2.get(1).get(0))); - skills.put(SkillType.ENCHANTING, Integer.valueOf(stats2.get(1).get(1))); - skills.put(SkillType.ALCHEMY, Integer.valueOf(stats2.get(1).get(2))); - } - HashMap> experience = mcMMO.database.Read("SELECT taming, mining, repair, woodcutting, unarmed, herbalism, excavation, archery, swords, axes, acrobatics FROM "+LoadProperties.MySQLtablePrefix+"experience WHERE user_id = " + id); + skills.put(SkillType.FISHING, Integer.valueOf(stats.get(1).get(11))); + HashMap> experience = mcMMO.database.Read("SELECT taming, mining, repair, woodcutting, unarmed, herbalism, excavation, archery, swords, axes, acrobatics, fishing FROM "+LoadProperties.MySQLtablePrefix+"experience WHERE user_id = " + id); skillsXp.put(SkillType.TAMING, Integer.valueOf(experience.get(1).get(0))); skillsXp.put(SkillType.MINING, Integer.valueOf(experience.get(1).get(1))); skillsXp.put(SkillType.REPAIR, Integer.valueOf(experience.get(1).get(2))); @@ -197,15 +190,7 @@ public class PlayerProfile skillsXp.put(SkillType.SWORDS, Integer.valueOf(experience.get(1).get(8))); skillsXp.put(SkillType.AXES, Integer.valueOf(experience.get(1).get(9))); skillsXp.put(SkillType.ACROBATICS, Integer.valueOf(experience.get(1).get(10))); - HashMap> experience2 = mcMMO.database.Read("SELECT fishing, enchanting, alchemy FROM "+LoadProperties.MySQLtablePrefix+"experience2 WHERE user_id = " + id); - if(experience2.get(1) == null) - { - mcMMO.database.Write("INSERT INTO "+LoadProperties.MySQLtablePrefix+"experience2 (user_id) VALUES ("+id+")"); - } else { - skillsXp.put(SkillType.FISHING, Integer.valueOf(experience2.get(1).get(0))); - skillsXp.put(SkillType.ENCHANTING, Integer.valueOf(experience2.get(1).get(1))); - skillsXp.put(SkillType.ALCHEMY, Integer.valueOf(experience2.get(1).get(2))); - } + skillsXp.put(SkillType.FISHING, Integer.valueOf(experience.get(1).get(11))); return true; } else { @@ -219,9 +204,7 @@ public class PlayerProfile mcMMO.database.Write("INSERT INTO "+LoadProperties.MySQLtablePrefix+"cooldowns (user_id) VALUES ("+id+")"); mcMMO.database.Write("INSERT INTO "+LoadProperties.MySQLtablePrefix+"spawn (user_id) VALUES ("+id+")"); mcMMO.database.Write("INSERT INTO "+LoadProperties.MySQLtablePrefix+"skills (user_id) VALUES ("+id+")"); - mcMMO.database.Write("INSERT INTO "+LoadProperties.MySQLtablePrefix+"skills2 (user_id) VALUES ("+id+")"); mcMMO.database.Write("INSERT INTO "+LoadProperties.MySQLtablePrefix+"experience (user_id) VALUES ("+id+")"); - mcMMO.database.Write("INSERT INTO "+LoadProperties.MySQLtablePrefix+"experience2 (user_id) VALUES ("+id+")"); this.userid = id; } @@ -364,11 +347,7 @@ public class PlayerProfile +", swords = " +skills.get(SkillType.SWORDS) +", axes = "+skills.get(SkillType.AXES) +", acrobatics = "+skills.get(SkillType.ACROBATICS) - +" WHERE user_id = "+this.userid); - mcMMO.database.Write("UPDATE "+LoadProperties.MySQLtablePrefix+"skills2 SET " - +" fishing = "+skills.get(SkillType.TAMING) - +", enchanting = "+skills.get(SkillType.MINING) - +", alchemy = "+skills.get(SkillType.REPAIR) + +", fishing = "+skills.get(SkillType.FISHING) +" WHERE user_id = "+this.userid); mcMMO.database.Write("UPDATE "+LoadProperties.MySQLtablePrefix+"experience SET " +" taming = "+skillsXp.get(SkillType.TAMING) @@ -382,11 +361,7 @@ public class PlayerProfile +", swords = " +skillsXp.get(SkillType.SWORDS) +", axes = "+skillsXp.get(SkillType.AXES) +", acrobatics = "+skillsXp.get(SkillType.ACROBATICS) - +" WHERE user_id = "+this.userid); - mcMMO.database.Write("UPDATE "+LoadProperties.MySQLtablePrefix+"experience2 SET " - +" fishing = "+skills.get(SkillType.TAMING) - +", enchanting = "+skills.get(SkillType.MINING) - +", alchemy = "+skills.get(SkillType.REPAIR) + +", fishing = "+skillsXp.get(SkillType.FISHING) +" WHERE user_id = "+this.userid); } else {