mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 18:23:06 +00:00
Ten - Remove beautify in favour of clean
This commit is contained in:
parent
f8336d6adb
commit
64bb6714a3
@ -52,7 +52,6 @@ import com.volmit.iris.util.function.NoiseProvider;
|
|||||||
import com.volmit.iris.util.interpolation.InterpolationMethod;
|
import com.volmit.iris.util.interpolation.InterpolationMethod;
|
||||||
import com.volmit.iris.util.io.IO;
|
import com.volmit.iris.util.io.IO;
|
||||||
import com.volmit.iris.util.json.JSONArray;
|
import com.volmit.iris.util.json.JSONArray;
|
||||||
import com.volmit.iris.util.json.JSONCleaner;
|
|
||||||
import com.volmit.iris.util.json.JSONObject;
|
import com.volmit.iris.util.json.JSONObject;
|
||||||
import com.volmit.iris.util.math.RNG;
|
import com.volmit.iris.util.math.RNG;
|
||||||
import com.volmit.iris.util.noise.CNG;
|
import com.volmit.iris.util.noise.CNG;
|
||||||
@ -294,22 +293,6 @@ public class DecIrisStudio implements DecreeExecutor {
|
|||||||
sender().sendMessage(C.GREEN + "The \"" + dimension.getName() + "\" pack has version: " + dimension.getVersion());
|
sender().sendMessage(C.GREEN + "The \"" + dimension.getName() + "\" pack has version: " + dimension.getVersion());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Decree(description = "Beatify a pack", aliases = {"beauty", "prettify"})
|
|
||||||
public void beautify(
|
|
||||||
@Param(name = "dimension", defaultValue = "overworld", description = "The to-beautify dimension", aliases = "dim")
|
|
||||||
IrisDimension dimension
|
|
||||||
) {
|
|
||||||
File folder = dimension.getLoadFile().getParentFile().getParentFile();
|
|
||||||
sender().sendMessage(C.GREEN + "Cleaned " + Form.f(JSONCleaner.clean(sender(), folder)) + " JSON Files");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Decree(description = "Beatify a pack - must be in studio!", aliases = {"beauty", "prettify"})
|
|
||||||
public void beautify() {
|
|
||||||
if (noStudio()) return;
|
|
||||||
File folder = Iris.proj.getActiveProject().getPath();
|
|
||||||
sender().sendMessage(C.GREEN + "Cleaned " + Form.f(JSONCleaner.clean(sender(), folder)) + " JSON Files");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Decree(description = "Convert objects in the \"convert\" folder", aliases = "conv")
|
@Decree(description = "Convert objects in the \"convert\" folder", aliases = "conv")
|
||||||
public void convert() {
|
public void convert() {
|
||||||
Iris.convert.check(sender());
|
Iris.convert.check(sender());
|
||||||
|
@ -1,66 +0,0 @@
|
|||||||
package com.volmit.iris.util.json;
|
|
||||||
|
|
||||||
import com.volmit.iris.Iris;
|
|
||||||
import com.volmit.iris.util.io.IO;
|
|
||||||
import com.volmit.iris.util.plugin.VolmitSender;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public class JSONCleaner {
|
|
||||||
public static int clean(VolmitSender s, File clean) {
|
|
||||||
int c = 0;
|
|
||||||
if (clean.isDirectory()) {
|
|
||||||
for (File i : clean.listFiles()) {
|
|
||||||
c += clean(s, i);
|
|
||||||
}
|
|
||||||
} else if (clean.getName().endsWith(".json")) {
|
|
||||||
try {
|
|
||||||
clean(clean);
|
|
||||||
} catch (Throwable e) {
|
|
||||||
Iris.reportError(e);
|
|
||||||
Iris.error("Failed to beautify " + clean.getAbsolutePath() + " You may have errors in your json!");
|
|
||||||
}
|
|
||||||
|
|
||||||
c++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void clean(File clean) throws IOException {
|
|
||||||
JSONObject obj = new JSONObject(IO.readAll(clean));
|
|
||||||
fixBlocks(obj, clean);
|
|
||||||
|
|
||||||
IO.writeAll(clean, obj.toString(4));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void fixBlocks(JSONObject obj, File f) {
|
|
||||||
for (String i : obj.keySet()) {
|
|
||||||
Object o = obj.get(i);
|
|
||||||
|
|
||||||
if (i.equals("block") && o instanceof String && !o.toString().trim().isEmpty() && !o.toString().contains(":")) {
|
|
||||||
obj.put(i, "minecraft:" + o);
|
|
||||||
Iris.debug("Updated Block Key: " + o + " to " + obj.getString(i) + " in " + f.getPath());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (o instanceof JSONObject) {
|
|
||||||
fixBlocks((JSONObject) o, f);
|
|
||||||
} else if (o instanceof JSONArray) {
|
|
||||||
fixBlocks((JSONArray) o, f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void fixBlocks(JSONArray obj, File f) {
|
|
||||||
for (int i = 0; i < obj.length(); i++) {
|
|
||||||
Object o = obj.get(i);
|
|
||||||
|
|
||||||
if (o instanceof JSONObject) {
|
|
||||||
fixBlocks((JSONObject) o, f);
|
|
||||||
} else if (o instanceof JSONArray) {
|
|
||||||
fixBlocks((JSONArray) o, f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user