Iris debug toggle

This commit is contained in:
Daniel Mills 2021-07-23 17:44:03 -04:00
parent 993d433d03
commit ce2d386b7e
3 changed files with 68 additions and 0 deletions

View File

@ -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;

View File

@ -36,6 +36,9 @@ public class CommandIris extends MortarCommand {
@Command
private CommandIrisVerify verify;
@Command
private CommandIrisDebug debug;
@Command
private CommandIrisFix fix;

View File

@ -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 <https://www.gnu.org/licenses/>.
*/
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<String> 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 "<number> [|,&,^,>>,<<,%] <other>";
}
}