Clean up code
This commit is contained in:
parent
769b879f2c
commit
b84f507644
@ -6,8 +6,9 @@ import java.io.*;
|
||||
import java.util.Properties;
|
||||
|
||||
public abstract class CachingTransformer implements StringTransformer {
|
||||
Properties cache = null;
|
||||
private static final File cacheFile = new File(FabricLoader.getInstance().getConfigDirectory(), "Translater.cache");
|
||||
Properties cache = null;
|
||||
|
||||
@Override
|
||||
public String transform(String str) {
|
||||
if (cache == null) {
|
||||
|
@ -8,30 +8,31 @@ import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public class ModInit implements ModInitializer {
|
||||
public static final String MOD_NAME = "translater";
|
||||
public static final String MOD_ID = "translater";
|
||||
public static Cfg cfg;
|
||||
public ModInit() {
|
||||
AutoConfig.register(Cfg.class, JanksonConfigSerializer::new);
|
||||
cfg = AutoConfig.getConfigHolder(Cfg.class).getConfig();
|
||||
}
|
||||
public static final String MOD_NAME = "translater";
|
||||
public static final String MOD_ID = "translater";
|
||||
private static final Logger logger = LogManager.getFormatterLogger(MOD_ID);
|
||||
public static Cfg cfg;
|
||||
|
||||
private static final Logger logger = LogManager.getFormatterLogger(MOD_ID);
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
Log("Loaded translater");
|
||||
}
|
||||
public ModInit() {
|
||||
AutoConfig.register(Cfg.class, JanksonConfigSerializer::new);
|
||||
cfg = AutoConfig.getConfigHolder(Cfg.class).getConfig();
|
||||
}
|
||||
|
||||
public static void Log(String msg) {
|
||||
logger.log(Level.INFO, "[" + MOD_NAME + "]" + msg);
|
||||
}
|
||||
public static void Log(String msg) {
|
||||
logger.log(Level.INFO, "[" + MOD_NAME + "]" + msg);
|
||||
}
|
||||
|
||||
public static void Warn(String msg) {
|
||||
logger.log(Level.WARN, "[" + MOD_NAME + "]" + msg);
|
||||
}
|
||||
public static void Warn(String msg) {
|
||||
logger.log(Level.WARN, "[" + MOD_NAME + "]" + msg);
|
||||
}
|
||||
|
||||
public static void LogDebug(String msg) {
|
||||
logger.log(Level.DEBUG, "[" + MOD_NAME + "]" + msg);
|
||||
}
|
||||
public static void LogDebug(String msg) {
|
||||
logger.log(Level.DEBUG, "[" + MOD_NAME + "]" + msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
Log("Loaded translater");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,18 +2,17 @@ package io.gitlab.jfronny.translater;
|
||||
|
||||
import com.github.vbauer.yta.model.Direction;
|
||||
import com.github.vbauer.yta.model.Language;
|
||||
import com.github.vbauer.yta.model.Languages;
|
||||
import com.github.vbauer.yta.service.YTranslateApiImpl;
|
||||
import com.sun.org.apache.xpath.internal.operations.Mod;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
public class YnTransformer extends CachingTransformer {
|
||||
|
||||
private static final Random rnd = new Random();
|
||||
private static YTranslateApiImpl api = null;
|
||||
private static Set<Language> languages = null;
|
||||
private static final Random rnd = new Random();
|
||||
|
||||
@Override
|
||||
public String getTransformed(String str) {
|
||||
@ -35,8 +34,7 @@ public class YnTransformer extends CachingTransformer {
|
||||
f = false;
|
||||
}
|
||||
return res.toString();
|
||||
}
|
||||
else if (str.contains("$")) {
|
||||
} else if (str.contains("$")) {
|
||||
StringBuilder res = new StringBuilder();
|
||||
boolean f = true;
|
||||
for (String s : str.split("\\$")) {
|
||||
@ -47,8 +45,7 @@ public class YnTransformer extends CachingTransformer {
|
||||
f = false;
|
||||
}
|
||||
return res.toString();
|
||||
}
|
||||
else if (str.contains("§")) {
|
||||
} else if (str.contains("§")) {
|
||||
StringBuilder res = new StringBuilder();
|
||||
boolean f = true;
|
||||
for (String s : str.split("§")) {
|
||||
@ -59,8 +56,7 @@ public class YnTransformer extends CachingTransformer {
|
||||
f = false;
|
||||
}
|
||||
return res.toString();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return Break(str);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
@ -8,8 +8,6 @@ import net.fabricmc.loader.api.MappingResolver;
|
||||
import net.minecraft.client.resource.language.TranslationStorage;
|
||||
import net.minecraft.util.Language;
|
||||
import org.apache.commons.lang3.reflect.FieldUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
|
Loading…
Reference in New Issue
Block a user