nossr50 4 gadi atpakaļ
vecāks
revīzija
da1fcfe30a

+ 1 - 0
Changelog.txt

@@ -10,6 +10,7 @@ Version 2.1.196
     (API) Added McMMOEntityDamageByRuptureEvent (thanks qixils)
 
     NOTES:
+    For now Rupture is non-lethal, I may add back a lethal component at the end of its damage
     Rupture will be in a state of change for a while as I receive feedback (give me feedback in Discord!)
     Crossbows is not in the default fishing loot list, you'd have to add it yourself.
     For Devs: McMMOEntityDamageByRuptureEvent extends EntityDamageByEntityEvent and uses CUSTOM type damage

+ 1 - 1
pom.xml

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

+ 41 - 25
src/main/java/com/gmail/nossr50/runnables/skills/RuptureTask.java

@@ -13,7 +13,7 @@ import org.jetbrains.annotations.NotNull;
 public class RuptureTask extends BukkitRunnable {
 
     public static final int DAMAGE_TICK_INTERVAL = 10;
-    public static final int ANIMATION_TICK_INTERVAL = 2;
+    public static final int ANIMATION_TICK_INTERVAL = 1;
 
     private final @NotNull McMMOPlayer ruptureSource;
     private final @NotNull LivingEntity targetEntity;
@@ -44,38 +44,22 @@ public class RuptureTask extends BukkitRunnable {
             ruptureTick += 1; //Advance rupture tick by 1.
             damageTickTracker += 1; //Increment damage tick tracker
 
+            //TODO: Clean this code up, applyRupture() is a confusing name for something that returns boolean
             //Rupture hasn't ended yet
             if(ruptureTick < expireTick) {
                 //Is it time to damage?
                 if(damageTickTracker >= DAMAGE_TICK_INTERVAL) {
 
                     damageTickTracker = 0; //Reset timer
-                    double healthBeforeRuptureIsApplied = targetEntity.getHealth();
-
-                    //Ensure victim has health
-                    if (healthBeforeRuptureIsApplied > 0.01) {
-                        //Send a fake damage event
-                        McMMOEntityDamageByRuptureEvent event = new McMMOEntityDamageByRuptureEvent(ruptureSource, targetEntity, calculateAdjustedTickDamage());
-                        mcMMO.p.getServer().getPluginManager().callEvent(event);
-
-                        //Ensure the event wasn't cancelled and damage is still greater than 0
-                        double damage = event.getFinalDamage();
-                        if (event.isCancelled() || damage <= 0 || healthBeforeRuptureIsApplied - damage <= 0)
-                            return;
-
-                        if(animationTick >= ANIMATION_TICK_INTERVAL) {
-                            ParticleEffectUtils.playBleedEffect(targetEntity); //Animate
-                            animationTick = 0;
-                        } else {
-                            animationTick++;
-                        }
-
-                        double damagedHealth = healthBeforeRuptureIsApplied - damage;
-
-                        targetEntity.setHealth(damagedHealth); //Hurt entity without the unwanted side effects of damage()}
-                    }
+                    if (applyRupture()) return;
+
+                    playAnimation();
                 }
             } else {
+                if(!applyRupture()) {
+                    playAnimation();
+                }
+
                 endRupture();
             }
         } else {
@@ -84,6 +68,38 @@ public class RuptureTask extends BukkitRunnable {
         }
     }
 
+    private void playAnimation() {
+        if(animationTick >= ANIMATION_TICK_INTERVAL) {
+            ParticleEffectUtils.playBleedEffect(targetEntity); //Animate
+            animationTick = 0;
+        } else {
+            animationTick++;
+        }
+    }
+
+    private boolean applyRupture() {
+        double healthBeforeRuptureIsApplied = targetEntity.getHealth();
+
+        //Ensure victim has health
+        if (healthBeforeRuptureIsApplied > 0.01) {
+            //Send a fake damage event
+            McMMOEntityDamageByRuptureEvent event = new McMMOEntityDamageByRuptureEvent(ruptureSource, targetEntity, calculateAdjustedTickDamage());
+            mcMMO.p.getServer().getPluginManager().callEvent(event);
+
+            //Ensure the event wasn't cancelled and damage is still greater than 0
+            double damage = event.getFinalDamage();
+
+            if (event.isCancelled() || damage <= 0 || healthBeforeRuptureIsApplied - damage <= 0)
+                return true;
+
+            double damagedHealth = healthBeforeRuptureIsApplied - damage;
+
+            targetEntity.setHealth(damagedHealth); //Hurt entity without the unwanted side effects of damage()}
+        }
+
+        return false;
+    }
+
     public void refreshRupture() {
         damageTickTracker = DAMAGE_TICK_INTERVAL;
         ruptureTick = 0;