From 7186ed17e2a49b72bbc84cc2d15ee3588d63375e Mon Sep 17 00:00:00 2001 From: LimeGlass <16087552+TheLimeGlass@users.noreply.github.com> Date: Mon, 18 Jul 2022 02:29:14 -0600 Subject: [PATCH] Feature/pathfinding to be double (#4915) --- .../java/ch/njol/skript/effects/EffPathfind.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main/java/ch/njol/skript/effects/EffPathfind.java b/src/main/java/ch/njol/skript/effects/EffPathfind.java index 5f290efe71e..eb53966d0f6 100644 --- a/src/main/java/ch/njol/skript/effects/EffPathfind.java +++ b/src/main/java/ch/njol/skript/effects/EffPathfind.java @@ -28,6 +28,7 @@ import ch.njol.skript.doc.Description; import ch.njol.skript.doc.Examples; import ch.njol.skript.doc.Name; +import ch.njol.skript.doc.RequiredPlugins; import ch.njol.skript.doc.Since; import ch.njol.skript.lang.Effect; import ch.njol.skript.lang.Expression; @@ -40,9 +41,10 @@ @Examples({ "make all creepers pathfind towards player", "make all cows stop pathfinding", - "make event-entity pathfind towards player" + "make event-entity pathfind towards player at speed 1" }) @Since("INSERT VERSION") +@RequiredPlugins("Paper") public class EffPathfind extends Effect { static { @@ -72,7 +74,7 @@ public boolean init(Expression[] exprs, int matchedPattern, Kleenean isDelaye @Override protected void execute(Event event) { Object target = this.target != null ? this.target.getSingle(event) : null; - int speed = this.speed != null ? this.speed.getSingle(event).intValue() : 1; + double speed = this.speed != null ? this.speed.getOptionalSingle(event).orElse(1).doubleValue() : 1; for (LivingEntity entity : entities.getArray(event)) { if (!(entity instanceof Mob)) continue; @@ -87,13 +89,12 @@ protected void execute(Event event) { } @Override - public String toString(@Nullable Event e, boolean debug) { + public String toString(@Nullable Event event, boolean debug) { if (target == null) - return "make " + entities.toString(e, debug) + " stop pathfinding"; - - String repr = "make " + entities.toString(e, debug) + " pathfind towards " + target.toString(e, debug); + return "make " + entities.toString(event, debug) + " stop pathfinding"; + String repr = "make " + entities.toString(event, debug) + " pathfind towards " + target.toString(event, debug); if (speed != null) - repr += " at speed " + speed.toString(e, debug); + repr += " at speed " + speed.toString(event, debug); return repr; }