mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-06-28 03:34:43 +02:00
General cleanup to satisfy my OCD a little while longer.
This commit is contained in:
@ -84,7 +84,7 @@ public class Anniversary {
|
||||
GregorianCalendar day = new GregorianCalendar();
|
||||
|
||||
if (hasCelebrated.contains(sender.getName())) {
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
if (getDateRange(day.getTime(), anniversaryStart.getTime(), anniversaryEnd.getTime())) {
|
||||
|
@ -156,7 +156,7 @@ public class Database {
|
||||
/**
|
||||
* Check database structure for missing values.
|
||||
*
|
||||
* @param update Type of data to check updates for
|
||||
* @param update Type of data to check updates for
|
||||
*/
|
||||
public void checkDatabaseStructure(DatabaseUpdate update) {
|
||||
String sql = null;
|
||||
@ -195,7 +195,7 @@ public class Database {
|
||||
+ "ADD INDEX `idx_fishing` (`fishing`) USING BTREE;");
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -469,7 +469,7 @@ public class Database {
|
||||
|
||||
return rows;
|
||||
}
|
||||
|
||||
|
||||
public Map<String, Integer> readSQLRank(String playerName) {
|
||||
ResultSet resultSet;
|
||||
Map<String, Integer> skills = new HashMap<String, Integer>();
|
||||
@ -502,7 +502,7 @@ public class Database {
|
||||
statement.close();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
catch (SQLException ex) {
|
||||
printErrors(ex);
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.gmail.nossr50.util;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.api.SpoutToolsAPI;
|
||||
@ -470,7 +470,7 @@ public class ItemChecks {
|
||||
public static boolean isEnchantable(ItemStack is) {
|
||||
Material type = is.getType();
|
||||
return isArmor(is) || isSword(is) || isAxe(is) || isShovel(is) || isPickaxe(is) ||
|
||||
type == Material.SHEARS || type == Material.FISHING_ROD || type == Material.CARROT_STICK ||
|
||||
type == Material.FLINT_AND_STEEL || type == Material.BOW;
|
||||
type == Material.SHEARS || type == Material.FISHING_ROD || type == Material.CARROT_STICK ||
|
||||
type == Material.FLINT_AND_STEEL || type == Material.BOW;
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ public class Leaderboard {
|
||||
private final static String location = mcMMO.getUsersFile();
|
||||
private static HashMap<SkillType, List<PlayerStat>> playerStatHash = new HashMap<SkillType, List<PlayerStat>>();
|
||||
private static long lastUpdate = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Update the leader boards.
|
||||
*/
|
||||
@ -25,9 +25,9 @@ public class Leaderboard {
|
||||
if(System.currentTimeMillis() < lastUpdate + 600000) {
|
||||
return; //Only update FFS leaderboards every 10 minutes.. this puts a lot of strain on the server (depending on the size of the database) and should not be done frequently
|
||||
}
|
||||
|
||||
|
||||
lastUpdate = System.currentTimeMillis(); //Log when the last update was run
|
||||
|
||||
|
||||
//Initialize lists
|
||||
List<PlayerStat> mining, woodcutting, herbalism, excavation, acrobatics, repair, swords, axes, archery, unarmed, taming, fishing, powerlevel;
|
||||
|
||||
@ -147,7 +147,7 @@ public class Leaderboard {
|
||||
Collections.sort(taming, c);
|
||||
Collections.sort(fishing, c);
|
||||
Collections.sort(powerlevel, c);
|
||||
|
||||
|
||||
playerStatHash.put(SkillType.MINING, mining);
|
||||
playerStatHash.put(SkillType.WOODCUTTING, woodcutting);
|
||||
playerStatHash.put(SkillType.REPAIR, repair);
|
||||
@ -174,10 +174,10 @@ public class Leaderboard {
|
||||
String[] info = new String[10];
|
||||
|
||||
List<PlayerStat> statsList = playerStatHash.get(skillType);
|
||||
|
||||
|
||||
if(statsList != null) {
|
||||
int destination;
|
||||
|
||||
|
||||
//How many lines to skip through
|
||||
if (pagenumber == 1) {
|
||||
destination = 0;
|
||||
@ -185,9 +185,9 @@ public class Leaderboard {
|
||||
else {
|
||||
destination = (pagenumber * 10) - 9;
|
||||
}
|
||||
|
||||
|
||||
int currentPos = 0;
|
||||
|
||||
|
||||
for(PlayerStat ps : statsList) {
|
||||
if(currentPos == 10)
|
||||
break;
|
||||
@ -195,28 +195,28 @@ public class Leaderboard {
|
||||
destination--;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
info[currentPos] = ps.name+":"+ps.statVal;
|
||||
currentPos++;
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
info[0] = "DummyPlayer:0"; //Coming up with a better solution soon...
|
||||
}
|
||||
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
|
||||
public static int[] getPlayerRank(String playerName, SkillType skillType) {
|
||||
int currentPos = 1;
|
||||
List<PlayerStat> statsList = playerStatHash.get(skillType);
|
||||
|
||||
|
||||
if (statsList != null) {
|
||||
for (PlayerStat stat : statsList) {
|
||||
if (stat.name.equalsIgnoreCase(playerName)) {
|
||||
return new int[] {currentPos, stat.statVal};
|
||||
}
|
||||
|
||||
|
||||
currentPos++;
|
||||
continue;
|
||||
}
|
||||
@ -225,7 +225,7 @@ public class Leaderboard {
|
||||
|
||||
return new int[] {0};
|
||||
}
|
||||
|
||||
|
||||
private static class SkillComparator implements Comparator<PlayerStat> {
|
||||
@Override
|
||||
public int compare(PlayerStat o1, PlayerStat o2) {
|
||||
|
@ -13,7 +13,7 @@ public class Permissions {
|
||||
}
|
||||
|
||||
public static boolean hasPermission(Player sender, String perm)
|
||||
{
|
||||
{
|
||||
if (sender.hasPermission(perm))
|
||||
return true;
|
||||
|
||||
|
@ -1,12 +1,10 @@
|
||||
package com.gmail.nossr50.util.blockmeta.chunkmeta;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.lang.Boolean;
|
||||
import java.lang.Integer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
@ -18,11 +16,10 @@ import org.bukkit.Chunk;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.getspout.spoutapi.chunkstore.mcMMOSimpleRegionFile;
|
||||
|
||||
import com.gmail.nossr50.runnables.blockstoreconversion.BlockStoreConversionZDirectory;
|
||||
|
||||
import org.getspout.spoutapi.chunkstore.mcMMOSimpleRegionFile;
|
||||
|
||||
public class HashChunkManager implements ChunkManager {
|
||||
private HashMap<UUID, HashMap<Long, mcMMOSimpleRegionFile>> regionFiles = new HashMap<UUID, HashMap<Long, mcMMOSimpleRegionFile>>();
|
||||
public HashMap<String, ChunkStore> store = new HashMap<String, ChunkStore>();
|
||||
@ -577,34 +574,41 @@ public class HashChunkManager implements ChunkManager {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSpawnedMob(Entity entity) {
|
||||
return spawnedMobs.contains(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSpawnedPet(Entity entity) {
|
||||
return spawnedMobs.contains(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSpawnedMob(Entity entity) {
|
||||
if (!isSpawnedMob(entity))
|
||||
spawnedMobs.add(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSpawnedPet(Entity entity) {
|
||||
if (!isSpawnedMob(entity))
|
||||
spawnedMobs.add(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeSpawnedMob(Entity entity) {
|
||||
if (isSpawnedMob(entity))
|
||||
spawnedMobs.remove(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeSpawnedPet(Entity entity) {
|
||||
if (isSpawnedMob(entity))
|
||||
spawnedMobs.remove(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void cleanMobLists() {
|
||||
if (!safeToRemoveMobs || iteratingMobs)
|
||||
return;
|
||||
|
@ -88,11 +88,18 @@ public class NullChunkManager implements ChunkManager {
|
||||
@Override
|
||||
public void cleanUp() {}
|
||||
|
||||
@Override
|
||||
public boolean isSpawnedMob(Entity entity) {return false;}
|
||||
@Override
|
||||
public boolean isSpawnedPet(Entity entity) {return false;}
|
||||
@Override
|
||||
public void addSpawnedMob(Entity entity) {}
|
||||
@Override
|
||||
public void addSpawnedPet(Entity entity) {}
|
||||
@Override
|
||||
public void removeSpawnedMob(Entity entity) {}
|
||||
@Override
|
||||
public void removeSpawnedPet(Entity entity) {}
|
||||
@Override
|
||||
public synchronized void cleanMobLists() {}
|
||||
}
|
@ -24,9 +24,9 @@ public class PrimitiveChunkStore implements ChunkStore {
|
||||
private UUID worldUid;
|
||||
private List<UUID> spawnedMobs = new ArrayList<UUID>();
|
||||
transient private int worldHeight;
|
||||
|
||||
|
||||
transient private int xBitShifts;
|
||||
transient private int zBitShifts;
|
||||
transient private int zBitShifts;
|
||||
transient private boolean conversionNeeded;
|
||||
|
||||
public PrimitiveChunkStore(World world, int cx, int cz) {
|
||||
@ -104,14 +104,17 @@ public class PrimitiveChunkStore implements ChunkStore {
|
||||
dirty = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSpawnedMob(UUID id) {
|
||||
return spawnedMobs.contains(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSpawnedPet(UUID id) {
|
||||
return spawnedMobs.contains(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSpawnedMob(UUID id) {
|
||||
if (!isSpawnedMob(id)) {
|
||||
spawnedMobs.add(id);
|
||||
@ -119,6 +122,7 @@ public class PrimitiveChunkStore implements ChunkStore {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSpawnedPet(UUID id) {
|
||||
if (!isSpawnedPet(id)) {
|
||||
spawnedMobs.add(id);
|
||||
@ -126,6 +130,7 @@ public class PrimitiveChunkStore implements ChunkStore {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeSpawnedMob(UUID id) {
|
||||
if (isSpawnedMob(id)) {
|
||||
spawnedMobs.remove(id);
|
||||
@ -133,6 +138,7 @@ public class PrimitiveChunkStore implements ChunkStore {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeSpawnedPet(UUID id) {
|
||||
if (isSpawnedPet(id)) {
|
||||
spawnedMobs.remove(id);
|
||||
@ -140,6 +146,7 @@ public class PrimitiveChunkStore implements ChunkStore {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearSpawnedMobs() {
|
||||
if (!spawnedMobs.isEmpty()) {
|
||||
spawnedMobs.clear();
|
||||
@ -147,6 +154,7 @@ public class PrimitiveChunkStore implements ChunkStore {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearSpawnedPets() {
|
||||
if (!spawnedMobs.isEmpty()) {
|
||||
spawnedMobs.clear();
|
||||
@ -154,10 +162,12 @@ public class PrimitiveChunkStore implements ChunkStore {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UUID> getSpawnedMobs() {
|
||||
return spawnedMobs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UUID> getSpawnedPets() {
|
||||
return spawnedMobs;
|
||||
}
|
||||
|
Reference in New Issue
Block a user