本文整理汇总了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;
}