mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-19 10:43:14 +00:00
Fix console sender, add descriptions, add -here
This commit is contained in:
parent
26dee50e68
commit
705c5ce790
@ -49,8 +49,12 @@ public class CommandIrisPregen extends MortarCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(VolmitSender sender, String[] args) {
|
public boolean handle(VolmitSender sender, String[] args) {
|
||||||
if (!IrisToolbelt.isIrisWorld(sender.player().getWorld())){
|
if (sender.isPlayer()) {
|
||||||
sender.sendMessage("Pregen only works in Iris worlds!");
|
if (!IrisToolbelt.isIrisWorld(sender.player().getWorld())) {
|
||||||
|
sender.sendMessage("Pregen only works in Iris worlds!");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
sender.sendMessage("Note that pregeneration only works in Iris worlds!");
|
||||||
}
|
}
|
||||||
|
|
||||||
sender.sendMessage("Iris Pregen Commands:");
|
sender.sendMessage("Iris Pregen Commands:");
|
||||||
|
@ -3,7 +3,6 @@ package com.volmit.iris.core.command.pregen;
|
|||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
import com.volmit.iris.core.gui.PregeneratorJob;
|
import com.volmit.iris.core.gui.PregeneratorJob;
|
||||||
import com.volmit.iris.core.pregenerator.PregenTask;
|
import com.volmit.iris.core.pregenerator.PregenTask;
|
||||||
import com.volmit.iris.core.pregenerator.methods.HybridPregenMethod;
|
|
||||||
import com.volmit.iris.core.tools.IrisToolbelt;
|
import com.volmit.iris.core.tools.IrisToolbelt;
|
||||||
import com.volmit.iris.util.collection.KList;
|
import com.volmit.iris.util.collection.KList;
|
||||||
import com.volmit.iris.util.math.Position2;
|
import com.volmit.iris.util.math.Position2;
|
||||||
@ -13,15 +12,28 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.checkerframework.checker.units.qual.K;
|
import org.checkerframework.checker.units.qual.K;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
public class CommandIrisPregenCreate extends MortarCommand {
|
public class CommandIrisPregenCreate extends MortarCommand {
|
||||||
|
|
||||||
public CommandIrisPregenCreate() {
|
public CommandIrisPregenCreate() {
|
||||||
super("create", "c", "new", "+");
|
super("create", "c", "new", "+");
|
||||||
requiresPermission(Iris.perm);
|
requiresPermission(Iris.perm);
|
||||||
setCategory("Pregen");
|
setCategory("Pregen");
|
||||||
setDescription("Create a new pregeneration task");
|
setDescription("""
|
||||||
|
Create a new pregeneration task.
|
||||||
|
Command usage & examples:
|
||||||
|
/iris pregen [radius=<radius>] [width=<width>] [height=<height>] [x=<centerX>] [z=<centerZ>] [world=<world>] [-here]
|
||||||
|
/iris pregen radius=5000 x=10r z=10r world=IrisWorld
|
||||||
|
/iris pregen 5k -here
|
||||||
|
|
||||||
|
<radius>: Sets both width and height to a value.
|
||||||
|
<x> & <z>: Give the center point of the pregeneration.
|
||||||
|
<world>: Specify a specific world name for generation as well (required for console)
|
||||||
|
-here: If added, the center location is set to your position (player only)
|
||||||
|
|
||||||
|
For all numeric values (radius, centerX, etc.) you may use:
|
||||||
|
c => 16, r => 512, k => 1000
|
||||||
|
Example: entering '1000' is the same as '1k' (1 * 1000)
|
||||||
|
https://docs.volmit.com/iris/pregeneration""");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -38,7 +50,7 @@ public class CommandIrisPregenCreate extends MortarCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getArgsUsage() {
|
protected String getArgsUsage() {
|
||||||
return null;
|
return "<radius> [width=<width>] [height=<height>] [x=<centerX>] [z=<centerZ>] [world=<world>] [-here]";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -54,16 +66,26 @@ public class CommandIrisPregenCreate extends MortarCommand {
|
|||||||
int height = -1;
|
int height = -1;
|
||||||
int x = 0;
|
int x = 0;
|
||||||
int z = 0;
|
int z = 0;
|
||||||
|
boolean here = false;
|
||||||
|
|
||||||
KList<String> failed = new KList<>();
|
KList<String> failed = new KList<>();
|
||||||
for (String a : args) {
|
for (String a : args) {
|
||||||
if (a.contains("=")) {
|
if (a.equals("-here")){
|
||||||
|
here = true;
|
||||||
|
} else if (a.contains("=")) {
|
||||||
String pre = a.split("=")[0];
|
String pre = a.split("=")[0];
|
||||||
String val = a.split("=")[1];
|
String val = a.split("=")[1];
|
||||||
if (pre.equals("world")){
|
if (pre.equals("world")){
|
||||||
world = Bukkit.getWorld(val);
|
world = Bukkit.getWorld(val);
|
||||||
|
if (world == null){
|
||||||
|
failed.add(a + " (invalid world)");
|
||||||
|
sender.sendMessage("Entered world is " + val + ", but that world does not exist.");
|
||||||
|
sender.sendMessage("Cancelling the command.");
|
||||||
|
sender.sendMessage(getDescription());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
} else if (!isVal(val)){
|
} else if (!isVal(val)){
|
||||||
sender.sendMessage("Parameters other than `world=<name>` require a number (+ c|chunk|r|region|k), given: '" + a + "' is invalid");
|
failed.add(a + " (non-value)");
|
||||||
} else {
|
} else {
|
||||||
switch (pre) {
|
switch (pre) {
|
||||||
case "width" -> width = getVal(val);
|
case "width" -> width = getVal(val);
|
||||||
@ -74,31 +96,52 @@ public class CommandIrisPregenCreate extends MortarCommand {
|
|||||||
}
|
}
|
||||||
case "x" -> x = getVal(val);
|
case "x" -> x = getVal(val);
|
||||||
case "z" -> z = getVal(val);
|
case "z" -> z = getVal(val);
|
||||||
|
default -> failed.add(a + " (no type)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (isVal(a)) {
|
} else if (isVal(a)) {
|
||||||
width = getVal(a);
|
width = getVal(a);
|
||||||
height = getVal(a);
|
height = getVal(a);
|
||||||
} else {
|
} else {
|
||||||
failed.add(a);
|
failed.add(a + " (nothing)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (width == -1 || height == -1){
|
if (width == -1 || height == -1){
|
||||||
sender.sendMessage("Size not specified");
|
sender.sendMessage("Radius or (width & height) not specified. Cancelling...");
|
||||||
sender.sendMessage(getArgsUsage());
|
sender.sendMessage(getDescription());
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
world = world == null ? sender.player().getWorld() : world;
|
if (world == null){
|
||||||
|
if (sender.isPlayer()){
|
||||||
|
world = sender.player().getWorld();
|
||||||
|
} else {
|
||||||
|
sender.sendMessage("Must specify world=<name> if sending from console! Cancelling...");
|
||||||
|
sender.sendMessage(getDescription());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (here){
|
||||||
|
if (sender.isPlayer()) {
|
||||||
|
x = sender.player().getLocation().getBlockX();
|
||||||
|
z = sender.player().getLocation().getBlockZ();
|
||||||
|
} else {
|
||||||
|
sender.sendMessage("Specifying -here does not work from console!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
KList<String> details = new KList<>(
|
KList<String> details = new KList<>(
|
||||||
"Pregeneration details:",
|
"Pregeneration details:",
|
||||||
" - World > " + world.getName(),
|
" - World > " + world.getName(),
|
||||||
" - Width/Height > " + width + "/" + height,
|
" - Width/Height > " + width + "/" + height,
|
||||||
" - Center x,z > " + x + "," + z,
|
" - Center x,z > " + x + "," + z,
|
||||||
failed.isEmpty() ? "(No failed arguments)" : "FAILED ARGS: " + failed
|
failed.isEmpty() ? "(No failed arguments)" : "FAILED ARGS:"
|
||||||
|
);
|
||||||
|
failed.forEach(s ->
|
||||||
|
details.add(" - " + s)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
if (pregenerate(world, width, height, x, z)){
|
if (pregenerate(world, width, height, x, z)){
|
||||||
sender.sendMessage("Successfully started pregen");
|
sender.sendMessage("Successfully started pregen");
|
||||||
@ -129,6 +172,7 @@ public class CommandIrisPregenCreate extends MortarCommand {
|
|||||||
.build(), world);
|
.build(), world);
|
||||||
} catch (Throwable e){
|
} catch (Throwable e){
|
||||||
Iris.reportError(e);
|
Iris.reportError(e);
|
||||||
|
e.printStackTrace();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user