本文整理汇总了Java中cn.nukkit.scheduler.TaskHandler类的典型用法代码示例。如果您正苦于以下问题:Java TaskHandler类的具体用法?Java TaskHandler怎么用?Java TaskHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TaskHandler类属于cn.nukkit.scheduler包,在下文中一共展示了TaskHandler类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTaskTiming
import cn.nukkit.scheduler.TaskHandler; //导入依赖的package包/类
public static Timing getTaskTiming(TaskHandler handler, long period) {
String repeating = " ";
if (period > 0) {
repeating += "(interval:" + period + ")";
} else {
repeating += "(Single)";
}
if (handler.getTask() instanceof PluginTask) {
String owner = ((PluginTask) handler.getTask()).getOwner().getName();
return TimingsManager.getTiming(owner, "PluginTask: " + handler.getTaskId() + repeating, schedulerSyncTimer);
} else if (!handler.isAsynchronous()) {
return TimingsManager.getTiming(DEFAULT_GROUP.name, "Task: " + handler.getTaskId() + repeating, schedulerSyncTimer);
} else {
return null;
}
}
示例2: runRecheck
import cn.nukkit.scheduler.TaskHandler; //导入依赖的package包/类
private TaskHandler runRecheck() {
Long rescanTime = TimeUtil.parseTime(MultipassPlugin.getCfg().multiServerRecheck);
if (rescanTime <= 0) return null;
int delay = Math.max(TimeUtil.timeToTicks(rescanTime).intValue(), 20);
return Server.getInstance().getScheduler().scheduleDelayedRepeatingTask(() -> {
Collection<Group> groups = null;
List<User> users = new ArrayList<>();
groups = loadGroups();
for (Player player : Server.getInstance().getOnlinePlayers().values()) {
User user = loadUser(player.getName());
if (user != null) users.add(user);
}
if (groups != null) updateAllGroups(groups);
if (users != null && !users.isEmpty()) {
users.forEach(user -> Users.setUser(new User(user.getName(), user)));
}
}, delay, delay, true);
}
示例3: safeTeleport
import cn.nukkit.scheduler.TaskHandler; //导入依赖的package包/类
public void safeTeleport(final Player player, final Location homeSweetHome, boolean force, int home) {
final Location targetLoc = homeSweetHome.clone().add(0.5, 0, 0.5);
if (list.contains(player.getName())) {
list.remove(player.getName());
}
Utils.loadChunkAt(targetLoc);
if (player.hasPermission("is.bypass.wait") || (teleportDelay == 0) || force) {
player.teleport(targetLoc, PlayerTeleportEvent.TeleportCause.PLUGIN);
} else {
player.sendMessage(plugin.getPrefix() + plugin.getLocale(player).teleportDelay.replace("{0}", "" + teleportDelay));
TaskHandler task = plugin.getServer().getScheduler().scheduleDelayedTask(plugin, () -> {
// Save player inventory
if (Settings.saveInventory) {
plugin.getInventory().savePlayerInventory(player);
}
pendingTPs.remove(player.getUniqueId());
if (home == 1) {
player.sendMessage(plugin.getPrefix() + TextFormat.GREEN + "Teleported to your island");
} else {
player.sendMessage(plugin.getPrefix() + TextFormat.GREEN + "Teleported to your island #" + home);
}
player.teleport(targetLoc.add(0, 0.35), PlayerTeleportEvent.TeleportCause.PLUGIN); // Adjust spawn hieght
// Teleport in default gamemode
if (Settings.gamemode != -1) {
// BETA Testing: Add this later
//player.setGamemode(Settings.gamemode);
}
}, Utils.secondsAsMillis(teleportDelay));
time.put(player.getName(), Utils.secondsAsMillis(teleportDelay));
pendingTPs.put(player.getUniqueId(), new PendingTeleport(player.getLocation(), task));
}
}
示例4: PendingTeleport
import cn.nukkit.scheduler.TaskHandler; //导入依赖的package包/类
private PendingTeleport(Location location, TaskHandler task) {
this.location = location != null ? location.clone() : null;
this.task = task;
}
示例5: getTask
import cn.nukkit.scheduler.TaskHandler; //导入依赖的package包/类
public TaskHandler getTask() {
return task;
}
示例6: taskRepeat
import cn.nukkit.scheduler.TaskHandler; //导入依赖的package包/类
public int taskRepeat(Runnable r, int interval) {
TaskHandler task = ASkyBlock.get().getServer().getScheduler().scheduleRepeatingTask(ASkyBlock.get(), r, interval, false);
return task.getTaskId();
}
示例7: taskRepeatAsync
import cn.nukkit.scheduler.TaskHandler; //导入依赖的package包/类
@SuppressWarnings("deprecation")
public int taskRepeatAsync(Runnable r, int interval) {
TaskHandler task = ASkyBlock.get().getServer().getScheduler().scheduleRepeatingTask(ASkyBlock.get(), r, interval, true);
return task.getTaskId();
}
示例8: PokkitTask
import cn.nukkit.scheduler.TaskHandler; //导入依赖的package包/类
PokkitTask(TaskHandler nukkit, Plugin plugin) {
this.nukkit = Objects.requireNonNull(nukkit, "nukkit");
this.plugin = Objects.requireNonNull(plugin, "plugin");
}
示例9: repeat
import cn.nukkit.scheduler.TaskHandler; //导入依赖的package包/类
@Override
public int repeat(final Runnable r, final int interval) {
TaskHandler task = this.plugin.getServer().getScheduler().scheduleRepeatingTask(r, interval, false);
return task.getTaskId();
}
示例10: repeatAsync
import cn.nukkit.scheduler.TaskHandler; //导入依赖的package包/类
@Override
public int repeatAsync(final Runnable r, final int interval) {
TaskHandler task = this.plugin.getServer().getScheduler().scheduleRepeatingTask(r, interval, true);
return task.getTaskId();
}
示例11: taskRepeat
import cn.nukkit.scheduler.TaskHandler; //导入依赖的package包/类
@Override
public int taskRepeat(Runnable r, int interval) {
TaskHandler task = this.plugin.getServer().getScheduler().scheduleRepeatingTask(r, interval, false);
return task.getTaskId();
}
示例12: taskRepeatAsync
import cn.nukkit.scheduler.TaskHandler; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@Override
public int taskRepeatAsync(Runnable r, int interval) {
TaskHandler task = this.plugin.getServer().getScheduler().scheduleRepeatingTask(r, interval, true);
return task.getTaskId();
}