use of org.bukkit.configuration.file.FileConfiguration in project MyPet by xXKeyleXx.
the class MyPetPlugin method loadGroups.
private int loadGroups(File f) {
ConfigurationYAML yamlConfiguration = new ConfigurationYAML(f);
FileConfiguration config = yamlConfiguration.getConfig();
if (config == null) {
return 0;
}
WorldGroup.clearGroups();
Set<String> nodes;
try {
nodes = config.getConfigurationSection("Groups").getKeys(false);
} catch (NullPointerException e) {
nodes = new HashSet<>();
getLogger().info("No groups found. Everything will be in 'default' group.");
}
getLogger().info("--- Loading WorldGroups ---------------------------");
if (nodes.size() == 0) {
List<String> worldNames = new ArrayList<>();
WorldGroup defaultGroup = new WorldGroup("default");
defaultGroup.registerGroup();
for (World world : this.getServer().getWorlds()) {
getLogger().info("added " + ChatColor.GOLD + world.getName() + ChatColor.RESET + " to 'default' group.");
worldNames.add(world.getName());
defaultGroup.addWorld(world.getName());
}
config.set("Groups.default", worldNames);
yamlConfiguration.saveConfig();
} else {
for (String node : nodes) {
List<String> worlds = config.getStringList("Groups." + node);
if (worlds.size() > 0) {
WorldGroup newGroup = new WorldGroup(node);
for (String world : worlds) {
getLogger().info(" added '" + world + "' to '" + newGroup.getName() + "'");
newGroup.addWorld(world);
}
if (newGroup.getWorlds().size() > 0) {
newGroup.registerGroup();
}
}
}
WorldGroup defaultGroup = WorldGroup.getGroupByName("default");
if (defaultGroup == null) {
defaultGroup = new WorldGroup("default");
defaultGroup.registerGroup();
}
boolean saveConfig = false;
for (World world : getServer().getWorlds()) {
if (WorldGroup.getGroupByWorld(world.getName()) == null) {
getLogger().info("added " + ChatColor.GOLD + world.getName() + ChatColor.RESET + " to 'default' group.");
defaultGroup.addWorld(world.getName());
saveConfig = true;
}
}
if (saveConfig) {
config.set("Groups.default", defaultGroup.getWorlds());
yamlConfiguration.saveConfig();
}
}
getLogger().info("-------------------------------------------------");
return 0;
}
use of org.bukkit.configuration.file.FileConfiguration in project MyPet by xXKeyleXx.
the class ConfigurationLoader method loadCompatConfiguration.
public static void loadCompatConfiguration() {
FileConfiguration config = MyPetApi.getPlugin().getConfig();
Skilltree.Skill.CONTROL_ITEM = ConfigItem.createConfigItem(config.getString("MyPet.Skill.Control.Item", "" + Material.LEASH.getId()));
Skilltree.Skill.Ride.RIDE_ITEM = ConfigItem.createConfigItem(config.getString("MyPet.Skill.Ride.Item", "" + Material.LEASH.getId()));
File petConfigFile = new File(MyPetApi.getPlugin().getDataFolder().getPath(), "pet-config.yml");
if (petConfigFile.exists()) {
YamlConfiguration ymlcnf = new YamlConfiguration();
try {
ymlcnf.load(petConfigFile);
config = ymlcnf;
} catch (IOException | InvalidConfigurationException e) {
e.printStackTrace();
}
}
MyPet.Chicken.GROW_UP_ITEM = ConfigItem.createConfigItem(config.getString("MyPet.Pets.Chicken.GrowUpItem", "" + Material.POTION.getId()));
MyPet.Cow.GROW_UP_ITEM = ConfigItem.createConfigItem(config.getString("MyPet.Pets.Cow.GrowUpItem", "" + Material.POTION.getId()));
MyPet.Horse.GROW_UP_ITEM = ConfigItem.createConfigItem(config.getString("MyPet.Pets.Horse.GrowUpItem", "" + Material.BREAD.getId()));
MyPet.Llama.GROW_UP_ITEM = ConfigItem.createConfigItem(config.getString("MyPet.Pets.Llama.GrowUpItem", "" + Material.POTION.getId()));
MyPet.Mooshroom.GROW_UP_ITEM = ConfigItem.createConfigItem(config.getString("MyPet.Pets.Mooshroom.GrowUpItem", "" + Material.POTION.getId()));
MyPet.Ocelot.GROW_UP_ITEM = ConfigItem.createConfigItem(config.getString("MyPet.Pets.Ocelot.GrowUpItem", "" + Material.POTION.getId()));
MyPet.Pig.GROW_UP_ITEM = ConfigItem.createConfigItem(config.getString("MyPet.Pets.Pig.GrowUpItem", "" + Material.POTION.getId()));
MyPet.Sheep.GROW_UP_ITEM = ConfigItem.createConfigItem(config.getString("MyPet.Pets.Sheep.GrowUpItem", "" + Material.POTION.getId()));
MyPet.Villager.GROW_UP_ITEM = ConfigItem.createConfigItem(config.getString("MyPet.Pets.Villager.GrowUpItem", "" + Material.POTION.getId()));
MyPet.Wolf.GROW_UP_ITEM = ConfigItem.createConfigItem(config.getString("MyPet.Pets.Wolf.GrowUpItem", "" + Material.POTION.getId()));
MyPet.Zombie.GROW_UP_ITEM = ConfigItem.createConfigItem(config.getString("MyPet.Pets.Zombie.GrowUpItem", "" + Material.POTION.getId()));
MyPet.PigZombie.GROW_UP_ITEM = ConfigItem.createConfigItem(config.getString("MyPet.Pets.PigZombie.GrowUpItem", "" + Material.POTION.getId()));
MyPet.Rabbit.GROW_UP_ITEM = ConfigItem.createConfigItem(config.getString("MyPet.Pets.Rabbit.GrowUpItem", "" + Material.POTION.getId()));
for (MyPetType petType : MyPetType.values()) {
DefaultInfo pi = petType.getMyPetClass().getAnnotation(DefaultInfo.class);
MyPetApi.getMyPetInfo().setStartHP(petType, config.getDouble("MyPet.Pets." + petType.name() + ".HP", pi.hp()));
MyPetApi.getMyPetInfo().setSpeed(petType, config.getDouble("MyPet.Pets." + petType.name() + ".Speed", pi.walkSpeed()));
if (config.get("MyPet.Pets." + petType.name() + ".Food") instanceof ArrayList) {
List<String> foodList = config.getStringList("MyPet.Pets." + petType.name() + ".Food");
for (String foodString : foodList) {
ConfigItem ci = ConfigItem.createConfigItem(foodString);
if (ci.getItem() != null && ci.getItem().getType() != Material.AIR) {
MyPetApi.getMyPetInfo().setFood(petType, ci);
} else {
MyPetApi.getLogger().warning(foodString + " is not a valid food item!");
}
}
} else {
seperateFood(petType, config.getString("MyPet.Pets." + petType.name() + ".Food", "0"));
}
seperateLeashFlags(petType, config.getString("MyPet.Pets." + petType + ".LeashFlags", linkLeashFlags(pi.leashFlags())));
MyPetApi.getMyPetInfo().setCustomRespawnTimeFactor(petType, config.getInt("MyPet.Pets." + petType.name() + ".CustomRespawnTimeFactor", 0));
MyPetApi.getMyPetInfo().setCustomRespawnTimeFixed(petType, config.getInt("MyPet.Pets." + petType.name() + ".CustomRespawnTimeFixed", 0));
MyPetApi.getMyPetInfo().setLeashItem(petType, ConfigItem.createConfigItem(config.getString("MyPet.Pets." + petType.name() + ".LeashItem", "" + Material.LEASH.getId())));
}
}
use of org.bukkit.configuration.file.FileConfiguration in project MyPet by xXKeyleXx.
the class ConfigurationLoader method setDefault.
public static void setDefault() {
FileConfiguration config = MyPetApi.getPlugin().getConfig();
config.options().header("" + "########################################################\n" + " This is the main configuration of MyPet #\n" + " You can find more info in the wiki: #\n" + " https://wiki.mypet-plugin.de/configfile #\n" + "########################################################\n");
config.options().copyHeader(true);
config.addDefault("MyPet.Update.Check", Update.CHECK);
config.addDefault("MyPet.Update.Download", Update.DOWNLOAD);
config.addDefault("MyPet.Update.ReplaceOld", Update.REPLACE_OLD);
config.addDefault("MyPet.Update.In-Background", Update.ASYNC);
config.addDefault("MyPet.Leash.Consume", Misc.CONSUME_LEASH_ITEM);
config.addDefault("MyPet.Leash.AllowRanged", Misc.ALLOW_RANGED_LEASHING);
config.addDefault("MyPet.OwnerCanAttackPet", Misc.OWNER_CAN_ATTACK_PET);
config.addDefault("MyPet.DisablePetVersusPlayer", Misc.DISABLE_PET_VS_PLAYER);
config.addDefault("MyPet.RemovePetsAfterRelease", Misc.REMOVE_PETS_AFTER_RELEASE);
config.addDefault("MyPet.FollowStartDistance", Misc.MYPET_FOLLOW_START_DISTANCE);
config.addDefault("MyPet.ReleasePetsOnDeath", Misc.RELEASE_PETS_ON_DEATH);
config.addDefault("MyPet.RetainEquipmentOnTame", Misc.RETAIN_EQUIPMENT_ON_TAME);
config.addDefault("MyPet.Make-Pet-Invisible-When-Owner-Is-Invisible", Misc.INVISIBLE_LIKE_OWNER);
config.addDefault("MyPet.Log.Level", Log.LEVEL);
config.addDefault("MyPet.Max-Stored-Pet-Count", Misc.MAX_STORED_PET_COUNT);
config.addDefault("MyPet.Throw-PlayerMoveEvent-While-Riding", Misc.THROW_PLAYER_MOVE_EVENT_WHILE_RIDING);
config.addDefault("MyPet.Disable-All-Actionbar-Messages", Misc.DISABLE_ALL_ACTIONBAR_MESSAGES);
config.addDefault("MyPet.OverwriteLanguages", Misc.OVERWRITE_LANGUAGE);
config.addDefault("MyPet.Respawn.Time.Default.Factor", Respawn.TIME_FACTOR);
config.addDefault("MyPet.Respawn.Time.Player.Factor", Respawn.TIME_PLAYER_FACTOR);
config.addDefault("MyPet.Respawn.Time.Default.Fixed", Respawn.TIME_FIXED);
config.addDefault("MyPet.Respawn.Time.Player.Fixed", Respawn.TIME_PLAYER_FIXED);
config.addDefault("MyPet.Respawn.EconomyCost.Fixed", Respawn.COSTS_FIXED);
config.addDefault("MyPet.Respawn.EconomyCost.Factor", Respawn.COSTS_FACTOR);
config.addDefault("MyPet.Permissions.Enabled", Permissions.ENABLED);
config.addDefault("MyPet.Permissions.Extended", Permissions.EXTENDED);
config.addDefault("MyPet.Permissions.Legacy", Permissions.LEGACY);
config.addDefault("MyPet.LevelSystem.CalculationMode", LevelSystem.CALCULATION_MODE);
config.addDefault("MyPet.HungerSystem.Active", HungerSystem.USE_HUNGER_SYSTEM);
config.addDefault("MyPet.HungerSystem.Time", HungerSystem.HUNGER_SYSTEM_TIME);
config.addDefault("MyPet.HungerSystem.SaturationPerFeed", HungerSystem.HUNGER_SYSTEM_SATURATION_PER_FEED);
config.addDefault("MyPet.HungerSystem.Affect-Ride-Speed", HungerSystem.AFFECT_RIDE_SPEED);
config.addDefault("MyPet.HungerSystem.Affect-Beacon-Range", HungerSystem.AFFECT_BEACON_RANGE);
config.addDefault("MyPet.Skilltree.AutomaticAssignment", Skilltree.AUTOMATIC_SKILLTREE_ASSIGNMENT);
config.addDefault("MyPet.Skilltree.RandomAssignment", Skilltree.RANDOM_SKILLTREE_ASSIGNMENT);
config.addDefault("MyPet.Skilltree.InheritAlreadyInheritedSkills", Skilltree.INHERIT_ALREADY_INHERITED_SKILLS);
config.addDefault("MyPet.Skilltree.ChooseOnce", Skilltree.CHOOSE_SKILLTREE_ONLY_ONCE);
config.addDefault("MyPet.Skilltree.PreventLevellingWithout", Skilltree.PREVENT_LEVELLING_WITHOUT_SKILLTREE);
config.addDefault("MyPet.Skilltree.SwitchFee.Fixed", Skilltree.SWITCH_FEE_FIXED);
config.addDefault("MyPet.Skilltree.SwitchFee.Percent", Skilltree.SWITCH_FEE_PERCENT);
config.addDefault("MyPet.Skilltree.SwitchFee.Admin", Skilltree.SWITCH_FEE_ADMIN);
config.addDefault("MyPet.Hooks.Kingdoms", Hooks.USE_Kingdoms);
config.addDefault("MyPet.Hooks.Towny", Hooks.USE_Towny);
config.addDefault("MyPet.Hooks.Heroes", Hooks.USE_Heroes);
config.addDefault("MyPet.Hooks.Factions", Hooks.USE_Factions);
config.addDefault("MyPet.Hooks.WorldGuard", Hooks.USE_WorldGuard);
config.addDefault("MyPet.Hooks.Citizens", Hooks.USE_Citizens);
config.addDefault("MyPet.Hooks.mcMMO", Hooks.USE_McMMO);
config.addDefault("MyPet.Hooks.SimpleClans", Hooks.USE_SimpleClans);
config.addDefault("MyPet.Hooks.RedProtect", Hooks.USE_RedProtect);
config.addDefault("MyPet.Hooks.MobArena.Enabled", Hooks.MobArena.ENABLED);
config.addDefault("MyPet.Hooks.MobArena.AllowPets", Hooks.MobArena.ALLOW_PETS);
config.addDefault("MyPet.Hooks.MobArena.RespectPvPRule", Hooks.MobArena.RESPECT_PVP_RULE);
config.addDefault("MyPet.Hooks.Residence", Hooks.USE_Residence);
config.addDefault("MyPet.Hooks.AncientRPG", Hooks.USE_AncientRPG);
config.addDefault("MyPet.Hooks.GriefPrevention", Hooks.USE_GriefPrevention);
config.addDefault("MyPet.Hooks.PvPManager", Hooks.USE_PvPManager);
config.addDefault("MyPet.Hooks.PvPDiffTimer", Hooks.USE_PvPDiffTimer);
config.addDefault("MyPet.Hooks.Minigames.DisablePetsInGames", Hooks.DISABLE_PETS_IN_MINIGAMES);
config.addDefault("MyPet.Hooks.PvPArena.DisablePetsInArena", Hooks.DISABLE_PETS_IN_ARENA);
config.addDefault("MyPet.Hooks.PlotSquared", Hooks.USE_PlotSquared);
config.addDefault("MyPet.Hooks.PvPArena.PvP", Hooks.USE_PvPArena);
config.addDefault("MyPet.Hooks.SurvivalGames.PvP", Hooks.USE_SurvivalGame);
config.addDefault("MyPet.Hooks.SurvivalGames.DisablePetsInGames", Hooks.DISABLE_PETS_IN_SURVIVAL_GAMES);
config.addDefault("MyPet.Hooks.MyHungerGames.DisablePetsInGames", Hooks.DISABLE_PETS_IN_HUNGER_GAMES);
config.addDefault("MyPet.Hooks.BattleArena.DisablePetsInArena", Hooks.DISABLE_PETS_IN_ARENA);
config.addDefault("MyPet.Hooks.Vault.Economy", Hooks.USE_ECONOMY);
config.addDefault("MyPet.Hooks.SkillAPI.GrantExp", Hooks.SkillAPI.GRANT_EXP);
config.addDefault("MyPet.Hooks.SkillAPI.Disable-Vanilla-Exp", Hooks.SkillAPI.DISABLE_VANILLA_EXP);
config.addDefault("MyPet.Hooks.MythicMobs.Disable-Leashing", Hooks.DISABLE_MYTHIC_MOB_LEASHING);
config.addDefault("MyPet.Name.Filter", Lists.newArrayList("whore", "fuck"));
config.addDefault("MyPet.Name.MaxLength", Name.MAX_LENGTH);
config.addDefault("MyPet.Name.Tag.Show", Name.Tag.SHOW);
config.addDefault("MyPet.Name.Tag.Prefix", Name.Tag.PREFIX);
config.addDefault("MyPet.Name.Tag.Suffix", Name.Tag.SUFFIX);
config.addDefault("MyPet.Exp.DamageWeightedExperienceDistribution", LevelSystem.Experience.DAMAGE_WEIGHTED_EXPERIENCE_DISTRIBUTION);
config.addDefault("MyPet.Exp.Passive.Always-Grant-Passive-XP", LevelSystem.Experience.ALWAYS_GRANT_PASSIVE_XP);
config.addDefault("MyPet.Exp.Passive.PercentPerMonster", LevelSystem.Experience.PASSIVE_PERCENT_PER_MONSTER);
config.addDefault("MyPet.Exp.Loss.Percent", LevelSystem.Experience.LOSS_PERCENT);
config.addDefault("MyPet.Exp.Loss.Fixed", LevelSystem.Experience.LOSS_FIXED);
config.addDefault("MyPet.Exp.Loss.Drop", LevelSystem.Experience.DROP_LOST_EXP);
config.addDefault("MyPet.Exp.Gain.PreventFromSpawnReason", new ArrayList<>());
config.addDefault("MyPet.Exp.LevelCap", LevelSystem.Experience.LEVEL_CAP);
config.addDefault("MyPet.Exp.Disabled-Worlds", new String[0]);
config.addDefault("MyPet.Skill.Control.Item", Material.LEASH.getId());
config.addDefault("MyPet.Skill.Inventory.Creative", Skilltree.Skill.Inventory.OPEN_IN_CREATIVE);
config.addDefault("MyPet.Skill.Inventory.DropWhenOwnerDies", Skilltree.Skill.Inventory.DROP_WHEN_OWNER_DIES);
config.addDefault("MyPet.Skill.Beacon.HungerDecreaseTime", Skilltree.Skill.Beacon.HUNGER_DECREASE_TIME);
config.addDefault("MyPet.Skill.Beacon.Party-Support", Skilltree.Skill.Beacon.PARTY_SUPPORT);
config.addDefault("MyPet.Skill.Ride.Item", Material.LEASH.getId());
config.addDefault("MyPet.Skill.Ride.HungerPerMeter", Skilltree.Skill.Ride.HUNGER_PER_METER);
config.addDefault("MyPet.Info.Wiki-URL", Misc.WIKI_URL);
for (EntityType entityType : EntityType.values()) {
if (MonsterExperience.mobExp.containsKey(entityType.name())) {
config.addDefault("MyPet.Exp.Active." + entityType.name() + ".Min", MonsterExperience.getMonsterExperience(entityType).getMin());
config.addDefault("MyPet.Exp.Active." + entityType.name() + ".Max", MonsterExperience.getMonsterExperience(entityType).getMax());
}
}
config.options().copyDefaults(true);
MyPetApi.getPlugin().saveConfig();
File petConfigFile = new File(MyPetApi.getPlugin().getDataFolder().getPath() + File.separator + "pet-config.yml");
config = new YamlConfiguration();
if (petConfigFile.exists()) {
try {
config.load(petConfigFile);
} catch (IOException | InvalidConfigurationException e) {
e.printStackTrace();
}
}
config.options().header("" + "#######################################################\n" + " This is the pet configuration of MyPet #\n" + " You can find more info in the wiki: #\n" + " https://wiki.mypet-plugin.de/petconfig #\n" + "#######################################################\n");
config.options().copyHeader(true);
for (MyPetType petType : MyPetType.values()) {
DefaultInfo pi = petType.getMyPetClass().getAnnotation(DefaultInfo.class);
if (pi == null) {
continue;
}
config.addDefault("MyPet.Pets." + petType.name() + ".HP", pi.hp());
config.addDefault("MyPet.Pets." + petType.name() + ".Speed", pi.walkSpeed());
config.addDefault("MyPet.Pets." + petType.name() + ".Food", linkFood(pi.food()));
config.addDefault("MyPet.Pets." + petType.name() + ".LeashFlags", linkLeashFlags(pi.leashFlags()));
config.addDefault("MyPet.Pets." + petType.name() + ".CustomRespawnTimeFactor", 0);
config.addDefault("MyPet.Pets." + petType.name() + ".CustomRespawnTimeFixed", 0);
config.addDefault("MyPet.Pets." + petType.name() + ".LeashItem", Material.LEASH.getId());
}
config.addDefault("MyPet.Pets.Chicken.CanLayEggs", MyPet.Chicken.CAN_LAY_EGGS);
config.addDefault("MyPet.Pets.Cow.CanGiveMilk", MyPet.Cow.CAN_GIVE_MILK);
config.addDefault("MyPet.Pets.Sheep.CanBeSheared", MyPet.Sheep.CAN_BE_SHEARED);
config.addDefault("MyPet.Pets.Sheep.CanRegrowWool", MyPet.Sheep.CAN_REGROW_WOOL);
config.addDefault("MyPet.Pets.IronGolem.CanThrowUp", MyPet.IronGolem.CAN_THROW_UP);
config.addDefault("MyPet.Pets.Snowman.FixSnowTrack", MyPet.Snowman.FIX_SNOW_TRACK);
config.addDefault("MyPet.Pets.Chicken.GrowUpItem", Material.POTION.getId());
config.addDefault("MyPet.Pets.Cow.GrowUpItem", Material.POTION.getId());
config.addDefault("MyPet.Pets.Horse.GrowUpItem", Material.BREAD.getId());
config.addDefault("MyPet.Pets.Llama.GrowUpItem", Material.POTION.getId());
config.addDefault("MyPet.Pets.Mooshroom.GrowUpItem", Material.POTION.getId());
config.addDefault("MyPet.Pets.Mooshroom.CanGiveStew", MyPet.Mooshroom.CAN_GIVE_SOUP);
config.addDefault("MyPet.Pets.Ocelot.GrowUpItem", Material.POTION.getId());
config.addDefault("MyPet.Pets.Pig.GrowUpItem", Material.POTION.getId());
config.addDefault("MyPet.Pets.Sheep.GrowUpItem", Material.POTION.getId());
config.addDefault("MyPet.Pets.Villager.GrowUpItem", Material.POTION.getId());
config.addDefault("MyPet.Pets.Wolf.GrowUpItem", Material.POTION.getId());
config.addDefault("MyPet.Pets.Zombie.GrowUpItem", Material.POTION.getId());
config.addDefault("MyPet.Pets.PigZombie.GrowUpItem", Material.POTION.getId());
config.addDefault("MyPet.Pets.Rabbit.GrowUpItem", Material.POTION.getId());
config.options().copyDefaults(true);
try {
config.save(petConfigFile);
} catch (IOException e) {
e.printStackTrace();
}
}
use of org.bukkit.configuration.file.FileConfiguration in project MyPet by xXKeyleXx.
the class ConfigurationLoader method upgradeConfig.
public static void upgradeConfig() {
FileConfiguration config = MyPetApi.getPlugin().getConfig();
if (config.contains("MyPet.Skilltree.SwitchPenalty.Fixed")) {
Skilltree.SWITCH_FEE_FIXED = config.getDouble("MyPet.Skilltree.SwitchPenalty.Fixed", 0.0);
Skilltree.SWITCH_FEE_PERCENT = config.getInt("MyPet.Skilltree.SwitchPenalty.Percent", 5);
Skilltree.SWITCH_FEE_ADMIN = config.getBoolean("MyPet.Skilltree.SwitchPenalty.Admin", false);
config.getConfigurationSection("MyPet.Skilltree").set("SwitchPenalty", null);
}
if (config.contains("MyPet.Hooks.MobArena.DisablePetsInArena")) {
Hooks.MobArena.ALLOW_PETS = !config.getBoolean("MyPet.Hooks.MobArena.DisablePetsInArena", false);
Hooks.MobArena.RESPECT_PVP_RULE = config.getBoolean("MyPet.Hooks.MobArena.PvP", true);
config.getConfigurationSection("MyPet.Hooks.MobArena").set("DisablePetsInArena", null);
config.getConfigurationSection("MyPet.Hooks.MobArena").set("PvP", null);
}
if (config.contains("MyPet.Name.OverHead")) {
Name.Tag.SHOW = config.getBoolean("MyPet.Name.OverHead.Visible", Name.Tag.SHOW);
Name.Tag.PREFIX = config.getString("MyPet.Name.OverHead.Prefix", Name.Tag.PREFIX);
Name.Tag.SUFFIX = config.getString("MyPet.Name.OverHead.Suffix", Name.Tag.SUFFIX);
config.getConfigurationSection("MyPet.Name").set("OverHead", null);
}
if (config.contains("MyPet.Update-Check")) {
Update.CHECK = config.getBoolean("MyPet.Update-Check", Update.CHECK);
config.getConfigurationSection("MyPet").set("Update-Check", null);
}
if (config.contains("MyPet.HungerSystem.HungerPointsPerFeed")) {
HungerSystem.HUNGER_SYSTEM_SATURATION_PER_FEED = config.getDouble("MyPet.HungerSystem.HungerPointsPerFeed", HungerSystem.HUNGER_SYSTEM_SATURATION_PER_FEED);
config.getConfigurationSection("MyPet.HungerSystem").set("HungerPointsPerFeed", null);
}
if (config.contains("MyPet.Backup")) {
config.getConfigurationSection("MyPet").set("Backup", null);
}
MyPetApi.getPlugin().saveConfig();
File petConfigFile = new File(MyPetApi.getPlugin().getDataFolder().getPath() + File.separator + "pet-config.yml");
config = new YamlConfiguration();
if (petConfigFile.exists()) {
try {
config.load(petConfigFile);
} catch (IOException | InvalidConfigurationException e) {
e.printStackTrace();
}
}
try {
config.save(petConfigFile);
} catch (IOException e) {
e.printStackTrace();
}
}
use of org.bukkit.configuration.file.FileConfiguration in project Network-depr by Mas281.
the class Lang method registerLocale.
/**
* Registers a locale
*
* @param locale The locale to register
*/
private void registerLocale(String locale) {
FileConfiguration config = getLocaleConfig(locale);
if (config == null) {
logFatal("Unable to fetch FileConfiguration instance for locale " + locale);
return;
}
LangData data = new LangData();
locales.put(locale, data);
for (String messageId : config.getKeys(true)) {
if (!config.isConfigurationSection(messageId)) {
String message = UtilString.colour(config.getString(messageId));
data.addMessage(messageId.toLowerCase(), message);
}
}
}
Aggregations