From 49d43255236bdb0b735e5627ac3d29a0e4b4b76d Mon Sep 17 00:00:00 2001 From: TonytheMacaroni Date: Thu, 18 Jan 2024 22:21:01 -0500 Subject: [PATCH 1/2] Add SneakSpell --- .../spells/targeted/SneakSpell.java | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 core/src/main/java/com/nisovin/magicspells/spells/targeted/SneakSpell.java diff --git a/core/src/main/java/com/nisovin/magicspells/spells/targeted/SneakSpell.java b/core/src/main/java/com/nisovin/magicspells/spells/targeted/SneakSpell.java new file mode 100644 index 000000000..75eca0b29 --- /dev/null +++ b/core/src/main/java/com/nisovin/magicspells/spells/targeted/SneakSpell.java @@ -0,0 +1,37 @@ +package com.nisovin.magicspells.spells.targeted; + +import org.bukkit.entity.LivingEntity; + +import com.nisovin.magicspells.util.*; +import com.nisovin.magicspells.spells.TargetedSpell; +import com.nisovin.magicspells.util.config.ConfigData; +import com.nisovin.magicspells.spells.TargetedEntitySpell; + +public class SneakSpell extends TargetedSpell implements TargetedEntitySpell { + + private final ConfigData targetState; + + public SneakSpell(MagicConfig config, String spellName) { + super(config, spellName); + + targetState = getConfigDataTargetBooleanState("target-state", TargetBooleanState.TOGGLE); + } + + @Override + public CastResult cast(SpellData data) { + TargetInfo info = getTargetedEntity(data); + if (info.noTarget()) return noTarget(info); + + return castAtEntity(info.spellData()); + } + + @Override + public CastResult castAtEntity(SpellData data) { + TargetBooleanState targetState = this.targetState.get(data); + data.target().setSneaking(targetState.getBooleanState(data.target().isSneaking())); + + playSpellEffects(data); + return new CastResult(PostCastAction.HANDLE_NORMALLY, data); + } + +} From 8017ee62d0aa0319e860b0cc011696f7e3a2df07 Mon Sep 17 00:00:00 2001 From: TonytheMacaroni Date: Thu, 18 Jan 2024 22:25:45 -0500 Subject: [PATCH 2/2] Add SilentCondition --- .../conditions/SilentCondition.java | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 core/src/main/java/com/nisovin/magicspells/castmodifiers/conditions/SilentCondition.java diff --git a/core/src/main/java/com/nisovin/magicspells/castmodifiers/conditions/SilentCondition.java b/core/src/main/java/com/nisovin/magicspells/castmodifiers/conditions/SilentCondition.java new file mode 100644 index 000000000..793e58e2c --- /dev/null +++ b/core/src/main/java/com/nisovin/magicspells/castmodifiers/conditions/SilentCondition.java @@ -0,0 +1,32 @@ +package com.nisovin.magicspells.castmodifiers.conditions; + +import org.jetbrains.annotations.NotNull; + +import org.bukkit.Location; +import org.bukkit.entity.LivingEntity; + +import com.nisovin.magicspells.castmodifiers.Condition; + +public class SilentCondition extends Condition { + + @Override + public boolean initialize(@NotNull String var) { + return var.isEmpty(); + } + + @Override + public boolean check(LivingEntity caster) { + return caster.isSilent(); + } + + @Override + public boolean check(LivingEntity caster, LivingEntity target) { + return target.isSilent(); + } + + @Override + public boolean check(LivingEntity caster, Location location) { + return false; + } + +}