mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-12-29 12:09:07 +00:00
@@ -52,6 +52,7 @@ dependencies {
|
||||
implementation 'org.apache.logging.log4j:log4j-core:2.19.0'
|
||||
implementation 'commons-lang:commons-lang:2.6'
|
||||
implementation 'com.github.oshi:oshi-core:5.8.5'
|
||||
compileOnly 'org.lz4:lz4-java:1.8.0'
|
||||
|
||||
// Third Party Integrations
|
||||
implementation 'com.ticxo.playeranimator:PlayerAnimator:R1.2.7'
|
||||
|
||||
@@ -27,7 +27,6 @@ import com.volmit.iris.engine.framework.Engine;
|
||||
import com.volmit.iris.engine.mantle.EngineMantle;
|
||||
import com.volmit.iris.engine.mantle.MantleWriter;
|
||||
import com.volmit.iris.util.collection.KMap;
|
||||
import com.volmit.iris.util.collection.KSet;
|
||||
import com.volmit.iris.util.documentation.BlockCoordinates;
|
||||
import com.volmit.iris.util.documentation.ChunkCoordinates;
|
||||
import com.volmit.iris.util.documentation.RegionCoordinates;
|
||||
@@ -40,7 +39,6 @@ import com.volmit.iris.util.matter.MatterSlice;
|
||||
import com.volmit.iris.util.parallel.BurstExecutor;
|
||||
import com.volmit.iris.util.parallel.HyperLock;
|
||||
import com.volmit.iris.util.parallel.MultiBurst;
|
||||
import com.volmit.iris.util.scheduling.Looper;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Chunk;
|
||||
|
||||
@@ -112,7 +110,7 @@ public class Mantle {
|
||||
* @return the file
|
||||
*/
|
||||
public static File fileForRegion(File folder, Long key) {
|
||||
File f = new File(folder, "p." + key + ".ttp");
|
||||
File f = new File(folder, "p." + key + ".ttp.lz4");
|
||||
if (!f.getParentFile().exists()) {
|
||||
f.getParentFile().mkdirs();
|
||||
}
|
||||
@@ -447,10 +445,11 @@ public class Mantle {
|
||||
AtomicInteger i = new AtomicInteger();
|
||||
Set<Long> toUnload = this.toUnload;
|
||||
this.toUnload = new HashSet<>();
|
||||
toUnload.removeIf(Objects::isNull);
|
||||
try {
|
||||
List<Future<?>> futures = new ArrayList<>();
|
||||
ExecutorService service = Executors.newFixedThreadPool(dynamicThreads.get());
|
||||
for (Long id : new ArrayList<>(toUnload)) {
|
||||
for (long id : new ArrayList<>(toUnload)) {
|
||||
futures.add(service.submit(() ->
|
||||
hyperLock.withLong(id, () -> {
|
||||
TectonicPlate m = loadedRegions.get(id);
|
||||
@@ -468,10 +467,13 @@ public class Mantle {
|
||||
}
|
||||
})));
|
||||
}
|
||||
while (!futures.isEmpty()) {
|
||||
futures.remove(0).get();
|
||||
}
|
||||
service.shutdown();
|
||||
|
||||
try {
|
||||
while (!futures.isEmpty()) {
|
||||
futures.remove(0).get();
|
||||
}
|
||||
service.shutdown();
|
||||
} catch (InterruptedException ignored) {}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
@@ -549,6 +551,8 @@ public class Mantle {
|
||||
}
|
||||
|
||||
File file = fileForRegion(dataFolder, x, z);
|
||||
if (!file.exists())
|
||||
file = new File(dataFolder, file.getName().substring(".lz4".length()));
|
||||
|
||||
if (file.exists()) {
|
||||
try {
|
||||
|
||||
@@ -26,6 +26,9 @@ import com.volmit.iris.util.format.C;
|
||||
import com.volmit.iris.util.format.Form;
|
||||
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
||||
import lombok.Getter;
|
||||
import net.jpountz.lz4.LZ4BlockInputStream;
|
||||
import net.jpountz.lz4.LZ4FrameInputStream;
|
||||
import net.jpountz.lz4.LZ4FrameOutputStream;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.concurrent.atomic.AtomicReferenceArray;
|
||||
@@ -79,8 +82,14 @@ public class TectonicPlate {
|
||||
|
||||
public static TectonicPlate read(int worldHeight, File file) throws IOException, ClassNotFoundException {
|
||||
FileInputStream fin = new FileInputStream(file);
|
||||
GZIPInputStream gzi = new GZIPInputStream(fin);
|
||||
DataInputStream din = new DataInputStream(gzi);
|
||||
DataInputStream din;
|
||||
if (file.getName().endsWith("ttp")) {
|
||||
GZIPInputStream gzi = new GZIPInputStream(fin);
|
||||
din = new DataInputStream(gzi);
|
||||
} else {
|
||||
LZ4FrameInputStream lz4 = new LZ4FrameInputStream(fin);
|
||||
din = new DataInputStream(lz4);
|
||||
}
|
||||
TectonicPlate p = new TectonicPlate(worldHeight, din);
|
||||
din.close();
|
||||
|
||||
@@ -164,8 +173,14 @@ public class TectonicPlate {
|
||||
public void write(File file) throws IOException {
|
||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||
FileOutputStream fos = new FileOutputStream(file);
|
||||
GZIPOutputStream gzo = new GZIPOutputStream(fos);
|
||||
DataOutputStream dos = new DataOutputStream(gzo);
|
||||
DataOutputStream dos;
|
||||
if (file.getName().endsWith("ttp")) {
|
||||
GZIPOutputStream gzo = new GZIPOutputStream(fos);
|
||||
dos = new DataOutputStream(gzo);
|
||||
} else {
|
||||
LZ4FrameOutputStream lz4 = new LZ4FrameOutputStream(fos);
|
||||
dos = new DataOutputStream(lz4);
|
||||
}
|
||||
write(dos);
|
||||
dos.close();
|
||||
Iris.info("Saved Tectonic Plate " + C.DARK_GREEN + file.getName().split("\\Q.\\E")[0] + C.RED + " in " + Form.duration(p.getMilliseconds(), 2));
|
||||
|
||||
@@ -17,6 +17,7 @@ libraries:
|
||||
- org.ow2.asm:asm:9.2
|
||||
- rhino:js:1.7R2
|
||||
- bsf:bsf:2.4.0
|
||||
- org.lz4:lz4-java:1.8.0
|
||||
commands:
|
||||
iris:
|
||||
aliases: [ ir, irs ]
|
||||
|
||||
Reference in New Issue
Block a user