mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-06-26 10:44:43 +02:00
Introduction of new Alchemy skill!
This commit is contained in:
@ -265,6 +265,8 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
writer.append(System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR).append(":");
|
||||
MobHealthbarType mobHealthbarType = profile.getMobHealthbarType();
|
||||
writer.append(mobHealthbarType == null ? Config.getInstance().getMobHealthbarDefault().toString() : mobHealthbarType.toString()).append(":");
|
||||
writer.append(profile.getSkillLevel(SkillType.ALCHEMY)).append(":");
|
||||
writer.append(profile.getSkillXpLevel(SkillType.ALCHEMY)).append(":");
|
||||
writer.append("\r\n");
|
||||
}
|
||||
}
|
||||
@ -354,7 +356,9 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
out.append("0:"); // Blast Mining
|
||||
out.append(String.valueOf(System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR)).append(":"); // LastLogin
|
||||
out.append(Config.getInstance().getMobHealthbarDefault().toString()).append(":"); // Mob Healthbar HUD
|
||||
|
||||
out.append("0:"); // Alchemy
|
||||
out.append("0:"); // AlchemyXp
|
||||
|
||||
// Add more in the same format as the line above
|
||||
|
||||
out.newLine();
|
||||
@ -503,6 +507,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
List<PlayerStat> unarmed = new ArrayList<PlayerStat>();
|
||||
List<PlayerStat> taming = new ArrayList<PlayerStat>();
|
||||
List<PlayerStat> fishing = new ArrayList<PlayerStat>();
|
||||
List<PlayerStat> alchemy = new ArrayList<PlayerStat>();
|
||||
|
||||
BufferedReader in = null;
|
||||
String playerName = null;
|
||||
@ -520,6 +525,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
Map<SkillType, Integer> skills = getSkillMapFromLine(data);
|
||||
|
||||
powerLevel += putStat(acrobatics, playerName, skills.get(SkillType.ACROBATICS));
|
||||
powerLevel += putStat(alchemy, playerName, skills.get(SkillType.ALCHEMY));
|
||||
powerLevel += putStat(archery, playerName, skills.get(SkillType.ARCHERY));
|
||||
powerLevel += putStat(axes, playerName, skills.get(SkillType.AXES));
|
||||
powerLevel += putStat(excavation, playerName, skills.get(SkillType.EXCAVATION));
|
||||
@ -557,6 +563,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
Collections.sort(acrobatics, c);
|
||||
Collections.sort(taming, c);
|
||||
Collections.sort(fishing, c);
|
||||
Collections.sort(alchemy, c);
|
||||
Collections.sort(powerLevels, c);
|
||||
|
||||
playerStatHash.put(SkillType.MINING, mining);
|
||||
@ -571,6 +578,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
playerStatHash.put(SkillType.ACROBATICS, acrobatics);
|
||||
playerStatHash.put(SkillType.TAMING, taming);
|
||||
playerStatHash.put(SkillType.FISHING, fishing);
|
||||
playerStatHash.put(SkillType.ALCHEMY, alchemy);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -623,7 +631,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
}
|
||||
|
||||
// If they're valid, rewrite them to the file.
|
||||
if (character.length > 38) {
|
||||
if (character.length > 40) {
|
||||
writer.append(line).append("\r\n");
|
||||
continue;
|
||||
}
|
||||
@ -675,6 +683,15 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
oldVersion = "1.4.06";
|
||||
}
|
||||
}
|
||||
if (character.length <= 40) {
|
||||
// Addition of Alchemy
|
||||
// Version 1.4.08
|
||||
newLine.append("0").append(":");
|
||||
newLine.append("0").append(":");
|
||||
if (oldVersion == null) {
|
||||
oldVersion = "1.4.08";
|
||||
}
|
||||
}
|
||||
|
||||
if (oldVersion != null) {
|
||||
mcMMO.p.debug("Updating database line for player " + character[0] + " from before version " + oldVersion);
|
||||
@ -771,6 +788,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
skillsXp.put(SkillType.AXES, (float) Integer.valueOf(character[21]));
|
||||
skillsXp.put(SkillType.ACROBATICS, (float) Integer.valueOf(character[22]));
|
||||
skillsXp.put(SkillType.FISHING, (float) Integer.valueOf(character[35]));
|
||||
skillsXp.put(SkillType.ALCHEMY, (float) Integer.valueOf(character[40]));
|
||||
|
||||
// Taming - Unused
|
||||
skillsDATS.put(AbilityType.SUPER_BREAKER, Integer.valueOf(character[32]));
|
||||
@ -810,6 +828,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
skills.put(SkillType.AXES, Integer.valueOf(character[13]));
|
||||
skills.put(SkillType.ACROBATICS, Integer.valueOf(character[14]));
|
||||
skills.put(SkillType.FISHING, Integer.valueOf(character[34]));
|
||||
skills.put(SkillType.ALCHEMY, Integer.valueOf(character[39]));
|
||||
|
||||
return skills;
|
||||
}
|
||||
|
@ -152,7 +152,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
+ " taming = ?, mining = ?, repair = ?, woodcutting = ?"
|
||||
+ ", unarmed = ?, herbalism = ?, excavation = ?"
|
||||
+ ", archery = ?, swords = ?, axes = ?, acrobatics = ?"
|
||||
+ ", fishing = ? WHERE user_id = ?",
|
||||
+ ", fishing = ?, alchemy = ? WHERE user_id = ?",
|
||||
profile.getSkillLevel(SkillType.TAMING),
|
||||
profile.getSkillLevel(SkillType.MINING),
|
||||
profile.getSkillLevel(SkillType.REPAIR),
|
||||
@ -165,13 +165,14 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
profile.getSkillLevel(SkillType.AXES),
|
||||
profile.getSkillLevel(SkillType.ACROBATICS),
|
||||
profile.getSkillLevel(SkillType.FISHING),
|
||||
profile.getSkillLevel(SkillType.ALCHEMY),
|
||||
userId);
|
||||
success &= saveIntegers(
|
||||
"UPDATE " + tablePrefix + "experience SET "
|
||||
+ " taming = ?, mining = ?, repair = ?, woodcutting = ?"
|
||||
+ ", unarmed = ?, herbalism = ?, excavation = ?"
|
||||
+ ", archery = ?, swords = ?, axes = ?, acrobatics = ?"
|
||||
+ ", fishing = ? WHERE user_id = ?",
|
||||
+ ", fishing = ?, alchemy = ? WHERE user_id = ?",
|
||||
profile.getSkillXpLevel(SkillType.TAMING),
|
||||
profile.getSkillXpLevel(SkillType.MINING),
|
||||
profile.getSkillXpLevel(SkillType.REPAIR),
|
||||
@ -184,6 +185,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
profile.getSkillXpLevel(SkillType.AXES),
|
||||
profile.getSkillXpLevel(SkillType.ACROBATICS),
|
||||
profile.getSkillXpLevel(SkillType.FISHING),
|
||||
profile.getSkillXpLevel(SkillType.ALCHEMY),
|
||||
userId);
|
||||
return success;
|
||||
}
|
||||
@ -192,7 +194,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
List<PlayerStat> stats = new ArrayList<PlayerStat>();
|
||||
|
||||
if (checkConnected()) {
|
||||
String query = skill == null ? "taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing" : skill.name().toLowerCase();
|
||||
String query = skill == null ? "taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing+alchemy" : skill.name().toLowerCase();
|
||||
ResultSet resultSet = null;
|
||||
PreparedStatement statement = null;
|
||||
|
||||
@ -271,9 +273,9 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
}
|
||||
|
||||
String sql = "SELECT COUNT(*) AS rank FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id " +
|
||||
"WHERE taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing > 0 " +
|
||||
"AND taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing > " +
|
||||
"(SELECT taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing " +
|
||||
"WHERE taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing+alchemy > 0 " +
|
||||
"AND taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing+alchemy > " +
|
||||
"(SELECT taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing+alchemy " +
|
||||
"FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE user = ?)";
|
||||
|
||||
PreparedStatement statement = connection.prepareStatement(sql);
|
||||
@ -286,11 +288,11 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
|
||||
statement.close();
|
||||
|
||||
sql = "SELECT user, taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing " +
|
||||
sql = "SELECT user, taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing+alchemy " +
|
||||
"FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id " +
|
||||
"WHERE taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing > 0 " +
|
||||
"AND taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing = " +
|
||||
"(SELECT taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing " +
|
||||
"WHERE taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing+alchemy > 0 " +
|
||||
"AND taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing+alchemy = " +
|
||||
"(SELECT taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing+alchemy " +
|
||||
"FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE user = ?) ORDER BY user";
|
||||
|
||||
statement = connection.prepareStatement(sql);
|
||||
@ -359,8 +361,8 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
try {
|
||||
statement = connection.prepareStatement(
|
||||
"SELECT "
|
||||
+ "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, "
|
||||
+ "s.taming, s.mining, s.repair, s.woodcutting, s.unarmed, s.herbalism, s.excavation, s.archery, s.swords, s.axes, s.acrobatics, s.fishing, s.alchemy, "
|
||||
+ "e.taming, e.mining, e.repair, e.woodcutting, e.unarmed, e.herbalism, e.excavation, e.archery, e.swords, e.axes, e.acrobatics, e.fishing, e.alchemy, "
|
||||
+ "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.mobhealthbar "
|
||||
+ "FROM " + tablePrefix + "users u "
|
||||
@ -435,8 +437,8 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
try {
|
||||
statement = connection.prepareStatement(
|
||||
"SELECT "
|
||||
+ "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, "
|
||||
+ "s.taming, s.mining, s.repair, s.woodcutting, s.unarmed, s.herbalism, s.excavation, s.archery, s.swords, s.axes, s.acrobatics, s.fishing, s.alchemy, "
|
||||
+ "e.taming, e.mining, e.repair, e.woodcutting, e.unarmed, e.herbalism, e.excavation, e.archery, e.swords, e.axes, e.acrobatics, e.fishing, e.alchemy, "
|
||||
+ "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.mobhealthbar "
|
||||
+ "FROM " + tablePrefix + "users u "
|
||||
@ -687,6 +689,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
+ "`axes` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`acrobatics` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`fishing` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`alchemy` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "PRIMARY KEY (`user_id`)) "
|
||||
+ "DEFAULT CHARSET=latin1;");
|
||||
write("CREATE TABLE IF NOT EXISTS `" + tablePrefix + "experience` ("
|
||||
@ -703,6 +706,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
+ "`axes` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`acrobatics` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`fishing` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`alchemy` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "PRIMARY KEY (`user_id`)) "
|
||||
+ "DEFAULT CHARSET=latin1;");
|
||||
|
||||
@ -728,6 +732,10 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
sql = "SELECT * FROM `" + tablePrefix + "experience` ORDER BY `" + tablePrefix + "experience`.`fishing` ASC LIMIT 0 , 30";
|
||||
break;
|
||||
|
||||
case ALCHEMY:
|
||||
sql = "SELECT * FROM `" + tablePrefix + "experience` ORDER BY `" + tablePrefix + "experience`.`alchemy` ASC LIMIT 0 , 30";
|
||||
break;
|
||||
|
||||
case INDEX:
|
||||
if (read("SHOW INDEX FROM " + tablePrefix + "skills").size() != 13 && checkConnected()) {
|
||||
mcMMO.p.getLogger().info("Indexing tables, this may take a while on larger databases");
|
||||
@ -830,6 +838,12 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
write("ALTER TABLE `" + tablePrefix + "huds` ADD `mobhealthbar` varchar(50) NOT NULL DEFAULT '" + Config.getInstance().getMobHealthbarDefault() + "' ;");
|
||||
break;
|
||||
|
||||
case ALCHEMY:
|
||||
mcMMO.p.getLogger().info("Updating mcMMO MySQL tables for Alchemy...");
|
||||
write("ALTER TABLE `"+tablePrefix + "skills` ADD `alchemy` int(10) NOT NULL DEFAULT '0' ;");
|
||||
write("ALTER TABLE `"+tablePrefix + "experience` ADD `alchemy` int(10) NOT NULL DEFAULT '0' ;");
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -1199,6 +1213,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
skills.put(SkillType.AXES, result.getInt(OFFSET_SKILLS + 10));
|
||||
skills.put(SkillType.ACROBATICS, result.getInt(OFFSET_SKILLS + 11));
|
||||
skills.put(SkillType.FISHING, result.getInt(OFFSET_SKILLS + 12));
|
||||
skills.put(SkillType.ALCHEMY, result.getInt(OFFSET_SKILLS + 13));
|
||||
|
||||
skillsXp.put(SkillType.TAMING, result.getFloat(OFFSET_XP + 1));
|
||||
skillsXp.put(SkillType.MINING, result.getFloat(OFFSET_XP + 2));
|
||||
@ -1212,6 +1227,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
skillsXp.put(SkillType.AXES, result.getFloat(OFFSET_XP + 10));
|
||||
skillsXp.put(SkillType.ACROBATICS, result.getFloat(OFFSET_XP + 11));
|
||||
skillsXp.put(SkillType.FISHING, result.getFloat(OFFSET_XP + 12));
|
||||
skillsXp.put(SkillType.ALCHEMY, result.getFloat(OFFSET_XP + 13));
|
||||
|
||||
// Taming - Unused - result.getInt(OFFSET_DATS + 1)
|
||||
skillsDATS.put(AbilityType.SUPER_BREAKER, result.getInt(OFFSET_DATS + 2));
|
||||
|
Reference in New Issue
Block a user