mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-12-19 15:09:18 +00:00
move the updater command out of dev
This commit is contained in:
@@ -64,7 +64,6 @@ import java.util.zip.GZIPOutputStream;
|
|||||||
public class CommandDeveloper implements DecreeExecutor {
|
public class CommandDeveloper implements DecreeExecutor {
|
||||||
private CommandTurboPregen turboPregen;
|
private CommandTurboPregen turboPregen;
|
||||||
private CommandLazyPregen lazyPregen;
|
private CommandLazyPregen lazyPregen;
|
||||||
private CommandUpdater updater;
|
|
||||||
|
|
||||||
@Decree(description = "Get Loaded TectonicPlates Count", origin = DecreeOrigin.BOTH, sync = true)
|
@Decree(description = "Get Loaded TectonicPlates Count", origin = DecreeOrigin.BOTH, sync = true)
|
||||||
public void EngineStatus() {
|
public void EngineStatus() {
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ package com.volmit.iris.core.commands;
|
|||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
import com.volmit.iris.core.IrisSettings;
|
import com.volmit.iris.core.IrisSettings;
|
||||||
import com.volmit.iris.core.nms.INMS;
|
import com.volmit.iris.core.nms.INMS;
|
||||||
import com.volmit.iris.core.pregenerator.ChunkUpdater;
|
|
||||||
import com.volmit.iris.core.service.StudioSVC;
|
import com.volmit.iris.core.service.StudioSVC;
|
||||||
import com.volmit.iris.core.tools.IrisToolbelt;
|
import com.volmit.iris.core.tools.IrisToolbelt;
|
||||||
import com.volmit.iris.engine.framework.Engine;
|
import com.volmit.iris.engine.framework.Engine;
|
||||||
@@ -33,7 +32,6 @@ import com.volmit.iris.util.decree.annotations.Decree;
|
|||||||
import com.volmit.iris.util.decree.annotations.Param;
|
import com.volmit.iris.util.decree.annotations.Param;
|
||||||
import com.volmit.iris.util.decree.specialhandlers.NullablePlayerHandler;
|
import com.volmit.iris.util.decree.specialhandlers.NullablePlayerHandler;
|
||||||
import com.volmit.iris.util.format.C;
|
import com.volmit.iris.util.format.C;
|
||||||
import com.volmit.iris.util.format.Form;
|
|
||||||
import com.volmit.iris.util.io.IO;
|
import com.volmit.iris.util.io.IO;
|
||||||
import com.volmit.iris.util.misc.ServerProperties;
|
import com.volmit.iris.util.misc.ServerProperties;
|
||||||
import com.volmit.iris.util.plugin.VolmitSender;
|
import com.volmit.iris.util.plugin.VolmitSender;
|
||||||
@@ -56,6 +54,7 @@ import static org.bukkit.Bukkit.getServer;
|
|||||||
|
|
||||||
@Decree(name = "iris", aliases = {"ir", "irs"}, description = "Basic Command")
|
@Decree(name = "iris", aliases = {"ir", "irs"}, description = "Basic Command")
|
||||||
public class CommandIris implements DecreeExecutor {
|
public class CommandIris implements DecreeExecutor {
|
||||||
|
private CommandUpdater updater;
|
||||||
private CommandStudio studio;
|
private CommandStudio studio;
|
||||||
private CommandPregen pregen;
|
private CommandPregen pregen;
|
||||||
private CommandSettings settings;
|
private CommandSettings settings;
|
||||||
@@ -318,24 +317,6 @@ public class CommandIris implements DecreeExecutor {
|
|||||||
return dir.delete();
|
return dir.delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Decree(description = "Updates all chunk in the specified world")
|
|
||||||
public void updater(
|
|
||||||
@Param(description = "World to update chunks at")
|
|
||||||
World world
|
|
||||||
) {
|
|
||||||
if (!IrisToolbelt.isIrisWorld(world)) {
|
|
||||||
sender().sendMessage(C.GOLD + "This is not an Iris world");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ChunkUpdater updater = new ChunkUpdater(world);
|
|
||||||
if (sender().isPlayer()) {
|
|
||||||
sender().sendMessage(C.GREEN + "Updating " + world.getName() + " Total chunks: " + Form.f(updater.getChunks()));
|
|
||||||
} else {
|
|
||||||
Iris.info(C.GREEN + "Updating " + world.getName() + " Total chunks: " + Form.f(updater.getChunks()));
|
|
||||||
}
|
|
||||||
updater.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Decree(description = "Set aura spins")
|
@Decree(description = "Set aura spins")
|
||||||
public void aura(
|
public void aura(
|
||||||
@Param(description = "The h color value", defaultValue = "-20")
|
@Param(description = "The h color value", defaultValue = "-20")
|
||||||
|
|||||||
@@ -182,17 +182,32 @@ public class CommandStudio implements DecreeExecutor {
|
|||||||
int rad = engine.getMantle().getRadius();
|
int rad = engine.getMantle().getRadius();
|
||||||
var mantle = engine.getMantle().getMantle();
|
var mantle = engine.getMantle().getMantle();
|
||||||
var chunkMap = new KMap<Position2, MantleChunk>();
|
var chunkMap = new KMap<Position2, MantleChunk>();
|
||||||
for (int i = -(radius + rad); i <= radius + rad; i++) {
|
ParallelQueueJob<Position2> prep = new ParallelQueueJob<>() {
|
||||||
for (int j = -(radius + rad); j <= radius + rad; j++) {
|
@Override
|
||||||
int xx = i + x, zz = j + z;
|
public void execute(Position2 pos) {
|
||||||
if (Math.abs(i) <= radius && Math.abs(j) <= radius) {
|
var cpos = pos.add(x, z);
|
||||||
mantle.deleteChunk(xx, zz);
|
if (Math.abs(pos.getX()) <= radius && Math.abs(pos.getZ()) <= radius) {
|
||||||
continue;
|
mantle.deleteChunk(cpos.getX(), cpos.getZ());
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
chunkMap.put(new Position2(xx, zz), mantle.getChunk(xx, zz));
|
chunkMap.put(cpos, mantle.getChunk(cpos.getX(), cpos.getZ()));
|
||||||
mantle.deleteChunk(xx, zz);
|
mantle.deleteChunk(cpos.getX(), cpos.getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "Preparing Mantle";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
for (int xx = -(radius + rad); xx <= radius + rad; xx++) {
|
||||||
|
for (int zz = -(radius + rad); zz <= radius + rad; zz++) {
|
||||||
|
prep.queue(new Position2(xx, zz));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
CountDownLatch pLatch = new CountDownLatch(1);
|
||||||
|
prep.execute(sender(), pLatch::countDown);
|
||||||
|
pLatch.await();
|
||||||
|
|
||||||
|
|
||||||
ParallelQueueJob<Position2> job = new ParallelQueueJob<>() {
|
ParallelQueueJob<Position2> job = new ParallelQueueJob<>() {
|
||||||
@Override
|
@Override
|
||||||
@@ -210,14 +225,14 @@ public class CommandStudio implements DecreeExecutor {
|
|||||||
job.queue(new Position2(i + x, j + z));
|
job.queue(new Position2(i + x, j + z));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CountDownLatch latch = new CountDownLatch(1);
|
CountDownLatch latch = new CountDownLatch(1);
|
||||||
job.execute(sender(), latch::countDown);
|
job.execute(sender(), latch::countDown);
|
||||||
latch.await();
|
latch.await();
|
||||||
|
|
||||||
int sections = mantle.getWorldHeight() >> 4;
|
int sections = mantle.getWorldHeight() >> 4;
|
||||||
chunkMap.forEach((pos, chunk) -> {
|
chunkMap.forEach((pos, chunk) -> {
|
||||||
var c = mantle.getChunk(pos.getX(), pos.getZ());
|
var c = mantle.getChunk(pos.getX(), pos.getZ()).use();
|
||||||
|
try {
|
||||||
for (MantleFlag flag : MantleFlag.values()) {
|
for (MantleFlag flag : MantleFlag.values()) {
|
||||||
c.flag(flag, chunk.isFlagged(flag));
|
c.flag(flag, chunk.isFlagged(flag));
|
||||||
}
|
}
|
||||||
@@ -228,6 +243,9 @@ public class CommandStudio implements DecreeExecutor {
|
|||||||
var s = c.getOrCreate(y);
|
var s = c.getOrCreate(y);
|
||||||
slice.getSliceMap().forEach(s::putSlice);
|
slice.getSliceMap().forEach(s::putSlice);
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
c.release();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
sender().sendMessage("Error while regenerating chunks");
|
sender().sendMessage("Error while regenerating chunks");
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
package com.volmit.iris.core.commands;
|
package com.volmit.iris.core.commands;
|
||||||
|
|
||||||
|
import lombok.Synchronized;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
|
||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
@@ -32,7 +33,8 @@ import com.volmit.iris.util.format.Form;
|
|||||||
|
|
||||||
@Decree(name = "updater", origin = DecreeOrigin.BOTH, description = "Iris World Updater")
|
@Decree(name = "updater", origin = DecreeOrigin.BOTH, description = "Iris World Updater")
|
||||||
public class CommandUpdater implements DecreeExecutor {
|
public class CommandUpdater implements DecreeExecutor {
|
||||||
private ChunkUpdater chunkUpdater;
|
private final Object lock = new Object();
|
||||||
|
private transient ChunkUpdater chunkUpdater;
|
||||||
|
|
||||||
@Decree(description = "Updates all chunk in the specified world")
|
@Decree(description = "Updates all chunk in the specified world")
|
||||||
public void start(
|
public void start(
|
||||||
@@ -43,6 +45,7 @@ public class CommandUpdater implements DecreeExecutor {
|
|||||||
sender().sendMessage(C.GOLD + "This is not an Iris world");
|
sender().sendMessage(C.GOLD + "This is not an Iris world");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
synchronized (lock) {
|
||||||
if (chunkUpdater != null) {
|
if (chunkUpdater != null) {
|
||||||
chunkUpdater.stop();
|
chunkUpdater.stop();
|
||||||
}
|
}
|
||||||
@@ -55,7 +58,9 @@ public class CommandUpdater implements DecreeExecutor {
|
|||||||
}
|
}
|
||||||
chunkUpdater.start();
|
chunkUpdater.start();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Synchronized("lock")
|
||||||
@Decree(description = "Pause the updater")
|
@Decree(description = "Pause the updater")
|
||||||
public void pause( ) {
|
public void pause( ) {
|
||||||
if (chunkUpdater == null) {
|
if (chunkUpdater == null) {
|
||||||
@@ -78,6 +83,7 @@ public class CommandUpdater implements DecreeExecutor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Synchronized("lock")
|
||||||
@Decree(description = "Stops the updater")
|
@Decree(description = "Stops the updater")
|
||||||
public void stop() {
|
public void stop() {
|
||||||
if (chunkUpdater == null) {
|
if (chunkUpdater == null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user