Prechádzať zdrojové kódy

fix thrown tridents not getting XP or subskill benefits

nossr50 1 rok pred
rodič
commit
cf49fc7599

+ 3 - 0
Changelog.txt

@@ -1,3 +1,6 @@
+Version 2.2.002
+    Fixed bug where thrown tridents did not grant XP or benefit from subskills
+
 Version 2.2.001
     Fixed Crossbow's Powered shot showing the text for the wrong skill from the locale when using /crossbows command
 

+ 1 - 1
pom.xml

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

+ 45 - 4
src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java

@@ -111,7 +111,7 @@ public final class CombatUtils {
             }
         }
     }
-    private static void processTridentCombat(@NotNull LivingEntity target, @NotNull Player player, @NotNull EntityDamageByEntityEvent event) {
+    private static void processTridentCombatMelee(@NotNull LivingEntity target, @NotNull Player player, @NotNull EntityDamageByEntityEvent event) {
         if (event.getCause() == DamageCause.THORNS) {
             return;
         }
@@ -127,10 +127,40 @@ public final class CombatUtils {
 
         TridentsManager tridentsManager = mcMMOPlayer.getTridentsManager();
 
-        if (tridentsManager.canActivateAbility()) {
-            mcMMOPlayer.checkAbilityActivation(PrimarySkillType.TRIDENTS);
+//        if (tridentsManager.canActivateAbility()) {
+//            mcMMOPlayer.checkAbilityActivation(PrimarySkillType.TRIDENTS);
+//        }
+
+        if (SkillUtils.canUseSubskill(player, SubSkillType.TRIDENTS_IMPALE)) {
+            boostedDamage += (tridentsManager.impaleDamageBonus() * mcMMOPlayer.getAttackStrength());
+        }
+
+        if(canUseLimitBreak(player, target, SubSkillType.TRIDENTS_TRIDENTS_LIMIT_BREAK)) {
+            boostedDamage += (getLimitBreakDamage(player, target, SubSkillType.TRIDENTS_TRIDENTS_LIMIT_BREAK) * mcMMOPlayer.getAttackStrength());
+        }
+
+        event.setDamage(boostedDamage);
+        processCombatXP(mcMMOPlayer, target, PrimarySkillType.TRIDENTS);
+
+        printFinalDamageDebug(player, event, mcMMOPlayer);
+    }
+
+    private static void processTridentCombatRanged(@NotNull Trident trident, @NotNull LivingEntity target, @NotNull Player player, @NotNull EntityDamageByEntityEvent event) {
+        if (event.getCause() == DamageCause.THORNS) {
+            return;
         }
 
+        double boostedDamage = event.getDamage();
+
+        McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
+
+        //Make sure the profiles been loaded
+        if(mcMMOPlayer == null) {
+            return;
+        }
+
+        TridentsManager tridentsManager = mcMMOPlayer.getTridentsManager();
+
         if (SkillUtils.canUseSubskill(player, SubSkillType.TRIDENTS_IMPALE)) {
             boostedDamage += (tridentsManager.impaleDamageBonus() * mcMMOPlayer.getAttackStrength());
         }
@@ -465,7 +495,7 @@ public final class CombatUtils {
                 }
 
                 if (mcMMO.p.getSkillTools().doesPlayerHaveSkillPermission(player, PrimarySkillType.TRIDENTS)) {
-                    processTridentCombat(target, player, event);
+                    processTridentCombatMelee(target, player, event);
                 }
             }
         }
@@ -481,6 +511,17 @@ public final class CombatUtils {
                 }
             }
         }
+        else if (painSource instanceof Trident trident) {
+            ProjectileSource projectileSource = trident.getShooter();
+
+            if (projectileSource instanceof Player player) {
+                if (!Misc.isNPCEntityExcludingVillagers(player)) {
+                    if(mcMMO.p.getSkillTools().canCombatSkillsTrigger(PrimarySkillType.TRIDENTS, target)) {
+                        processTridentCombatRanged(trident, target, player, event);
+                    }
+                }
+            }
+        }
         else if (painSource instanceof Arrow arrow) {
             ProjectileSource projectileSource = arrow.getShooter();
             boolean isCrossbow = arrow.isShotFromCrossbow();