Browse Source

Increase compatiblility with crazy enchants

nossr50 6 năm trước cách đây
mục cha
commit
517ca6568f

+ 3 - 0
Changelog.txt

@@ -1,3 +1,6 @@
+Version 2.1.91
+    mcMMO is now more compatible with plugins that spawn arrows in unexpected ways, this fixes some NPE in mcMMO when using certain plugins
+
 Version 2.1.90
 Version 2.1.90
     Salvaged items now travel much slower towards the player
     Salvaged items now travel much slower towards the player
     Books from salvage will now travel towards the player
     Books from salvage will now travel towards the player

+ 1 - 1
pom.xml

@@ -2,7 +2,7 @@
     <modelVersion>4.0.0</modelVersion>
     <modelVersion>4.0.0</modelVersion>
     <groupId>com.gmail.nossr50.mcMMO</groupId>
     <groupId>com.gmail.nossr50.mcMMO</groupId>
     <artifactId>mcMMO</artifactId>
     <artifactId>mcMMO</artifactId>
-    <version>2.1.90</version>
+    <version>2.1.91-SNAPSHOT</version>
     <name>mcMMO</name>
     <name>mcMMO</name>
     <url>https://github.com/mcMMO-Dev/mcMMO</url>
     <url>https://github.com/mcMMO-Dev/mcMMO</url>
     <scm>
     <scm>

+ 0 - 1
src/main/java/com/gmail/nossr50/listeners/EntityListener.java

@@ -128,7 +128,6 @@ public class EntityListener implements Listener {
 
 
         if(event.getEntity().getShooter() instanceof Player)
         if(event.getEntity().getShooter() instanceof Player)
         {
         {
-
             Player player = (Player) event.getEntity().getShooter();
             Player player = (Player) event.getEntity().getShooter();
 
 
             /* WORLD GUARD MAIN FLAG CHECK */
             /* WORLD GUARD MAIN FLAG CHECK */

+ 4 - 0
src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java

@@ -53,6 +53,10 @@ public class ArcheryManager extends SkillManager {
      * @param damager The {@link Entity} who shot the arrow
      * @param damager The {@link Entity} who shot the arrow
      */
      */
     public double distanceXpBonusMultiplier(LivingEntity target, Entity damager) {
     public double distanceXpBonusMultiplier(LivingEntity target, Entity damager) {
+        //Hacky Fix - some plugins spawn arrows and assign them to players after the ProjectileLaunchEvent fires
+        if(!damager.hasMetadata(mcMMO.arrowDistanceKey))
+            return damager.getLocation().distance(target.getLocation());
+
         Location firedLocation = (Location) damager.getMetadata(mcMMO.arrowDistanceKey).get(0).value();
         Location firedLocation = (Location) damager.getMetadata(mcMMO.arrowDistanceKey).get(0).value();
         Location targetLocation = target.getLocation();
         Location targetLocation = target.getLocation();
 
 

+ 5 - 1
src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java

@@ -232,9 +232,13 @@ public final class CombatUtils {
         }
         }
 
 
         double distanceMultiplier = archeryManager.distanceXpBonusMultiplier(target, arrow);
         double distanceMultiplier = archeryManager.distanceXpBonusMultiplier(target, arrow);
+        double forceMultiplier = 1.0; //Hacky Fix - some plugins spawn arrows and assign them to players after the ProjectileLaunchEvent fires
+
+        if(arrow.hasMetadata(mcMMO.bowForceKey))
+            forceMultiplier = arrow.getMetadata(mcMMO.bowForceKey).get(0).asDouble();
 
 
         applyScaledModifiers(initialDamage, finalDamage, event);
         applyScaledModifiers(initialDamage, finalDamage, event);
-        startGainXp(mcMMOPlayer, target, PrimarySkillType.ARCHERY, arrow.getMetadata(mcMMO.bowForceKey).get(0).asDouble() * distanceMultiplier);
+        startGainXp(mcMMOPlayer, target, PrimarySkillType.ARCHERY, forceMultiplier * distanceMultiplier);
     }
     }
 
 
     /**
     /**