Skip to content

Instantly share code, notes, and snippets.

@geNAZt
Created May 6, 2014 21:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save geNAZt/60ecc7ba4c9be1d48336 to your computer and use it in GitHub Desktop.
Save geNAZt/60ecc7ba4c9be1d48336 to your computer and use it in GitHub Desktop.
private void moveBitch( final Location start, final ArrayList<Tile> tiles, final Callback<Void> callback ) {
final AtomicInteger curPos = new AtomicInteger( 0 );
final Plugin plugin = this;
final Runnable moveRunnable = new Runnable() {
@Override
public void run() {
if (skeleton1 != null) {
int current = curPos.getAndAdd( 1 );
if ( current >= tiles.size() ) {
Bukkit.getScheduler().scheduleSyncDelayedTask( plugin, new Runnable() {
@Override
public void run() {
callback.done( null );
}
}, ((Double) ( Math.random() * (double) 60 )).intValue() );
return;
}
Tile tile = tiles.get( current );
Location location1 = tile.getLocation( start ).add( 0, 1, 0 );
((CraftSkeleton) skeleton1).getHandle().setLocation( location1.getX(), location1.getY(), location1.getZ(), location1.getYaw(), location1.getPitch() );
Bukkit.getScheduler().scheduleSyncDelayedTask( plugin, this, 5 );
}
}
};
Bukkit.getScheduler().scheduleSyncDelayedTask( this, moveRunnable, 5 );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment