Skip to content

Commit

Permalink
Animation.Scheduler -> Animation.SequentialExecutor
Browse files Browse the repository at this point in the history
  • Loading branch information
jpenilla committed Mar 14, 2024
1 parent 2b849af commit 3f80c5f
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/main/java/xyz/jpenilla/chesscraft/BoardManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ public void close() {
this.pauseMatch(board);
}
}
board.animationScheduler().cancel();
board.animationExecutor().cancel();
});
this.boards.clear();
this.displays.clear();
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/xyz/jpenilla/chesscraft/ChessBoard.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public final class ChessBoard {
private final PieceHandler pieceHandler;
private final List<? extends BoardDisplaySettings<?>> displays;
private @Nullable ChessGame game;
private final SteppedAnimation.Scheduler animationScheduler;
private final SteppedAnimation.SequentialExecutor animationExecutor;

public ChessBoard(
final ChessCraft plugin,
Expand All @@ -69,7 +69,7 @@ public ChessBoard(
final Sound moveSound
) {
this.plugin = plugin;
this.animationScheduler = new SteppedAnimation.Scheduler(plugin);
this.animationExecutor = new SteppedAnimation.SequentialExecutor(plugin);
this.name = name;
this.loc = loc;
this.facing = facing;
Expand All @@ -85,12 +85,12 @@ public ChessBoard(
this.pieceHandler = plugin.config().pieces().createHandler(plugin);
}

public SteppedAnimation.Scheduler animationScheduler() {
return this.animationScheduler;
public SteppedAnimation.SequentialExecutor animationExecutor() {
return this.animationExecutor;
}

public void cancelCurrentAnimation() {
this.animationScheduler.clearCurrent();
this.animationExecutor.clearCurrent();
}

public Sound moveSound() {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/xyz/jpenilla/chesscraft/PieceHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ private void configureItemDisplay(final ChessBoard board, final ItemDisplay item

@Override
public void applyMoveToWorld(final ChessBoard board, final BoardStateHolder game, final World world, final ChessGame.Move move) {
board.animationScheduler().schedule(() -> this.makeAnimation(board, game, world, move));
board.animationExecutor().schedule(() -> this.makeAnimation(board, game, world, move));
}

private @Nullable SteppedAnimation makeAnimation(final ChessBoard board, final BoardStateHolder game, final World world, final ChessGame.Move move) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ public boolean tick(final int tick) {
return !this.steps.isEmpty();
}

public static final class Scheduler {
public static final class SequentialExecutor {
private final Deque<Supplier<SteppedAnimation>> animations = new ConcurrentLinkedDeque<>();
private final BukkitTask task;
private int tick = 0;
private volatile @Nullable SteppedAnimation current;

public Scheduler(final JavaPlugin plugin) {
public SequentialExecutor(final JavaPlugin plugin) {
this.task = plugin.getServer().getScheduler().runTaskTimer(plugin, this::tick, 0, 1);
}

Expand Down

0 comments on commit 3f80c5f

Please sign in to comment.