mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 18:23:06 +00:00
Pregen & create
This commit is contained in:
parent
a3d6776c02
commit
15721f1279
@ -21,18 +21,63 @@ package com.volmit.iris.core.decrees;
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.IrisSettings;
|
||||
import com.volmit.iris.core.tools.IrisToolbelt;
|
||||
import com.volmit.iris.engine.object.dimensional.IrisDimension;
|
||||
import com.volmit.iris.util.decree.DecreeExecutor;
|
||||
import com.volmit.iris.util.decree.DecreeOrigin;
|
||||
import com.volmit.iris.util.decree.annotations.Decree;
|
||||
import com.volmit.iris.util.decree.annotations.Param;
|
||||
import com.volmit.iris.util.exceptions.IrisException;
|
||||
import com.volmit.iris.util.format.C;
|
||||
import org.bukkit.World;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Objects;
|
||||
|
||||
@Decree(name = "irisd", aliases = {"ird"}, description = "Basic Command")
|
||||
public class DecIris implements DecreeExecutor
|
||||
{
|
||||
private DecIrisStudio studio;
|
||||
|
||||
private DecIrisPregen pregen;
|
||||
|
||||
@Decree(description = "Create a new world", aliases = "+")
|
||||
public void create(
|
||||
@Param(name = "name", aliases = "worldName", description = "The name of the world to create", defaultValue = "IrisWorld")
|
||||
String name,
|
||||
@Param(name = "type", aliases = "dimension", description = "The dimension type to create the world with", defaultValue = "overworld")
|
||||
IrisDimension type,
|
||||
@Param(name = "seed", description = "The seed to generate the world with", defaultValue = "1337")
|
||||
long seed
|
||||
){
|
||||
if (name.equals("iris")) {
|
||||
sender().sendMessage(C.RED + "You cannot use the world name \"iris\" for creating worlds as Iris uses this directory for studio worlds.");
|
||||
sender().sendMessage(C.RED + "May we suggest the name \"IrisWorld\" instead?");
|
||||
return;
|
||||
}
|
||||
|
||||
if (new File(name).exists()){
|
||||
sender().sendMessage(C.RED + "That folder already exists!");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
IrisToolbelt.createWorld()
|
||||
.dimension(type.getLoadKey())
|
||||
.name(name)
|
||||
.seed(seed)
|
||||
.sender(sender())
|
||||
.studio(false)
|
||||
.create();
|
||||
} catch (Throwable e){
|
||||
sender().sendMessage(C.RED + "Exception raised during creation. See the console for more details.");
|
||||
Iris.error("Exception raised during world creation: " + e.getMessage());
|
||||
Iris.reportError(e);
|
||||
return;
|
||||
}
|
||||
|
||||
sender().sendMessage(C.GREEN + "Successfully created your world!");
|
||||
}
|
||||
|
||||
@Decree(description = "Print version information")
|
||||
public void version(){
|
||||
sender().sendMessage("Iris v" + Iris.instance.getDescription().getVersion() + " by Volmit Software");
|
||||
|
@ -0,0 +1,59 @@
|
||||
package com.volmit.iris.core.decrees;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.gui.PregeneratorJob;
|
||||
import com.volmit.iris.core.pregenerator.PregenTask;
|
||||
import com.volmit.iris.core.tools.IrisToolbelt;
|
||||
import com.volmit.iris.util.decree.DecreeExecutor;
|
||||
import com.volmit.iris.util.decree.annotations.Decree;
|
||||
import com.volmit.iris.util.decree.annotations.Param;
|
||||
import com.volmit.iris.util.format.C;
|
||||
import com.volmit.iris.util.math.Position2;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
@Decree(name = "pregen", aliases = "pregenerate", description = "Pregenerate your Iris worlds!")
|
||||
public class DecIrisPregen implements DecreeExecutor {
|
||||
@Decree(description = "Pregenerate a world")
|
||||
public void start(
|
||||
@Param(name = "world", description = "The world to pregen", contextual = true)
|
||||
World world,
|
||||
@Param(name = "radius", description = "The radius of the pregen in blocks", aliases = "size")
|
||||
int radius,
|
||||
@Param(name = "center", aliases = "middle", description = "The center location of the pregen. Use \"me\" for your current location", defaultValue = "0,0")
|
||||
Vector center
|
||||
) {
|
||||
try {
|
||||
IrisToolbelt.pregenerate(PregenTask
|
||||
.builder()
|
||||
.center(new Position2(center))
|
||||
.width((radius >> 9 + 1) * 2)
|
||||
.height((radius >> 9 + 1) * 2)
|
||||
.build(), world);
|
||||
sender().sendMessage(C.GREEN + "Successfully started the pregeneration task!");
|
||||
} catch (Throwable e) {
|
||||
sender().sendMessage(C.RED + "Epic fail");
|
||||
Iris.reportError(e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Decree(description = "Stop the active pregeneration task", aliases = "x")
|
||||
public void stop(){
|
||||
if (PregeneratorJob.shutdownInstance()) {
|
||||
sender().sendMessage(C.GREEN + "Stopped pregeneration task");
|
||||
} else {
|
||||
sender().sendMessage(C.YELLOW + "No active pregeneration tasks to stop");
|
||||
}
|
||||
}
|
||||
|
||||
@Decree(description = "Pause / continue the active pregeneration task", aliases = {"t", "resume", "unpause"})
|
||||
public void pause() {
|
||||
if (PregeneratorJob.pauseResume()) {
|
||||
sender().sendMessage(C.GREEN + "Paused/unpaused pregeneration task, now: " + (PregeneratorJob.isPaused() ? "Paused" : "Running") + ".");
|
||||
} else {
|
||||
sender().sendMessage(C.YELLOW + "No active pregeneration tasks to pause/unpause.");
|
||||
}
|
||||
}
|
||||
}
|
@ -19,6 +19,7 @@
|
||||
package com.volmit.iris.util.math;
|
||||
|
||||
import com.volmit.iris.engine.object.basic.IrisPosition;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class Position2 {
|
||||
private int x;
|
||||
@ -29,6 +30,11 @@ public class Position2 {
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public Position2(Vector center) {
|
||||
this.x = center.getBlockX();
|
||||
this.z = center.getBlockZ();
|
||||
}
|
||||
|
||||
public int getX() {
|
||||
return x;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user