2019-01-03 03:13:03 +01:00
|
|
|
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;
|
2020-02-19 00:57:39 +01:00
|
|
|
import me.libraryaddict.disguise.utilities.params.ParamInfo;
|
|
|
|
import me.libraryaddict.disguise.utilities.params.ParamInfoManager;
|
2021-05-20 20:23:01 +02:00
|
|
|
import me.libraryaddict.disguise.utilities.parser.WatcherMethod;
|
2017-06-19 19:44:31 +02:00
|
|
|
import org.apache.commons.lang.StringUtils;
|
2017-06-22 13:36:45 +02:00
|
|
|
import org.bukkit.entity.Entity;
|
2020-02-22 23:30:56 +01:00
|
|
|
import org.bukkit.entity.EntityType;
|
2017-06-11 23:36:54 +02:00
|
|
|
|
2020-02-22 23:30:56 +01:00
|
|
|
import java.util.ArrayList;
|
2020-09-14 05:01:05 +02:00
|
|
|
import java.util.Locale;
|
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
|
|
|
|
|
2018-09-07 04:35:38 +02:00
|
|
|
for (ParamInfo info : ParamInfoManager.getParamInfos()) {
|
2020-02-06 00:15:20 +01:00
|
|
|
TranslateType.DISGUISE_OPTIONS_PARAMETERS
|
|
|
|
.save(info.getRawName(), "A disguise option name, has description " + info.getDescription());
|
2018-09-07 04:35:38 +02:00
|
|
|
|
|
|
|
if (!info.getRawName().equals(info.getRawDescriptiveName())) {
|
|
|
|
TranslateType.DISGUISE_OPTIONS_PARAMETERS
|
|
|
|
.save(info.getRawDescriptiveName(), "A disguise option descriptive name");
|
|
|
|
}
|
|
|
|
|
2017-06-19 20:11:08 +02:00
|
|
|
TranslateType.DISGUISE_OPTIONS_PARAMETERS
|
|
|
|
.save(info.getRawDescription(), "Description for the disguise option " + info.getRawName());
|
|
|
|
|
2018-09-07 04:35:38 +02:00
|
|
|
if (info.canTranslateValues()) {
|
|
|
|
for (String e : info.getValues().keySet()) {
|
|
|
|
TranslateType.DISGUISE_OPTIONS_PARAMETERS
|
|
|
|
.save(e, "Used for the disguise option " + info.getRawName());
|
|
|
|
}
|
|
|
|
}
|
2017-06-21 21:20:12 +02:00
|
|
|
|
2020-04-10 07:19:43 +02:00
|
|
|
/*if (info.getOtherValues() != null) {
|
2018-09-07 04:35:38 +02:00
|
|
|
for (String e : info.getOtherValues()) {
|
|
|
|
TranslateType.DISGUISE_OPTIONS_PARAMETERS
|
|
|
|
.save(e, "Used for the disguise option " + info.getRawName());
|
|
|
|
}
|
2020-04-10 07:19:43 +02:00
|
|
|
}*/
|
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++) {
|
2020-09-14 05:01:05 +02:00
|
|
|
split[i] = split[i].charAt(0) + split[i].substring(1).toLowerCase(Locale.ENGLISH);
|
2017-06-19 19:44:31 +02:00
|
|
|
}
|
|
|
|
|
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-05-20 20:23:01 +02:00
|
|
|
for (WatcherMethod method : ParamInfoManager.getDisguiseWatcherMethods(type.getWatcherClass())) {
|
|
|
|
Class para = method.getParam();
|
|
|
|
String className = method.getWatcherClass().getSimpleName().replace("Watcher", "");
|
2017-06-19 11:23:02 +02:00
|
|
|
|
|
|
|
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(),
|
2018-07-11 20:05:36 +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
|
|
|
|
2017-06-22 13:36:45 +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");
|
|
|
|
|
2020-02-22 23:30:56 +01:00
|
|
|
ArrayList<Class> validClasses = new ArrayList<>();
|
|
|
|
|
|
|
|
for (EntityType type : EntityType.values()) {
|
|
|
|
Class c = type.getEntityClass();
|
|
|
|
|
2020-02-23 02:00:22 +01:00
|
|
|
while (c != null && Entity.class.isAssignableFrom(c) && !validClasses.contains(c)) {
|
2020-02-22 23:30:56 +01:00
|
|
|
validClasses.add(c);
|
|
|
|
|
|
|
|
c = c.getSuperclass();
|
2017-06-22 13:36:45 +02:00
|
|
|
}
|
|
|
|
}
|
2020-02-22 23:30:56 +01:00
|
|
|
|
|
|
|
for (Class c : validClasses) {
|
|
|
|
if (c != Entity.class && Entity.class.isAssignableFrom(c) && c.getAnnotation(Deprecated.class) == null) {
|
|
|
|
TranslateType.DISGUISES.save(c.getSimpleName(),
|
|
|
|
"Name for the " + c.getSimpleName() + " EntityType, " + "this is used in radius commands");
|
|
|
|
}
|
2020-02-22 22:54:09 +01:00
|
|
|
}
|
2017-06-22 13:36:45 +02:00
|
|
|
|
|
|
|
TranslateType.DISGUISES.save("EntityType", "Used for the disgiuse radius command to list all entitytypes");
|
2017-07-07 20:06:36 +02:00
|
|
|
TranslateType.DISGUISES
|
|
|
|
.save("DisgiseType", "Used for the disgiuse modify radius command to list all " + "disguisetypes");
|
2017-06-22 13:36:45 +02:00
|
|
|
|
2017-06-19 19:06:35 +02:00
|
|
|
for (LibsMsg msg : LibsMsg.values()) {
|
2021-05-23 03:10:46 +02:00
|
|
|
TranslateType.MESSAGES.save(DisguiseUtilities.translateAlternateColorCodes(msg.getRaw()), "Reference: " + msg.name());
|
2017-06-19 19:44:31 +02:00
|
|
|
}
|
|
|
|
|
2017-07-07 20:06:36 +02:00
|
|
|
for (TranslateType type : TranslateType.values()) {
|
2018-07-11 20:05:36 +02:00
|
|
|
type.saveTranslations();
|
2017-06-19 19:06:35 +02:00
|
|
|
}
|
2017-06-11 23:36:54 +02:00
|
|
|
}
|
|
|
|
}
|