Skip to content

Commit

Permalink
Only match all poses if no trigger var specified
Browse files Browse the repository at this point in the history
  • Loading branch information
TonytheMacaroni committed Jan 15, 2024
1 parent 58f27eb commit f8f457e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@

public class StartPoseListener extends PassiveListener {

private final Set<Pose> poses = EnumSet.noneOf(Pose.class);
private Set<Pose> poses;

@Override
public void initialize(String var) {
if (var == null || var.isEmpty()) return;

String[] split = var.split(",");
for (String pose : split) {
poses = EnumSet.noneOf(Pose.class);

for (String pose : var.split(",")) {
try {
poses.add(Pose.valueOf(pose.trim().toUpperCase()));
} catch (IllegalArgumentException e) {
Expand All @@ -34,7 +35,7 @@ public void initialize(String var) {
@EventHandler
public void onPoseChange(EntityPoseChangeEvent event) {
if (!(event.getEntity() instanceof LivingEntity caster) || !canTrigger(caster) || !hasSpell(caster)) return;
if (!poses.isEmpty() && !poses.contains(event.getPose())) return;
if (poses != null && !poses.contains(event.getPose())) return;

passiveSpell.activate(caster);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@

public class StopPoseListener extends PassiveListener {

private final Set<Pose> poses = EnumSet.noneOf(Pose.class);
private Set<Pose> poses;

@Override
public void initialize(String var) {
if (var == null || var.isEmpty()) return;

String[] split = var.split(",");
for (String pose : split) {
poses = EnumSet.noneOf(Pose.class);

for (String pose : var.split(",")) {
try {
poses.add(Pose.valueOf(pose.trim().toUpperCase()));
} catch (IllegalArgumentException e) {
Expand All @@ -34,7 +35,7 @@ public void initialize(String var) {
@EventHandler
public void onPoseChange(EntityPoseChangeEvent event) {
if (!(event.getEntity() instanceof LivingEntity caster) || !canTrigger(caster) || !hasSpell(caster)) return;
if (!poses.isEmpty() && !poses.contains(caster.getPose())) return;
if (poses != null && !poses.contains(caster.getPose())) return;

passiveSpell.activate(caster);
}
Expand Down

0 comments on commit f8f457e

Please sign in to comment.