LibsDisguises/plugin/src/main/java/me/libraryaddict/disguise/utilities/translations/TranslateFiller.java

110 lines
4.6 KiB
Java
Raw Normal View History

package me.libraryaddict.disguise.utilities.translations;
2017-06-11 23:36:54 +02:00
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
2021-05-23 03:10:46 +02:00
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
import me.libraryaddict.disguise.utilities.params.ParamInfo;
import me.libraryaddict.disguise.utilities.params.ParamInfoManager;
import me.libraryaddict.disguise.utilities.parser.WatcherMethod;
import org.apache.commons.lang.StringUtils;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
2017-06-11 23:36:54 +02:00
2022-02-02 08:16:24 +01:00
import java.util.ArrayList;
import java.util.Locale;
2023-03-31 05:24:17 +02:00
import java.util.Map;
2022-02-02 08:16:24 +01:00
2017-06-11 23:36:54 +02:00
/**
* Created by libraryaddict on 10/06/2017.
*/
public class TranslateFiller {
public static void fillConfigs() {
// Fill the configs
for (ParamInfo info : ParamInfoManager.getParamInfos()) {
2024-03-06 03:48:26 +01:00
TranslateType.DISGUISE_OPTIONS_PARAMETERS.save(info.getRawName(),
"A disguise option name, has description " + info.getDescription());
if (!info.getRawName().equals(info.getRawDescriptiveName())) {
2022-02-02 08:16:24 +01:00
TranslateType.DISGUISE_OPTIONS_PARAMETERS.save(info.getRawDescriptiveName(), "A disguise option descriptive name");
}
2024-03-06 03:48:26 +01:00
TranslateType.DISGUISE_OPTIONS_PARAMETERS.save(info.getRawDescription(),
"Description for the disguise option " + info.getRawName());
2017-06-19 20:11:08 +02:00
if (info.canTranslateValues()) {
2023-03-31 05:24:17 +02:00
for (String e : ((Map<String, Object>) info.getValues()).keySet()) {
2022-02-02 08:16:24 +01: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()) {
String[] split = type.name().split("_");
for (int i = 0; i < split.length; i++) {
split[i] = split[i].charAt(0) + split[i].substring(1).toLowerCase(Locale.ENGLISH);
}
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
2020-02-06 00:15:20 +01:00
if (type.getEntityType() == null) {
continue;
}
2021-09-10 16:33:01 +02:00
for (WatcherMethod method : ParamInfoManager.getDisguiseWatcherMethods(type.getWatcherClass(), true)) {
Class para = method.getParam();
String className = method.getWatcherClass().getSimpleName().replace("Watcher", "");
2017-06-19 11:23:02 +02:00
2022-02-02 08:16:24 +01:00
if (className.equals("Flag") || className.equals("Disguise")) {
2017-06-19 11:23:02 +02:00
className = "Entity";
2022-02-02 08:16:24 +01:00
} else if (className.equals("Living")) {
2017-06-19 11:23:02 +02:00
className = "Living Entity";
2022-02-02 08:16:24 +01:00
} else if (className.equals("AbstractHorse")) {
2017-06-19 11:23:02 +02:00
className = "Horse";
2022-02-02 08:16:24 +01:00
} else if (className.equals("DroppedItem")) {
2017-06-19 11:23:02 +02:00
className = "Item";
2022-02-02 08:16:24 +01:00
} else if (className.equals("IllagerWizard")) {
2017-06-19 11:23:02 +02:00
className = "Illager";
2022-02-02 08:16:24 +01:00
}
2017-06-19 11:23:02 +02:00
2017-06-19 20:11:08 +02:00
TranslateType.DISGUISE_OPTIONS.save(method.getName(),
2022-02-02 08:16:24 +01: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
TranslateType.DISGUISE_OPTIONS.save("baby", "Used as a shortcut for setBaby when disguising an entity");
TranslateType.DISGUISE_OPTIONS.save("adult", "Used as a shortcut for setBaby(false) when disguising an entity");
ArrayList<Class> validClasses = new ArrayList<>();
for (EntityType type : EntityType.values()) {
Class c = type.getEntityClass();
while (c != null && Entity.class.isAssignableFrom(c) && !validClasses.contains(c)) {
validClasses.add(c);
c = c.getSuperclass();
}
}
for (Class c : validClasses) {
if (c != Entity.class && Entity.class.isAssignableFrom(c) && c.getAnnotation(Deprecated.class) == null) {
2024-03-06 03:48:26 +01:00
TranslateType.DISGUISES.save(c.getSimpleName(),
"Name for the " + c.getSimpleName() + " EntityType, " + "this is used in radius commands");
}
}
TranslateType.DISGUISES.save("EntityType", "Used for the disgiuse radius command to list all entitytypes");
2022-02-02 08:16:24 +01:00
TranslateType.DISGUISES.save("DisgiseType", "Used for the disgiuse modify radius command to list all " + "disguisetypes");
2017-06-19 19:06:35 +02:00
for (LibsMsg msg : LibsMsg.values()) {
2021-05-31 15:08:26 +02:00
TranslateType.MESSAGES.save(msg, DisguiseUtilities.translateAlternateColorCodes(msg.getRaw()), "Reference: " + msg.name());
}
for (TranslateType type : TranslateType.values()) {
type.saveTranslations();
2017-06-19 19:06:35 +02:00
}
2017-06-11 23:36:54 +02:00
}
}