mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-09-16 17:57:53 +02:00
Code Cleanup Pt 2
This commit is contained in:
@@ -581,7 +581,7 @@ public final class BlockUtils {
|
||||
* @return HashSet with the IDs of every transparent block
|
||||
*/
|
||||
public static HashSet<Material> getTransparentBlocks() {
|
||||
HashSet<Material> transparentBlocks = new HashSet<Material>();
|
||||
HashSet<Material> transparentBlocks = new HashSet<>();
|
||||
|
||||
for (Material material : Material.values()) {
|
||||
if (material.isTransparent()) {
|
||||
|
@@ -150,7 +150,7 @@ public final class ChimaeraWing {
|
||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||
itemMeta.setDisplayName(ChatColor.GOLD + LocaleLoader.getString("Item.ChimaeraWing.Name"));
|
||||
|
||||
List<String> itemLore = new ArrayList<String>();
|
||||
List<String> itemLore = new ArrayList<>();
|
||||
itemLore.add("mcMMO Item");
|
||||
itemLore.add(LocaleLoader.getString("Item.ChimaeraWing.Lore"));
|
||||
itemMeta.setLore(itemLore);
|
||||
|
@@ -6,7 +6,7 @@ import java.util.HashMap;
|
||||
|
||||
public class EnchantmentUtils {
|
||||
|
||||
private static final HashMap<String, Enchantment> enchants = new HashMap<String, Enchantment>();
|
||||
private static final HashMap<String, Enchantment> enchants = new HashMap<>();
|
||||
|
||||
static {
|
||||
enchants.put("SHARPNESS", Enchantment.DAMAGE_ALL);
|
||||
|
@@ -20,8 +20,8 @@ public final class HardcoreManager {
|
||||
PlayerProfile playerProfile = UserManager.getPlayer(player).getProfile();
|
||||
int totalLevelsLost = 0;
|
||||
|
||||
HashMap<String, Integer> levelChanged = new HashMap<String, Integer>();
|
||||
HashMap<String, Float> experienceChanged = new HashMap<String, Float>();
|
||||
HashMap<String, Integer> levelChanged = new HashMap<>();
|
||||
HashMap<String, Float> experienceChanged = new HashMap<>();
|
||||
|
||||
for (PrimarySkillType primarySkillType : PrimarySkillType.NON_CHILD_SKILLS) {
|
||||
if (!primarySkillType.getHardcoreStatLossEnabled()) {
|
||||
@@ -63,8 +63,8 @@ public final class HardcoreManager {
|
||||
PlayerProfile victimProfile = UserManager.getPlayer(victim).getProfile();
|
||||
int totalLevelsStolen = 0;
|
||||
|
||||
HashMap<String, Integer> levelChanged = new HashMap<String, Integer>();
|
||||
HashMap<String, Float> experienceChanged = new HashMap<String, Float>();
|
||||
HashMap<String, Integer> levelChanged = new HashMap<>();
|
||||
HashMap<String, Float> experienceChanged = new HashMap<>();
|
||||
|
||||
for (PrimarySkillType primarySkillType : PrimarySkillType.NON_CHILD_SKILLS) {
|
||||
if (!primarySkillType.getHardcoreVampirismEnabled()) {
|
||||
|
@@ -40,7 +40,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() {}
|
||||
|
||||
public static boolean isNPCEntity(Entity entity) {
|
||||
return (entity == null || entity.hasMetadata("NPC") || entity instanceof NPC || entity.getClass().getName().equalsIgnoreCase("cofh.entity.PlayerFake"));
|
||||
|
@@ -127,19 +127,19 @@ public final class MobHealthbarUtils {
|
||||
int coloredDisplay = (int) Math.ceil(fullDisplay * (healthPercentage / 100.0D));
|
||||
int grayDisplay = fullDisplay - coloredDisplay;
|
||||
|
||||
String healthbar = color + "";
|
||||
StringBuilder healthbar = new StringBuilder(color + "");
|
||||
|
||||
for (int i = 0; i < coloredDisplay; i++) {
|
||||
healthbar += symbol;
|
||||
healthbar.append(symbol);
|
||||
}
|
||||
|
||||
healthbar += ChatColor.GRAY;
|
||||
healthbar.append(ChatColor.GRAY);
|
||||
|
||||
for (int i = 0; i < grayDisplay; i++) {
|
||||
healthbar += symbol;
|
||||
healthbar.append(symbol);
|
||||
}
|
||||
|
||||
return healthbar;
|
||||
return healthbar.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -10,8 +10,8 @@ public class BiomeAdapter {
|
||||
|
||||
static {
|
||||
List<Biome> allBiomes = Arrays.asList(Biome.values());
|
||||
List<Biome> waterBiomes = new ArrayList<Biome>();
|
||||
List<Biome> iceBiomes = new ArrayList<Biome>();
|
||||
List<Biome> waterBiomes = new ArrayList<>();
|
||||
List<Biome> iceBiomes = new ArrayList<>();
|
||||
for (Biome biome : allBiomes) {
|
||||
if (isWater(biome.name()) && !isCold(biome.name())) {
|
||||
waterBiomes.add(biome);
|
||||
|
@@ -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,7 +8,7 @@ import java.io.*;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class HashChunkletManager implements ChunkletManager {
|
||||
public HashMap<String, ChunkletStore> store = new HashMap<String, ChunkletStore>();
|
||||
public HashMap<String, ChunkletStore> store = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void loadChunklet(int cx, int cy, int cz, World world) {
|
||||
|
@@ -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>>();
|
||||
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 HashMap<UUID, HashMap<Long, McMMOSimpleRegionFile>> regionFiles = new HashMap<>();
|
||||
public HashMap<String, ChunkStore> store = new HashMap<>();
|
||||
public ArrayList<BlockStoreConversionZDirectory> converters = new ArrayList<>();
|
||||
private HashMap<UUID, Boolean> oldData = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public synchronized void closeAll() {
|
||||
@@ -38,31 +38,19 @@ public class HashChunkManager implements ChunkManager {
|
||||
if (in == null) {
|
||||
return null;
|
||||
}
|
||||
ObjectInputStream objectStream = new ObjectInputStream(in);
|
||||
try {
|
||||
try (ObjectInputStream objectStream = new ObjectInputStream(in)) {
|
||||
Object o = objectStream.readObject();
|
||||
if (o instanceof ChunkStore) {
|
||||
return (ChunkStore) o;
|
||||
}
|
||||
|
||||
throw new RuntimeException("Wrong class type read for chunk meta data for " + x + ", " + z);
|
||||
}
|
||||
catch (IOException e) {
|
||||
} catch (IOException | ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
// Assume the format changed
|
||||
return null;
|
||||
//throw new RuntimeException("Unable to process chunk meta data for " + x + ", " + z, e);
|
||||
}
|
||||
catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
// Assume the format changed
|
||||
//System.out.println("[SpoutPlugin] is Unable to find serialized class for " + x + ", " + z + ", " + e.getMessage());
|
||||
return null;
|
||||
//throw new RuntimeException("Unable to find serialized class for " + x + ", " + z, e);
|
||||
}
|
||||
finally {
|
||||
objectStream.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -101,7 +89,7 @@ public class HashChunkManager implements ChunkManager {
|
||||
HashMap<Long, McMMOSimpleRegionFile> worldRegions = regionFiles.get(key);
|
||||
|
||||
if (worldRegions == null) {
|
||||
worldRegions = new HashMap<Long, McMMOSimpleRegionFile>();
|
||||
worldRegions = new HashMap<>();
|
||||
regionFiles.put(key, worldRegions);
|
||||
}
|
||||
|
||||
@@ -222,7 +210,7 @@ public class HashChunkManager implements ChunkManager {
|
||||
closeAll();
|
||||
String worldName = world.getName();
|
||||
|
||||
List<String> keys = new ArrayList<String>(store.keySet());
|
||||
List<String> keys = new ArrayList<>(store.keySet());
|
||||
for (String key : keys) {
|
||||
String[] info = key.split(",");
|
||||
if (worldName.equals(info[0])) {
|
||||
@@ -245,7 +233,7 @@ public class HashChunkManager implements ChunkManager {
|
||||
closeAll();
|
||||
String worldName = world.getName();
|
||||
|
||||
List<String> keys = new ArrayList<String>(store.keySet());
|
||||
List<String> keys = new ArrayList<>(store.keySet());
|
||||
for (String key : keys) {
|
||||
String[] info = key.split(",");
|
||||
if (worldName.equals(info[0])) {
|
||||
|
@@ -29,7 +29,7 @@ public class McMMOSimpleRegionFile {
|
||||
private final int[] dataStart = new int[1024];
|
||||
private final int[] dataActualLength = new int[1024];
|
||||
private final int[] dataLength = new int[1024];
|
||||
private final ArrayList<Boolean> inuse = new ArrayList<Boolean>();
|
||||
private final ArrayList<Boolean> inuse = new ArrayList<>();
|
||||
private int segmentSize;
|
||||
private int segmentMask;
|
||||
private final int rx;
|
||||
|
@@ -25,7 +25,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public final class CommandRegistrationManager {
|
||||
private CommandRegistrationManager() {};
|
||||
private CommandRegistrationManager() {}
|
||||
|
||||
private static String permissionsMessage = LocaleLoader.getString("mcMMO.NoPermission");
|
||||
|
||||
@@ -183,7 +183,7 @@ public final class CommandRegistrationManager {
|
||||
}
|
||||
|
||||
private static void registerXprateCommand() {
|
||||
List<String> aliasList = new ArrayList<String>();
|
||||
List<String> aliasList = new ArrayList<>();
|
||||
aliasList.add("mcxprate");
|
||||
|
||||
PluginCommand command = mcMMO.p.getCommand("xprate");
|
||||
|
@@ -225,7 +225,7 @@ public final class CommandUtils {
|
||||
private static void printGroupedSkillData(Player inspect, CommandSender display, String header, List<PrimarySkillType> skillGroup) {
|
||||
PlayerProfile profile = UserManager.getPlayer(inspect).getProfile();
|
||||
|
||||
List<String> displayData = new ArrayList<String>();
|
||||
List<String> displayData = new ArrayList<>();
|
||||
displayData.add(header);
|
||||
|
||||
for (PrimarySkillType skill : skillGroup) {
|
||||
@@ -243,7 +243,7 @@ public final class CommandUtils {
|
||||
|
||||
public static List<String> getOnlinePlayerNames(CommandSender sender) {
|
||||
Player player = sender instanceof Player ? (Player) sender : null;
|
||||
List<String> onlinePlayerNames = new ArrayList<String>();
|
||||
List<String> onlinePlayerNames = new ArrayList<>();
|
||||
|
||||
for (Player onlinePlayer : mcMMO.p.getServer().getOnlinePlayers()) {
|
||||
if (player != null && player.canSee(onlinePlayer)) {
|
||||
@@ -290,7 +290,7 @@ public final class CommandUtils {
|
||||
* @return List of all possible names
|
||||
*/
|
||||
private static List<String> matchPlayer(String partialName) {
|
||||
List<String> matchedPlayers = new ArrayList<String>();
|
||||
List<String> matchedPlayers = new ArrayList<>();
|
||||
|
||||
for (OfflinePlayer offlinePlayer : mcMMO.p.getServer().getOfflinePlayers()) {
|
||||
String playerName = offlinePlayer.getName();
|
||||
|
@@ -14,8 +14,8 @@ public class FormulaManager {
|
||||
private static File formulaFile = new File(mcMMO.getFlatFileDirectory() + "formula.yml");
|
||||
|
||||
// Experience needed to reach a level, cached values to improve conversion speed
|
||||
private final Map<Integer, Integer> experienceNeededLinear = new HashMap<Integer, Integer>();
|
||||
private final Map<Integer, Integer> experienceNeededExponential = new HashMap<Integer, Integer>();
|
||||
private final Map<Integer, Integer> experienceNeededLinear = new HashMap<>();
|
||||
private final Map<Integer, Integer> experienceNeededExponential = new HashMap<>();
|
||||
|
||||
private FormulaType previousFormula;
|
||||
|
||||
|
@@ -62,7 +62,7 @@ public final class UserManager {
|
||||
}
|
||||
|
||||
public static Collection<McMMOPlayer> getPlayers() {
|
||||
Collection<McMMOPlayer> playerCollection = new ArrayList<McMMOPlayer>();
|
||||
Collection<McMMOPlayer> playerCollection = new ArrayList<>();
|
||||
|
||||
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
|
||||
if (hasPlayerDataKey(player)) {
|
||||
|
@@ -23,7 +23,7 @@ import java.util.*;
|
||||
* Manages the Scoreboards used to display a variety of mcMMO related information to the player
|
||||
*/
|
||||
public class ScoreboardManager {
|
||||
static final Map<String, ScoreboardWrapper> PLAYER_SCOREBOARDS = new HashMap<String, ScoreboardWrapper>();
|
||||
static final Map<String, ScoreboardWrapper> PLAYER_SCOREBOARDS = new HashMap<>();
|
||||
|
||||
// do not localize; these are internal identifiers
|
||||
static final String SIDEBAR_OBJECTIVE = "mcmmo_sidebar";
|
||||
@@ -128,7 +128,7 @@ public class ScoreboardManager {
|
||||
abilityLabelsSkill = abilityLabelSkillBuilder.build();
|
||||
}
|
||||
|
||||
private static List<String> dirtyPowerLevels = new ArrayList<String>();
|
||||
private static List<String> dirtyPowerLevels = new ArrayList<>();
|
||||
|
||||
public enum SidebarType {
|
||||
NONE,
|
||||
@@ -136,7 +136,7 @@ public class ScoreboardManager {
|
||||
STATS_BOARD,
|
||||
COOLDOWNS_BOARD,
|
||||
RANK_BOARD,
|
||||
TOP_BOARD;
|
||||
TOP_BOARD
|
||||
}
|
||||
|
||||
private static String formatAbility(String abilityName) {
|
||||
|
@@ -701,7 +701,7 @@ public final class CombatUtils {
|
||||
|
||||
@Deprecated
|
||||
public static double getFakeDamageFinalResult(Entity attacker, Entity target, double damage) {
|
||||
return getFakeDamageFinalResult(attacker, target, DamageCause.ENTITY_ATTACK, new EnumMap<DamageModifier, Double>(ImmutableMap.of(DamageModifier.BASE, damage)));
|
||||
return getFakeDamageFinalResult(attacker, target, DamageCause.ENTITY_ATTACK, new EnumMap<>(ImmutableMap.of(DamageModifier.BASE, damage)));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@@ -751,7 +751,7 @@ public final class CombatUtils {
|
||||
}
|
||||
|
||||
private static Map<DamageModifier, Double> getModifiers(EntityDamageEvent event) {
|
||||
Map<DamageModifier, Double> modifiers = new HashMap<DamageModifier, Double>();
|
||||
Map<DamageModifier, Double> modifiers = new HashMap<>();
|
||||
for (DamageModifier modifier : DamageModifier.values()) {
|
||||
modifiers.put(modifier, event.getDamage(modifier));
|
||||
}
|
||||
@@ -760,7 +760,7 @@ public final class CombatUtils {
|
||||
}
|
||||
|
||||
private static Map<DamageModifier, Double> getScaledModifiers(double damage, Map<DamageModifier, Double> modifiers) {
|
||||
Map<DamageModifier, Double> scaledModifiers = new HashMap<DamageModifier, Double>();
|
||||
Map<DamageModifier, Double> scaledModifiers = new HashMap<>();
|
||||
|
||||
for (DamageModifier modifier : modifiers.keySet()) {
|
||||
if (modifier == DamageModifier.BASE) {
|
||||
|
@@ -12,7 +12,7 @@ import org.bukkit.entity.Player;
|
||||
|
||||
public final class ParticleEffectUtils {
|
||||
|
||||
private ParticleEffectUtils() {};
|
||||
private ParticleEffectUtils() {}
|
||||
|
||||
public static void playBleedEffect(LivingEntity livingEntity) {
|
||||
if (!MainConfig.getInstance().getBleedEffectEnabled()) {
|
||||
|
@@ -9,7 +9,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)) {
|
||||
|
@@ -265,8 +265,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)
|
||||
|
@@ -133,7 +133,7 @@ public class SkillUtils {
|
||||
|
||||
int efficiencyLevel = heldItem.getEnchantmentLevel(Enchantment.DIG_SPEED);
|
||||
ItemMeta itemMeta = heldItem.getItemMeta();
|
||||
List<String> itemLore = new ArrayList<String>();
|
||||
List<String> itemLore = new ArrayList<>();
|
||||
|
||||
if (itemMeta.hasLore()) {
|
||||
itemLore = itemMeta.getLore();
|
||||
|
@@ -31,7 +31,7 @@ public class UUIDFetcher implements Callable<Map<String, UUID>> {
|
||||
}
|
||||
|
||||
public Map<String, UUID> call() throws Exception {
|
||||
Map<String, UUID> uuidMap = new HashMap<String, UUID>();
|
||||
Map<String, UUID> uuidMap = new HashMap<>();
|
||||
int requests = (int) Math.ceil(names.size() / PROFILES_PER_REQUEST);
|
||||
for (int i = 0; i < requests; i++) {
|
||||
HttpURLConnection connection = createConnection();
|
||||
@@ -92,6 +92,6 @@ public class UUIDFetcher implements Callable<Map<String, UUID>> {
|
||||
}
|
||||
|
||||
public static UUID getUUIDOf(String name) throws Exception {
|
||||
return new UUIDFetcher(Arrays.asList(name)).call().get(name);
|
||||
return new UUIDFetcher(Collections.singletonList(name)).call().get(name);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user