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,21 +161,24 @@ public class EntityListener implements Listener {
} }
Projectile projectile = event.getEntity(); Projectile projectile = event.getEntity();
EntityType entityType = projectile.getType();
if(!(projectile instanceof Arrow)) if(entityType == EntityType.ARROW || entityType == EntityType.SPECTRAL_ARROW) {
return; if(!projectile.hasMetadata(mcMMO.bowForceKey))
projectile.setMetadata(mcMMO.bowForceKey, new FixedMetadataValue(pluginRef, 1.0));
projectile.setMetadata(mcMMO.bowForceKey, new FixedMetadataValue(pluginRef, 1.0)); if(!projectile.hasMetadata(mcMMO.arrowDistanceKey))
projectile.setMetadata(mcMMO.arrowDistanceKey, new FixedMetadataValue(pluginRef, projectile.getLocation())); projectile.setMetadata(mcMMO.arrowDistanceKey, new FixedMetadataValue(pluginRef, projectile.getLocation()));
for (Enchantment enchantment : player.getInventory().getItemInMainHand().getEnchantments().keySet()) { for (Enchantment enchantment : player.getInventory().getItemInMainHand().getEnchantments().keySet()) {
if (enchantment.getKey().equals(piercingEnchantment)) { if (enchantment.getKey().equals(piercingEnchantment)) {
return; return;
}
} }
}
if (RandomChanceUtil.isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.ARCHERY_ARROW_RETRIEVAL, player)) { if (RandomChanceUtil.isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.ARCHERY_ARROW_RETRIEVAL, player)) {
projectile.setMetadata(mcMMO.trackedArrow, mcMMO.metadataValue); projectile.setMetadata(mcMMO.trackedArrow, mcMMO.metadataValue);
}
} }
} }
} }

View File

@ -36,6 +36,8 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.metadata.MetadataValue; import org.bukkit.metadata.MetadataValue;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import org.bukkit.projectiles.ProjectileSource; import org.bukkit.projectiles.ProjectileSource;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.EnumMap; import java.util.EnumMap;
import java.util.HashMap; import java.util.HashMap;
@ -117,9 +119,14 @@ public final class CombatUtils {
printFinalDamageDebug(player, event, mcMMOPlayer); 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()) { if(mcMMOPlayer.isDebugMode()) {
player.sendMessage("Final Damage value after mcMMO modifiers: "+ event.getFinalDamage()); 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(); forceMultiplier = arrow.getMetadata(mcMMO.bowForceKey).get(0).asDouble();
applyScaledModifiers(initialDamage, finalDamage, event); applyScaledModifiers(initialDamage, finalDamage, event);
processCombatXP(mcMMOPlayer, target, PrimarySkillType.ARCHERY, forceMultiplier * distanceMultiplier); 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);
} }
/** /**