Skip to content

Commit

Permalink
avoid world change bork in shoot command
Browse files Browse the repository at this point in the history
also opti some logic when script arg not used
  • Loading branch information
mcmonkey4eva committed Dec 5, 2020
1 parent fb8a1f9 commit ba84944
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit ba84944

Please sign in to comment.