Improve boolean handling in DecIris

This commit is contained in:
CocoTheOwner 2021-08-18 13:14:41 +02:00
parent 2de5bc2855
commit 10da9182d1

View File

@ -32,6 +32,7 @@ import com.volmit.iris.util.decree.exceptions.DecreeParsingException;
import com.volmit.iris.util.decree.exceptions.DecreeWhichException; import com.volmit.iris.util.decree.exceptions.DecreeWhichException;
import com.volmit.iris.util.format.C; import com.volmit.iris.util.format.C;
import com.volmit.iris.util.math.M; import com.volmit.iris.util.math.M;
import lombok.val;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
@ -51,7 +52,7 @@ public class DecIris implements DecreeExecutor {
@Decree(description = "Create a new world", aliases = {"+", "c"}) @Decree(description = "Create a new world", aliases = {"+", "c"})
public void create( public void create(
@Param(aliases = "world-name", description = "The name of the world to create", defaultValue = "IrisWorld") @Param(aliases = "world-name", description = "The name of the world to create")
String name, String name,
@Param(aliases = "dimension", description = "The dimension type to create the world with", defaultValue = "overworld") @Param(aliases = "dimension", description = "The dimension type to create the world with", defaultValue = "overworld")
IrisDimension type, IrisDimension type,
@ -139,18 +140,18 @@ public class DecIris implements DecreeExecutor {
String on String on
) { ) {
Boolean val; Boolean val;
try { if (on.equals("toggle") || on.equals("t")) {
val = (Boolean) DecreeSystem.getHandler(boolean.class).parse(on); val = !IrisSettings.get().getGeneral().isDebug();
} catch (Throwable e) { } else {
if (on.equals("toggle")){ try {
val = !IrisSettings.get().getGeneral().isDebug(); val = (Boolean) DecreeSystem.getHandler(boolean.class).parse(on);
} else { } catch (Throwable e){
sender().sendMessage(C.RED + "Failed to convert input: " + on + " to a true or false value"); sender().sendMessage(C.RED + "Failed to convert input: " + on + " to a true or false value");
Iris.reportError(e); Iris.reportError(e);
return; return;
} }
} }
sender().sendMessage(C.GREEN + "Set debug to " + val); sender().sendMessage(C.GREEN + "Set debug to " +val);
IrisSettings.get().getGeneral().setDebug(val); IrisSettings.get().getGeneral().setDebug(val);
} }