Vazkey pls
This commit is contained in:
parent
3752e7a54f
commit
70ad6fe09e
2 changed files with 41 additions and 16 deletions
|
@ -0,0 +1,25 @@
|
|||
package com.blamejared.compat.botania;
|
||||
|
||||
import net.minecraft.client.resources.*;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Map;
|
||||
|
||||
public class LocalizationHelper {
|
||||
|
||||
|
||||
public static void setLocale(String unlocalized, String localized) {
|
||||
try {
|
||||
Field locale = I18n.class.getDeclaredField("i18nLocale");
|
||||
locale.setAccessible(true);
|
||||
Locale loc = (Locale) locale.get(null);
|
||||
Field propMap = loc.getClass().getDeclaredField("properties");
|
||||
propMap.setAccessible(true);
|
||||
Map<String, String> map = (Map<String, String>) propMap.get(loc);
|
||||
map.put(unlocalized, localized);
|
||||
} catch(Exception e) {
|
||||
//NO-OP people will complain if it stops translating, and this will get rid of errors on the server
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,52 +1,52 @@
|
|||
package com.blamejared.compat.botania.handlers;
|
||||
|
||||
import com.blamejared.ModTweaker;
|
||||
import crafttweaker.CraftTweakerAPI;
|
||||
import crafttweaker.IAction;
|
||||
import crafttweaker.annotations.ModOnly;
|
||||
import crafttweaker.annotations.ZenRegister;
|
||||
import com.blamejared.compat.botania.LocalizationHelper;
|
||||
import crafttweaker.*;
|
||||
import crafttweaker.annotations.*;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
import stanhebben.zenscript.annotations.*;
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
|
||||
@ZenClass("mods.botania.Knowledge")
|
||||
@ModOnly("botania")
|
||||
@ZenRegister
|
||||
public class Knowledge {
|
||||
|
||||
private static final String typeName = "Botania Knowledge Variable:";
|
||||
|
||||
|
||||
@ZenMethod
|
||||
public static void registerKnowledgeType(String unlocalized, String color, boolean autoUnlock){
|
||||
if (unlocalized == null || unlocalized.isEmpty()) {
|
||||
public static void registerKnowledgeType(String unlocalized, String localized, String color, boolean autoUnlock) {
|
||||
if(unlocalized == null || unlocalized.isEmpty()) {
|
||||
CraftTweakerAPI.logError("Found null String in " + typeName + " name");
|
||||
} else if (color == null || color.isEmpty()){
|
||||
} else if(color == null || color.isEmpty()) {
|
||||
CraftTweakerAPI.logError("Found null String in " + typeName + " color");
|
||||
} else {
|
||||
LocalizationHelper.setLocale("botania.knowledge." + unlocalized, localized);
|
||||
CraftTweakerAPI.apply(new Add(unlocalized, color, autoUnlock));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static class Add implements IAction {
|
||||
|
||||
String unlocalized;
|
||||
String color;
|
||||
boolean autoUnlock;
|
||||
|
||||
|
||||
public Add(String name, String color, boolean autoUnlock) {
|
||||
this.unlocalized = name;
|
||||
this.color = color;
|
||||
this.autoUnlock = autoUnlock;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
BotaniaAPI.registerKnowledgeType(unlocalized, TextFormatting.getValueByName(color.toUpperCase()), autoUnlock);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
String Output;
|
||||
if (autoUnlock){
|
||||
if(autoUnlock) {
|
||||
Output = "Enabled";
|
||||
} else {
|
||||
Output = "Disabled";
|
||||
|
|
Loading…
Reference in a new issue