Skip to content

Commit 417a176

Browse files
Merge pull request #982 from JasperLorelai/main
Fixes
2 parents f7063e1 + c749dd9 commit 417a176

File tree

6 files changed

+37
-22
lines changed

6 files changed

+37
-22
lines changed

core/src/main/java/com/nisovin/magicspells/spelleffects/trackers/BuffEffectlibTracker.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import org.bukkit.Location;
44
import org.bukkit.entity.Entity;
5+
import org.bukkit.entity.Player;
56

67
import de.slikey.effectlib.Effect;
78
import de.slikey.effectlib.effect.ModifiedEffect;
@@ -14,10 +15,6 @@ public class BuffEffectlibTracker extends AsyncEffectTracker implements Runnable
1415

1516
private final Effect effectlibEffect;
1617

17-
private Location entityLoc;
18-
19-
private Effect modifiedEffect;
20-
2118
public BuffEffectlibTracker(Entity entity, SpellEffectActiveChecker checker, SpellEffect effect, SpellData data) {
2219
super(entity, checker, effect, data);
2320

@@ -32,11 +29,16 @@ public void run() {
3229
return;
3330
}
3431

35-
entityLoc = effect.applyOffsets(entity.getLocation(), data);
32+
if (!entity.isValid()) {
33+
if (!(entity instanceof Player)) stop();
34+
return;
35+
}
36+
37+
Location entityLoc = effect.applyOffsets(entity.getLocation(), data);
3638

3739
effectlibEffect.setLocation(entityLoc);
3840
if (effectlibEffect instanceof ModifiedEffect) {
39-
modifiedEffect = ((ModifiedEffect) effectlibEffect).getInnerEffect();
41+
Effect modifiedEffect = ((ModifiedEffect) effectlibEffect).getInnerEffect();
4042
if (modifiedEffect != null) modifiedEffect.setLocation(entityLoc);
4143
}
4244
}
@@ -53,7 +55,6 @@ public Effect getEffectlibEffect() {
5355

5456
public boolean canRun() {
5557
if (entity == null) return false;
56-
if (!entity.isValid()) return false;
5758
if (!checker.isActive(entity)) return false;
5859
if (effect == null) return false;
5960
if (effectlibEffect == null) return false;

core/src/main/java/com/nisovin/magicspells/spelleffects/trackers/BuffTracker.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.nisovin.magicspells.spelleffects.trackers;
22

33
import org.bukkit.entity.Entity;
4+
import org.bukkit.entity.Player;
45
import org.bukkit.entity.LivingEntity;
56

67
import com.nisovin.magicspells.util.SpellData;
@@ -20,11 +21,16 @@ public BuffTracker(Entity entity, SpellEffectActiveChecker checker, SpellEffect
2021

2122
@Override
2223
public void run() {
23-
if (!entity.isValid() || !checker.isActive(entity) || effect == null) {
24+
if (!checker.isActive(entity) || effect == null) {
2425
stop();
2526
return;
2627
}
2728

29+
if (!entity.isValid()) {
30+
if (!(entity instanceof Player)) stop();
31+
return;
32+
}
33+
2834
if (entity instanceof LivingEntity livingEntity && effect.getModifiers() != null) {
2935
ModifierResult result = effect.getModifiers().apply(livingEntity, data);
3036
data = result.data();

core/src/main/java/com/nisovin/magicspells/spelleffects/trackers/OrbitEffectlibTracker.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import org.bukkit.Location;
55
import org.bukkit.util.Vector;
66
import org.bukkit.entity.Entity;
7+
import org.bukkit.entity.Player;
78
import org.bukkit.scheduler.BukkitTask;
89

910
import com.nisovin.magicspells.util.Util;
@@ -39,10 +40,6 @@ public class OrbitEffectlibTracker extends AsyncEffectTracker implements Runnabl
3940

4041
private final Effect effectlibEffect;
4142

42-
private Location loc;
43-
44-
private Effect modifiedEffect;
45-
4643
public OrbitEffectlibTracker(Entity entity, SpellEffectActiveChecker checker, SpellEffect effect, SpellData data) {
4744
super(entity, checker, effect, data);
4845

@@ -82,15 +79,20 @@ public void run() {
8279
return;
8380
}
8481

82+
if (!entity.isValid()) {
83+
if (!(entity instanceof Player)) stop();
84+
return;
85+
}
86+
8587
xAxis += orbitXAxis;
8688
yAxis += orbitYAxis;
8789
zAxis += orbitZAxis;
8890

89-
loc = effect.applyOffsets(getLocation(), data);
91+
Location loc = effect.applyOffsets(getLocation(), data);
9092

9193
effectlibEffect.setLocation(loc);
9294
if (effectlibEffect instanceof ModifiedEffect) {
93-
modifiedEffect = ((ModifiedEffect) effectlibEffect).getInnerEffect();
95+
Effect modifiedEffect = ((ModifiedEffect) effectlibEffect).getInnerEffect();
9496
if (modifiedEffect != null) modifiedEffect.setLocation(loc);
9597
}
9698
}
@@ -119,7 +121,6 @@ public Effect getEffectlibEffect() {
119121

120122
public boolean canRun() {
121123
if (entity == null) return false;
122-
if (!entity.isValid()) return false;
123124
if (!checker.isActive(entity)) return false;
124125
if (effect == null) return false;
125126
if (effectlibEffect == null) return false;

core/src/main/java/com/nisovin/magicspells/spelleffects/trackers/OrbitTracker.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import org.bukkit.Location;
44
import org.bukkit.util.Vector;
55
import org.bukkit.entity.Entity;
6+
import org.bukkit.entity.Player;
67
import org.bukkit.entity.LivingEntity;
78

89
import com.nisovin.magicspells.util.Util;
@@ -66,11 +67,16 @@ public OrbitTracker(Entity entity, SpellEffectActiveChecker checker, SpellEffect
6667

6768
@Override
6869
public void run() {
69-
if (!entity.isValid() || !checker.isActive(entity) || effect == null) {
70+
if (!checker.isActive(entity) || effect == null) {
7071
stop();
7172
return;
7273
}
7374

75+
if (!entity.isValid()) {
76+
if (!(entity instanceof Player)) stop();
77+
return;
78+
}
79+
7480
xAxis += orbitXAxis;
7581
yAxis += orbitYAxis;
7682
zAxis += orbitZAxis;

core/src/main/java/com/nisovin/magicspells/spells/buff/InvulnerabilitySpell.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public class InvulnerabilitySpell extends BuffSpell {
2828
private static final DeprecationNotice DEPRECATION_NOTICE = new DeprecationNotice(
2929
"The 'damage-causes' option does not function properly.",
3030
"Use the 'damage-types' option.",
31-
"https://github.com/TheComputerGeek2/MagicSpells/wiki/Deprecations#buffinvulernabilityspell-damage-causes"
31+
"https://github.com/TheComputerGeek2/MagicSpells/wiki/Deprecations#buffinvulnerabilityspell-damage-causes"
3232
);
3333

3434
private final Set<UUID> entities;

core/src/main/java/com/nisovin/magicspells/spells/targeted/LoopSpell.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -352,8 +352,9 @@ private Loop(SpellData data) {
352352

353353
@Override
354354
public void run() {
355-
if (data.hasTarget() && !data.target().isValid()) {
356-
cancel();
355+
LivingEntity loopingEntity = data.hasTarget() ? data.target() : data.hasCaster() ? data.caster() : null;
356+
if (loopingEntity != null && !loopingEntity.isValid()) {
357+
if (loopingEntity instanceof Player) cancel();
357358
return;
358359
}
359360

@@ -379,7 +380,7 @@ public void run() {
379380
}
380381
}
381382

382-
if (loopModifiers != null && (!skipFirstLoopModifiers || !firstIteration)) {
383+
if (data.hasCaster() && loopModifiers != null && (!skipFirstLoopModifiers || !firstIteration)) {
383384
ModifierResult result = loopModifiers.apply(data.caster(), data);
384385
data = result.data();
385386

@@ -389,7 +390,7 @@ public void run() {
389390
}
390391
}
391392

392-
if (data.hasTarget() && loopTargetModifiers != null && (!skipFirstLoopTargetModifiers || !firstIteration)) {
393+
if (data.hasCaster() && data.hasTarget() && loopTargetModifiers != null && (!skipFirstLoopTargetModifiers || !firstIteration)) {
393394
ModifierResult result = loopTargetModifiers.apply(data.caster(), data.target(), data);
394395
data = result.data();
395396

@@ -399,7 +400,7 @@ public void run() {
399400
}
400401
}
401402

402-
if (data.hasLocation() && loopLocationModifiers != null && (!skipFirstLoopLocationModifiers || !firstIteration)) {
403+
if (data.hasCaster() && data.hasLocation() && loopLocationModifiers != null && (!skipFirstLoopLocationModifiers || !firstIteration)) {
403404
ModifierResult result = loopLocationModifiers.apply(data.caster(), data.location(), data);
404405
data = result.data();
405406

0 commit comments

Comments
 (0)