2017-06-11 23:36:54 +02:00
|
|
|
package me.libraryaddict.disguise.utilities;
|
|
|
|
|
2017-06-19 19:44:31 +02:00
|
|
|
import me.libraryaddict.disguise.DisguiseConfig;
|
2017-06-11 23:36:54 +02:00
|
|
|
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
2017-06-19 19:44:31 +02:00
|
|
|
import org.apache.commons.lang.StringUtils;
|
2017-06-19 11:23:02 +02:00
|
|
|
import org.bukkit.inventory.ItemStack;
|
2017-06-11 23:36:54 +02:00
|
|
|
|
|
|
|
import java.lang.reflect.Method;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Created by libraryaddict on 10/06/2017.
|
|
|
|
*/
|
|
|
|
public class TranslateFiller {
|
|
|
|
public static void fillConfigs() {
|
|
|
|
// Fill the configs
|
|
|
|
|
|
|
|
for (ReflectionFlagWatchers.ParamInfo info : ReflectionFlagWatchers.getParamInfos()) {
|
|
|
|
if (!info.isEnums())
|
|
|
|
continue;
|
|
|
|
|
2017-06-19 11:23:02 +02:00
|
|
|
if (info.getParamClass() == ItemStack.class || info.getParamClass() == ItemStack[].class)
|
|
|
|
continue;
|
|
|
|
|
2017-06-19 20:11:08 +02:00
|
|
|
TranslateType.DISGUISE_OPTIONS_PARAMETERS.save(info.getRawName(), "Used as a disguise option");
|
|
|
|
TranslateType.DISGUISE_OPTIONS_PARAMETERS
|
|
|
|
.save(info.getRawDescription(), "Description for the disguise option " + info.getRawName());
|
|
|
|
|
2017-06-11 23:36:54 +02:00
|
|
|
for (String e : info.getEnums("")) {
|
2017-06-19 20:11:08 +02:00
|
|
|
TranslateType.DISGUISE_OPTIONS_PARAMETERS.save(e, "Used for the disguise option " + info.getRawName());
|
2017-06-11 23:36:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (DisguiseType type : DisguiseType.values()) {
|
2017-06-19 19:44:31 +02:00
|
|
|
String[] split = type.name().split("_");
|
|
|
|
|
|
|
|
for (int i = 0; i < split.length; i++) {
|
|
|
|
split[i] = split[i].substring(0, 1) + split[i].substring(1).toLowerCase();
|
|
|
|
}
|
|
|
|
|
2017-06-19 20:11:08 +02:00
|
|
|
TranslateType.DISGUISES.save(StringUtils.join(split, " "), "Name for the " + type.name() + " disguise");
|
2017-06-11 23:36:54 +02:00
|
|
|
|
|
|
|
for (Method method : ReflectionFlagWatchers.getDisguiseWatcherMethods(type.getWatcherClass())) {
|
2017-06-19 11:23:02 +02:00
|
|
|
Class para = method.getParameterTypes()[0];
|
|
|
|
String className = method.getDeclaringClass().getSimpleName().replace("Watcher", "");
|
|
|
|
|
|
|
|
if (className.equals("Flag") || className.equals("Disguise"))
|
|
|
|
className = "Entity";
|
|
|
|
else if (className.equals("Living"))
|
|
|
|
className = "Living Entity";
|
|
|
|
else if (className.equals("AbstractHorse"))
|
|
|
|
className = "Horse";
|
|
|
|
else if (className.equals("DroppedItem"))
|
|
|
|
className = "Item";
|
|
|
|
else if (className.equals("IllagerWizard"))
|
|
|
|
className = "Illager";
|
|
|
|
|
2017-06-19 20:11:08 +02:00
|
|
|
TranslateType.DISGUISE_OPTIONS.save(method.getName(),
|
2017-06-19 11:23:02 +02:00
|
|
|
"Found in the disguise options for " + className + " and uses " + (para.isArray() ?
|
|
|
|
"multiple" + " " : "a ") + para.getSimpleName().replace("[]", "s"));
|
2017-06-11 23:36:54 +02:00
|
|
|
}
|
|
|
|
}
|
2017-06-19 19:06:35 +02:00
|
|
|
|
|
|
|
for (LibsMsg msg : LibsMsg.values()) {
|
2017-06-19 20:11:08 +02:00
|
|
|
TranslateType.MESSAGES.save(msg.getRaw());
|
2017-06-19 19:44:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!LibsPremium.isPremium() || !DisguiseConfig.isUseTranslations()) {
|
|
|
|
for (TranslateType type : TranslateType.values()) {
|
|
|
|
type.wipeTranslations();
|
|
|
|
}
|
2017-06-19 19:06:35 +02:00
|
|
|
}
|
2017-06-11 23:36:54 +02:00
|
|
|
}
|
|
|
|
}
|