Added option for XP gained by killing bred animals

Fixes #2402
This commit is contained in:
TfT_02 2015-01-10 12:31:13 +01:00
parent eddadcc179
commit 385fe1bb05
6 changed files with 23 additions and 5 deletions

View File

@ -10,6 +10,7 @@ Key:
Version 1.5.02-dev
+ Added option to config.yml for Chimaera Wings to stop using bed spawn points
+ Added option to config.yml to let non-tools in hand count as unarmed
+ Added option to experience.yml to control XP gained by killing bred animals
= Fixed bug where no Mining XP was granted when Flux Mining was successful
= Fixed bug where MobHealthbarTypes were not saved between server restarts
! Changed Flux Mining mechanics. In order to use the ability, you need to infuse a pickaxe with furnace powers first.

View File

@ -72,6 +72,11 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
reason.add("Experience_Formula.Mobspawners.Multiplier should be at least 0!");
}
/* Bred Mob modifier */
if (getBredMobXpMultiplier() < 0) {
reason.add("Experience_Formula.Breeding.Multiplier should be at least 0!");
}
/* Conversion */
if (getExpModifier() <= 0) {
reason.add("Conversion.Exp_Modifier should be greater than 0!");
@ -177,6 +182,7 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
/* Spawned Mob modifier */
public double getSpawnedMobXpMultiplier() { return config.getDouble("Experience_Formula.Mobspawners.Multiplier", 0.0); }
public double getBredMobXpMultiplier() { return config.getDouble("Experience_Formula.Breeding.Multiplier", 1.0); }
/* Skill modifiers */
public double getFormulaSkillModifier(SkillType skill) { return config.getDouble("Experience_Formula.Modifier." + StringUtils.getCapitalized(skill.toString())); }

View File

@ -416,19 +416,24 @@ public class EntityListener implements Listener {
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onCreatureSpawn(CreatureSpawnEvent event) {
LivingEntity entity = event.getEntity();
switch (event.getSpawnReason()) {
case SPAWNER:
case SPAWNER_EGG:
LivingEntity entity = event.getEntity();
Entity passenger = entity.getPassenger();
entity.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue);
Entity passenger = entity.getPassenger();
if (passenger != null) {
passenger.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue);
}
return;
case BREEDING:
entity.setMetadata(mcMMO.bredMetadataKey, mcMMO.metadataValue);
return;
default:
return;
}

View File

@ -121,6 +121,7 @@ public class mcMMO extends JavaPlugin {
public final static String greenThumbDataKey = "mcMMO: Green Thumb";
public final static String pistonDataKey = "mcMMO: Piston State";
public final static String databaseCommandKey = "mcMMO: Processing Database Command";
public final static String bredMetadataKey = "mcMMO: Bred Animal";
public static FixedMetadataValue metadataValue;

View File

@ -10,7 +10,6 @@ import org.bukkit.entity.Animals;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Guardian;
import org.bukkit.entity.IronGolem;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
@ -41,7 +40,6 @@ import com.gmail.nossr50.skills.axes.AxesManager;
import com.gmail.nossr50.skills.swords.Swords;
import com.gmail.nossr50.skills.swords.SwordsManager;
import com.gmail.nossr50.skills.taming.TamingManager;
import com.gmail.nossr50.skills.unarmed.Unarmed;
import com.gmail.nossr50.skills.unarmed.UnarmedManager;
import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.ItemUtils;
@ -50,6 +48,7 @@ import com.gmail.nossr50.util.MobHealthbarUtils;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.temp.CompatableGuardianXP;
import com.google.common.collect.ImmutableMap;
public final class CombatUtils {
@ -530,6 +529,10 @@ public final class CombatUtils {
baseXP *= ExperienceConfig.getInstance().getSpawnedMobXpMultiplier();
}
if (target.hasMetadata(mcMMO.bredMetadataKey)) {
baseXP *= ExperienceConfig.getInstance().getBredMobXpMultiplier();
}
xpGainReason = XPGainReason.PVE;
baseXP *= 10;

View File

@ -37,6 +37,8 @@ Experience_Formula:
# Experience gained from mobs not naturally spawned will get multiplied by this value. 0 by default.
Mobspawners:
Multiplier: 0
Breeding:
Multiplier: 1.0
# Experience gained will get divided by these values. 1.0 by default, 2.0 means two times less XP gained.
Modifier: