Skip to content

Commit

Permalink
Merge pull request #834 from TonytheMacaroni/main
Browse files Browse the repository at this point in the history
Additions
  • Loading branch information
Chronoken authored Jan 19, 2024
2 parents 240edcd + 8017ee6 commit 6be301a
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
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;
}

}
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);
}

}

0 comments on commit 6be301a

Please sign in to comment.