Java Code Examples for org.bukkit.scheduler.BukkitRunnable#cancel()
The following examples show how to use
org.bukkit.scheduler.BukkitRunnable#cancel() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FileStorage.java From GriefDefender with MIT License | 6 votes |
public void unloadWorldData(World world) { GDClaimManager claimWorldManager = this.getClaimWorldManager(world.getUID()); for (Claim claim : claimWorldManager.getWorldClaims()) { ((GDClaim) claim).unload(); } // Task must be cancelled before removing the claimWorldManager reference to avoid a memory leak BukkitRunnable cleanupTask = cleanupClaimTasks.get(world.getUID()); if (cleanupTask != null) { cleanupTask.cancel(); cleanupClaimTasks.remove(world.getUID()); } claimWorldManager.unload(); this.claimWorldManagers.remove(world.getUID()); BaseStorage.dimensionConfigMap.remove(world.getUID()); BaseStorage.worldConfigMap.remove(world.getUID()); }
Example 2
Source File: ParticleEffect.java From Civs with GNU General Public License v3.0 | 6 votes |
public void apply() { Object target = getTarget(); if (!(target instanceof LivingEntity)) { return; } LivingEntity livingEntity = (LivingEntity) target; final BukkitRunnable runnable = new BukkitRunnable() { @Override public void run() { onUpdate(); } }; runnable.runTaskAsynchronously(Civs.getInstance()); if (duration > 0) { BukkitRunnable runnable1 = new BukkitRunnable() { @Override public void run() { runnable.cancel(); } }; } }
Example 3
Source File: EventExecutor.java From PlayerSQL with GNU General Public License v2.0 | 6 votes |
private void receiveContents(Player player, PlayerSqlProtocol packet) { main.debug("recv data_buf"); DataSupply dataSupply = (DataSupply) packet; if (dataSupply.getBuf() == null || dataSupply.getBuf().length == 0 || !group.equals(dataSupply.getGroup())) { return; } PlayerData data = PlayerDataHelper.decode(dataSupply.getBuf()); BukkitRunnable pend = (BukkitRunnable) pending.remove(dataSupply.getId()); if (pend == null) { main.debug("pending received data_buf"); pending.put(dataSupply.getId(), data); } else { main.debug("process received data_buf"); pend.cancel(); main.run(() -> { manager.pend(player, data); runAsync(() -> manager.updateDataLock(dataSupply.getId(), true)); }); } }
Example 4
Source File: CombatTagger.java From BetonQuest with GNU General Public License v3.0 | 6 votes |
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onDamage(EntityDamageByEntityEvent event) { ArrayList<String> IDs = new ArrayList<>(); if (event.getEntity() instanceof Player) { IDs.add(PlayerConverter.getID((Player) event.getEntity())); } if (event.getDamager() instanceof Player) { IDs.add(PlayerConverter.getID((Player) event.getDamager())); } for (final String playerID : IDs) { tagged.put(playerID, true); BukkitRunnable run = untaggers.get(playerID); if (run != null) { run.cancel(); } untaggers.put(playerID, new BukkitRunnable() { @Override public void run() { tagged.put(playerID, false); } }); untaggers.get(playerID).runTaskLater(BetonQuest.getInstance(), delay * 20); } }
Example 5
Source File: GriefDefenderPlugin.java From GriefDefender with MIT License | 5 votes |
private void cleanup() { for (BukkitRunnable task : this.runningTasks) { task.cancel(); } for (World world : Bukkit.getServer().getWorlds()) { for (Player player : world.getPlayers()) { if (player.isDead()) { continue; } final GDPlayerData playerData = GriefDefenderPlugin.getInstance().dataStore.getOrCreatePlayerData(player.getWorld(), player.getUniqueId()); playerData.onDisconnect(); } } }
Example 6
Source File: PlayerResetter.java From UHC with MIT License | 5 votes |
private void setCache(String actor, List<Action> toRevert) { BukkitRunnable task = removeTasks.get(actor); if (task != null) { task.cancel(); } task = new RemoveTask(actor); task.runTaskLater(plugin, cacheTicks); cache.replaceValues(actor, toRevert); removeTasks.put(actor, task); }
Example 7
Source File: CombatTagger.java From BetonQuest with GNU General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onDeath(PlayerDeathEvent event) { String playerID = PlayerConverter.getID(event.getEntity()); tagged.remove(playerID); BukkitRunnable runnable = untaggers.remove(playerID); if (runnable != null) runnable.cancel(); }