forked from nisovin/MagicSpells
-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #834 from TonytheMacaroni/main
Additions
- Loading branch information
Showing
2 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
core/src/main/java/com/nisovin/magicspells/castmodifiers/conditions/SilentCondition.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
|
||
} |
37 changes: 37 additions & 0 deletions
37
core/src/main/java/com/nisovin/magicspells/spells/targeted/SneakSpell.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<TargetBooleanState> targetState; | ||
|
||
public SneakSpell(MagicConfig config, String spellName) { | ||
super(config, spellName); | ||
|
||
targetState = getConfigDataTargetBooleanState("target-state", TargetBooleanState.TOGGLE); | ||
} | ||
|
||
@Override | ||
public CastResult cast(SpellData data) { | ||
TargetInfo<LivingEntity> 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); | ||
} | ||
|
||
} |