Skip to content

Instantly share code, notes, and snippets.

@CeramicTitan
Forked from IamRob-/gist:8539877
Created January 21, 2014 13:36
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 CeramicTitan/8540153 to your computer and use it in GitHub Desktop.
Save CeramicTitan/8540153 to your computer and use it in GitHub Desktop.
lastHit.put(victim.getName(), attacker.getName());
final Player vic = victim.getPlayer();
final BukkitScheduler scheduler = Bukkit.getScheduler();
if (lastHitId.containsKey(vic.getName())) {
int taskId = lastHitId.get(vic.getName());
if (scheduler.isCurrentlyRunning(taskId)) {
scheduler.cancelTask(taskId);
}
}
BukkitTask task = scheduler.runTaskLater(plugin, new BukkitRunnable() {
@Override
public void run() {
lastHit.remove(vic.getName());
}
}, 300);
lastHitId.put(vic.getName(), task.getTaskId());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment