mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-01-19 08:55:26 +01:00
Minor cleanup.
This commit is contained in:
parent
599bbe73b4
commit
bfe8403d75
@ -25,22 +25,12 @@ public class PrimitiveChunkStore implements ChunkStore {
|
||||
private List<UUID> spawnedMobs = new ArrayList<UUID>();
|
||||
transient private int worldHeight;
|
||||
|
||||
transient private int xBitShifts;
|
||||
transient private int zBitShifts;
|
||||
transient private boolean conversionNeeded;
|
||||
|
||||
public PrimitiveChunkStore(World world, int cx, int cz) {
|
||||
this.cx = cx;
|
||||
this.cz = cz;
|
||||
this.worldUid = world.getUID();
|
||||
|
||||
this.worldHeight = world != null ? world.getMaxHeight() : 128;
|
||||
this.xBitShifts = 11;
|
||||
this.zBitShifts = 7;
|
||||
|
||||
this.worldHeight = world.getMaxHeight();
|
||||
this.store = new boolean[16][16][this.worldHeight];
|
||||
|
||||
conversionNeeded = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -207,8 +197,6 @@ public class PrimitiveChunkStore implements ChunkStore {
|
||||
World world = mcMMO.p.getServer().getWorld(this.worldUid);
|
||||
|
||||
this.worldHeight = world.getMaxHeight();
|
||||
this.xBitShifts = 11;
|
||||
this.zBitShifts = 7;
|
||||
|
||||
store = (boolean[][][]) in.readObject();
|
||||
|
||||
|
@ -179,7 +179,7 @@ public final class Database {
|
||||
break;
|
||||
|
||||
case INDEX:
|
||||
if(read("SHOW INDEX FROM " + tablePrefix + "skills").size() != 13) {
|
||||
if (read("SHOW INDEX FROM " + tablePrefix + "skills").size() != 13) {
|
||||
mcMMO.p.getLogger().info("Indexing tables, this may take a while on larger databases");
|
||||
write("ALTER TABLE `" + tablePrefix + "skills` ADD INDEX `idx_taming` (`taming`) USING BTREE, "
|
||||
+ "ADD INDEX `idx_mining` (`mining`) USING BTREE, "
|
||||
@ -478,24 +478,26 @@ public final class Database {
|
||||
for (SkillType skillType: SkillType.values()) {
|
||||
if (skillType.isChildSkill()) continue;
|
||||
String sql;
|
||||
if(skillType != SkillType.ALL) {
|
||||
if (skillType != SkillType.ALL) {
|
||||
sql = "SELECT COUNT(*) AS rank FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE " + skillType.name().toLowerCase() + " > 0 AND " + skillType.name().toLowerCase() + " > (SELECT " + skillType.name().toLowerCase() + " FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE user = '" + playerName + "')";
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
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 FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE user = '" + playerName + "')";
|
||||
}
|
||||
PreparedStatement statement = connection.prepareStatement(sql);
|
||||
resultSet = statement.executeQuery();
|
||||
resultSet.next();
|
||||
int rank = resultSet.getInt("rank");
|
||||
if(skillType != SkillType.ALL) {
|
||||
if (skillType != SkillType.ALL) {
|
||||
sql = "SELECT user, " + skillType.name().toLowerCase() + " FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE " + skillType.name().toLowerCase() + " > 0 AND " + skillType.name().toLowerCase() + " = (SELECT " + skillType.name().toLowerCase() + " FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE user = '" + playerName + "') ORDER BY user";
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
sql = "SELECT user, taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing 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 FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE user = '" + playerName + "') ORDER BY user";
|
||||
}
|
||||
statement = connection.prepareStatement(sql);
|
||||
resultSet = statement.executeQuery();
|
||||
while (resultSet.next()) {
|
||||
if(resultSet.getString("user").equalsIgnoreCase(playerName)) {
|
||||
if (resultSet.getString("user").equalsIgnoreCase(playerName)) {
|
||||
skills.put(skillType.name(), rank + resultSet.getRow());
|
||||
break;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user