Version 1.2.03

This commit is contained in:
nossr50 2011-12-03 15:48:41 -08:00
parent 59429f066d
commit b9c8117937
4 changed files with 45 additions and 44 deletions

View File

@ -1,6 +1,10 @@
Changelog: Changelog:
#Versions without changelogs probably had very small misc fixes, like tweaks to the source code #Versions without changelogs probably had very small misc fixes, like tweaks to the source code
Version 1.2.03 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 Fixed problems with mmoedit and fishing
Version 1.2.02 Version 1.2.02

View File

@ -48,7 +48,6 @@ public class Database {
} }
} }
//Create the DB structure //Create the DB structure
public void createStructure() { public void createStructure() {
Write("CREATE TABLE IF NOT EXISTS `" + LoadProperties.MySQLtablePrefix + "huds` (`user_id` int(10) unsigned NOT NULL," Write("CREATE TABLE IF NOT EXISTS `" + LoadProperties.MySQLtablePrefix + "huds` (`user_id` int(10) unsigned NOT NULL,"
+ "`hudtype` varchar(50) NOT NULL DEFAULT ''," + "`hudtype` varchar(50) NOT NULL DEFAULT '',"
@ -85,11 +84,6 @@ public class Database {
+ "`axes` int(10) unsigned NOT NULL DEFAULT '0'," + "`axes` int(10) unsigned NOT NULL DEFAULT '0',"
+ "`acrobatics` int(10) unsigned NOT NULL DEFAULT '0'," + "`acrobatics` int(10) unsigned NOT NULL DEFAULT '0',"
+ "PRIMARY KEY (`user_id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1;"); + "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," Write("CREATE TABLE IF NOT EXISTS `" + LoadProperties.MySQLtablePrefix + "experience` (`user_id` int(10) unsigned NOT NULL,"
+ "`taming` int(10) unsigned NOT NULL DEFAULT '0'," + "`taming` int(10) unsigned NOT NULL DEFAULT '0',"
+ "`mining` 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'," + "`axes` int(10) unsigned NOT NULL DEFAULT '0',"
+ "`acrobatics` int(10) unsigned NOT NULL DEFAULT '0'," + "`acrobatics` int(10) unsigned NOT NULL DEFAULT '0',"
+ "PRIMARY KEY (`user_id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1;"); + "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," Write("CREATE TABLE IF NOT EXISTS `" + LoadProperties.MySQLtablePrefix + "spawn` (`user_id` int(10) NOT NULL,"
+ "`x` int(64) NOT NULL DEFAULT '0'," + "`x` int(64) NOT NULL DEFAULT '0',"
+ "`y` int(64) NOT NULL DEFAULT '0'," + "`y` int(64) NOT NULL DEFAULT '0',"
+ "`z` int(64) NOT NULL DEFAULT '0'," + "`z` int(64) NOT NULL DEFAULT '0',"
+ "`world` varchar(50) NOT NULL DEFAULT ''," + "`world` varchar(50) NOT NULL DEFAULT '',"
+ "PRIMARY KEY (`user_id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1;"); + "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<Integer, ArrayList<String>> Rows = new HashMap<Integer, ArrayList<String>>();
try {
Connection conn = DriverManager.getConnection(connectionString);
PreparedStatement stmt = conn.prepareStatement(sql);
if (stmt.executeQuery() != null) {
stmt.executeQuery();
rs = stmt.getResultSet();
while (rs.next()) {
ArrayList<String> Col = new ArrayList<String>();
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 // write query
public boolean Write(String sql) { public boolean Write(String sql) {
try { try {

View File

@ -743,7 +743,7 @@ public class Commands
/* /*
* MYSQL LEADERBOARDS * 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])){ if(split.length >= 2 && Skills.isSkill(split[1])){
/* /*
* Create a nice consistent capitalized leaderboard name * Create a nice consistent capitalized leaderboard name

View File

@ -33,6 +33,7 @@ import org.bukkit.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import com.gmail.nossr50.config.LoadProperties; import com.gmail.nossr50.config.LoadProperties;
import com.gmail.nossr50.party.Party; import com.gmail.nossr50.party.Party;
import com.gmail.nossr50.Database;
import com.gmail.nossr50.Users; import com.gmail.nossr50.Users;
import com.gmail.nossr50.m; import com.gmail.nossr50.m;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
@ -164,7 +165,7 @@ public class PlayerProfile
serratedStrikesDATS = Integer.valueOf(cooldowns.get(1).get(5)); serratedStrikesDATS = Integer.valueOf(cooldowns.get(1).get(5));
skullSplitterDATS = Integer.valueOf(cooldowns.get(1).get(6)); skullSplitterDATS = Integer.valueOf(cooldowns.get(1).get(6));
} }
HashMap<Integer, ArrayList<String>> 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<Integer, ArrayList<String>> 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.TAMING, Integer.valueOf(stats.get(1).get(0)));
skills.put(SkillType.MINING, Integer.valueOf(stats.get(1).get(1))); skills.put(SkillType.MINING, Integer.valueOf(stats.get(1).get(1)));
skills.put(SkillType.REPAIR, Integer.valueOf(stats.get(1).get(2))); 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.SWORDS, Integer.valueOf(stats.get(1).get(8)));
skills.put(SkillType.AXES, Integer.valueOf(stats.get(1).get(9))); skills.put(SkillType.AXES, Integer.valueOf(stats.get(1).get(9)));
skills.put(SkillType.ACROBATICS, Integer.valueOf(stats.get(1).get(10))); skills.put(SkillType.ACROBATICS, Integer.valueOf(stats.get(1).get(10)));
HashMap<Integer, ArrayList<String>> stats2 = mcMMO.database.Read("SELECT fishing, enchanting, alchemy FROM "+LoadProperties.MySQLtablePrefix+"skills2 WHERE user_id = " + id); skills.put(SkillType.FISHING, Integer.valueOf(stats.get(1).get(11)));
if(stats2.get(1) == null) HashMap<Integer, ArrayList<String>> 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);
{
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<Integer, ArrayList<String>> experience = mcMMO.database.Read("SELECT taming, mining, repair, woodcutting, unarmed, herbalism, excavation, archery, swords, axes, acrobatics FROM "+LoadProperties.MySQLtablePrefix+"experience WHERE user_id = " + id);
skillsXp.put(SkillType.TAMING, Integer.valueOf(experience.get(1).get(0))); 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.MINING, Integer.valueOf(experience.get(1).get(1)));
skillsXp.put(SkillType.REPAIR, Integer.valueOf(experience.get(1).get(2))); 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.SWORDS, Integer.valueOf(experience.get(1).get(8)));
skillsXp.put(SkillType.AXES, Integer.valueOf(experience.get(1).get(9))); skillsXp.put(SkillType.AXES, Integer.valueOf(experience.get(1).get(9)));
skillsXp.put(SkillType.ACROBATICS, Integer.valueOf(experience.get(1).get(10))); skillsXp.put(SkillType.ACROBATICS, Integer.valueOf(experience.get(1).get(10)));
HashMap<Integer, ArrayList<String>> experience2 = mcMMO.database.Read("SELECT fishing, enchanting, alchemy FROM "+LoadProperties.MySQLtablePrefix+"experience2 WHERE user_id = " + id); skillsXp.put(SkillType.FISHING, Integer.valueOf(experience.get(1).get(11)));
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)));
}
return true; return true;
} }
else { 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+"cooldowns (user_id) VALUES ("+id+")");
mcMMO.database.Write("INSERT INTO "+LoadProperties.MySQLtablePrefix+"spawn (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+"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+"experience (user_id) VALUES ("+id+")");
mcMMO.database.Write("INSERT INTO "+LoadProperties.MySQLtablePrefix+"experience2 (user_id) VALUES ("+id+")");
this.userid = id; this.userid = id;
} }
@ -364,11 +347,7 @@ public class PlayerProfile
+", swords = " +skills.get(SkillType.SWORDS) +", swords = " +skills.get(SkillType.SWORDS)
+", axes = "+skills.get(SkillType.AXES) +", axes = "+skills.get(SkillType.AXES)
+", acrobatics = "+skills.get(SkillType.ACROBATICS) +", acrobatics = "+skills.get(SkillType.ACROBATICS)
+" WHERE user_id = "+this.userid); +", fishing = "+skills.get(SkillType.FISHING)
mcMMO.database.Write("UPDATE "+LoadProperties.MySQLtablePrefix+"skills2 SET "
+" fishing = "+skills.get(SkillType.TAMING)
+", enchanting = "+skills.get(SkillType.MINING)
+", alchemy = "+skills.get(SkillType.REPAIR)
+" WHERE user_id = "+this.userid); +" WHERE user_id = "+this.userid);
mcMMO.database.Write("UPDATE "+LoadProperties.MySQLtablePrefix+"experience SET " mcMMO.database.Write("UPDATE "+LoadProperties.MySQLtablePrefix+"experience SET "
+" taming = "+skillsXp.get(SkillType.TAMING) +" taming = "+skillsXp.get(SkillType.TAMING)
@ -382,11 +361,7 @@ public class PlayerProfile
+", swords = " +skillsXp.get(SkillType.SWORDS) +", swords = " +skillsXp.get(SkillType.SWORDS)
+", axes = "+skillsXp.get(SkillType.AXES) +", axes = "+skillsXp.get(SkillType.AXES)
+", acrobatics = "+skillsXp.get(SkillType.ACROBATICS) +", acrobatics = "+skillsXp.get(SkillType.ACROBATICS)
+" WHERE user_id = "+this.userid); +", fishing = "+skillsXp.get(SkillType.FISHING)
mcMMO.database.Write("UPDATE "+LoadProperties.MySQLtablePrefix+"experience2 SET "
+" fishing = "+skills.get(SkillType.TAMING)
+", enchanting = "+skills.get(SkillType.MINING)
+", alchemy = "+skills.get(SkillType.REPAIR)
+" WHERE user_id = "+this.userid); +" WHERE user_id = "+this.userid);
} else } else
{ {