Fixed a bug where Spectral arrow awarded too much XP

This commit is contained in:
nossr50 2020-11-09 13:53:17 -08:00
parent 34d9f70ac0
commit da06d5c075
2 changed files with 27 additions and 12 deletions

View File

@ -161,11 +161,13 @@ public class EntityListener implements Listener {
}
Projectile projectile = event.getEntity();
EntityType entityType = projectile.getType();
if(!(projectile instanceof Arrow))
return;
if(entityType == EntityType.ARROW || entityType == EntityType.SPECTRAL_ARROW) {
if(!projectile.hasMetadata(mcMMO.bowForceKey))
projectile.setMetadata(mcMMO.bowForceKey, new FixedMetadataValue(pluginRef, 1.0));
if(!projectile.hasMetadata(mcMMO.arrowDistanceKey))
projectile.setMetadata(mcMMO.arrowDistanceKey, new FixedMetadataValue(pluginRef, projectile.getLocation()));
for (Enchantment enchantment : player.getInventory().getItemInMainHand().getEnchantments().keySet()) {
@ -179,6 +181,7 @@ public class EntityListener implements Listener {
}
}
}
}
/**
* Monitor EntityChangeBlock events.

View File

@ -36,6 +36,8 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.metadata.MetadataValue;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.projectiles.ProjectileSource;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.EnumMap;
import java.util.HashMap;
@ -117,9 +119,14 @@ public final class CombatUtils {
printFinalDamageDebug(player, event, mcMMOPlayer);
}
private static void printFinalDamageDebug(Player player, EntityDamageByEntityEvent event, McMMOPlayer mcMMOPlayer) {
private static void printFinalDamageDebug(@NotNull Player player, @NotNull EntityDamageByEntityEvent event, @NotNull McMMOPlayer mcMMOPlayer, @Nullable String... extraInfoLines) {
if(mcMMOPlayer.isDebugMode()) {
player.sendMessage("Final Damage value after mcMMO modifiers: "+ event.getFinalDamage());
if(extraInfoLines != null) {
for(String str : extraInfoLines) {
player.sendMessage(str);
}
}
}
}
@ -317,9 +324,14 @@ public final class CombatUtils {
forceMultiplier = arrow.getMetadata(mcMMO.bowForceKey).get(0).asDouble();
applyScaledModifiers(initialDamage, finalDamage, event);
processCombatXP(mcMMOPlayer, target, PrimarySkillType.ARCHERY, forceMultiplier * distanceMultiplier);
printFinalDamageDebug(player, event, mcMMOPlayer);
printFinalDamageDebug(player, event, mcMMOPlayer,
"Distance Multiplier: "+distanceMultiplier,
"Force Multiplier: "+forceMultiplier,
"Initial Damage: "+initialDamage,
"Final Damage: "+finalDamage);
}
/**