diff --git a/src/main/java/com/volmit/iris/core/IrisSettings.java b/src/main/java/com/volmit/iris/core/IrisSettings.java index 4849c9d76..b9df38381 100644 --- a/src/main/java/com/volmit/iris/core/IrisSettings.java +++ b/src/main/java/com/volmit/iris/core/IrisSettings.java @@ -64,6 +64,17 @@ public class IrisSettings { return Math.max(2, c < 0 ? Runtime.getRuntime().availableProcessors() / -c : c); } + public void forceSave() { + File s = Iris.instance.getDataFile("settings.json"); + + try { + IO.writeAll(s, new JSONObject(new Gson().toJson(settings)).toString(4)); + } catch (JSONException | IOException e) { + e.printStackTrace(); + Iris.reportError(e); + } + } + @Data public static class IrisSettingsCache { public int complexCacheSize = 131072; diff --git a/src/main/java/com/volmit/iris/core/command/CommandIris.java b/src/main/java/com/volmit/iris/core/command/CommandIris.java index 3c3229c31..6ebefe105 100644 --- a/src/main/java/com/volmit/iris/core/command/CommandIris.java +++ b/src/main/java/com/volmit/iris/core/command/CommandIris.java @@ -36,6 +36,9 @@ public class CommandIris extends MortarCommand { @Command private CommandIrisVerify verify; + @Command + private CommandIrisDebug debug; + @Command private CommandIrisFix fix; diff --git a/src/main/java/com/volmit/iris/core/command/CommandIrisDebug.java b/src/main/java/com/volmit/iris/core/command/CommandIrisDebug.java new file mode 100644 index 000000000..184948e03 --- /dev/null +++ b/src/main/java/com/volmit/iris/core/command/CommandIrisDebug.java @@ -0,0 +1,54 @@ +/* + * Iris is a World Generator for Minecraft Bukkit Servers + * Copyright (c) 2021 Arcane Arts (Volmit Software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.volmit.iris.core.command; + +import com.volmit.iris.Iris; +import com.volmit.iris.core.IrisSettings; +import com.volmit.iris.util.collection.KList; +import com.volmit.iris.util.plugin.MortarCommand; +import com.volmit.iris.util.plugin.VolmitSender; + +public class CommandIrisDebug extends MortarCommand { + public CommandIrisDebug() { + super("debug", "dbg"); + requiresPermission(Iris.perm.studio); + setDescription("Toggle debug mode"); + setCategory("Studio"); + } + + + @Override + public void addTabOptions(VolmitSender sender, String[] args, KList list) { + + } + + @Override + public boolean handle(VolmitSender sender, String[] args) { + IrisSettings.get().getGeneral().setDebug(!IrisSettings.get().getGeneral().isDebug()); + IrisSettings.get().forceSave(); + sender.sendMessage("Debug Mode: " + (IrisSettings.get().getGeneral().isDebug() ? "Enabled" : "Disabled")); + + return true; + } + + @Override + protected String getArgsUsage() { + return " [|,&,^,>>,<<,%] "; + } +}