本文整理匯總了Java中org.bukkit.scheduler.BukkitRunnable.cancel方法的典型用法代碼示例。如果您正苦於以下問題:Java BukkitRunnable.cancel方法的具體用法?Java BukkitRunnable.cancel怎麽用?Java BukkitRunnable.cancel使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bukkit.scheduler.BukkitRunnable
的用法示例。
在下文中一共展示了BukkitRunnable.cancel方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onDisable
import org.bukkit.scheduler.BukkitRunnable; //導入方法依賴的package包/類
public void onDisable() {
Hive.getInstance().setStatus(Status.CLOSED);
Chat.log("Cancelling tasks...");
for (BukkitRunnable runnable : schedules) {
Chat.log("Cancelling: #" + runnable.getTaskId() + " runnable");
runnable.cancel();
}
Chat.log("Clearing ranks, infractions, and sign change packets...");
Rank.getRanks().clear();
Infraction.getList().clear();
Chat.log("MC Zone HIVE is disabled");
SignChangePacket.getList().clear();
}
示例2: onCommand
import org.bukkit.scheduler.BukkitRunnable; //導入方法依賴的package包/類
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (args.length == 0) {
sender.sendMessage(Main.PREFIX + "Usage: /nineslots <info|enable|disable>");
return true;
}
if (args[0].equalsIgnoreCase("info")) {
sender.sendMessage(Main.PREFIX + "Plugin creator: §aLeonTG");
sender.sendMessage(Main.PREFIX + "Version: §a" + plugin.getDescription().getVersion());
sender.sendMessage(Main.PREFIX + "Description:");
sender.sendMessage("§8» §f" + plugin.getDescription().getDescription());
return true;
}
if (args[0].equalsIgnoreCase("enable")) {
if (!sender.hasPermission(PERMISSION)) {
sender.sendMessage(ChatColor.RED + "You don't have permission.");
return true;
}
if (enabled) {
sender.sendMessage(Main.PREFIX + "Nine Slots is already enabled.");
return true;
}
plugin.broadcast(Main.PREFIX + "Nine Slots has been enabled.");
enabled = true;
Bukkit.getPluginManager().registerEvents(listener, plugin);
task = new BukkitRunnable() {
@Override
public void run() {
for (Player online : Bukkit.getOnlinePlayers()) {
for (int i = 9; i < 36; i++) {
online.getInventory().setItem(i, Main.BLOCKED_ITEM);
}
}
}
};
task.runTaskTimer(plugin, 0L, 100L);
return true;
}
if (args[0].equalsIgnoreCase("disable")) {
if (!sender.hasPermission(PERMISSION)) {
sender.sendMessage(ChatColor.RED + "You don't have permission.");
return true;
}
if (!enabled) {
sender.sendMessage(Main.PREFIX + "Nine Slots is not enabled.");
return true;
}
plugin.broadcast(Main.PREFIX + "Nine Slots has been disabled.");
enabled = false;
HandlerList.unregisterAll(listener);
if (task != null) {
task.cancel();
}
task = null;
return true;
}
sender.sendMessage(Main.PREFIX + "Usage: /nineslots <info|enable|disable>");
return true;
}