Java源码示例:com.dsh105.commodus.GeneralUtil
示例1
@Command(
command = "holodebug",
description = "Smashing bugs and coloring books",
permission = "holo.debug"
)
public boolean debug(CommandEvent event) {
event.respond("Debug results: ");
event.respond("--------------[HoloAPI Stuff]--------------");
event.respond("HoloAPI-Version: " + HoloAPI.getCore().getDescription().getVersion());
event.respond("Message of the day: " + messages[GeneralUtil.random().nextInt(messages.length)]);
event.respond("--------------[CraftBukkit Stuff]--------------");
event.respond("Version tag: " + MinecraftReflection.getVersionTag());
event.respond("NMS-package: " + MinecraftReflection.getMinecraftPackage());
event.respond("CB-package: " + MinecraftReflection.getCraftBukkitPackage());
event.respond("Bukkit version: " + Bukkit.getBukkitVersion());
event.respond("--------------[Minecraft Server Stuff]--------------");
event.respond("Using Netty: " + MinecraftReflection.isUsingNetty());
event.respond("MinecraftServer: " + MinecraftReflection.getMinecraftClass("MinecraftServer").getCanonicalName());
event.respond("Entity: " + MinecraftReflection.getMinecraftClass("Entity"));
event.respond("Is (forge) Modded: " + (MinecraftReflection.getMinecraftClass("Entity").getCanonicalName().startsWith("net.minecraft.entity") ? "Definitely" : "Probably not"));
return true;
}
示例2
public PetMenu(IPet pet, ArrayList<MenuOption> options, int size) {
this.pet = pet;
this.size = size;
this.inv = Bukkit.createInventory(pet.getOwner(), size, "EchoPet DataMenu");
this.options = options;
for (MenuOption o : this.options) {
if (o.item.getMenuType() == DataMenu.DataMenuType.BOOLEAN) {
MenuItem mi = o.item;
if (GeneralUtil.isEnumType(PetData.class, mi.toString())) {
PetData pd = PetData.valueOf(mi.toString());
if (pet.getPetData().contains(pd)) {
this.inv.setItem(o.position, o.item.getBoolean(false));
} else {
this.inv.setItem(o.position, o.item.getBoolean(true));
}
} else {
if (mi.toString().equals("HAT")) {
if (pet.isHat()) {
this.inv.setItem(o.position, o.item.getBoolean(false));
} else {
this.inv.setItem(o.position, o.item.getBoolean(true));
}
}
if (mi.toString().equals("RIDE")) {
if (pet.isOwnerRiding()) {
this.inv.setItem(o.position, o.item.getBoolean(false));
} else {
this.inv.setItem(o.position, o.item.getBoolean(true));
}
}
}
} else {
this.inv.setItem(o.position, o.item.getItem());
}
}
int book = size - 1;
this.inv.setItem(book, DataMenuItem.CLOSE.getItem());
}
示例3
public static void loadLayout() {
if (selectorMenu != null) {
HandlerList.unregisterAll(selectorMenu);
}
selectorLayout.clear();
YAMLConfig config = ConfigOptions.instance.getConfig();
String s = "petSelector.menu";
int size = config.getInt(s + ".slots");
for (int i = 1; i <= size; i++) {
String cmd = config.getString(s + ".slot-" + i + ".command");
String petType = config.getString(s + ".slot-" + i + ".petType");
PetType pt = null;
if (petType != null && GeneralUtil.isEnumType(PetType.class, petType.toUpperCase())) {
pt = PetType.valueOf(petType.toUpperCase());
}
int id = config.getInt(s + ".slot-" + i + ".materialId");
int data = config.getInt(s + ".slot-" + i + ".materialData");
String name = config.getString(s + ".slot-" + i + ".name");
if (name == null) {
continue;
}
List<String> lore = config.config().getStringList(s + ".slot-" + i + ".lore");
if (lore == null) {
lore = new ArrayList<String>();
}
ArrayList<String> loreList = new ArrayList<String>();
if (lore.size() > 0) {
for (String part : lore) {
loreList.add(ChatColor.translateAlternateColorCodes('&', part));
}
}
Material type = Material.getMaterial(id);
selectorLayout.add(new SelectorIcon(i - 1, cmd, pt, ItemData.create(type, data).withDisplayName(name.trim().isEmpty() ? Optional.empty() : Optional.of(name)).withLore(loreList)));
}
selectorMenu = new SelectorMenu();
}
示例4
@Override
public void loadRiderFromFile(String type, IPet pet) {
String path = type + "." + pet.getOwnerUUID();
if (EchoPet.getConfig(EchoPet.ConfigType.DATA).get(path + ".rider.type") != null) {
ArrayList<PetData> riderData = new ArrayList<>();
PetType riderPetType = PetType.fromDataString(EchoPet.getConfig(EchoPet.ConfigType.DATA).getString(path + ".rider.type"), riderData);
String riderName = EchoPet.getConfig(EchoPet.ConfigType.DATA).getString(path + ".rider.name");
if (Strings.isNullOrEmpty(riderName)) {
riderName = riderPetType.getDefaultName(pet.getNameOfOwner());
}
if (EchoPet.getOptions().allowRidersFor(pet.getPetType())) {
IPet rider = pet.createRider(riderPetType, true);
if (rider != null && rider.isSpawned()) {
rider.setPetName(riderName);
ConfigurationSection mcs = EchoPet.getConfig(EchoPet.ConfigType.DATA).getConfigurationSection(path + ".rider.data");
if (mcs != null) {
for (String key : mcs.getKeys(false)) {
if (GeneralUtil.isEnumType(PetData.class, key.toUpperCase())) {
PetData pd = PetData.valueOf(key.toUpperCase());
riderData.add(pd);
} else {
Logger.log(Logger.LogLevel.WARNING, "Error whilst loading data Pet Rider Save Data for " + pet.getNameOfOwner() + ". Unknown enum type: " + key + ".", true);
}
}
}
if (!riderData.isEmpty()) {
setData(pet, riderData.toArray(new PetData[riderData.size()]), true);
}
}
}
}
}
示例5
@Override
public boolean isValid(ConversationContext context, String input) {
if (input.contains(" ")) {
String[] split = input.split("\\s");
if (split.length == 4) {
if (Bukkit.getWorld(split[0]) != null) {
for (int i = 1; i <= 3; i++) {
if (!GeneralUtil.isInt(split[i])) {
context.setSessionData("fail_int", true);
return false;
}
}
this.location = new Location(Bukkit.getWorld(split[0]), Integer.parseInt(split[1]), Integer.parseInt(split[2]), Integer.parseInt(split[3]));
} else {
context.setSessionData("fail_world", true);
return false;
}
} else {
context.setSessionData("fail_format", true);
return false;
}
} else {
context.setSessionData("fail_format", true);
return false;
}
return true;
}
示例6
@Override
protected boolean isInputValid(ConversationContext conversationContext, String s) {
if (conversationContext.getSessionData("askingForDelay") == null) {
conversationContext.setSessionData("askingForDelay", false);
}
if (conversationContext.getSessionData("nextFrame") == null) {
conversationContext.setSessionData("nextFrame", false);
}
return !((Boolean) conversationContext.getSessionData("askingForDelay") && !GeneralUtil.isInt(s)) && !(this.first && s.equalsIgnoreCase("DONE")) && !(s.equalsIgnoreCase("NEXT") && this.lines.isEmpty());
}
示例7
@Command(
command = "edit <id> <line> <content...>",
description = "Edit a line of an existing hologram",
permission = "holoapi.holo.edit",
help = "The content can be more than one word"
)
public boolean editWithContent(CommandEvent event) {
final Hologram hologram = HoloAPI.getManager().getHologram(event.variable("id"));
if (hologram == null) {
event.respond(Lang.HOLOGRAM_NOT_FOUND.getValue("id", event.variable("id")));
return true;
}
int lineNumber;
try {
lineNumber = GeneralUtil.toInteger(event.variable("line_number"));
} catch (NumberFormatException e) {
event.respond(Lang.INT_ONLY.getValue("string", event.variable("line_number")));
return true;
}
if (lineNumber > hologram.getLines().length) {
event.respond(Lang.LINE_INDEX_TOO_BIG.getValue("index", event.variable("line_number")));
return true;
}
hologram.updateLine(lineNumber - 1, event.variable("content"));
event.respond(Lang.HOLOGRAM_UPDATE_LINE.getValue("index", lineNumber, "input", ChatColor.translateAlternateColorCodes('&', event.variable("content"))));
return true;
}
示例8
@Command(
command = "nearby <radius>",
description = "View information on all nearby holograms within the specified radius",
permission = "holoapi.holo.nearby"
)
public boolean command(CommandEvent<Player> event) {
int radius;
try {
radius = GeneralUtil.toInteger(event.variable("radius"));
} catch (NumberFormatException e) {
event.respond(Lang.INT_ONLY.getValue("string", event.variable("radius")));
return true;
}
ArrayList<Hologram> nearby = new ArrayList<Hologram>();
for (Hologram hologram : HoloAPI.getManager().getAllComplexHolograms().keySet()) {
if (GeometryUtil.getNearbyEntities(hologram.getDefaultLocation(), radius).contains(event.sender())) {
nearby.add(hologram);
}
}
if (nearby.isEmpty()) {
event.respond(Lang.NO_NEARBY_HOLOGRAMS.getValue("radius", radius));
return true;
}
event.respond(Lang.HOLOGRAM_NEARBY.getValue("radius", radius));
InfoCommand.info(event.sender(), nearby);
if (MinecraftReflection.isUsingNetty()) {
event.respond(Lang.TIP_HOVER_PREVIEW.getValue());
}
return true;
}
示例9
@Command(
command = "script editcurrent <line>",
description = "Edits a script currently being built. Not intended for general use outside of context.",
includeInHelp = false
// No permission, as this cannot be called without another command executing it
)
public boolean editCurrentScript(CommandEvent event) {
if (!(event.sender() instanceof Conversable)) {
event.respond(Lang.NOT_CONVERSABLE.getValue());
return true;
}
ScriptBuilderPrompt scriptBuilder = SCRIPT_EDITORS.get(getIdent((Conversable) event.sender()));
if (scriptBuilder == null) {
event.respond(Lang.PROMPT_SCRIPT_NOT_EDITING.getValue());
return true;
}
int line = 0;
try {
line = GeneralUtil.toInteger(event.variable("line"));
} catch (NumberFormatException e) {
event.respond(Lang.INT_ONLY.getValue("string", event.variable("line")));
}
event.respond(Lang.PROMPT_SCRIPT_LINE_CHANGE.getValue("line", event.variable("line")));
scriptBuilder.setCurrentlyEditing(line);
return true;
}
示例10
@Command(
command = "help <index>",
description = "Retrieve a certain help page of all HoloAPI commands"
)
public boolean helpPage(CommandEvent event) {
try {
HoloAPI.getCommandManager().getHelpService().sendPage(event.sender(), GeneralUtil.toInteger(event.variable("index")));
if (MinecraftReflection.isUsingNetty() && event.sender() instanceof Player) {
event.respond(Lang.TIP_HOVER_COMMANDS.getValue());
}
} catch (NumberFormatException e) {
event.respond(Lang.HELP_INDEX_TOO_BIG.getValue("index", event.variable("index")));
}
return true;
}
示例11
public void loadAnimationConfiguration(YAMLConfig config) {
KEY_TO_IMAGE_MAP.clear();
URL_UNLOADED.clear();
File imageFolder = new File(HoloAPI.getCore().getDataFolder() + File.separator + "animations");
if (!imageFolder.exists()) {
imageFolder.mkdirs();
}
ConfigurationSection cs = config.getConfigurationSection("animations");
if (cs != null) {
for (String key : cs.getKeys(false)) {
String path = "animations." + key + ".";
String imagePath = config.getString(path + "path");
if (imagePath == null) {
HoloAPI.LOG.info("Failed to load animation: " + key + ". Invalid path");
continue;
}
int imageHeight = config.getInt(path + "height", 10);
int frameRate = config.getInt(path + "frameRate", 10);
boolean requiresBorder = config.getBoolean(path + "requiresBorder", true);
String imageChar = config.getString(path + "characterType", ImageChar.BLOCK.getHumanName());
String imageType = config.getString(path + "type", "FILE");
if (!GeneralUtil.isEnumType(ImageLoader.ImageLoadType.class, imageType.toUpperCase())) {
HoloAPI.LOG.info("Failed to load animation: " + key + ". Invalid image type.");
continue;
}
AnimationLoadType type = AnimationLoadType.valueOf(imageType.toUpperCase());
AnimatedImageGenerator generator = findGenerator(type, key, imagePath, frameRate, imageHeight, imageChar, requiresBorder);
if (generator != null) {
this.KEY_TO_IMAGE_MAP.put(key, generator);
}
}
}
loaded = true;
if (!KEY_TO_IMAGE_MAP.isEmpty() || !URL_UNLOADED.isEmpty()) {
HoloAPI.LOG.info("Animations loaded.");
}
}
示例12
public void loadImageConfiguration(YAMLConfig config) {
KEY_TO_IMAGE_MAP.clear();
URL_UNLOADED.clear();
File imageFolder = new File(HoloAPI.getCore().getDataFolder() + File.separator + "images");
if (!imageFolder.exists()) {
imageFolder.mkdirs();
}
ConfigurationSection cs = config.getConfigurationSection("images");
if (cs != null) {
for (String key : cs.getKeys(false)) {
String path = "images." + key + ".";
String imagePath = config.getString(path + "path");
int imageHeight = config.getInt(path + "height", 10);
String imageChar = config.getString(path + "characterType", ImageChar.BLOCK.getHumanName());
String imageType = config.getString(path + "type", "FILE");
boolean requiresBorder = config.getBoolean(path + "requiresBorder", true);
if (!GeneralUtil.isEnumType(ImageLoader.ImageLoadType.class, imageType.toUpperCase())) {
HoloAPI.LOG.info("Failed to load image: " + key + ". Invalid image type.");
continue;
}
ImageLoader.ImageLoadType type = ImageLoader.ImageLoadType.valueOf(imageType.toUpperCase());
ImageGenerator generator = findGenerator(type, key, imagePath, imageHeight, imageChar, requiresBorder);
if (generator != null) {
this.KEY_TO_IMAGE_MAP.put(key, generator);
}
}
}
loaded = true;
if (!KEY_TO_IMAGE_MAP.isEmpty() || !URL_UNLOADED.isEmpty()) {
HoloAPI.LOG.info("Images loaded.");
}
}
示例13
@Override
public void despawn(ControllableEntity controllableEntity, DespawnReason reason) {
if (controllableEntity.isSpawned()) {
controllableEntity.despawn(reason);
}
if (!controllableEntity.isSpawned()) {
Integer id = GeneralUtil.getKeyAtValue(ENTITIES, controllableEntity);
if (id != null) { // May have already been removed
this.ENTITIES.remove(id);
}
}
}
示例14
@Override
public void loadRiderFromFile(String type, IPet pet) {
if (pet.getOwner() != null) {
String path = type + "." + pet.getOwnerIdentification();
if (EchoPet.getConfig(EchoPet.ConfigType.DATA).get(path + ".rider.type") != null) {
PetType riderPetType = PetType.valueOf(EchoPet.getConfig(EchoPet.ConfigType.DATA).getString(path + ".rider.type"));
String riderName = EchoPet.getConfig(EchoPet.ConfigType.DATA).getString(path + ".rider.name");
if (riderName.equalsIgnoreCase("") || riderName == null) {
riderName = riderPetType.getDefaultName(pet.getNameOfOwner());
}
if (riderPetType == null) return;
if (EchoPet.getOptions().allowRidersFor(pet.getPetType())) {
IPet rider = pet.createRider(riderPetType, true);
if (rider != null && rider.getEntityPet() != null) {
rider.setPetName(riderName);
ArrayList<PetData> riderData = new ArrayList<PetData>();
ConfigurationSection mcs = EchoPet.getConfig(EchoPet.ConfigType.DATA).getConfigurationSection(path + ".rider.data");
if (mcs != null) {
for (String key : mcs.getKeys(false)) {
if (GeneralUtil.isEnumType(PetData.class, key.toUpperCase())) {
PetData pd = PetData.valueOf(key.toUpperCase());
riderData.add(pd);
} else {
Logger.log(Logger.LogLevel.WARNING, "Error whilst loading data Pet Rider Save Data for " + pet.getNameOfOwner() + ". Unknown enum type: " + key + ".", true);
}
}
}
if (!riderData.isEmpty()) {
setData(pet, riderData.toArray(new PetData[riderData.size()]), true);
}
}
}
}
}
}
示例15
public PetMenu(IPet pet, ArrayList<MenuOption> options, int size) {
this.pet = pet;
this.size = size;
this.inv = Bukkit.createInventory(pet.getOwner(), size, "EchoPet DataMenu");
this.options = options;
for (MenuOption o : this.options) {
if (o.item.getMenuType() == DataMenu.DataMenuType.BOOLEAN) {
MenuItem mi = o.item;
if (GeneralUtil.isEnumType(PetData.class, mi.toString())) {
PetData pd = PetData.valueOf(mi.toString());
if (pet.getPetData().contains(pd)) {
this.inv.setItem(o.position, o.item.getBoolean(false));
} else {
this.inv.setItem(o.position, o.item.getBoolean(true));
}
} else {
if (mi.toString().equals("HAT")) {
if (pet.isHat()) {
this.inv.setItem(o.position, o.item.getBoolean(false));
} else {
this.inv.setItem(o.position, o.item.getBoolean(true));
}
}
if (mi.toString().equals("RIDE")) {
if (pet.isOwnerRiding()) {
this.inv.setItem(o.position, o.item.getBoolean(false));
} else {
this.inv.setItem(o.position, o.item.getBoolean(true));
}
}
}
} else {
this.inv.setItem(o.position, o.item.getItem());
}
}
int book = size - 1;
this.inv.setItem(book, DataMenuItem.CLOSE.getItem());
}
示例16
public static void loadLayout() {
if (selectorMenu != null) {
HandlerList.unregisterAll(selectorMenu);
}
selectorLayout.clear();
YAMLConfig config = ConfigOptions.instance.getConfig();
String s = "petSelector.menu";
int size = config.getInt(s + ".slots");
for (int i = 1; i <= size; i++) {
String cmd = config.getString(s + ".slot-" + i + ".command");
String petType = config.getString(s + ".slot-" + i + ".petType");
PetType pt = null;
if (petType != null && GeneralUtil.isEnumType(PetType.class, petType.toUpperCase())) {
pt = PetType.valueOf(petType.toUpperCase());
}
int id = config.getInt(s + ".slot-" + i + ".materialId");
int data = config.getInt(s + ".slot-" + i + ".materialData");
String name = config.getString(s + ".slot-" + i + ".name");
if (name == null) {
continue;
}
List<String> lore = config.config().getStringList(s + ".slot-" + i + ".lore");
if (lore == null) {
lore = new ArrayList<String>();
}
ArrayList<String> loreList = new ArrayList<String>();
if (lore.size() > 0) {
for (String part : lore) {
loreList.add(ChatColor.translateAlternateColorCodes('&', part));
}
}
selectorLayout.add(new SelectorIcon(i - 1, cmd, pt, id, data, name, loreList.toArray(new String[0])));
}
selectorMenu = new SelectorMenu();
}
示例17
@Override
public IPet createPetFromFile(String type, Player p) {
if (EchoPet.getOptions().getConfig().getBoolean("loadSavedPets", true)) {
String path = type + "." + UUIDMigration.getIdentificationFor(p);
if (EchoPet.getConfig(EchoPet.ConfigType.DATA).get(path) != null) {
ArrayList<PetData> data = new ArrayList<>();
PetType petType = PetType.fromDataString(EchoPet.getConfig(EchoPet.ConfigType.DATA).getString(path + ".pet.type"), data);
String name = EchoPet.getConfig(EchoPet.ConfigType.DATA).getString(path + ".pet.name");
if (Strings.isNullOrEmpty(name)) {
name = petType.getDefaultName(p.getName());
}
if (!EchoPet.getOptions().allowPetType(petType)) {
return null;
}
IPet pi = this.createPet(p, petType, true);
if (pi == null) {
return null;
}
//Pet pi = petType.getNewPetInstance(p, petType);
//Pet pi = new Pet(p, petType);
pi.setPetName(name);
ConfigurationSection cs = EchoPet.getConfig(EchoPet.ConfigType.DATA).getConfigurationSection(path + ".pet.data");
if (cs != null) {
for (String key : cs.getKeys(false)) {
if (GeneralUtil.isEnumType(PetData.class, key.toUpperCase())) {
PetData pd = PetData.valueOf(key.toUpperCase());
data.add(pd);
} else {
Logger.log(Logger.LogLevel.WARNING, "Error whilst loading data Pet Save Data for " + pi.getNameOfOwner() + ". Unknown enum type: " + key + ".", true);
}
}
}
if (!data.isEmpty()) {
setData(pi, data.toArray(new PetData[data.size()]), true);
}
this.loadRiderFromFile(type, pi);
forceAllValidData(pi);
return pi;
}
}
return null;
}
示例18
public ArrayList<String> loadFileData() {
ArrayList<String> unprepared = new ArrayList<>();
ConfigurationSection cs = config.getConfigurationSection("holograms");
if (cs != null) {
for (String key : cs.getKeys(false)) {
String path = "holograms." + key + ".";
String worldName = config.getString(path + "worldName");
double x = config.getDouble(path + "x");
double y = config.getDouble(path + "y");
double z = config.getDouble(path + "z");
if (config.get(path + "animatedImage.image") != null) {
if (config.getBoolean(path + "animatedImage.image")) {
unprepared.add(key);
} else {
ArrayList<Frame> frameList = new ArrayList<>();
ConfigurationSection frames = config.getConfigurationSection("holograms." + key + ".animatedImage.frames");
if (frames != null) {
for (String frameKey : frames.getKeys(false)) {
ConfigurationSection lines = config.getConfigurationSection("holograms." + key + ".animatedImage.frames." + frameKey);
if (lines != null) {
ArrayList<String> tagList = new ArrayList<>();
int delay = config.getInt("holograms." + key + ".animatedImage.frames." + frameKey + ".delay", 5);
for (String tagKey : lines.getKeys(false)) {
if (!tagKey.equalsIgnoreCase("delay")) {
tagList.add(config.getString("holograms." + key + ".animatedImage.frames." + frameKey + "." + tagKey));
}
}
if (!tagList.isEmpty()) {
frameList.add(new Frame(delay, tagList.toArray(new String[tagList.size()])));
}
}
}
}
if (!frameList.isEmpty()) {
this.loadExtraData(new AnimatedHologramFactory(HoloAPI.getCore())
.withSaveId(key)
.withText(new AnimatedTextGenerator(frameList.toArray(new Frame[frameList.size()])))
.withLocation(new Vector(x, y, z), worldName)
.build(),
key);
}
}
} else {
ConfigurationSection cs1 = config.getConfigurationSection("holograms." + key + ".lines");
boolean containsImage = false;
if (cs1 != null) {
//ArrayList<String> lines = new ArrayList<String>();
HologramFactory hf = new HologramFactory(HoloAPI.getCore());
for (String key1 : cs1.getKeys(false)) {
if (GeneralUtil.isInt(key1)) {
String type = config.getString(path + "lines." + key1 + ".type");
String value = config.getString(path + "lines." + key1 + ".value");
if (type.equalsIgnoreCase("image")) {
containsImage = true;
break;
} else {
hf.withText(value);
}
} else {
HoloAPI.LOG.warning("Failed to load line section of " + key1 + " for Hologram of ID " + key + ".");
}
}
if (containsImage) {
unprepared.add(key);
continue;
}
this.loadExtraData(hf.withSaveId(key).withLocation(new Vector(x, y, z), worldName).build(), key);
}
}
}
}
return unprepared;
}
示例19
@Override
public IPet createPetFromFile(String type, Player p) {
if (EchoPet.getOptions().getConfig().getBoolean("loadSavedPets", true)) {
String path = type + "." + UUIDMigration.getIdentificationFor(p);
if (EchoPet.getConfig(EchoPet.ConfigType.DATA).get(path) != null) {
PetType petType = PetType.valueOf(EchoPet.getConfig(EchoPet.ConfigType.DATA).getString(path + ".pet.type"));
String name = EchoPet.getConfig(EchoPet.ConfigType.DATA).getString(path + ".pet.name");
if (name.equalsIgnoreCase("") || name == null) {
name = petType.getDefaultName(p.getName());
}
if (petType == null) return null;
if (!EchoPet.getOptions().allowPetType(petType)) {
return null;
}
IPet pi = this.createPet(p, petType, true);
if (pi == null) {
return null;
}
//Pet pi = petType.getNewPetInstance(p, petType);
//Pet pi = new Pet(p, petType);
pi.setPetName(name);
ArrayList<PetData> data = new ArrayList<PetData>();
ConfigurationSection cs = EchoPet.getConfig(EchoPet.ConfigType.DATA).getConfigurationSection(path + ".pet.data");
if (cs != null) {
for (String key : cs.getKeys(false)) {
if (GeneralUtil.isEnumType(PetData.class, key.toUpperCase())) {
PetData pd = PetData.valueOf(key.toUpperCase());
data.add(pd);
} else {
Logger.log(Logger.LogLevel.WARNING, "Error whilst loading data Pet Save Data for " + pi.getNameOfOwner() + ". Unknown enum type: " + key + ".", true);
}
}
}
if (!data.isEmpty()) {
setData(pi, data.toArray(new PetData[data.size()]), true);
}
this.loadRiderFromFile(type, pi);
forceAllValidData(pi);
return pi;
}
}
return null;
}