Java Code Examples for org.bukkit.scheduler.BukkitTask#cancel()
The following examples show how to use
org.bukkit.scheduler.BukkitTask#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: BukkitViaLoader.java From ViaVersion with MIT License | 5 votes |
@Override public void unload() { for (Listener listener : listeners) { HandlerList.unregisterAll(listener); } listeners.clear(); for (BukkitTask task : tasks) { task.cancel(); } tasks.clear(); }
Example 2
Source File: NametagHandler.java From NametagEdit with GNU General Public License v3.0 | 5 votes |
private BukkitTask createTask(String path, BukkitTask existing, Runnable runnable) { if (existing != null) { existing.cancel(); } if (config.getInt(path, -1) <= 0) return null; return Bukkit.getScheduler().runTaskTimer(plugin, runnable, 0, 20 * config.getInt(path)); }
Example 3
Source File: CrazyCrates.java From Crazy-Crates with MIT License | 5 votes |
/** * Ends the tasks running by a player. * @param player The player using the crate. */ public void endQuadCrate(Player player) { if (currentQuadTasks.containsKey(player.getUniqueId())) { for (BukkitTask task : currentQuadTasks.get(player.getUniqueId())) { task.cancel(); } currentQuadTasks.remove(player.getUniqueId()); } }
Example 4
Source File: Game.java From BedwarsRel with GNU General Public License v3.0 | 5 votes |
public void stopWorkers() { for (BukkitTask task : this.runningTasks) { try { task.cancel(); } catch (Exception ex) { BedwarsRel.getInstance().getBugsnag().notify(ex); // already cancelled } } this.runningTasks.clear(); }
Example 5
Source File: TaskMaster.java From civcraft with GNU General Public License v2.0 | 5 votes |
public static void stopAllTimers() { for (BukkitTask timer : timers.values()) { timer.cancel(); } //RJ.out("clearing timers"); timers.clear(); }
Example 6
Source File: TaskMaster.java From civcraft with GNU General Public License v2.0 | 5 votes |
public static void cancelTask(String name) { BukkitTask task = tasks.get(name); if (task != null) { task.cancel(); } //RJ.out("clearing tasks"); tasks.remove(name); }
Example 7
Source File: TaskMaster.java From civcraft with GNU General Public License v2.0 | 5 votes |
public static void cancelTimer(String name) { BukkitTask timer = tasks.get(name); if (timer != null) { timer.cancel(); } //RJ.out("cancel timer:"+name); timers.remove(name); }
Example 8
Source File: EffectManager.java From EffectLib with MIT License | 5 votes |
public void done(Effect effect) { synchronized (this) { BukkitTask existingTask = effects.get(effect); if (existingTask != null) { existingTask.cancel(); } effects.remove(effect); } if (effect.callback != null && owningPlugin.isEnabled()) { Bukkit.getScheduler().runTask(owningPlugin, effect.callback); } if (disposeOnTermination && effects.isEmpty()) { dispose(); } }
Example 9
Source File: ClaimVisualApplyTask.java From GriefDefender with MIT License | 4 votes |
@Override public void run() { if (!this.player.isOnline()) { this.playerData.revertAllVisuals(); return; } // Only revert active visual if we are not currently creating a claim if (!this.playerData.visualClaimBlocks.isEmpty() && this.playerData.lastShovelLocation == null) { if (this.resetActive) { this.playerData.revertAllVisuals(); } } for (BlockTransaction transaction : this.visualization.getVisualTransactions()) { this.playerData.queuedVisuals.add(transaction.getFinal()); } if (this.visualization.getClaim() != null) { this.visualization.getClaim().playersWatching.add(this.player.getUniqueId()); } UUID visualUniqueId = null; if (this.visualization.getClaim() == null) { visualUniqueId = UUID.randomUUID(); playerData.tempVisualUniqueId = visualUniqueId; } else { visualUniqueId = this.visualization.getClaim().getUniqueId(); } final List<BlockTransaction> blockTransactions = this.playerData.visualClaimBlocks.get(visualUniqueId); if (blockTransactions == null) { this.playerData.visualClaimBlocks.put(visualUniqueId, new ArrayList<>(this.visualization.getVisualTransactions())); } else { // support multi layer visuals i.e. water blockTransactions.addAll(this.visualization.getVisualTransactions()); // cancel existing task final BukkitTask task = this.playerData.claimVisualRevertTasks.get(visualUniqueId); if (task != null) { task.cancel(); this.playerData.claimVisualRevertTasks.remove(visualUniqueId); } } int tickTime = (this.playerData.lastShovelLocation != null && this.visualization.getClaim() == null ? GriefDefenderPlugin.getGlobalConfig().getConfig().visual.createBlockVisualTime : GriefDefenderPlugin.getGlobalConfig().getConfig().visual.claimVisualTime) * 20; if (tickTime <= 0) { tickTime = this.playerData.lastShovelLocation == null ? 1200 : 3600; } final ClaimVisualRevertTask runnable = new ClaimVisualRevertTask(visualUniqueId, this.player, this.playerData); if (this.playerData.lastShovelLocation != null && this.visualization.getClaim() == null) { this.playerData.createBlockVisualTransactions.put(visualUniqueId, new ArrayList<>(this.visualization.getVisualTransactions())); this.playerData.createBlockVisualRevertRunnables.put(visualUniqueId, runnable); } this.playerData.claimVisualRevertTasks.put(visualUniqueId, Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(GDBootstrap.getInstance(), runnable, tickTime)); }
Example 10
Source File: BukkitSchedulerBackend.java From ProjectAres with GNU Affero General Public License v3.0 | 4 votes |
@Override public void cancelTask(BukkitTask bukkitTask) { bukkitTask.cancel(); }
Example 11
Source File: TaskMaster.java From civcraft with GNU General Public License v2.0 | 4 votes |
public static void stopAllTasks() { for (BukkitTask task : tasks.values()) { task.cancel(); } tasks.clear(); }
Example 12
Source File: RegionVisualizer.java From HeavySpleef with GNU General Public License v3.0 | 4 votes |
@SuppressWarnings("deprecation") @Override public void run() { boolean finish = !player.isOnline(); if (player.isOnline()) { Player bukkitPlayer = player.getBukkitPlayer(); // Stores the current wool data byte data; if (currentRepetitions % 2 == 0) { data = LIME_WOOL_DATA; } else { data = RED_WOOL_DATA; } finish = currentRepetitions > REPETITIONS; Iterator<BlockVector> iterator = region.iterator(); while (iterator.hasNext()) { BlockVector vec = iterator.next(); int x = vec.getBlockX(); int y = vec.getBlockY(); int z = vec.getBlockZ(); Location location = new Location(world, x, y, z); if (!finish) { bukkitPlayer.sendBlockChange(location, Material.WOOL, data); } else { Block block = world.getBlockAt(location); Material material = block.getType(); data = block.getData(); bukkitPlayer.sendBlockChange(location, material, data); } } } if (finish) { BukkitTask task = tasks.get(player); task.cancel(); tasks.remove(player); } ++currentRepetitions; }