mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-19 10:43:14 +00:00
Patch command usage
This commit is contained in:
parent
f73db056f2
commit
baebadb7a6
@ -11,47 +11,32 @@ import com.volmit.iris.util.plugin.VolmitSender;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
|
||||||
public class CommandIrisPregenStart extends MortarCommand {
|
public class CommandIrisPregenStart extends MortarCommand {
|
||||||
|
|
||||||
private static final KList<String> argus = new KList<>("radius=", "x=", "z=");
|
private static final KList<String> argus = new KList<>("radius=", "x=", "z=");
|
||||||
|
|
||||||
public CommandIrisPregenStart() {
|
public CommandIrisPregenStart() {
|
||||||
super("start", "s", "create", "c", "new", "+");
|
super("start", "create", "c", "new", "+");
|
||||||
requiresPermission(Iris.perm);
|
requiresPermission(Iris.perm);
|
||||||
setCategory("Pregen");
|
setCategory("Pregen");
|
||||||
setDescription("""
|
setDescription("Create a new pregeneration task.");
|
||||||
Create a new pregeneration task.
|
|
||||||
Command usage:
|
|
||||||
/iris pregen create [radius=<radius>] [x=<centerX>] [z=<centerZ>] [world=<world>] [-here]
|
|
||||||
|
|
||||||
Examples:
|
|
||||||
/iris pregen start 5k -here
|
|
||||||
/iris pregen start radius=5000 x=10r z=10r world=IrisWorld
|
|
||||||
/iris pregen start 10k world=WorldName
|
|
||||||
|
|
||||||
<radius>: Sets both width and height to a value. (Size is: 2 * radius by 2 * radius)
|
|
||||||
<x> & <z>: Give the center point of the pregen.
|
|
||||||
<world>: Specify a different world name for generation than the one you're currently in.
|
|
||||||
The console is not in any world, so this is required for console!
|
|
||||||
If you specify this, the `-here` is ignored.
|
|
||||||
-here: If added, the center location is set to your position (player only)
|
|
||||||
This overrides <x> and <z>.
|
|
||||||
|
|
||||||
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
|
||||||
public void addTabOptions(VolmitSender sender, String[] args, KList<String> list) {
|
public void addTabOptions(VolmitSender sender, String[] args, KList<String> list) {
|
||||||
|
|
||||||
|
if (args.length == 0){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Add arguments
|
// Add arguments
|
||||||
argus.forEach(p -> {
|
argus.forEach(p -> {
|
||||||
boolean hasArg = false;
|
boolean hasArg = false;
|
||||||
for (String arg : args) {
|
for (String arg : args) {
|
||||||
if (!arg.contains("=") || !p.contains("=")) {
|
if (!arg.contains("=") || !p.contains("=") || arg.equals("=")) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (arg.split("=")[0].equals(p.split("=")[0])) {
|
if (arg.split("=")[0].equals(p.split("=")[0])) {
|
||||||
@ -96,6 +81,11 @@ public class CommandIrisPregenStart extends MortarCommand {
|
|||||||
@Override
|
@Override
|
||||||
public boolean handle(VolmitSender sender, String[] args) {
|
public boolean handle(VolmitSender sender, String[] args) {
|
||||||
|
|
||||||
|
if (args.length == 0){
|
||||||
|
sender.sendMessage(getHelp());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (PregeneratorJob.getInstance() != null) {
|
if (PregeneratorJob.getInstance() != null) {
|
||||||
sender.sendMessage("Pregeneration task already ongoing. You can stop it with /ir p stop.");
|
sender.sendMessage("Pregeneration task already ongoing. You can stop it with /ir p stop.");
|
||||||
sender.sendMessage("Cannot create new pregen while one is already going. Cancelling...");
|
sender.sendMessage("Cannot create new pregen while one is already going. Cancelling...");
|
||||||
@ -123,7 +113,7 @@ public class CommandIrisPregenStart extends MortarCommand {
|
|||||||
failed.add(a + " (invalid world)");
|
failed.add(a + " (invalid world)");
|
||||||
sender.sendMessage("Entered world is " + val + ", but that world does not exist.");
|
sender.sendMessage("Entered world is " + val + ", but that world does not exist.");
|
||||||
sender.sendMessage("Cancelling the command.");
|
sender.sendMessage("Cancelling the command.");
|
||||||
sender.sendMessage(getDescription());
|
sender.sendMessage(getHelp());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else if (!isVal(val)) {
|
} else if (!isVal(val)) {
|
||||||
@ -152,7 +142,7 @@ public class CommandIrisPregenStart extends MortarCommand {
|
|||||||
// Checking if a radius was specified or forgotten
|
// Checking if a radius was specified or forgotten
|
||||||
if (width == -1 || height == -1) {
|
if (width == -1 || height == -1) {
|
||||||
sender.sendMessage("Radius not specified! Cancelling...");
|
sender.sendMessage("Radius not specified! Cancelling...");
|
||||||
sender.sendMessage(getDescription());
|
sender.sendMessage(getHelp());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,18 +152,12 @@ public class CommandIrisPregenStart extends MortarCommand {
|
|||||||
world = sender.player().getWorld();
|
world = sender.player().getWorld();
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage("Must specify world=<name> if sending from console! Cancelling...");
|
sender.sendMessage("Must specify world=<name> if sending from console! Cancelling...");
|
||||||
sender.sendMessage(getDescription());
|
sender.sendMessage(getHelp());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else {
|
} else if (sender.isPlayer() && !world.equals(sender.player().getWorld()) && here) {
|
||||||
if (sender.isPlayer()) {
|
sender.sendMessage("Ignoring `-here` because `world=` is specified!");
|
||||||
if (!world.equals(sender.player().getWorld())) {
|
here = false;
|
||||||
if (here) {
|
|
||||||
sender.sendMessage("Ignoring `-here` because `world=` is specified!");
|
|
||||||
here = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Checking if -here is used
|
// Checking if -here is used
|
||||||
@ -213,7 +197,7 @@ public class CommandIrisPregenStart extends MortarCommand {
|
|||||||
|
|
||||||
// Start pregen and append info to details
|
// Start pregen and append info to details
|
||||||
if (pregenerate(world, width, height, x, z)) {
|
if (pregenerate(world, width, height, x, z)) {
|
||||||
details.append("Successfully started pregen");
|
details.append("Successfully started pregen.");
|
||||||
} else {
|
} else {
|
||||||
details.append("Failed to start pregen. Doublecheck your arguments!");
|
details.append("Failed to start pregen. Doublecheck your arguments!");
|
||||||
}
|
}
|
||||||
@ -295,4 +279,29 @@ public class CommandIrisPregenStart extends MortarCommand {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get command help
|
||||||
|
* @return help string
|
||||||
|
*/
|
||||||
|
private String getHelp() {
|
||||||
|
return """
|
||||||
|
Create a new pregeneration task.
|
||||||
|
Command usage:
|
||||||
|
/iris pregen create [radius=<radius>] [x=<centerX>] [z=<centerZ>] [world=<world>] [-here]
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
/iris pregen start 5k -here
|
||||||
|
/iris pregen start radius=5000 x=10r z=10r world=IrisWorld
|
||||||
|
/iris pregen start 10k world=WorldName
|
||||||
|
|
||||||
|
<radius>: Sets both width and height to a value
|
||||||
|
<x> & <z>: Give the center point of the pregen
|
||||||
|
-here: Sets the center x and z to the current location
|
||||||
|
<world>: Specify a world name for generation
|
||||||
|
|
||||||
|
In radius, x and z multiply the value by c => 16, r => 512, k => 1000
|
||||||
|
Example: entering '1000' is the same as '1k' (1 * 1000)
|
||||||
|
Make sure to check https://docs.volmit.com/iris/pregeneration for guidance""";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user