Skip to content

Commit

Permalink
schematic: fix double-callback after rotate
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Apr 16, 2022
1 parent 45616a4 commit 450f60a
Showing 1 changed file with 24 additions and 20 deletions.
Expand Up @@ -188,34 +188,38 @@ else if (!scriptEntry.hasObject("area")

public static void rotateSchem(CuboidBlockSet schematic, int angle, boolean delayed, Runnable callback) {
Runnable rotateRunnable = () -> {
int ang = angle;
while (ang < 0) {
ang = 360 + ang;
}
while (ang >= 360) {
ang -= 360;
try {
int ang = angle;
while (ang < 0) {
ang = 360 + ang;
}
while (ang >= 360) {
ang -= 360;
}
if (ang != 0) {
ang = 360 - ang;
while (ang > 0) {
ang -= 90;
schematic.rotateOne();
}
}
}
if (ang != 0) {
ang = 360 - ang;
while (ang > 0) {
ang -= 90;
schematic.rotateOne();
finally {
if (callback != null) {
if (delayed) {
Bukkit.getScheduler().runTask(Denizen.getInstance(), callback);
}
else {
callback.run();
}
}
}
Bukkit.getScheduler().runTask(Denizen.getInstance(), callback);
};
if (delayed) {
Bukkit.getScheduler().runTaskAsynchronously(Denizen.getInstance(), rotateRunnable);
}
else {
try {
rotateRunnable.run();
}
finally {
if (callback != null) {
callback.run();
}
}
rotateRunnable.run();
}
}

Expand Down

0 comments on commit 450f60a

Please sign in to comment.