mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-06-27 19:24:44 +02:00
Misc code fixes
This commit is contained in:
@ -25,8 +25,8 @@ import java.util.*;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public final class HolidayManager {
|
||||
private ArrayList<String> hasCelebrated;
|
||||
private int currentYear;
|
||||
private final ArrayList<String> hasCelebrated;
|
||||
private final int currentYear;
|
||||
private static final int START_YEAR = 2011;
|
||||
|
||||
private static final List<Color> ALL_COLORS;
|
||||
|
@ -6,7 +6,7 @@ import java.util.logging.Filter;
|
||||
import java.util.logging.LogRecord;
|
||||
|
||||
public class LogFilter implements Filter {
|
||||
private boolean debug;
|
||||
private final boolean debug;
|
||||
|
||||
public LogFilter(mcMMO plugin) {
|
||||
// Doing a config loading lite here, because we can't depend on the config loader to have loaded before any debug messages are sent
|
||||
|
@ -15,46 +15,46 @@ import java.util.Locale;
|
||||
*/
|
||||
public class MaterialMapStore {
|
||||
|
||||
private HashSet<String> abilityBlackList;
|
||||
private HashSet<String> toolBlackList;
|
||||
private HashSet<String> mossyWhiteList;
|
||||
private HashSet<String> leavesWhiteList;
|
||||
private HashSet<String> herbalismAbilityBlackList;
|
||||
private HashSet<String> blockCrackerWhiteList;
|
||||
private HashSet<String> canMakeShroomyWhiteList;
|
||||
private HashSet<String> multiBlockPlant;
|
||||
private HashSet<String> foodItemWhiteList;
|
||||
private HashSet<String> glassBlocks;
|
||||
private final HashSet<String> abilityBlackList;
|
||||
private final HashSet<String> toolBlackList;
|
||||
private final HashSet<String> mossyWhiteList;
|
||||
private final HashSet<String> leavesWhiteList;
|
||||
private final HashSet<String> herbalismAbilityBlackList;
|
||||
private final HashSet<String> blockCrackerWhiteList;
|
||||
private final HashSet<String> canMakeShroomyWhiteList;
|
||||
private final HashSet<String> multiBlockPlant;
|
||||
private final HashSet<String> foodItemWhiteList;
|
||||
private final HashSet<String> glassBlocks;
|
||||
|
||||
private HashSet<String> netheriteArmor;
|
||||
private HashSet<String> netheriteTools;
|
||||
private HashSet<String> woodTools;
|
||||
private HashSet<String> stoneTools;
|
||||
private HashSet<String> leatherArmor;
|
||||
private HashSet<String> ironArmor;
|
||||
private HashSet<String> ironTools;
|
||||
private HashSet<String> stringTools;
|
||||
private HashSet<String> goldArmor;
|
||||
private HashSet<String> goldTools;
|
||||
private HashSet<String> chainmailArmor;
|
||||
private HashSet<String> diamondArmor;
|
||||
private HashSet<String> diamondTools;
|
||||
private HashSet<String> armors;
|
||||
private final HashSet<String> netheriteArmor;
|
||||
private final HashSet<String> netheriteTools;
|
||||
private final HashSet<String> woodTools;
|
||||
private final HashSet<String> stoneTools;
|
||||
private final HashSet<String> leatherArmor;
|
||||
private final HashSet<String> ironArmor;
|
||||
private final HashSet<String> ironTools;
|
||||
private final HashSet<String> stringTools;
|
||||
private final HashSet<String> goldArmor;
|
||||
private final HashSet<String> goldTools;
|
||||
private final HashSet<String> chainmailArmor;
|
||||
private final HashSet<String> diamondArmor;
|
||||
private final HashSet<String> diamondTools;
|
||||
private final HashSet<String> armors;
|
||||
|
||||
private HashSet<String> swords;
|
||||
private HashSet<String> axes;
|
||||
private HashSet<String> hoes;
|
||||
private HashSet<String> shovels;
|
||||
private HashSet<String> pickAxes;
|
||||
private HashSet<String> tridents;
|
||||
private HashSet<String> bows;
|
||||
private HashSet<String> tools;
|
||||
private final HashSet<String> swords;
|
||||
private final HashSet<String> axes;
|
||||
private final HashSet<String> hoes;
|
||||
private final HashSet<String> shovels;
|
||||
private final HashSet<String> pickAxes;
|
||||
private final HashSet<String> tridents;
|
||||
private final HashSet<String> bows;
|
||||
private final HashSet<String> tools;
|
||||
|
||||
private HashSet<String> enchantables;
|
||||
private final HashSet<String> enchantables;
|
||||
|
||||
private HashSet<String> ores;
|
||||
private final HashSet<String> ores;
|
||||
|
||||
private HashMap<String, Integer> tierValue;
|
||||
private final HashMap<String, Integer> tierValue;
|
||||
|
||||
|
||||
public MaterialMapStore()
|
||||
|
@ -18,7 +18,7 @@ import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
public final class Misc {
|
||||
private static Random random = new Random();
|
||||
private static final Random random = new Random();
|
||||
|
||||
public static final int TIME_CONVERSION_FACTOR = 1000;
|
||||
public static final int TICK_CONVERSION_FACTOR = 20;
|
||||
@ -39,7 +39,7 @@ public final class Misc {
|
||||
|
||||
public static final Set<String> modNames = ImmutableSet.of("LOTR", "BUILDCRAFT", "ENDERIO", "ENHANCEDBIOMES", "IC2", "METALLURGY", "FORESTRY", "GALACTICRAFT", "RAILCRAFT", "TWILIGHTFOREST", "THAUMCRAFT", "GRAVESTONEMOD", "GROWTHCRAFT", "ARCTICMOBS", "DEMONMOBS", "INFERNOMOBS", "SWAMPMOBS", "MARICULTURE", "MINESTRAPPOLATION");
|
||||
|
||||
private Misc() {};
|
||||
private Misc() {}
|
||||
|
||||
/**
|
||||
* Determines if an entity is an NPC but not a villager
|
||||
|
@ -22,36 +22,36 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class ModManager {
|
||||
private List<Repairable> repairables = new ArrayList<Repairable>();
|
||||
private final List<Repairable> repairables = new ArrayList<Repairable>();
|
||||
|
||||
// Armor Mods
|
||||
private List<Material> customBoots = new ArrayList<Material>();
|
||||
private List<Material> customChestplates = new ArrayList<Material>();
|
||||
private List<Material> customHelmets = new ArrayList<Material>();
|
||||
private List<Material> customLeggings = new ArrayList<Material>();
|
||||
private final List<Material> customBoots = new ArrayList<Material>();
|
||||
private final List<Material> customChestplates = new ArrayList<Material>();
|
||||
private final List<Material> customHelmets = new ArrayList<Material>();
|
||||
private final List<Material> customLeggings = new ArrayList<Material>();
|
||||
|
||||
// Block Mods
|
||||
private List<Material> customExcavationBlocks = new ArrayList<Material>();
|
||||
private List<Material> customHerbalismBlocks = new ArrayList<Material>();
|
||||
private List<Material> customMiningBlocks = new ArrayList<Material>();
|
||||
private List<Material> customOres = new ArrayList<Material>();
|
||||
private List<Material> customLogs = new ArrayList<Material>();
|
||||
private List<Material> customLeaves = new ArrayList<Material>();
|
||||
private List<Material> customAbilityBlocks = new ArrayList<Material>();
|
||||
private HashMap<Material, CustomBlock> customBlockMap = new HashMap<>();
|
||||
private final List<Material> customExcavationBlocks = new ArrayList<Material>();
|
||||
private final List<Material> customHerbalismBlocks = new ArrayList<Material>();
|
||||
private final List<Material> customMiningBlocks = new ArrayList<Material>();
|
||||
private final List<Material> customOres = new ArrayList<Material>();
|
||||
private final List<Material> customLogs = new ArrayList<Material>();
|
||||
private final List<Material> customLeaves = new ArrayList<Material>();
|
||||
private final List<Material> customAbilityBlocks = new ArrayList<Material>();
|
||||
private final HashMap<Material, CustomBlock> customBlockMap = new HashMap<>();
|
||||
|
||||
// Entity Mods
|
||||
private HashMap<String, CustomEntity> customEntityClassMap = new HashMap<String, CustomEntity>();
|
||||
private HashMap<String, CustomEntity> customEntityTypeMap = new HashMap<String, CustomEntity>();
|
||||
private final HashMap<String, CustomEntity> customEntityClassMap = new HashMap<String, CustomEntity>();
|
||||
private final HashMap<String, CustomEntity> customEntityTypeMap = new HashMap<String, CustomEntity>();
|
||||
|
||||
// Tool Mods
|
||||
private List<Material> customAxes = new ArrayList<Material>();
|
||||
private List<Material> customBows = new ArrayList<Material>();
|
||||
private List<Material> customHoes = new ArrayList<Material>();
|
||||
private List<Material> customPickaxes = new ArrayList<Material>();
|
||||
private List<Material> customShovels = new ArrayList<Material>();
|
||||
private List<Material> customSwords = new ArrayList<Material>();
|
||||
private HashMap<Material, CustomTool> customToolMap = new HashMap<Material, CustomTool>();
|
||||
private final List<Material> customAxes = new ArrayList<Material>();
|
||||
private final List<Material> customBows = new ArrayList<Material>();
|
||||
private final List<Material> customHoes = new ArrayList<Material>();
|
||||
private final List<Material> customPickaxes = new ArrayList<Material>();
|
||||
private final List<Material> customShovels = new ArrayList<Material>();
|
||||
private final List<Material> customSwords = new ArrayList<Material>();
|
||||
private final HashMap<Material, CustomTool> customToolMap = new HashMap<Material, CustomTool>();
|
||||
|
||||
public void registerCustomArmor(CustomArmorConfig config) {
|
||||
customBoots.addAll(config.customBoots);
|
||||
|
@ -44,8 +44,7 @@ public class TextComponentFactory {
|
||||
|
||||
public static TextComponent getNotificationLevelUpTextComponent(PrimarySkillType skill, int levelsGained, int currentLevel)
|
||||
{
|
||||
TextComponent textComponent = new TextComponent(LocaleLoader.getString("Overhaul.Levelup", LocaleLoader.getString("Overhaul.Name."+StringUtils.getCapitalized(skill.toString())), levelsGained, currentLevel));
|
||||
return textComponent;
|
||||
return new TextComponent(LocaleLoader.getString("Overhaul.Levelup", LocaleLoader.getString("Overhaul.Name."+StringUtils.getCapitalized(skill.toString())), levelsGained, currentLevel));
|
||||
}
|
||||
|
||||
private static TextComponent getNotificationTextComponent(String text)
|
||||
@ -347,7 +346,6 @@ public class TextComponentFactory {
|
||||
ChatColor ccRank = ChatColor.BLUE;
|
||||
ChatColor ccCurRank = ChatColor.GREEN;
|
||||
ChatColor ccPossessive = ChatColor.WHITE;
|
||||
ChatColor ccNumRanks = ccCurRank;
|
||||
//ChatColor ccDescriptionHeader = ChatColor.DARK_PURPLE;
|
||||
//ChatColor ccDescription = ChatColor.WHITE;
|
||||
ChatColor ccLocked = ChatColor.DARK_GRAY;
|
||||
@ -375,7 +373,7 @@ public class TextComponentFactory {
|
||||
nextRank = RankUtils.getRankUnlockLevel(abstractSubSkill, curRank+1);
|
||||
}
|
||||
|
||||
addRanked(ccRank, ccCurRank, ccPossessive, ccNumRanks, componentBuilder, abstractSubSkill.getNumRanks(), RankUtils.getRank(player, abstractSubSkill), nextRank);
|
||||
addRanked(ccRank, ccCurRank, ccPossessive, ccCurRank, componentBuilder, abstractSubSkill.getNumRanks(), RankUtils.getRank(player, abstractSubSkill), nextRank);
|
||||
|
||||
componentBuilder.append(LocaleLoader.getString("JSON.DescriptionHeader"));
|
||||
componentBuilder.append("\n").append(abstractSubSkill.getDescription()).append("\n");
|
||||
@ -456,7 +454,6 @@ public class TextComponentFactory {
|
||||
ChatColor ccRank = ChatColor.BLUE;
|
||||
ChatColor ccCurRank = ChatColor.GREEN;
|
||||
ChatColor ccPossessive = ChatColor.WHITE;
|
||||
ChatColor ccNumRanks = ccCurRank;
|
||||
ChatColor ccDescriptionHeader = ChatColor.DARK_PURPLE;
|
||||
ChatColor ccDescription = ChatColor.DARK_GRAY;
|
||||
ChatColor ccLocked = ChatColor.DARK_GRAY;
|
||||
@ -484,7 +481,7 @@ public class TextComponentFactory {
|
||||
nextRank = RankUtils.getRankUnlockLevel(subSkillType, curRank+1);
|
||||
}
|
||||
|
||||
addRanked(ccRank, ccCurRank, ccPossessive, ccNumRanks, componentBuilder, subSkillType.getNumRanks(), RankUtils.getRank(player, subSkillType), nextRank);
|
||||
addRanked(ccRank, ccCurRank, ccPossessive, ccCurRank, componentBuilder, subSkillType.getNumRanks(), RankUtils.getRank(player, subSkillType), nextRank);
|
||||
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ public interface ChunkletManager {
|
||||
* @param cz Chunklet Z coordinate that needs to be loaded
|
||||
* @param world World that the chunklet needs to be loaded in
|
||||
*/
|
||||
public void loadChunklet(int cx, int cy, int cz, World world);
|
||||
void loadChunklet(int cx, int cy, int cz, World world);
|
||||
|
||||
/**
|
||||
* Unload a specific chunklet
|
||||
@ -22,7 +22,7 @@ public interface ChunkletManager {
|
||||
* @param cz Chunklet Z coordinate that needs to be unloaded
|
||||
* @param world World that the chunklet needs to be unloaded from
|
||||
*/
|
||||
public void unloadChunklet(int cx, int cy, int cz, World world);
|
||||
void unloadChunklet(int cx, int cy, int cz, World world);
|
||||
|
||||
/**
|
||||
* Load a given Chunk's Chunklet data
|
||||
@ -31,7 +31,7 @@ public interface ChunkletManager {
|
||||
* @param cz Chunk Z coordinate that is to be loaded
|
||||
* @param world World that the Chunk is in
|
||||
*/
|
||||
public void loadChunk(int cx, int cz, World world);
|
||||
void loadChunk(int cx, int cz, World world);
|
||||
|
||||
/**
|
||||
* Unload a given Chunk's Chunklet data
|
||||
@ -40,7 +40,7 @@ public interface ChunkletManager {
|
||||
* @param cz Chunk Z coordinate that is to be unloaded
|
||||
* @param world World that the Chunk is in
|
||||
*/
|
||||
public void unloadChunk(int cx, int cz, World world);
|
||||
void unloadChunk(int cx, int cz, World world);
|
||||
|
||||
/**
|
||||
* Informs the ChunkletManager a chunk is loaded
|
||||
@ -49,7 +49,7 @@ public interface ChunkletManager {
|
||||
* @param cz Chunk Z coordinate that is loaded
|
||||
* @param world World that the chunk was loaded in
|
||||
*/
|
||||
public void chunkLoaded(int cx, int cz, World world);
|
||||
void chunkLoaded(int cx, int cz, World world);
|
||||
|
||||
/**
|
||||
* Informs the ChunkletManager a chunk is unloaded
|
||||
@ -58,38 +58,38 @@ public interface ChunkletManager {
|
||||
* @param cz Chunk Z coordinate that is unloaded
|
||||
* @param world World that the chunk was unloaded in
|
||||
*/
|
||||
public void chunkUnloaded(int cx, int cz, World world);
|
||||
void chunkUnloaded(int cx, int cz, World world);
|
||||
|
||||
/**
|
||||
* Save all ChunkletStores related to the given world
|
||||
*
|
||||
* @param world World to save
|
||||
*/
|
||||
public void saveWorld(World world);
|
||||
void saveWorld(World world);
|
||||
|
||||
/**
|
||||
* Unload all ChunkletStores from memory related to the given world after saving them
|
||||
*
|
||||
* @param world World to unload
|
||||
*/
|
||||
public void unloadWorld(World world);
|
||||
void unloadWorld(World world);
|
||||
|
||||
/**
|
||||
* Load all ChunkletStores from all loaded chunks from this world into memory
|
||||
*
|
||||
* @param world World to load
|
||||
*/
|
||||
public void loadWorld(World world);
|
||||
void loadWorld(World world);
|
||||
|
||||
/**
|
||||
* Save all ChunkletStores
|
||||
*/
|
||||
public void saveAll();
|
||||
void saveAll();
|
||||
|
||||
/**
|
||||
* Unload all ChunkletStores after saving them
|
||||
*/
|
||||
public void unloadAll();
|
||||
void unloadAll();
|
||||
|
||||
/**
|
||||
* Check to see if a given location is set to true
|
||||
@ -100,7 +100,7 @@ public interface ChunkletManager {
|
||||
* @param world World to check in
|
||||
* @return true if the given location is set to true, false if otherwise
|
||||
*/
|
||||
public boolean isTrue(int x, int y, int z, World world);
|
||||
boolean isTrue(int x, int y, int z, World world);
|
||||
|
||||
/**
|
||||
* Check to see if a given block location is set to true
|
||||
@ -108,7 +108,7 @@ public interface ChunkletManager {
|
||||
* @param block Block location to check
|
||||
* @return true if the given block location is set to true, false if otherwise
|
||||
*/
|
||||
public boolean isTrue(Block block);
|
||||
boolean isTrue(Block block);
|
||||
|
||||
/**
|
||||
* Set a given location to true, should create stores as necessary if the location does not exist
|
||||
@ -118,14 +118,14 @@ public interface ChunkletManager {
|
||||
* @param z Z coordinate to set
|
||||
* @param world World to set in
|
||||
*/
|
||||
public void setTrue(int x, int y, int z, World world);
|
||||
void setTrue(int x, int y, int z, World world);
|
||||
|
||||
/**
|
||||
* Set a given block location to true, should create stores as necessary if the location does not exist
|
||||
*
|
||||
* @param block Block location to set
|
||||
*/
|
||||
public void setTrue(Block block);
|
||||
void setTrue(Block block);
|
||||
|
||||
/**
|
||||
* Set a given location to false, should not create stores if one does not exist for the given location
|
||||
@ -135,17 +135,17 @@ public interface ChunkletManager {
|
||||
* @param z Z coordinate to set
|
||||
* @param world World to set in
|
||||
*/
|
||||
public void setFalse(int x, int y, int z, World world);
|
||||
void setFalse(int x, int y, int z, World world);
|
||||
|
||||
/**
|
||||
* Set a given block location to false, should not create stores if one does not exist for the given location
|
||||
*
|
||||
* @param block Block location to set
|
||||
*/
|
||||
public void setFalse(Block block);
|
||||
void setFalse(Block block);
|
||||
|
||||
/**
|
||||
* Delete any ChunkletStores that are empty
|
||||
*/
|
||||
public void cleanUp();
|
||||
void cleanUp();
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ public interface ChunkletStore extends Serializable {
|
||||
* @param z z coordinate in current chunklet
|
||||
* @return true if the value is true at the given coordinates, false if otherwise
|
||||
*/
|
||||
public boolean isTrue(int x, int y, int z);
|
||||
boolean isTrue(int x, int y, int z);
|
||||
|
||||
/**
|
||||
* Set the value to true at the given coordinates
|
||||
@ -23,7 +23,7 @@ public interface ChunkletStore extends Serializable {
|
||||
* @param y y coordinate in current chunklet
|
||||
* @param z z coordinate in current chunklet
|
||||
*/
|
||||
public void setTrue(int x, int y, int z);
|
||||
void setTrue(int x, int y, int z);
|
||||
|
||||
/**
|
||||
* Set the value to false at the given coordinates
|
||||
@ -32,17 +32,17 @@ public interface ChunkletStore extends Serializable {
|
||||
* @param y y coordinate in current chunklet
|
||||
* @param z z coordinate in current chunklet
|
||||
*/
|
||||
public void setFalse(int x, int y, int z);
|
||||
void setFalse(int x, int y, int z);
|
||||
|
||||
/**
|
||||
* @return true if all values in the chunklet are false, false if otherwise
|
||||
*/
|
||||
public boolean isEmpty();
|
||||
boolean isEmpty();
|
||||
|
||||
/**
|
||||
* Set all values in this ChunkletStore to the values from another provided ChunkletStore
|
||||
*
|
||||
* @param otherStore Another ChunkletStore that this one should copy all data from
|
||||
*/
|
||||
public void copyFrom(ChunkletStore otherStore);
|
||||
void copyFrom(ChunkletStore otherStore);
|
||||
}
|
||||
|
@ -8,13 +8,13 @@ import org.bukkit.entity.Entity;
|
||||
import java.io.IOException;
|
||||
|
||||
public interface ChunkManager {
|
||||
public void closeAll();
|
||||
void closeAll();
|
||||
|
||||
public ChunkStore readChunkStore(World world, int x, int z) throws IOException;
|
||||
ChunkStore readChunkStore(World world, int x, int z) throws IOException;
|
||||
|
||||
public void writeChunkStore(World world, int x, int z, ChunkStore data);
|
||||
void writeChunkStore(World world, int x, int z, ChunkStore data);
|
||||
|
||||
public void closeChunkStore(World world, int x, int z);
|
||||
void closeChunkStore(World world, int x, int z);
|
||||
|
||||
/**
|
||||
* Loads a specific chunklet
|
||||
@ -24,7 +24,7 @@ public interface ChunkManager {
|
||||
* @param cz Chunklet Z coordinate that needs to be loaded
|
||||
* @param world World that the chunklet needs to be loaded in
|
||||
*/
|
||||
public void loadChunklet(int cx, int cy, int cz, World world);
|
||||
void loadChunklet(int cx, int cy, int cz, World world);
|
||||
|
||||
/**
|
||||
* Unload a specific chunklet
|
||||
@ -34,7 +34,7 @@ public interface ChunkManager {
|
||||
* @param cz Chunklet Z coordinate that needs to be unloaded
|
||||
* @param world World that the chunklet needs to be unloaded from
|
||||
*/
|
||||
public void unloadChunklet(int cx, int cy, int cz, World world);
|
||||
void unloadChunklet(int cx, int cy, int cz, World world);
|
||||
|
||||
/**
|
||||
* Load a given Chunk's Chunklet data
|
||||
@ -43,7 +43,7 @@ public interface ChunkManager {
|
||||
* @param cz Chunk Z coordinate that is to be loaded
|
||||
* @param world World that the Chunk is in
|
||||
*/
|
||||
public void loadChunk(int cx, int cz, World world, Entity[] entities);
|
||||
void loadChunk(int cx, int cz, World world, Entity[] entities);
|
||||
|
||||
/**
|
||||
* Unload a given Chunk's Chunklet data
|
||||
@ -52,7 +52,7 @@ public interface ChunkManager {
|
||||
* @param cz Chunk Z coordinate that is to be unloaded
|
||||
* @param world World that the Chunk is in
|
||||
*/
|
||||
public void unloadChunk(int cx, int cz, World world);
|
||||
void unloadChunk(int cx, int cz, World world);
|
||||
|
||||
/**
|
||||
* Saves a given Chunk's Chunklet data
|
||||
@ -61,9 +61,9 @@ public interface ChunkManager {
|
||||
* @param cz Chunk Z coordinate that is to be saved
|
||||
* @param world World that the Chunk is in
|
||||
*/
|
||||
public void saveChunk(int cx, int cz, World world);
|
||||
void saveChunk(int cx, int cz, World world);
|
||||
|
||||
public boolean isChunkLoaded(int cx, int cz, World world);
|
||||
boolean isChunkLoaded(int cx, int cz, World world);
|
||||
|
||||
/**
|
||||
* Informs the ChunkletManager a chunk is loaded
|
||||
@ -72,7 +72,7 @@ public interface ChunkManager {
|
||||
* @param cz Chunk Z coordinate that is loaded
|
||||
* @param world World that the chunk was loaded in
|
||||
*/
|
||||
public void chunkLoaded(int cx, int cz, World world);
|
||||
void chunkLoaded(int cx, int cz, World world);
|
||||
|
||||
/**
|
||||
* Informs the ChunkletManager a chunk is unloaded
|
||||
@ -81,38 +81,38 @@ public interface ChunkManager {
|
||||
* @param cz Chunk Z coordinate that is unloaded
|
||||
* @param world World that the chunk was unloaded in
|
||||
*/
|
||||
public void chunkUnloaded(int cx, int cz, World world);
|
||||
void chunkUnloaded(int cx, int cz, World world);
|
||||
|
||||
/**
|
||||
* Save all ChunkletStores related to the given world
|
||||
*
|
||||
* @param world World to save
|
||||
*/
|
||||
public void saveWorld(World world);
|
||||
void saveWorld(World world);
|
||||
|
||||
/**
|
||||
* Unload all ChunkletStores from memory related to the given world after saving them
|
||||
*
|
||||
* @param world World to unload
|
||||
*/
|
||||
public void unloadWorld(World world);
|
||||
void unloadWorld(World world);
|
||||
|
||||
/**
|
||||
* Load all ChunkletStores from all loaded chunks from this world into memory
|
||||
*
|
||||
* @param world World to load
|
||||
*/
|
||||
public void loadWorld(World world);
|
||||
void loadWorld(World world);
|
||||
|
||||
/**
|
||||
* Save all ChunkletStores
|
||||
*/
|
||||
public void saveAll();
|
||||
void saveAll();
|
||||
|
||||
/**
|
||||
* Unload all ChunkletStores after saving them
|
||||
*/
|
||||
public void unloadAll();
|
||||
void unloadAll();
|
||||
|
||||
/**
|
||||
* Check to see if a given location is set to true
|
||||
@ -123,7 +123,7 @@ public interface ChunkManager {
|
||||
* @param world World to check in
|
||||
* @return true if the given location is set to true, false if otherwise
|
||||
*/
|
||||
public boolean isTrue(int x, int y, int z, World world);
|
||||
boolean isTrue(int x, int y, int z, World world);
|
||||
|
||||
/**
|
||||
* Check to see if a given block location is set to true
|
||||
@ -131,7 +131,7 @@ public interface ChunkManager {
|
||||
* @param block Block location to check
|
||||
* @return true if the given block location is set to true, false if otherwise
|
||||
*/
|
||||
public boolean isTrue(Block block);
|
||||
boolean isTrue(Block block);
|
||||
|
||||
/**
|
||||
* Check to see if a given BlockState location is set to true
|
||||
@ -139,7 +139,7 @@ public interface ChunkManager {
|
||||
* @param blockState BlockState to check
|
||||
* @return true if the given BlockState location is set to true, false if otherwise
|
||||
*/
|
||||
public boolean isTrue(BlockState blockState);
|
||||
boolean isTrue(BlockState blockState);
|
||||
|
||||
/**
|
||||
* Set a given location to true, should create stores as necessary if the location does not exist
|
||||
@ -149,21 +149,21 @@ public interface ChunkManager {
|
||||
* @param z Z coordinate to set
|
||||
* @param world World to set in
|
||||
*/
|
||||
public void setTrue(int x, int y, int z, World world);
|
||||
void setTrue(int x, int y, int z, World world);
|
||||
|
||||
/**
|
||||
* Set a given block location to true, should create stores as necessary if the location does not exist
|
||||
*
|
||||
* @param block Block location to set
|
||||
*/
|
||||
public void setTrue(Block block);
|
||||
void setTrue(Block block);
|
||||
|
||||
/**
|
||||
* Set a given BlockState location to true, should create stores as necessary if the location does not exist
|
||||
*
|
||||
* @param blockState BlockState location to set
|
||||
*/
|
||||
public void setTrue(BlockState blockState);
|
||||
void setTrue(BlockState blockState);
|
||||
|
||||
/**
|
||||
* Set a given location to false, should not create stores if one does not exist for the given location
|
||||
@ -173,24 +173,24 @@ public interface ChunkManager {
|
||||
* @param z Z coordinate to set
|
||||
* @param world World to set in
|
||||
*/
|
||||
public void setFalse(int x, int y, int z, World world);
|
||||
void setFalse(int x, int y, int z, World world);
|
||||
|
||||
/**
|
||||
* Set a given block location to false, should not create stores if one does not exist for the given location
|
||||
*
|
||||
* @param block Block location to set
|
||||
*/
|
||||
public void setFalse(Block block);
|
||||
void setFalse(Block block);
|
||||
|
||||
/**
|
||||
* Set a given BlockState location to false, should not create stores if one does not exist for the given location
|
||||
*
|
||||
* @param blockState BlockState location to set
|
||||
*/
|
||||
public void setFalse(BlockState blockState);
|
||||
void setFalse(BlockState blockState);
|
||||
|
||||
/**
|
||||
* Delete any ChunkletStores that are empty
|
||||
*/
|
||||
public void cleanUp();
|
||||
void cleanUp();
|
||||
}
|
||||
|
@ -13,28 +13,28 @@ public interface ChunkStore extends Serializable {
|
||||
*
|
||||
* @return true if the has been modified since it was last saved
|
||||
*/
|
||||
public boolean isDirty();
|
||||
boolean isDirty();
|
||||
|
||||
/**
|
||||
* Checks the chunk's save state
|
||||
*
|
||||
* @param dirty the save state of the current chunk
|
||||
*/
|
||||
public void setDirty(boolean dirty);
|
||||
void setDirty(boolean dirty);
|
||||
|
||||
/**
|
||||
* Checks the chunk's x coordinate
|
||||
*
|
||||
* @return the chunk's x coordinate.
|
||||
*/
|
||||
public int getChunkX();
|
||||
int getChunkX();
|
||||
|
||||
/**
|
||||
* Checks the chunk's z coordinate
|
||||
*
|
||||
* @return the chunk's z coordinate.
|
||||
*/
|
||||
public int getChunkZ();
|
||||
int getChunkZ();
|
||||
|
||||
/**
|
||||
* Checks the value at the given coordinates
|
||||
@ -44,7 +44,7 @@ public interface ChunkStore extends Serializable {
|
||||
* @param z z coordinate in current chunklet
|
||||
* @return true if the value is true at the given coordinates, false if otherwise
|
||||
*/
|
||||
public boolean isTrue(int x, int y, int z);
|
||||
boolean isTrue(int x, int y, int z);
|
||||
|
||||
/**
|
||||
* Set the value to true at the given coordinates
|
||||
@ -53,7 +53,7 @@ public interface ChunkStore extends Serializable {
|
||||
* @param y y coordinate in current chunklet
|
||||
* @param z z coordinate in current chunklet
|
||||
*/
|
||||
public void setTrue(int x, int y, int z);
|
||||
void setTrue(int x, int y, int z);
|
||||
|
||||
/**
|
||||
* Set the value to false at the given coordinates
|
||||
@ -62,17 +62,17 @@ public interface ChunkStore extends Serializable {
|
||||
* @param y y coordinate in current chunklet
|
||||
* @param z z coordinate in current chunklet
|
||||
*/
|
||||
public void setFalse(int x, int y, int z);
|
||||
void setFalse(int x, int y, int z);
|
||||
|
||||
/**
|
||||
* @return true if all values in the chunklet are false, false if otherwise
|
||||
*/
|
||||
public boolean isEmpty();
|
||||
boolean isEmpty();
|
||||
|
||||
/**
|
||||
* Set all values in this ChunkletStore to the values from another provided ChunkletStore
|
||||
*
|
||||
* @param otherStore Another ChunkletStore that this one should copy all data from
|
||||
*/
|
||||
public void copyFrom(ChunkletStore otherStore);
|
||||
void copyFrom(ChunkletStore otherStore);
|
||||
}
|
||||
|
@ -11,10 +11,10 @@ import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public class HashChunkManager implements ChunkManager {
|
||||
private HashMap<UUID, HashMap<Long, McMMOSimpleRegionFile>> regionFiles = new HashMap<UUID, HashMap<Long, McMMOSimpleRegionFile>>();
|
||||
private final HashMap<UUID, HashMap<Long, McMMOSimpleRegionFile>> regionFiles = new HashMap<UUID, HashMap<Long, McMMOSimpleRegionFile>>();
|
||||
public HashMap<String, ChunkStore> store = new HashMap<String, ChunkStore>();
|
||||
public ArrayList<BlockStoreConversionZDirectory> converters = new ArrayList<BlockStoreConversionZDirectory>();
|
||||
private HashMap<UUID, Boolean> oldData = new HashMap<UUID, Boolean>();
|
||||
private final HashMap<UUID, Boolean> oldData = new HashMap<UUID, Boolean>();
|
||||
|
||||
@Override
|
||||
public synchronized void closeAll() {
|
||||
@ -98,12 +98,7 @@ public class HashChunkManager implements ChunkManager {
|
||||
|
||||
UUID key = world.getUID();
|
||||
|
||||
HashMap<Long, McMMOSimpleRegionFile> worldRegions = regionFiles.get(key);
|
||||
|
||||
if (worldRegions == null) {
|
||||
worldRegions = new HashMap<Long, McMMOSimpleRegionFile>();
|
||||
regionFiles.put(key, worldRegions);
|
||||
}
|
||||
HashMap<Long, McMMOSimpleRegionFile> worldRegions = regionFiles.computeIfAbsent(key, k -> new HashMap<Long, McMMOSimpleRegionFile>());
|
||||
|
||||
int rx = x >> 5;
|
||||
int rz = z >> 5;
|
||||
|
@ -39,7 +39,7 @@ public class McMMOSimpleRegionFile {
|
||||
@SuppressWarnings("unused")
|
||||
private long lastAccessTime = System.currentTimeMillis();
|
||||
@SuppressWarnings("unused")
|
||||
private static long TIMEOUT_TIME = 300000; // 5 min
|
||||
private static final long TIMEOUT_TIME = 300000; // 5 min
|
||||
|
||||
public McMMOSimpleRegionFile(File f, int rx, int rz) {
|
||||
this(f, rx, rz, 10);
|
||||
|
@ -32,9 +32,9 @@ import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public final class CommandRegistrationManager {
|
||||
private CommandRegistrationManager() {};
|
||||
private CommandRegistrationManager() {}
|
||||
|
||||
private static String permissionsMessage = LocaleLoader.getString("mcMMO.NoPermission");
|
||||
private static final String permissionsMessage = LocaleLoader.getString("mcMMO.NoPermission");
|
||||
|
||||
private static void registerSkillCommands() {
|
||||
for (PrimarySkillType skill : PrimarySkillType.values()) {
|
||||
|
@ -104,23 +104,21 @@ public class CompatibilityManager {
|
||||
}
|
||||
|
||||
private NMSVersion determineNMSVersion() {
|
||||
switch(minecraftGameVersion.getMajorVersion().asInt()) {
|
||||
case 1:
|
||||
switch(minecraftGameVersion.getMinorVersion().asInt()) {
|
||||
case 12:
|
||||
return NMSVersion.NMS_1_12_2;
|
||||
case 13:
|
||||
return NMSVersion.NMS_1_13_2;
|
||||
case 14:
|
||||
return NMSVersion.NMS_1_14_4;
|
||||
case 15:
|
||||
return NMSVersion.NMS_1_15_2;
|
||||
case 16:
|
||||
switch(minecraftGameVersion.getPatchVersion().asInt()) {
|
||||
case 1:
|
||||
return NMSVersion.NMS_1_16_1;
|
||||
}
|
||||
}
|
||||
if (minecraftGameVersion.getMajorVersion().asInt() == 1) {
|
||||
switch (minecraftGameVersion.getMinorVersion().asInt()) {
|
||||
case 12:
|
||||
return NMSVersion.NMS_1_12_2;
|
||||
case 13:
|
||||
return NMSVersion.NMS_1_13_2;
|
||||
case 14:
|
||||
return NMSVersion.NMS_1_14_4;
|
||||
case 15:
|
||||
return NMSVersion.NMS_1_15_2;
|
||||
case 16:
|
||||
if (minecraftGameVersion.getPatchVersion().asInt() == 1) {
|
||||
return NMSVersion.NMS_1_16_1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NMSVersion.UNSUPPORTED;
|
||||
|
@ -12,7 +12,7 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class FormulaManager {
|
||||
private static File formulaFile = new File(mcMMO.getFlatFileDirectory() + "formula.yml");
|
||||
private static final File formulaFile = new File(mcMMO.getFlatFileDirectory() + "formula.yml");
|
||||
|
||||
// Experience needed to reach a level, cached values to improve conversion speed
|
||||
private Map<Integer, Integer> experienceNeededRetroLinear;
|
||||
|
@ -3,7 +3,7 @@ package com.gmail.nossr50.util.platform.version;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class SimpleNumericVersion extends SimpleVersion implements NumericVersioned {
|
||||
private int versionNumber;
|
||||
private final int versionNumber;
|
||||
|
||||
public SimpleNumericVersion(int versionNumber) {
|
||||
super(String.valueOf(versionNumber));
|
||||
|
@ -130,7 +130,7 @@ public class ScoreboardManager {
|
||||
abilityLabelsSkill = abilityLabelSkillBuilder.build();
|
||||
}
|
||||
|
||||
private static List<String> dirtyPowerLevels = new ArrayList<String>();
|
||||
private static final List<String> dirtyPowerLevels = new ArrayList<String>();
|
||||
|
||||
public enum SidebarType {
|
||||
NONE,
|
||||
@ -138,7 +138,7 @@ public class ScoreboardManager {
|
||||
STATS_BOARD,
|
||||
COOLDOWNS_BOARD,
|
||||
RANK_BOARD,
|
||||
TOP_BOARD;
|
||||
TOP_BOARD
|
||||
}
|
||||
|
||||
private static String formatAbility(String abilityName) {
|
||||
|
@ -37,7 +37,7 @@ public class ScoreboardWrapper {
|
||||
// Internal usage variables (should exist)
|
||||
private SidebarType sidebarType;
|
||||
private Objective sidebarObjective;
|
||||
private Objective powerObjective;
|
||||
private final Objective powerObjective;
|
||||
|
||||
// Parameter variables (May be null / invalid)
|
||||
private Scoreboard oldBoard = null;
|
||||
|
@ -14,7 +14,7 @@ import org.bukkit.entity.Player;
|
||||
|
||||
public final class ParticleEffectUtils {
|
||||
|
||||
private ParticleEffectUtils() {};
|
||||
private ParticleEffectUtils() {}
|
||||
|
||||
public static void playGreenThumbEffect(Location location) {
|
||||
World world = location.getWorld();
|
||||
|
@ -11,7 +11,7 @@ public final class PerksUtils {
|
||||
private static final int LUCKY_SKILL_ACTIVATION_CHANCE = 75;
|
||||
private static final int NORMAL_SKILL_ACTIVATION_CHANCE = 100;
|
||||
|
||||
private PerksUtils() {};
|
||||
private PerksUtils() {}
|
||||
|
||||
public static int handleCooldownPerks(Player player, int cooldown) {
|
||||
if (Permissions.halvedCooldowns(player)) {
|
||||
@ -47,7 +47,6 @@ public final class PerksUtils {
|
||||
|
||||
public static float handleXpPerks(Player player, float xp, PrimarySkillType skill) {
|
||||
double modifier = 1.0F;
|
||||
double originalXP = xp;
|
||||
|
||||
if (Permissions.customXpBoost(player, skill)) {
|
||||
if(UserManager.getPlayer(player) != null && UserManager.getPlayer(player).isDebugMode()) {
|
||||
@ -79,7 +78,7 @@ public final class PerksUtils {
|
||||
|
||||
if(UserManager.getPlayer(player) != null && UserManager.getPlayer(player).isDebugMode()) {
|
||||
player.sendMessage(ChatColor.GOLD + "[DEBUG] " + ChatColor.RESET + "XP Perk Multiplier - " + ChatColor.GOLD + modifier);
|
||||
player.sendMessage(ChatColor.GOLD + "[DEBUG] " + ChatColor.RESET + "Original XP before perk boosts " + ChatColor.RED + originalXP);
|
||||
player.sendMessage(ChatColor.GOLD + "[DEBUG] " + ChatColor.RESET + "Original XP before perk boosts " + ChatColor.RED + (double) xp);
|
||||
player.sendMessage(ChatColor.GOLD + "[DEBUG] " + ChatColor.RESET + "XP AFTER PERKS " + ChatColor.DARK_RED + modifiedXP);
|
||||
}
|
||||
|
||||
|
@ -276,8 +276,7 @@ public class RankUtils {
|
||||
if (subSkillRanks == null)
|
||||
subSkillRanks = new HashMap<>();
|
||||
|
||||
if (subSkillRanks.get(s) == null)
|
||||
subSkillRanks.put(s, new HashMap<>());
|
||||
subSkillRanks.computeIfAbsent(s, k -> new HashMap<>());
|
||||
}
|
||||
|
||||
/* public static int getSubSkillUnlockRequirement(SubSkillType subSkillType)
|
||||
|
@ -1,111 +0,0 @@
|
||||
package com.gmail.nossr50.util.uuid;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
public class UUIDFetcher implements Callable<Map<String, UUID>> {
|
||||
private static final int PROFILES_PER_REQUEST = 10;
|
||||
private static final long RATE_LIMIT = 100L;
|
||||
private static final String PROFILE_URL = "https://api.mojang.com/profiles/minecraft";
|
||||
private final List<String> names;
|
||||
private final boolean rateLimiting;
|
||||
|
||||
public UUIDFetcher(List<String> names, boolean rateLimiting) {
|
||||
this.names = ImmutableList.copyOf(names);
|
||||
this.rateLimiting = rateLimiting;
|
||||
}
|
||||
|
||||
public UUIDFetcher(List<String> names) {
|
||||
this(names, true);
|
||||
}
|
||||
|
||||
public Map<String, UUID> call() throws Exception {
|
||||
Map<String, UUID> uuidMap = new HashMap<String, UUID>();
|
||||
int requests = (int) Math.ceil(names.size() / PROFILES_PER_REQUEST);
|
||||
for (int i = 0; i < requests; i++) {
|
||||
HttpURLConnection connection = createConnection();
|
||||
|
||||
List<String> nameSubList = names.subList(i * PROFILES_PER_REQUEST, Math.min((i + 1) * PROFILES_PER_REQUEST, names.size()));
|
||||
JsonArray array = new JsonArray();
|
||||
|
||||
for(String name : nameSubList)
|
||||
{
|
||||
JsonPrimitive element = new JsonPrimitive(name);
|
||||
array.add(element);
|
||||
}
|
||||
|
||||
Gson gson = new Gson();
|
||||
String body = array.toString();
|
||||
|
||||
writeBody(connection, body);
|
||||
InputStreamReader tempStream = new InputStreamReader(connection.getInputStream());
|
||||
JsonObject[] jsonStreamArray = gson.fromJson(tempStream, JsonObject[].class);
|
||||
tempStream.close();
|
||||
|
||||
for (JsonObject jsonProfile : jsonStreamArray) {
|
||||
String id = jsonProfile.get("id").getAsString();
|
||||
String name = jsonProfile.get("name").getAsString();
|
||||
UUID uuid = UUIDFetcher.getUUID(id);
|
||||
uuidMap.put(name, uuid);
|
||||
}
|
||||
if (rateLimiting && i != requests - 1) {
|
||||
Thread.sleep(RATE_LIMIT);
|
||||
}
|
||||
}
|
||||
return uuidMap;
|
||||
}
|
||||
|
||||
private static void writeBody(HttpURLConnection connection, String body) throws Exception {
|
||||
OutputStream stream = connection.getOutputStream();
|
||||
stream.write(body.getBytes());
|
||||
stream.flush();
|
||||
stream.close();
|
||||
}
|
||||
|
||||
private static HttpURLConnection createConnection() throws Exception {
|
||||
URL url = new URL(PROFILE_URL);
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
connection.setRequestMethod("POST");
|
||||
connection.setRequestProperty("Content-Type", "application/json");
|
||||
connection.setUseCaches(false);
|
||||
connection.setDoInput(true);
|
||||
connection.setDoOutput(true);
|
||||
return connection;
|
||||
}
|
||||
|
||||
private static UUID getUUID(String id) {
|
||||
return UUID.fromString(id.substring(0, 8) + "-" + id.substring(8, 12) + "-" + id.substring(12, 16) + "-" + id.substring(16, 20) + "-" + id.substring(20, 32));
|
||||
}
|
||||
|
||||
public static byte[] toBytes(UUID uuid) {
|
||||
ByteBuffer byteBuffer = ByteBuffer.wrap(new byte[16]);
|
||||
byteBuffer.putLong(uuid.getMostSignificantBits());
|
||||
byteBuffer.putLong(uuid.getLeastSignificantBits());
|
||||
return byteBuffer.array();
|
||||
}
|
||||
|
||||
public static UUID fromBytes(byte[] array) {
|
||||
if (array.length != 16) {
|
||||
throw new IllegalArgumentException("Illegal byte array length: " + array.length);
|
||||
}
|
||||
ByteBuffer byteBuffer = ByteBuffer.wrap(array);
|
||||
long mostSignificant = byteBuffer.getLong();
|
||||
long leastSignificant = byteBuffer.getLong();
|
||||
return new UUID(mostSignificant, leastSignificant);
|
||||
}
|
||||
|
||||
public static UUID getUUIDOf(String name) throws Exception {
|
||||
return new UUIDFetcher(Arrays.asList(name)).call().get(name);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user