Skip to content

Commit dc77afd

Browse files
committed
feat: Add EntityRemoveSpell
1 parent ef8fa00 commit dc77afd

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.nisovin.magicspells.spells.targeted;
2+
3+
import org.bukkit.entity.Player;
4+
import org.bukkit.entity.LivingEntity;
5+
6+
import com.nisovin.magicspells.util.*;
7+
import com.nisovin.magicspells.spells.TargetedSpell;
8+
import com.nisovin.magicspells.spells.TargetedEntitySpell;
9+
10+
public class EntityRemoveSpell extends TargetedSpell implements TargetedEntitySpell {
11+
12+
public EntityRemoveSpell(MagicConfig config, String spellName) {
13+
super(config, spellName);
14+
}
15+
16+
@Override
17+
public CastResult cast(SpellData data) {
18+
TargetInfo<LivingEntity> info = getTargetedEntity(data);
19+
if (info.noTarget()) return noTarget(info);
20+
21+
return castAtEntity(info.spellData());
22+
}
23+
24+
@Override
25+
public CastResult castAtEntity(SpellData data) {
26+
if (!data.hasTarget() || data.target() instanceof Player) return noTarget(data);
27+
28+
data.target().remove();
29+
30+
playSpellEffects(data);
31+
return new CastResult(PostCastAction.HANDLE_NORMALLY, data);
32+
}
33+
34+
}

0 commit comments

Comments
 (0)