use of de.Keyle.MyPet.api.skill.experience.MonsterExperience in project MyPet by xXKeyleXx.
the class MyPetExperience method addExp.
public double addExp(Entity entity, int percent, boolean modify) {
MonsterExperience monsterExperience = MonsterExperience.getMonsterExperience(entity);
if (monsterExperience != MonsterExperience.UNKNOWN) {
double exp = monsterExperience.getRandomExp();
if (modify) {
exp = modifyExp(exp);
}
exp = exp * percent / 100.;
return uppdateExp(exp, false);
}
return 0;
}
use of de.Keyle.MyPet.api.skill.experience.MonsterExperience in project MyPet by xXKeyleXx.
the class MyPetExperience method addExp.
public double addExp(EntityType type, int percent) {
MonsterExperience monsterExperience = MonsterExperience.getMonsterExperience(type);
if (monsterExperience.getEntityType() != EntityType.UNKNOWN) {
double exp = monsterExperience.getRandomExp() / 100. * percent;
MyPetExpEvent expEvent = new MyPetExpEvent(myPet, this.exp, Math.min(levelCapExp, this.exp + exp));
Bukkit.getServer().getPluginManager().callEvent(expEvent);
if (expEvent.isCancelled()) {
return 0;
}
int tmpLvl = getLevel();
this.exp = expEvent.getExp();
if (tmpLvl < getLevel()) {
Bukkit.getServer().getPluginManager().callEvent(new MyPetLevelUpEvent(myPet, getLevel(), tmpLvl));
}
return expEvent.getNewExp() - expEvent.getOldExp();
}
return 0;
}
use of de.Keyle.MyPet.api.skill.experience.MonsterExperience in project MyPet by xXKeyleXx.
the class MyPetExperience method addExp.
public double addExp(EntityType type) {
MonsterExperience monsterExperience = MonsterExperience.getMonsterExperience(type);
if (monsterExperience.getEntityType() != EntityType.UNKNOWN) {
MyPetExpEvent expEvent = new MyPetExpEvent(myPet, this.exp, Math.min(levelCapExp, monsterExperience.getRandomExp() + this.exp));
Bukkit.getServer().getPluginManager().callEvent(expEvent);
if (expEvent.isCancelled()) {
return 0;
}
int tmpLvl = getLevel();
this.exp = expEvent.getExp();
if (tmpLvl < getLevel()) {
Bukkit.getServer().getPluginManager().callEvent(new MyPetLevelUpEvent(myPet, getLevel(), tmpLvl));
}
return expEvent.getNewExp() - expEvent.getOldExp();
}
return 0;
}
use of de.Keyle.MyPet.api.skill.experience.MonsterExperience in project MyPet by xXKeyleXx.
the class ConfigurationLoader method loadConfiguration.
public static void loadConfiguration() {
MyPetApi.getPlugin().reloadConfig();
FileConfiguration config = MyPetApi.getPlugin().getConfig();
Misc.CONSUME_LEASH_ITEM = config.getBoolean("MyPet.Leash.Consume", false);
Misc.ALLOW_RANGED_LEASHING = config.getBoolean("MyPet.Leash.AllowRanged", true);
Misc.MAX_STORED_PET_COUNT = config.getInt("MyPet.Max-Stored-Pet-Count", Misc.MAX_STORED_PET_COUNT);
Misc.RIGHT_CLICK_COMMAND = config.getString("MyPet.Right-Click-Command", Misc.RIGHT_CLICK_COMMAND);
if (Misc.RIGHT_CLICK_COMMAND.startsWith("/")) {
Misc.RIGHT_CLICK_COMMAND = Misc.RIGHT_CLICK_COMMAND.substring(1);
}
Misc.RECALL_PET_AFTER_DESPAWN = config.getBoolean("MyPet.Recall-Pet-After-Despawn", Misc.RECALL_PET_AFTER_DESPAWN);
Update.ASYNC = config.getBoolean("MyPet.Update.In-Background", Update.ASYNC);
Update.CHECK = config.getBoolean("MyPet.Update.Check", Update.CHECK);
Update.DOWNLOAD = config.getBoolean("MyPet.Update.Download", Update.DOWNLOAD);
Update.REPLACE_OLD = config.getBoolean("MyPet.Update.ReplaceOld", Update.REPLACE_OLD);
Update.SHOW_OP = config.getBoolean("MyPet.Update.OP-Notification", Update.SHOW_OP);
Skilltree.Skill.Beacon.HUNGER_DECREASE_TIME = config.getInt("MyPet.Skill.Beacon.HungerDecreaseTime", 100);
Skilltree.Skill.Beacon.PARTY_SUPPORT = config.getBoolean("MyPet.Skill.Beacon.Party-Support", true);
Skilltree.Skill.Beacon.DISABLE_HEAD_TEXTURE = config.getBoolean("MyPet.Skill.Beacon.Disable-Head-Textures", false);
Skilltree.Skill.Backpack.OPEN_IN_CREATIVE = config.getBoolean("MyPet.Skill.Backpack.Creative", true);
Skilltree.Skill.Backpack.DROP_WHEN_OWNER_DIES = config.getBoolean("MyPet.Skill.Backpack.DropWhenOwnerDies", false);
Skilltree.Skill.Ride.HUNGER_PER_METER = config.getDouble("MyPet.Skill.Ride.HungerPerMeter", 0.01);
Skilltree.Skill.Ride.PREVENT_TELEPORTATION = config.getBoolean("MyPet.Skill.Ride.Prevent-Teleportation-While-Riding", false);
Skilltree.SWITCH_FEE_FIXED = config.getDouble("MyPet.Skilltree.SwitchFee.Fixed", 0.0);
Skilltree.SWITCH_FEE_PERCENT = config.getInt("MyPet.Skilltree.SwitchFee.Percent", 5);
Skilltree.SWITCH_FEE_ADMIN = config.getBoolean("MyPet.Skilltree.SwitchFee.Admin", false);
Respawn.DISABLE_AUTO_RESPAWN = config.getBoolean("MyPet.Respawn.Time.Disabled", false);
Respawn.TIME_FACTOR = config.getInt("MyPet.Respawn.Time.Default.Factor", 5);
Respawn.TIME_PLAYER_FACTOR = config.getInt("MyPet.Respawn.Time.Player.Factor", 5);
Respawn.TIME_FIXED = config.getInt("MyPet.Respawn.Time.Default.Fixed", 0);
Respawn.TIME_PLAYER_FIXED = config.getInt("MyPet.Respawn.Time.Player.Fixed", 0);
Respawn.COSTS_FACTOR = config.getDouble("MyPet.Respawn.EconomyCost.Factor", 1.0);
Respawn.COSTS_FIXED = config.getDouble("MyPet.Respawn.EconomyCost.Fixed", 0.0);
Skilltree.AUTOMATIC_SKILLTREE_ASSIGNMENT = config.getBoolean("MyPet.Skilltree.AutomaticAssignment", false);
Skilltree.RANDOM_SKILLTREE_ASSIGNMENT = config.getBoolean("MyPet.Skilltree.RandomAssignment", false);
Skilltree.CHOOSE_SKILLTREE_ONLY_ONCE = config.getBoolean("MyPet.Skilltree.ChooseOnce", false);
Skilltree.PREVENT_LEVELLING_WITHOUT_SKILLTREE = config.getBoolean("MyPet.Skilltree.PreventLevellingWithout", true);
Misc.OWNER_CAN_ATTACK_PET = config.getBoolean("MyPet.OwnerCanAttackPet", false);
Misc.DISABLE_PET_VS_PLAYER = config.getBoolean("MyPet.DisablePetVersusPlayer", false);
HungerSystem.USE_HUNGER_SYSTEM = config.getBoolean("MyPet.HungerSystem.Active", true);
HungerSystem.HUNGER_SYSTEM_TIME = config.getInt("MyPet.HungerSystem.Time", 60);
HungerSystem.HUNGER_SYSTEM_SATURATION_PER_FEED = config.getDouble("MyPet.HungerSystem.SaturationPerFeed", 6.0);
HungerSystem.AFFECT_RIDE_SPEED = config.getBoolean("MyPet.HungerSystem.Affect-Ride-Speed", true);
HungerSystem.AFFECT_BEACON_RANGE = config.getBoolean("MyPet.HungerSystem.Affect-Beacon-Range", true);
Misc.RETAIN_EQUIPMENT_ON_TAME = config.getBoolean("MyPet.RetainEquipmentOnTame", true);
Misc.INVISIBLE_LIKE_OWNER = config.getBoolean("MyPet.Make-Pet-Invisible-When-Owner-Is-Invisible", true);
Misc.THROW_PLAYER_MOVE_EVENT_WHILE_RIDING = config.getBoolean("MyPet.Throw-PlayerMoveEvent-While-Riding", true);
Misc.DISABLE_ALL_ACTIONBAR_MESSAGES = config.getBoolean("MyPet.Disable-All-Actionbar-Messages", false);
Misc.OVERWRITE_LANGUAGE = config.getString("MyPet.OverwriteLanguages", "");
LevelSystem.CALCULATION_MODE = config.getString("MyPet.LevelSystem.CalculationMode", "Default");
Entity.MYPET_FOLLOW_START_DISTANCE = config.getDouble("MyPet.Entity.FollowStartDistance", 7.0D);
Entity.SKIP_TARGET_AI_TICKS = config.getInt("MyPet.Entity.Skip-Target-AI-Ticks", 0);
Log.LEVEL = config.getString("MyPet.Log.Level", Log.LEVEL);
NameFilter.NAME_FILTER.clear();
for (Object o : config.getList("MyPet.Name.Filter", Lists.newArrayList("whore", "fuck"))) {
NameFilter.NAME_FILTER.add(String.valueOf(o));
}
Name.MAX_LENGTH = config.getInt("MyPet.Name.MaxLength", Name.MAX_LENGTH);
Name.Tag.SHOW = config.getBoolean("MyPet.Name.Tag.Show", Name.Tag.SHOW);
Name.Tag.PREFIX = Colorizer.setColors(config.getString("MyPet.Name.Tag.Prefix", Name.Tag.PREFIX));
Name.Tag.SUFFIX = Colorizer.setColors(config.getString("MyPet.Name.Tag.Suffix", Name.Tag.SUFFIX));
Repository.REPOSITORY_TYPE = config.getString("MyPet.Repository.Type", Repository.REPOSITORY_TYPE);
Repository.CONVERT_FROM = config.getString("MyPet.Repository.ConvertFrom", Repository.CONVERT_FROM);
Repository.EXTERNAL_LOAD_DELAY = config.getLong("MyPet.Repository.LoadDelay", Repository.EXTERNAL_LOAD_DELAY);
Repository.MySQL.DATABASE = config.getString("MyPet.Repository.MySQL.Database", Repository.MySQL.DATABASE);
Repository.MySQL.PREFIX = config.getString("MyPet.Repository.MySQL.TablePrefix", Repository.MySQL.PREFIX);
Repository.MySQL.HOST = config.getString("MyPet.Repository.MySQL.Host", Repository.MySQL.HOST);
Repository.MySQL.PASSWORD = config.getString("MyPet.Repository.MySQL.Password", Repository.MySQL.PASSWORD);
Repository.MySQL.USER = config.getString("MyPet.Repository.MySQL.User", Repository.MySQL.USER);
Repository.MySQL.PORT = config.getInt("MyPet.Repository.MySQL.Port", Repository.MySQL.PORT);
Repository.MySQL.POOL_SIZE = config.getInt("MyPet.Repository.MySQL.MaxConnections", Repository.MySQL.POOL_SIZE);
Repository.MySQL.CHARACTER_ENCODING = config.getString("MyPet.Repository.MySQL.CharacterEncoding", Repository.MySQL.CHARACTER_ENCODING);
Repository.MongoDB.DATABASE = config.getString("MyPet.Repository.MongoDB.Database", Repository.MongoDB.DATABASE);
Repository.MongoDB.PREFIX = config.getString("MyPet.Repository.MongoDB.CollectionPrefix", Repository.MongoDB.PREFIX);
Repository.MongoDB.HOST = config.getString("MyPet.Repository.MongoDB.Host", Repository.MongoDB.HOST);
Repository.MongoDB.PASSWORD = config.getString("MyPet.Repository.MongoDB.Password", Repository.MongoDB.PASSWORD);
Repository.MongoDB.USER = config.getString("MyPet.Repository.MongoDB.User", Repository.MongoDB.USER);
Repository.MongoDB.PORT = config.getInt("MyPet.Repository.MongoDB.Port", Repository.MongoDB.PORT);
Misc.WIKI_URL = config.getString("MyPet.Info.Wiki-URL", Misc.WIKI_URL);
Permissions.EXTENDED = config.getBoolean("MyPet.Permissions.Extended", false);
Permissions.ENABLED = config.getBoolean("MyPet.Permissions.Enabled", true);
Permissions.LEGACY = config.getBoolean("MyPet.Permissions.Legacy", Permissions.LEGACY);
LevelSystem.Experience.LEVEL_CAP = config.getInt("MyPet.Exp.LevelCap", LevelSystem.Experience.LEVEL_CAP);
LevelSystem.Experience.LOSS_PERCENT = config.getInt("MyPet.Exp.Loss.Percent", 0);
LevelSystem.Experience.LOSS_FIXED = config.getDouble("MyPet.Exp.Loss.Fixed", 0.0);
LevelSystem.Experience.DROP_LOST_EXP = config.getBoolean("MyPet.Exp.Loss.Drop", true);
LevelSystem.Experience.ALLOW_LEVEL_DOWNGRADE = config.getBoolean("MyPet.Exp.Loss.Allow-Level-Drowngrade", false);
LevelSystem.Experience.PASSIVE_PERCENT_PER_MONSTER = config.getInt("MyPet.Exp.Passive.PercentPerMonster", 25);
LevelSystem.Experience.ALWAYS_GRANT_PASSIVE_XP = config.getBoolean("MyPet.Exp.Passive.Always-Grant-Passive-XP", true);
LevelSystem.Experience.DAMAGE_WEIGHTED_EXPERIENCE_DISTRIBUTION = config.getBoolean("MyPet.Exp.DamageWeightedExperienceDistribution", true);
LevelSystem.Experience.DISABLED_WORLDS.clear();
LevelSystem.Experience.DISABLED_WORLDS.addAll(config.getStringList("MyPet.Exp.Disabled-Worlds"));
LevelSystem.Experience.Modifier.GLOBAL = config.getDouble("MyPet.Exp.Modifier.Global", 1D);
LevelSystem.Experience.Modifier.PERMISSION = config.getBoolean("MyPet.Exp.Modifier.Use-Permissions", false);
if (config.contains("MyPet.Exp.Gain.PreventFromSpawnReason")) {
LevelSystem.Experience.PREVENT_FROM_SPAWN_REASON.clear();
if (config.isList("MyPet.Exp.Gain.PreventFromSpawnReason")) {
for (String reason : config.getStringList("MyPet.Exp.Gain.PreventFromSpawnReason")) {
reason = reason.toUpperCase();
try {
CreatureSpawnEvent.SpawnReason.valueOf(reason);
LevelSystem.Experience.PREVENT_FROM_SPAWN_REASON.add(reason);
} catch (Exception ignored) {
}
}
}
}
File expConfigFile = new File(MyPetApi.getPlugin().getDataFolder().getPath(), "exp-config.yml");
if (expConfigFile.exists()) {
YamlConfiguration ymlcnf = new YamlConfiguration();
try {
ymlcnf.load(expConfigFile);
config = ymlcnf;
} catch (IOException | InvalidConfigurationException e) {
MyPetApi.getLogger().warning("There was an error while loading exp-config.yml");
}
}
for (EntityType entityType : EntityType.values()) {
if (MonsterExperience.mobExp.containsKey(entityType.name())) {
double max = config.getDouble("Default." + entityType.name() + ".Max", 0.);
double min = config.getDouble("Default." + entityType.name() + ".Min", 0.);
if (min == max) {
MonsterExperience.getMonsterExperience(entityType.name()).setExp(max);
} else {
MonsterExperience.getMonsterExperience(entityType).setMin(min);
MonsterExperience.getMonsterExperience(entityType).setMax(max);
}
}
}
ConfigurationSection customExpSection = config.getConfigurationSection("Custom");
MonsterExperience.CUSTOM_MOB_EXP.clear();
if (customExpSection != null) {
for (String name : customExpSection.getKeys(false)) {
MonsterExperience exp = new MonsterExperience(0, 0, name);
double max = config.getDouble("Custom." + name + ".Max", 0.);
double min = config.getDouble("Custom." + name + ".Min", 0.);
if (min == max) {
exp.setExp(max);
} else {
exp.setMin(min);
exp.setMax(max);
}
MonsterExperience.addCustomExperience(exp);
}
}
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) {
MyPetApi.getLogger().warning("There was an error while loading pet-config.yml");
}
}
MyPet.Chicken.CAN_LAY_EGGS = config.getBoolean("MyPet.Pets.Chicken.CanLayEggs", true);
MyPet.Cow.CAN_GIVE_MILK = config.getBoolean("MyPet.Pets.Cow.CanGiveMilk", true);
MyPet.Sheep.CAN_BE_SHEARED = config.getBoolean("MyPet.Pets.Sheep.CanBeSheared", true);
MyPet.Sheep.CAN_REGROW_WOOL = config.getBoolean("MyPet.Pets.Sheep.CanRegrowWool", true);
MyPet.IronGolem.CAN_TOSS_UP = config.getBoolean("MyPet.Pets.IronGolem.CanTossUp", true);
MyPet.Snowman.FIX_SNOW_TRACK = config.getBoolean("MyPet.Pets.Snowman.FixSnowTrack", true);
MyPet.Mooshroom.CAN_GIVE_SOUP = config.getBoolean("MyPet.Pets.Mooshroom.CanGiveStew", false);
MyPet.Bee.CAN_GLIDE = config.getBoolean("MyPet.Pets.Bee.CanGlide", true);
MyPet.Bat.CAN_GLIDE = config.getBoolean("MyPet.Pets.Bat.CanGlide", true);
MyPet.Blaze.CAN_GLIDE = config.getBoolean("MyPet.Pets.Blaze.CanGlide", true);
MyPet.Ghast.CAN_GLIDE = config.getBoolean("MyPet.Pets.Ghast.CanGlide", true);
MyPet.Chicken.CAN_GLIDE = config.getBoolean("MyPet.Pets.Chicken.CanGlide", true);
MyPet.EnderDragon.CAN_GLIDE = config.getBoolean("MyPet.Pets.EnderDragon.CanGlide", true);
MyPet.Wither.CAN_GLIDE = config.getBoolean("MyPet.Pets.Wither.CanGlide", true);
MyPet.Vex.CAN_GLIDE = config.getBoolean("MyPet.Pets.Vex.CanGlide", true);
MyPet.Parrot.CAN_GLIDE = config.getBoolean("MyPet.Pets.Parrot.CanGlide", true);
MyPet.Phantom.CAN_GLIDE = config.getBoolean("MyPet.Pets.Phantom.CanGlide", true);
}
Aggregations