Clean up logging

This commit is contained in:
JFronny 2020-12-28 12:12:59 +01:00
parent fa1438e0d2
commit e0b98d1a2e
12 changed files with 34 additions and 93 deletions

View File

@ -75,17 +75,13 @@ jar {
import com.modrinth.minotaur.TaskModrinthUpload
task publishModrinth (type: TaskModrinthUpload){
token = System.getenv("MODRINTH_API_TOKEN") // Use an environment property!
token = System.getenv("MODRINTH_API_TOKEN")
projectId = 'TiF5QWZY'
versionNumber = "${project.mod_version}"
uploadFile = remapJar // This is the java jar task
uploadFile = remapJar
addGameVersion("${project.minecraft_version}")
addLoader('fabric')
versionName = "[${project.minecraft_version}] ${project.mod_version}"
afterEvaluate {
tasks.publishModrinth.dependsOn(remapJar)
tasks.publishModrinth.dependsOn(sourcesJar)
}
}
curseforge {

View File

@ -99,7 +99,7 @@ public class GuiFactory {
}).build());
}
else if (e.isJsonNull()) {
System.out.println("[respackopts] Config definition contains null, skipping that entry");
Respackopts.logger.error("Config definition contains null, skipping that entry");
}
else if (e.isJsonObject()) {
JsonObject data = e.getAsJsonObject();
@ -116,7 +116,7 @@ public class GuiFactory {
Double minV = min.getAsNumber().doubleValue();
Double maxV = max.getAsNumber().doubleValue();
if (defV < minV || defV > maxV) {
System.err.println("[respackopts] default value out of range");
Respackopts.logger.error("default value out of range");
}
else if (isWhole(defV) && isWhole(minV) && isWhole(maxV)) {
Double currentValue = defV;
@ -136,11 +136,11 @@ public class GuiFactory {
.build());
}
else {
System.err.println("[respackopts] expected whole number");
Respackopts.logger.error("Expected whole number in slider definition");
}
}
else {
System.err.println("[respackopts] Expected numeric values");
Respackopts.logger.error("Expected numeric values in slider definition");
}
continue;
}
@ -150,7 +150,7 @@ public class GuiFactory {
config.addEntry(sc.build());
}
else {
System.err.println("[respackopts] Unsupported non-primitive datatype");
Respackopts.logger.error("Unsupported non-primitive datatype");
}
}
}

View File

@ -9,6 +9,8 @@ import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.loader.api.FabricLoader;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.*;
import java.nio.file.Files;
@ -31,6 +33,7 @@ public class Respackopts implements ClientModInitializer {
public static final Set<Runnable> saveActions = new HashSet<>();
public static final String fileExtension = ".rpo";
public static boolean forceRespackReload = false;
public static final Logger logger = LogManager.getFormatterLogger(ID);
@Override
public void onInitializeClient() {
try {
@ -47,7 +50,7 @@ public class Respackopts implements ClientModInitializer {
if (enumKeys == null)
enumKeys = new HashMap<>();
if (FabricLoader.getInstance().isDevelopmentEnvironment())
saveActions.add(() -> System.out.println("Save"));
saveActions.add(() -> logger.info("Save"));
}
public static void save() {
@ -102,8 +105,8 @@ public class Respackopts implements ClientModInitializer {
&& c.bools.get(i).isJsonPrimitive()
&& c.bools.get(i).getAsJsonPrimitive().isBoolean()) {
boolVals.get(id).put(i, c.bools.get(i).getAsBoolean());
} else
System.out.println("Could not find bool " + i + " in " + id);
} else if (FabricLoader.getInstance().isDevelopmentEnvironment())
Respackopts.logger.error("Could not find bool " + i + " in " + id);
});
}
if (c.doubles != null) {
@ -112,8 +115,8 @@ public class Respackopts implements ClientModInitializer {
&& c.doubles.get(i).isJsonPrimitive()
&& c.doubles.get(i).getAsJsonPrimitive().isNumber()) {
numVals.get(id).put(i, c.doubles.get(i).getAsNumber().doubleValue());
} else
System.out.println("Could not find num " + i + " in " + id);
} else if (FabricLoader.getInstance().isDevelopmentEnvironment())
Respackopts.logger.error("Could not find num " + i + " in " + id);
});
}
if (c.strings != null) {
@ -122,8 +125,8 @@ public class Respackopts implements ClientModInitializer {
&& c.strings.get(i).isJsonPrimitive()
&& c.strings.get(i).getAsJsonPrimitive().isString()) {
strVals.get(id).put(i, c.strings.get(i).getAsString());
} else
System.out.println("Could not find str " + i + " in " + id);
} else if (FabricLoader.getInstance().isDevelopmentEnvironment())
Respackopts.logger.error("Could not find str " + i + " in " + id);
});
}
} catch (IOException e) {

View File

@ -1,52 +0,0 @@
package io.gitlab.jfronny.respackopts;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.util.NarratorManager;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
public class TexturedButtonWidget extends ButtonWidget {
private final Identifier texture;
private final int u;
private final int v;
private final int uWidth;
private final int vHeight;
public TexturedButtonWidget(int x, int y, int width, int height, int u, int v, Identifier texture, int uWidth, int vHeight, PressAction onPress) {
this(x, y, width, height, u, v, texture, uWidth, vHeight, onPress, NarratorManager.EMPTY);
}
public TexturedButtonWidget(int x, int y, int width, int height, int u, int v, Identifier texture, int uWidth, int vHeight, PressAction onPress, Text message) {
this(x, y, width, height, u, v, texture, uWidth, vHeight, onPress, message, EMPTY);
}
public TexturedButtonWidget(int x, int y, int width, int height, int u, int v, Identifier texture, int uWidth, int vHeight, PressAction onPress, Text message, TooltipSupplier tooltipSupplier) {
super(x, y, width, height, message, onPress, tooltipSupplier);
this.uWidth = uWidth;
this.vHeight = vHeight;
this.u = u;
this.v = v;
this.texture = texture;
}
public void renderButton(MatrixStack matrices, int mouseX, int mouseY, float delta) {
MinecraftClient client = MinecraftClient.getInstance();
client.getTextureManager().bindTexture(this.texture);
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
RenderSystem.disableDepthTest();
int adjustedV = this.v;
if (!this.active) {
adjustedV += this.height * 2;
} else if (this.isHovered()) {
adjustedV += this.height;
}
drawTexture(matrices, this.x, this.y, (float)this.u, (float)adjustedV, this.width, this.height, this.uWidth, this.vHeight);
RenderSystem.enableDepthTest();
if (this.isHovered()) {
this.renderToolTip(matrices, mouseX, mouseY);
}
}
}

View File

@ -32,7 +32,7 @@ public class ResourcePackFilter {
return true;
}
else {
System.out.println("Conditions null for " + name);
Respackopts.logger.error("Conditions null for " + name);
return true;
}
}

View File

@ -51,7 +51,7 @@ public class FrexCompat implements FrexInitializer {
sb.append("\n#define respackopts_loaded");
return sb.toString();
});
System.out.println("[respackopts] enabled frex/canvas support");
Respackopts.logger.info("enabled frex/canvas support");
Respackopts.saveActions.add(() -> {
try {
if (!initial)

View File

@ -15,7 +15,6 @@ public class LibCDCompat implements ConditionInitializer {
throw new CDSyntaxError("Expected string");
}
String s = (String) q;
System.out.println(s);
try {
return Respackopts.matchStringCondition(s);
} catch (SyntaxError syntaxError) {

View File

@ -1,7 +1,8 @@
package io.gitlab.jfronny.respackopts;
package io.gitlab.jfronny.respackopts.integration;
import io.github.prospector.modmenu.api.ConfigScreenFactory;
import io.github.prospector.modmenu.api.ModMenuApi;
import io.gitlab.jfronny.respackopts.Respackopts;
import io.gitlab.jfronny.respackopts.abstractions.JfConfigCategoryPrimary;
import me.shedaniel.clothconfig2.api.ConfigBuilder;
import me.shedaniel.clothconfig2.api.ConfigCategory;
@ -10,7 +11,7 @@ import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.FatalErrorScreen;
import net.minecraft.text.TranslatableText;
public class MMI implements ModMenuApi {
public class ModMenuCompat implements ModMenuApi {
@Override
public ConfigScreenFactory<?> getModConfigScreenFactory() {
return parent -> {

View File

@ -31,7 +31,7 @@ public class ResourcePackManagerMixin {
try {
Respackmeta conf = Respackopts.g.fromJson(respackopts$readMetadata(v, "conf.json", Respackopts.g), Respackmeta.class);
if (!Respackopts.metaVersion.equals(conf.version)) {
System.err.println(s + " was not loaded as it specifies a different respackopts version than is installed");
Respackopts.logger.error(s + " was not loaded as it specifies a different respackopts version than is installed");
return;
}
if (!Respackopts.boolVals.containsKey(conf.id))
@ -66,17 +66,17 @@ public class ResourcePackManagerMixin {
double minV = min.getAsNumber().doubleValue();
double maxV = max.getAsNumber().doubleValue();
if (defV < minV || defV > maxV) {
System.err.println("[respackopts] default value out of range at " + id);
Respackopts.logger.error("Default value out of range in slider definition " + id);
}
else if (respackopts$isWhole(defV) && respackopts$isWhole(minV) && respackopts$isWhole(maxV)) {
Respackopts.numVals.get(id).put(keyPrefix, defV);
}
else {
System.err.println("[respackopts] expected whole number at " + id);
Respackopts.logger.error("Expected whole number in slider definition " + id);
}
}
else {
System.err.println("[respackopts] Expected numeric values at " + id);
Respackopts.logger.error("Expected numeric values in slider definition " + id);
}
return;
}
@ -103,7 +103,7 @@ public class ResourcePackManagerMixin {
JsonArray a = e.getAsJsonArray();
for (JsonElement element : a) {
if (!element.isJsonPrimitive()) {
System.err.println("[respackopts] Unsupported non-primitive datatype");
Respackopts.logger.error("Unsupported non-primitive datatype in enum definition");
continue;
}
if (!Respackopts.enumKeys.get(id).containsKey(n)) {
@ -111,12 +111,12 @@ public class ResourcePackManagerMixin {
}
JsonPrimitive p = element.getAsJsonPrimitive();
if (!p.isString()) {
System.err.println("[respackopts] Unsupported non-string enum key");
Respackopts.logger.error("Unsupported non-string enum key");
continue;
}
String b = p.getAsString();
if (b.contains(":") || b.contains(".") || b.contains("_")) {
System.err.println(b + " contains invalid characters");
Respackopts.logger.error(b + " contains invalid characters");
continue;
}
Respackopts.enumKeys.get(id).get(n).add(b);
@ -126,13 +126,13 @@ public class ResourcePackManagerMixin {
}
}
else if (e.isJsonNull()) {
System.out.println("[respackopts] Config definition contains null, skipping that entry");
Respackopts.logger.error("Config definition contains null, skipping that entry");
}
else if (e.isJsonObject()) {
respackopts$registerFields(e.getAsJsonObject(), id, n);
}
else {
System.err.println("[respackopts] Unsupported non-primitive datatype");
Respackopts.logger.error("Unsupported non-primitive datatype");
}
}
}

View File

@ -54,9 +54,6 @@ public abstract class DirectoryResourcePackMixin extends AbstractFileResourcePac
@Inject(at = @At("TAIL"), method = "findResources(Lnet/minecraft/resource/ResourceType;Ljava/lang/String;Ljava/lang/String;ILjava/util/function/Predicate;)Ljava/util/Collection;")
private void findResources(ResourceType type, String namespace, String prefix, int maxDepth, Predicate<String> pathFilter, CallbackInfoReturnable<Collection<Identifier>> info) {
info.getReturnValue().removeIf(s -> {
System.out.println(s.toString());
return !filter.fileVisible(s.getPath());
});
info.getReturnValue().removeIf(s -> !filter.fileVisible(s.getPath()));
}
}

View File

@ -55,9 +55,6 @@ public abstract class ZipResourcePackMixin extends AbstractFileResourcePack {
@Inject(at = @At("TAIL"), method = "findResources(Lnet/minecraft/resource/ResourceType;Ljava/lang/String;Ljava/lang/String;ILjava/util/function/Predicate;)Ljava/util/Collection;")
private void findResources(ResourceType type, String namespace, String prefix, int maxDepth, Predicate<String> pathFilter, CallbackInfoReturnable<Collection<Identifier>> info) {
info.getReturnValue().removeIf(s -> {
System.out.println(s.toString());
return !filter.fileVisible(s.getPath());
});
info.getReturnValue().removeIf(s -> !filter.fileVisible(s.getPath()));
}
}

View File

@ -16,7 +16,7 @@
"io.gitlab.jfronny.respackopts.Respackopts"
],
"modmenu": [
"io.gitlab.jfronny.respackopts.MMI"
"io.gitlab.jfronny.respackopts.integration.ModMenuCompat"
],
"libcd:conditions": [
"io.gitlab.jfronny.respackopts.integration.LibCDCompat"