From ba849441dcaba1f6cd5e4dcff58a497ac7796552 Mon Sep 17 00:00:00 2001 From: Alex 'mcmonkey' Goodwin Date: Sat, 5 Dec 2020 01:19:54 -0800 Subject: [PATCH] avoid world change bork in shoot command also opti some logic when script arg not used --- .../scripts/commands/entity/ShootCommand.java | 13 +++++++++---- .../scripts/commands/world/ChunkLoadCommand.java | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/entity/ShootCommand.java b/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/entity/ShootCommand.java index 3ec74b6e07..f3d667c35f 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/entity/ShootCommand.java +++ b/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/entity/ShootCommand.java @@ -246,7 +246,9 @@ public void execute(final ScriptEntry scriptEntry) { if (entity.isProjectile() && (shooter != null || originEntity != null)) { entity.setShooter(shooter != null ? shooter : originEntity); // Also, watch for it hitting a target - arrows.put(entity.getUUID(), null); + if (script != null) { + arrows.put(entity.getUUID(), null); + } } } // Add entities to context so that the specific entities created/spawned @@ -319,8 +321,9 @@ public void run() { // Otherwise, if the entity is no longer traveling through // the air, stop the task else if (lastLocation != null && lastVelocity != null) { - if (lastLocation.distanceSquared(lastEntity.getBukkitEntity().getLocation()) < 0.1 - && lastVelocity.distanceSquared(lastEntity.getBukkitEntity().getVelocity()) < 0.1) { + if (lastLocation.getWorld() != lastEntity.getBukkitEntity().getWorld() + || (lastLocation.distanceSquared(lastEntity.getBukkitEntity().getLocation()) < 0.1 + && lastVelocity.distanceSquared(lastEntity.getBukkitEntity().getVelocity()) < 0.1)) { flying = false; } } @@ -362,7 +365,9 @@ else if (lastLocation != null && lastVelocity != null) { } } }; - task.runTaskTimer(DenizenAPI.getCurrentInstance(), 1, 2); + if (script != null || !scriptEntry.shouldWaitFor()) { + task.runTaskTimer(DenizenAPI.getCurrentInstance(), 1, 2); + } } @EventHandler diff --git a/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/world/ChunkLoadCommand.java b/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/world/ChunkLoadCommand.java index 1e644875ec..26c2171ea4 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/world/ChunkLoadCommand.java +++ b/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/world/ChunkLoadCommand.java @@ -175,7 +175,7 @@ public void run() { Debug.echoDebug(scriptEntry, "...allowing unloading of chunk " + chunk.getX() + ", " + chunk.getZ()); } else { - Debug.echoError("Chunk was not on the load list!"); + Debug.echoError("Chunk '" + chunkString + "' was not on the load list!"); } break; case REMOVEALL: