some of zreeds work, because too lazy to fix merge compatability

This commit is contained in:
t00thpick1 2014-07-31 12:44:41 -04:00
parent 9668bb2ee7
commit 2248316ed3
2 changed files with 16 additions and 9 deletions

View File

@ -2,7 +2,6 @@ package com.gmail.nossr50.database;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.BufferedWriter; import java.io.BufferedWriter;
import java.io.Closeable;
import java.io.File; import java.io.File;
import java.io.FileReader; import java.io.FileReader;
import java.io.FileWriter; import java.io.FileWriter;
@ -10,6 +9,7 @@ import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.EnumMap;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
@ -367,7 +367,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
public Map<SkillType, Integer> readRank(String playerName) { public Map<SkillType, Integer> readRank(String playerName) {
updateLeaderboards(); updateLeaderboards();
Map<SkillType, Integer> skills = new HashMap<SkillType, Integer>(); Map<SkillType, Integer> skills = new EnumMap<SkillType, Integer>(SkillType.class);
for (SkillType skill : SkillType.NON_CHILD_SKILLS) { for (SkillType skill : SkillType.NON_CHILD_SKILLS) {
skills.put(skill, getPlayerRank(playerName, playerStatHash.get(skill))); skills.put(skill, getPlayerRank(playerName, playerStatHash.get(skill)));
@ -1081,8 +1081,8 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
private PlayerProfile loadFromLine(String[] character) { private PlayerProfile loadFromLine(String[] character) {
Map<SkillType, Integer> skills = getSkillMapFromLine(character); // Skill levels Map<SkillType, Integer> skills = getSkillMapFromLine(character); // Skill levels
Map<SkillType, Float> skillsXp = new HashMap<SkillType, Float>(); // Skill & XP Map<SkillType, Float> skillsXp = new EnumMap<SkillType, Float>(SkillType.class); // Skill & XP
Map<AbilityType, Integer> skillsDATS = new HashMap<AbilityType, Integer>(); // Ability & Cooldown Map<AbilityType, Integer> skillsDATS = new EnumMap<AbilityType, Integer>(AbilityType.class); // Ability & Cooldown
MobHealthbarType mobHealthbarType; MobHealthbarType mobHealthbarType;
// TODO on updates, put new values in a try{} ? // TODO on updates, put new values in a try{} ?
@ -1133,7 +1133,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
} }
private Map<SkillType, Integer> getSkillMapFromLine(String[] character) { private Map<SkillType, Integer> getSkillMapFromLine(String[] character) {
Map<SkillType, Integer> skills = new HashMap<SkillType, Integer>(); // Skill & Level Map<SkillType, Integer> skills = new EnumMap<SkillType, Integer>(SkillType.class); // Skill & Level
skills.put(SkillType.TAMING, Integer.valueOf(character[24])); skills.put(SkillType.TAMING, Integer.valueOf(character[24]));
skills.put(SkillType.MINING, Integer.valueOf(character[1])); skills.put(SkillType.MINING, Integer.valueOf(character[1]));

View File

@ -8,6 +8,7 @@ import java.sql.SQLException;
import java.sql.Statement; import java.sql.Statement;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.EnumMap;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -55,6 +56,10 @@ public final class SQLDatabaseManager implements DatabaseManager {
connectionProperties.put("user", Config.getInstance().getMySQLUserName()); connectionProperties.put("user", Config.getInstance().getMySQLUserName());
connectionProperties.put("password", Config.getInstance().getMySQLUserPassword()); connectionProperties.put("password", Config.getInstance().getMySQLUserPassword());
connectionProperties.put("autoReconnect", "false"); connectionProperties.put("autoReconnect", "false");
connectionProperties.put("cachePrepStmts", "true");
connectionProperties.put("prepStmtCacheSize", "64");
connectionProperties.put("prepStmtCacheSqlLimit", "2048");
connectionProperties.put("useServerPrepStmts", "true");
connectionPool = new ConnectionPool("mcMMO-Pool", connectionPool = new ConnectionPool("mcMMO-Pool",
1 /*Minimum of one*/, 1 /*Minimum of one*/,
Config.getInstance().getMySQLMaxPoolSize() /*max pool size */, Config.getInstance().getMySQLMaxPoolSize() /*max pool size */,
@ -415,7 +420,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
} }
public Map<SkillType, Integer> readRank(String playerName) { public Map<SkillType, Integer> readRank(String playerName) {
Map<SkillType, Integer> skills = new HashMap<SkillType, Integer>(); Map<SkillType, Integer> skills = new EnumMap<SkillType, Integer>(SkillType.class);
ResultSet resultSet = null; ResultSet resultSet = null;
PreparedStatement statement = null; PreparedStatement statement = null;
@ -1238,9 +1243,9 @@ public final class SQLDatabaseManager implements DatabaseManager {
} }
private PlayerProfile loadFromResult(String playerName, ResultSet result) throws SQLException { private PlayerProfile loadFromResult(String playerName, ResultSet result) throws SQLException {
Map<SkillType, Integer> skills = new HashMap<SkillType, Integer>(); // Skill & Level Map<SkillType, Integer> skills = new EnumMap<SkillType, Integer>(SkillType.class); // Skill & Level
Map<SkillType, Float> skillsXp = new HashMap<SkillType, Float>(); // Skill & XP Map<SkillType, Float> skillsXp = new EnumMap<SkillType, Float>(SkillType.class); // Skill & XP
Map<AbilityType, Integer> skillsDATS = new HashMap<AbilityType, Integer>(); // Ability & Cooldown Map<AbilityType, Integer> skillsDATS = new EnumMap<AbilityType, Integer>(AbilityType.class); // Ability & Cooldown
MobHealthbarType mobHealthbarType; MobHealthbarType mobHealthbarType;
UUID uuid; UUID uuid;
@ -1309,6 +1314,8 @@ public final class SQLDatabaseManager implements DatabaseManager {
} }
private void printErrors(SQLException ex) { private void printErrors(SQLException ex) {
StackTraceElement element = ex.getStackTrace()[0];
mcMMO.p.getLogger().severe("Location: " + element.getMethodName() + " " + element.getLineNumber());
mcMMO.p.getLogger().severe("SQLException: " + ex.getMessage()); mcMMO.p.getLogger().severe("SQLException: " + ex.getMessage());
mcMMO.p.getLogger().severe("SQLState: " + ex.getSQLState()); mcMMO.p.getLogger().severe("SQLState: " + ex.getSQLState());
mcMMO.p.getLogger().severe("VendorError: " + ex.getErrorCode()); mcMMO.p.getLogger().severe("VendorError: " + ex.getErrorCode());