Skip to content

Commit

Permalink
wrap detectArea in async Runnable task
Browse files Browse the repository at this point in the history
  • Loading branch information
Julian Weiss committed Feb 15, 2019
1 parent 58f7941 commit a0f3840
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions plugin/me/insanj/pride/PridePlayerListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,18 @@ public PridePlayerListener(Pride instance, String filename) {

@EventHandler
public void onPlayerMove(PlayerMoveEvent event) {
if (++bottleneck>=bottleneckThreshold) {
bottleneck = 0;
Location to = event.getTo();
detectPride(event.getPlayer().getName(), to);
}
PridePlayerListener listener = this;
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
@Override
public void run() {
if (++listener.bottleneck>=listener.bottleneckThreshold) {
listener.bottleneck = 0;
Location to = event.getTo();
String playerName = event.getPlayer().getName();
listener.detectPride(playerName, to);
}
}
});
}

private HashMap getPrideAreas(World world) {
Expand Down

0 comments on commit a0f3840

Please sign in to comment.