当前位置: 首页>>代码示例>>Java>>正文


Java BukkitRunnable.cancel方法代码示例

本文整理汇总了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();
}
 
开发者ID:thekeenant,项目名称:mczone,代码行数:14,代码来源:MCZone.java

示例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;
}
 
开发者ID:LeonTG,项目名称:NineSlots,代码行数:74,代码来源:NineSlotsCommand.java


注:本文中的org.bukkit.scheduler.BukkitRunnable.cancel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。