diff --git a/src/main/java/com/volmit/iris/Iris.java b/src/main/java/com/volmit/iris/Iris.java index 32d9f80ab..9c2c52cc4 100644 --- a/src/main/java/com/volmit/iris/Iris.java +++ b/src/main/java/com/volmit/iris/Iris.java @@ -524,30 +524,18 @@ public class Iris extends VolmitPlugin implements Listener { return; } - try - { + try { throw new RuntimeException(); - } - - catch(Throwable e) - { - try - { + } catch (Throwable e) { + try { String[] cc = e.getStackTrace()[1].getClassName().split("\\Q.\\E"); - if(cc.length > 5) - { - debug(cc[3] + "/" + cc[4] + "/" + cc[cc.length-1], e.getStackTrace()[1].getLineNumber(), string); - } - - else - { + if (cc.length > 5) { + debug(cc[3] + "/" + cc[4] + "/" + cc[cc.length - 1], e.getStackTrace()[1].getLineNumber(), string); + } else { debug(cc[3] + "/" + cc[4], e.getStackTrace()[1].getLineNumber(), string); } - } - - catch(Throwable ex) - { + } catch (Throwable ex) { debug("Origin", -1, string); } } @@ -558,7 +546,7 @@ public class Iris extends VolmitPlugin implements Listener { return; } - msg("" + category + " <#bf3b76>" + line + " " + C.LIGHT_PURPLE + string.replaceAll("\\Q<\\E", "[").replaceAll("\\Q>\\E", "]")); + msg("" + category + " <#bf3b76>" + line + " " + C.LIGHT_PURPLE + string.replaceAll("\\Q<\\E", "[").replaceAll("\\Q>\\E", "]")); } public static void verbose(String string) { diff --git a/src/main/java/com/volmit/iris/core/command/studio/CommandIrisStudioBeautify.java b/src/main/java/com/volmit/iris/core/command/studio/CommandIrisStudioBeautify.java index 72eca4610..16b465c3b 100644 --- a/src/main/java/com/volmit/iris/core/command/studio/CommandIrisStudioBeautify.java +++ b/src/main/java/com/volmit/iris/core/command/studio/CommandIrisStudioBeautify.java @@ -102,40 +102,29 @@ public class CommandIrisStudioBeautify extends MortarCommand { } private void fixBlocks(JSONObject obj, File f) { - for(String i : obj.keySet()) - { + for (String i : obj.keySet()) { Object o = obj.get(i); - if(i.equals("block") && o instanceof String && !o.toString().trim().isEmpty() && !o.toString().contains(":")) - { + if (i.equals("block") && o instanceof String && !o.toString().trim().isEmpty() && !o.toString().contains(":")) { obj.put(i, "minecraft:" + o); Iris.debug("Updated Block Key: " + o + " to " + obj.getString(i) + " in " + f.getPath()); } - if(o instanceof JSONObject) - { + if (o instanceof JSONObject) { fixBlocks((JSONObject) o, f); - } - - else if(o instanceof JSONArray) - { + } else if (o instanceof JSONArray) { fixBlocks((JSONArray) o, f); } } } private void fixBlocks(JSONArray obj, File f) { - for(int i = 0; i < obj.length(); i++) - { + for (int i = 0; i < obj.length(); i++) { Object o = obj.get(i); - if(o instanceof JSONObject) - { + if (o instanceof JSONObject) { fixBlocks((JSONObject) o, f); - } - - else if(o instanceof JSONArray) - { + } else if (o instanceof JSONArray) { fixBlocks((JSONArray) o, f); } } diff --git a/src/main/java/com/volmit/iris/engine/IrisEngine.java b/src/main/java/com/volmit/iris/engine/IrisEngine.java index a04883b4f..6be28e39f 100644 --- a/src/main/java/com/volmit/iris/engine/IrisEngine.java +++ b/src/main/java/com/volmit/iris/engine/IrisEngine.java @@ -20,7 +20,6 @@ package com.volmit.iris.engine; import com.google.gson.Gson; import com.volmit.iris.Iris; -import com.volmit.iris.core.IrisSettings; import com.volmit.iris.core.events.IrisEngineHotloadEvent; import com.volmit.iris.engine.data.cache.AtomicCache; import com.volmit.iris.engine.framework.*; @@ -29,13 +28,9 @@ import com.volmit.iris.engine.object.biome.IrisBiomePaletteLayer; import com.volmit.iris.engine.object.decoration.IrisDecorator; import com.volmit.iris.engine.object.engine.IrisEngineData; import com.volmit.iris.engine.object.objects.IrisObjectPlacement; -import com.volmit.iris.util.collection.KList; -import com.volmit.iris.util.collection.KMap; import com.volmit.iris.util.context.IrisContext; import com.volmit.iris.util.documentation.BlockCoordinates; import com.volmit.iris.util.documentation.ChunkCoordinates; -import com.volmit.iris.util.format.C; -import com.volmit.iris.util.format.Form; import com.volmit.iris.util.hunk.Hunk; import com.volmit.iris.util.io.IO; import com.volmit.iris.util.math.RNG; diff --git a/src/main/java/com/volmit/iris/engine/object/objects/IrisObject.java b/src/main/java/com/volmit/iris/engine/object/objects/IrisObject.java index 352068d15..340f96316 100644 --- a/src/main/java/com/volmit/iris/engine/object/objects/IrisObject.java +++ b/src/main/java/com/volmit/iris/engine/object/objects/IrisObject.java @@ -36,7 +36,6 @@ import com.volmit.iris.util.math.BlockPosition; import com.volmit.iris.util.math.Position2; import com.volmit.iris.util.math.RNG; import com.volmit.iris.util.scheduling.IrisLock; -import lombok.Data; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; diff --git a/src/main/java/com/volmit/iris/util/hunk/Hunk.java b/src/main/java/com/volmit/iris/util/hunk/Hunk.java index 6695535e5..e81c9673c 100644 --- a/src/main/java/com/volmit/iris/util/hunk/Hunk.java +++ b/src/main/java/com/volmit/iris/util/hunk/Hunk.java @@ -1069,41 +1069,38 @@ public interface Hunk { /** * Create a hunk that is optimized for specific uses - * @param w width - * @param h height - * @param d depth - * @param type the class type - * @param packed if the hunk is generally more than 50% full (non-null nodes) + * + * @param w width + * @param h height + * @param d depth + * @param type the class type + * @param packed if the hunk is generally more than 50% full (non-null nodes) * @param concurrent if this hunk must be thread safe - * @param the type + * @param the type * @return the hunk */ - static Hunk newHunk(int w, int h, int d, Class type, boolean packed, boolean concurrent) - { - if(type.equals(Double.class)) - { + static Hunk newHunk(int w, int h, int d, Class type, boolean packed, boolean concurrent) { + if (type.equals(Double.class)) { return concurrent ? - packed ? (Hunk) newAtomicDoubleHunk(w,h,d) : newMappedHunk(w,h,d) - : packed ? newArrayHunk(w,h,d) : newMappedHunkSynced(w,h,d); + packed ? (Hunk) newAtomicDoubleHunk(w, h, d) : newMappedHunk(w, h, d) + : packed ? newArrayHunk(w, h, d) : newMappedHunkSynced(w, h, d); } - if(type.equals(Integer.class)) - { + if (type.equals(Integer.class)) { return concurrent ? - packed ? (Hunk) newAtomicIntegerHunk(w,h,d) : newMappedHunk(w,h,d) - : packed ? newArrayHunk(w,h,d) : newMappedHunkSynced(w,h,d); + packed ? (Hunk) newAtomicIntegerHunk(w, h, d) : newMappedHunk(w, h, d) + : packed ? newArrayHunk(w, h, d) : newMappedHunkSynced(w, h, d); } - if(type.equals(Long.class)) - { + if (type.equals(Long.class)) { return concurrent ? - packed ? (Hunk) newAtomicLongHunk(w,h,d) : newMappedHunk(w,h,d) - : packed ? newArrayHunk(w,h,d) : newMappedHunkSynced(w,h,d); + packed ? (Hunk) newAtomicLongHunk(w, h, d) : newMappedHunk(w, h, d) + : packed ? newArrayHunk(w, h, d) : newMappedHunkSynced(w, h, d); } return concurrent ? - packed ? newAtomicHunk(w,h,d) : newMappedHunk(w,h,d) - : packed ? newArrayHunk(w,h,d) : newMappedHunkSynced(w,h,d); + packed ? newAtomicHunk(w, h, d) : newMappedHunk(w, h, d) + : packed ? newArrayHunk(w, h, d) : newMappedHunkSynced(w, h, d); } default void setIfExists(int x, int y, int z, T t) { @@ -1449,8 +1446,7 @@ public interface Hunk { c[1] = y; } - default boolean isEmpty() - { + default boolean isEmpty() { return false; } } diff --git a/src/main/java/com/volmit/iris/util/hunk/storage/ArrayHunk.java b/src/main/java/com/volmit/iris/util/hunk/storage/ArrayHunk.java index 4512ba9a8..48d17a70c 100644 --- a/src/main/java/com/volmit/iris/util/hunk/storage/ArrayHunk.java +++ b/src/main/java/com/volmit/iris/util/hunk/storage/ArrayHunk.java @@ -20,7 +20,6 @@ package com.volmit.iris.util.hunk.storage; import com.volmit.iris.engine.data.cache.Cache; import com.volmit.iris.util.hunk.Hunk; -import com.volmit.iris.util.hunk.HunkFactory; import lombok.Data; import lombok.EqualsAndHashCode; diff --git a/src/main/java/com/volmit/iris/util/hunk/storage/MappedHunk.java b/src/main/java/com/volmit/iris/util/hunk/storage/MappedHunk.java index 7cbe52f0a..4d5d9fba8 100644 --- a/src/main/java/com/volmit/iris/util/hunk/storage/MappedHunk.java +++ b/src/main/java/com/volmit/iris/util/hunk/storage/MappedHunk.java @@ -47,8 +47,7 @@ public class MappedHunk extends StorageHunk implements Hunk { return true; } - public boolean isEmpty() - { + public boolean isEmpty() { return data.isEmpty(); } diff --git a/src/main/java/com/volmit/iris/util/mantle/Mantle.java b/src/main/java/com/volmit/iris/util/mantle/Mantle.java index cf8dffcdd..5db78113a 100644 --- a/src/main/java/com/volmit/iris/util/mantle/Mantle.java +++ b/src/main/java/com/volmit/iris/util/mantle/Mantle.java @@ -31,7 +31,10 @@ import com.volmit.iris.util.parallel.BurstExecutor; import com.volmit.iris.util.parallel.HyperLock; import com.volmit.iris.util.parallel.MultiBurst; -import java.io.*; +import java.io.DataInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; import java.nio.charset.StandardCharsets; import java.util.Map; import java.util.UUID; @@ -43,8 +46,7 @@ import java.util.concurrent.atomic.AtomicBoolean; * The mantle can store any type of data slice anywhere and manage regions & IO on it's own. * This class is fully thread safe read & write */ -public class Mantle -{ +public class Mantle { private final File dataFolder; private final int worldHeight; private final Map lastUse; @@ -56,12 +58,12 @@ public class Mantle /** * Create a new mantle - * @param dataFolder the data folder + * + * @param dataFolder the data folder * @param worldHeight the world's height (in blocks) */ @BlockCoordinates - public Mantle(File dataFolder, int worldHeight) - { + public Mantle(File dataFolder, int worldHeight) { this.hyperLock = new HyperLock(); this.closed = new AtomicBoolean(false); this.dataFolder = dataFolder; @@ -82,25 +84,23 @@ public class Mantle * reading & writing other regions. Hyperlocks are slow sync, but in multicore * environments, they drastically speed up loading & saving large counts of plates * - * @param x the block's x coordinate - * @param y the block's y coordinate - * @param z the block's z coordinate - * @param t the data to set at the block + * @param x the block's x coordinate + * @param y the block's y coordinate + * @param z the block's z coordinate + * @param t the data to set at the block * @param the type of data (generic method) */ @BlockCoordinates - public void set(int x, int y, int z, T t) - { - if(closed.get()) - { + public void set(int x, int y, int z, T t) { + if (closed.get()) { throw new RuntimeException("The Mantle is closed"); } MantleMatter matter = null; try { matter = get((x >> 4) >> 5, (z >> 4) >> 5).get() - .getOrCreate((x >> 4) & 31, (z >> 4) & 31) - .getOrCreate(y >> 4); + .getOrCreate((x >> 4) & 31, (z >> 4) & 31) + .getOrCreate(y >> 4); } catch (InterruptedException e) { Iris.error("Failed to get Tectonic Plate " + ((x >> 4) >> 5) + " " + ((z >> 4) >> 5) + " Due to a thread intterruption"); Iris.reportError(e); @@ -111,13 +111,12 @@ public class Mantle e.printStackTrace(); } - if(matter == null) - { + if (matter == null) { return; } matter.slice(matter.getClass(t)) - .set(x & 15, y & 15, z & 15, t); + .set(x & 15, y & 15, z & 15, t); } /** @@ -128,19 +127,17 @@ public class Mantle * reading & writing other regions. Hyperlocks are slow sync, but in multicore * environments, they drastically speed up loading & saving large counts of plates * - * @param x the block's x coordinate - * @param y the block's y coordinate - * @param z the block's z coordinate - * @param t the class representing the type of data being requested + * @param x the block's x coordinate + * @param y the block's y coordinate + * @param z the block's z coordinate + * @param t the class representing the type of data being requested * @param the type assumed from the provided class * @return the returned result (or null) if it doesnt exist */ @SuppressWarnings("unchecked") @BlockCoordinates - public T get(int x, int y, int z, Class t) - { - if(closed.get()) - { + public T get(int x, int y, int z, Class t) { + if (closed.get()) { throw new RuntimeException("The Mantle is closed"); } @@ -167,18 +164,15 @@ public class Mantle * any data to the mantle or it's Tectonic Plates. Closing will also flush any * loaded regions to the disk in parallel. */ - public synchronized void close() - { + public synchronized void close() { Iris.debug("Closing The Mantle " + C.DARK_AQUA + dataFolder.getAbsolutePath()); - if(closed.get()) - { + if (closed.get()) { throw new RuntimeException("The Mantle is closed"); } closed.set(true); BurstExecutor b = ioBurst.burst(loadedRegions.size()); - for(Long i : loadedRegions.keySet()) - { + for (Long i : loadedRegions.keySet()) { b.queue(() -> { try { loadedRegions.get(i).write(fileForRegion(dataFolder, i)); @@ -196,34 +190,29 @@ public class Mantle /** * Save & unload regions that have not been used for more than the * specified amount of milliseconds + * * @param idleDuration the duration */ - public synchronized void trim(long idleDuration) - { - if(closed.get()) - { + public synchronized void trim(long idleDuration) { + if (closed.get()) { throw new RuntimeException("The Mantle is closed"); } - Iris.debug("Trimming Tectonic Plates older than " + Form.duration((double)idleDuration, 0)); + Iris.debug("Trimming Tectonic Plates older than " + Form.duration((double) idleDuration, 0)); unload.clear(); - for(Long i : lastUse.keySet()) - { - if(M.ms() - lastUse.get(i) >= idleDuration) - { + for (Long i : lastUse.keySet()) { + if (M.ms() - lastUse.get(i) >= idleDuration) { unload.add(i); } } - for(Long i : unload) - { + for (Long i : unload) { TectonicPlate m = loadedRegions.remove(i); lastUse.remove(i); Iris.debug("Unloaded Tectonic Plate " + C.DARK_GREEN + i); - if(m != null) - { + if (m != null) { ioBurst.lazy(() -> { try { m.write(fileForRegion(dataFolder, i)); @@ -238,39 +227,33 @@ public class Mantle /** * This retreives a future of the Tectonic Plate at the given coordinates. * All methods accessing tectonic plates should go through this method + * * @param x the region x * @param z the region z * @return the future of a tectonic plate. */ @RegionCoordinates - private CompletableFuture get(int x, int z) - { + private CompletableFuture get(int x, int z) { return ioBurst.completeValue(() -> hyperLock.withResult(x, z, () -> { Long k = key(x, z); lastUse.put(k, M.ms()); TectonicPlate region = loadedRegions.get(k); - if(region != null) - { + if (region != null) { return region; } File file = fileForRegion(dataFolder, x, z); - if(file.exists()) - { - try - { + if (file.exists()) { + try { FileInputStream fin = new FileInputStream(file); DataInputStream din = new DataInputStream(fin); region = new TectonicPlate(worldHeight, din); din.close(); loadedRegions.put(k, region); Iris.debug("Loaded Tectonic Plate " + C.DARK_GREEN + x + " " + z + C.DARK_AQUA + " " + file.getName()); - } - - catch(Throwable e) - { + } catch (Throwable e) { Iris.error("Failed to read Tectonic Plate " + file.getAbsolutePath() + " creating a new chunk instead."); Iris.reportError(e); e.printStackTrace(); @@ -300,8 +283,7 @@ public class Mantle return f; } - public static Long key(int x, int z) - { + public static Long key(int x, int z) { return Cache.key(x, z); } } diff --git a/src/main/java/com/volmit/iris/util/mantle/MantleChunk.java b/src/main/java/com/volmit/iris/util/mantle/MantleChunk.java index 1b7c293dc..136c3b27e 100644 --- a/src/main/java/com/volmit/iris/util/mantle/MantleChunk.java +++ b/src/main/java/com/volmit/iris/util/mantle/MantleChunk.java @@ -18,13 +18,10 @@ package com.volmit.iris.util.mantle; -import com.volmit.iris.engine.data.chunk.MCATerrainChunk; import com.volmit.iris.util.data.Varint; import com.volmit.iris.util.documentation.ChunkCoordinates; import com.volmit.iris.util.matter.IrisMatter; import com.volmit.iris.util.matter.Matter; -import com.volmit.iris.util.nbt.mca.Section; -import lombok.Data; import java.io.DataInputStream; import java.io.DataOutputStream; @@ -40,29 +37,28 @@ public class MantleChunk { /** * Create a mantle chunk + * * @param sectionHeight the height of the world in sections (blocks >> 4) */ @ChunkCoordinates - public MantleChunk(int sectionHeight) - { + public MantleChunk(int sectionHeight) { sections = new AtomicReferenceArray<>(sectionHeight); } /** * Load a mantle chunk from a data stream + * * @param sectionHeight the height of the world in sections (blocks >> 4) - * @param din the data input - * @throws IOException shit happens + * @param din the data input + * @throws IOException shit happens * @throws ClassNotFoundException shit happens */ public MantleChunk(int sectionHeight, DataInputStream din) throws IOException, ClassNotFoundException { this(sectionHeight); int s = Varint.readUnsignedVarInt(din); - for(int i = 0; i < s; i++) - { - if(din.readBoolean()) - { + for (int i = 0; i < s; i++) { + if (din.readBoolean()) { sections.set(i, Matter.read(din)); } } @@ -70,59 +66,56 @@ public class MantleChunk { /** * Check if a section exists (same as get(section) != null) + * * @param section the section (0 - (worldHeight >> 4)) * @return true if it exists */ @ChunkCoordinates - public boolean exists(int section) - { + public boolean exists(int section) { return get(section) != null; } /** * Get thje matter at the given section or null if it doesnt exist + * * @param section the section (0 - (worldHeight >> 4)) * @return the matter or null if it doesnt exist */ @ChunkCoordinates - public Matter get(int section) - { + public Matter get(int section) { return sections.get(section); } /** * Clear all matter from this chunk */ - public void clear() - { - for(int i = 0; i < sections.length(); i++) - { + public void clear() { + for (int i = 0; i < sections.length(); i++) { delete(i); } } /** * Delete the matter from the given section + * * @param section the section (0 - (worldHeight >> 4)) */ @ChunkCoordinates - public void delete(int section) - { + public void delete(int section) { sections.set(section, null); } /** * Get or create a new matter section at the given section + * * @param section the section (0 - (worldHeight >> 4)) * @return the matter */ @ChunkCoordinates - public Matter getOrCreate(int section) - { + public Matter getOrCreate(int section) { Matter matter = get(section); - if(matter == null) - { + if (matter == null) { matter = new IrisMatter(16, 16, 16); sections.set(section, matter); } @@ -132,23 +125,19 @@ public class MantleChunk { /** * Write this chunk to a data stream + * * @param dos the stream * @throws IOException shit happens */ public void write(DataOutputStream dos) throws IOException { Varint.writeUnsignedVarInt(sections.length(), dos); - for(int i = 0; i < sections.length(); i++) - { - if(exists(i)) - { + for (int i = 0; i < sections.length(); i++) { + if (exists(i)) { dos.writeBoolean(true); Matter matter = get(i); matter.writeDos(dos); - } - - else - { + } else { dos.writeBoolean(false); } } diff --git a/src/main/java/com/volmit/iris/util/mantle/TectonicPlate.java b/src/main/java/com/volmit/iris/util/mantle/TectonicPlate.java index cc6344b39..a09d18299 100644 --- a/src/main/java/com/volmit/iris/util/mantle/TectonicPlate.java +++ b/src/main/java/com/volmit/iris/util/mantle/TectonicPlate.java @@ -35,28 +35,27 @@ public class TectonicPlate { /** * Create a new tectonic plate + * * @param worldHeight the height of the world */ - public TectonicPlate(int worldHeight) - { + public TectonicPlate(int worldHeight) { this.sectionHeight = worldHeight >> 4; this.chunks = new AtomicReferenceArray<>(1024); } /** * Load a tectonic plate from a data stream + * * @param worldHeight the height of the world - * @param din the data input - * @throws IOException shit happens yo + * @param din the data input + * @throws IOException shit happens yo * @throws ClassNotFoundException real shit bro */ public TectonicPlate(int worldHeight, DataInputStream din) throws IOException, ClassNotFoundException { this(worldHeight); - for(int i = 0; i < chunks.length(); i++) - { - if(din.readBoolean()) - { + for (int i = 0; i < chunks.length(); i++) { + if (din.readBoolean()) { chunks.set(i, new MantleChunk(sectionHeight, din)); } } @@ -64,63 +63,60 @@ public class TectonicPlate { /** * Check if a chunk exists in this plate or not (same as get(x, z) != null) + * * @param x the chunk relative x (0-31) * @param z the chunk relative z (0-31) * @return true if the chunk exists */ @ChunkCoordinates - public boolean exists(int x, int z) - { + public boolean exists(int x, int z) { return get(x, z) != null; } /** * Get a chunk at the given coordinates or null if it doesnt exist + * * @param x the chunk relative x (0-31) * @param z the chunk relative z (0-31) * @return the chunk or null if it doesnt exist */ @ChunkCoordinates - public MantleChunk get(int x, int z) - { + public MantleChunk get(int x, int z) { return chunks.get(index(x, z)); } /** * Clear all chunks from this tectonic plate */ - public void clear() - { - for(int i = 0; i < chunks.length(); i++) - { + public void clear() { + for (int i = 0; i < chunks.length(); i++) { chunks.set(i, null); } } /** * Delete a chunk from this tectonic plate + * * @param x the chunk relative x (0-31) * @param z the chunk relative z (0-31) */ @ChunkCoordinates - public void delete(int x, int z) - { + public void delete(int x, int z) { chunks.set(index(x, z), null); } /** * Get a tectonic plate, or create one and insert it & return it if it diddnt exist + * * @param x the chunk relative x (0-31) * @param z the chunk relative z (0-31) * @return the chunk (read or created & inserted) */ @ChunkCoordinates - public MantleChunk getOrCreate(int x, int z) - { + public MantleChunk getOrCreate(int x, int z) { MantleChunk chunk = get(x, z); - if(chunk == null) - { + if (chunk == null) { chunk = new MantleChunk(sectionHeight); chunks.set(index(x, z), chunk); } @@ -135,6 +131,7 @@ public class TectonicPlate { /** * Write this tectonic plate to file + * * @param file the file to write it to * @throws IOException shit happens */ @@ -148,17 +145,16 @@ public class TectonicPlate { /** * Write this tectonic plate to a data stream + * * @param dos the data output * @throws IOException shit happens */ public void write(DataOutputStream dos) throws IOException { - for(int i = 0; i < chunks.length(); i++) - { + for (int i = 0; i < chunks.length(); i++) { MantleChunk chunk = chunks.get(i); dos.writeBoolean(chunk != null); - if(chunk != null) - { + if (chunk != null) { chunk.write(dos); } } diff --git a/src/main/java/com/volmit/iris/util/matter/Matter.java b/src/main/java/com/volmit/iris/util/matter/Matter.java index 5b7001eed..d81cbe08a 100644 --- a/src/main/java/com/volmit/iris/util/matter/Matter.java +++ b/src/main/java/com/volmit/iris/util/matter/Matter.java @@ -29,7 +29,6 @@ import org.bukkit.World; import org.bukkit.block.data.BlockData; import org.bukkit.entity.Entity; -import javax.xml.crypto.Data; import java.io.*; import java.util.Map; import java.util.Set; @@ -355,13 +354,11 @@ public interface Matter { return matter; } - default int getTotalCount() - { + default int getTotalCount() { int m = 0; - for(MatterSlice i : getSliceMap().values()) - { - m+= i.getEntryCount(); + for (MatterSlice i : getSliceMap().values()) { + m += i.getEntryCount(); } return m; diff --git a/src/main/java/com/volmit/iris/util/matter/MatterSlice.java b/src/main/java/com/volmit/iris/util/matter/MatterSlice.java index cc7a57508..e05194d56 100644 --- a/src/main/java/com/volmit/iris/util/matter/MatterSlice.java +++ b/src/main/java/com/volmit/iris/util/matter/MatterSlice.java @@ -21,7 +21,6 @@ package com.volmit.iris.util.matter; import com.volmit.iris.engine.data.cache.Cache; import com.volmit.iris.util.data.Varint; import com.volmit.iris.util.hunk.Hunk; -import com.volmit.iris.util.hunk.storage.MappedHunk; import org.bukkit.Location; import org.bukkit.World; import org.bukkit.block.data.BlockData; @@ -116,17 +115,13 @@ public interface MatterSlice extends Hunk { palette.writePalette(dos); dos.writeBoolean(isMapped()); - if(isMapped()) - { + if (isMapped()) { Varint.writeUnsignedVarInt(getEntryCount(), dos); iterateSyncIO((x, y, z, b) -> { Varint.writeUnsignedVarInt(Cache.to1D(x, y, z, w, h), dos); palette.writeNode(b, dos); }); - } - - else - { + } else { iterateSyncIO((x, y, z, b) -> palette.writeNode(b, dos)); } } @@ -135,8 +130,7 @@ public interface MatterSlice extends Hunk { int w = getWidth(); int h = getHeight(); MatterPalette palette = new MatterPalette(this, din); - if(din.readBoolean()) - { + if (din.readBoolean()) { int nodes = Varint.readUnsignedVarInt(din); int[] pos; @@ -144,10 +138,7 @@ public interface MatterSlice extends Hunk { pos = Cache.to3D(Varint.readUnsignedVarInt(din), w, h); setRaw(pos[0], pos[1], pos[2], palette.readNode(din)); } - } - - else - { + } else { iterateSyncIO((x, y, z, b) -> setRaw(x, y, z, palette.readNode(din))); } } @@ -156,18 +147,15 @@ public interface MatterSlice extends Hunk { rotate(x, y, z, (_x, _y, _z) -> n.slice(getType())); } - default boolean containsKey(BlockVector v) - { + default boolean containsKey(BlockVector v) { return get(v.getBlockX(), v.getBlockY(), v.getBlockZ()) != null; } - default void put(BlockVector v, T d) - { + default void put(BlockVector v, T d) { set(v.getBlockX(), v.getBlockY(), v.getBlockZ(), d); } - default T get(BlockVector v) - { + default T get(BlockVector v) { return get(v.getBlockX(), v.getBlockY(), v.getBlockZ()); } } diff --git a/src/main/java/com/volmit/iris/util/matter/slices/BlockMatter.java b/src/main/java/com/volmit/iris/util/matter/slices/BlockMatter.java index 6c53388ab..5790e758a 100644 --- a/src/main/java/com/volmit/iris/util/matter/slices/BlockMatter.java +++ b/src/main/java/com/volmit/iris/util/matter/slices/BlockMatter.java @@ -18,8 +18,6 @@ package com.volmit.iris.util.matter.slices; -import com.volmit.iris.engine.parallax.ParallaxAccess; -import com.volmit.iris.engine.parallax.ParallaxWorld; import com.volmit.iris.util.data.B; import com.volmit.iris.util.matter.Sliced; import org.bukkit.World; diff --git a/src/main/java/com/volmit/iris/util/parallel/HyperLock.java b/src/main/java/com/volmit/iris/util/parallel/HyperLock.java index 7af994b2b..f93358a29 100644 --- a/src/main/java/com/volmit/iris/util/parallel/HyperLock.java +++ b/src/main/java/com/volmit/iris/util/parallel/HyperLock.java @@ -67,19 +67,12 @@ public class HyperLock { Throwable ee = null; try { r.run(); - } - - catch(Throwable e) - { + } catch (Throwable e) { ee = e; - } - - finally - { + } finally { unlock(x, z); - if(ee != null) - { + if (ee != null) { throw ee; } } @@ -90,19 +83,12 @@ public class HyperLock { IOException ee = null; try { r.run(); - } - - catch(IOException e) - { + } catch (IOException e) { ee = e; - } - - finally - { + } finally { unlock(x, z); - if(ee != null) - { + if (ee != null) { throw ee; } }