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


Java TaskHandler类代码示例

本文整理汇总了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;
    }
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:18,代码来源:Timings.java

示例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);
}
 
开发者ID:fromgate,项目名称:Multipass,代码行数:19,代码来源:DatabaseSource.java

示例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));
    }
}
 
开发者ID:TheSolidCrafter,项目名称:ASkyBlock-Nukkit,代码行数:33,代码来源:TeleportLogic.java

示例4: PendingTeleport

import cn.nukkit.scheduler.TaskHandler; //导入依赖的package包/类
private PendingTeleport(Location location, TaskHandler task) {
    this.location = location != null ? location.clone() : null;
    this.task = task;
}
 
开发者ID:TheSolidCrafter,项目名称:ASkyBlock-Nukkit,代码行数:5,代码来源:TeleportLogic.java

示例5: getTask

import cn.nukkit.scheduler.TaskHandler; //导入依赖的package包/类
public TaskHandler getTask() {
    return task;
}
 
开发者ID:TheSolidCrafter,项目名称:ASkyBlock-Nukkit,代码行数:4,代码来源:TeleportLogic.java

示例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();
}
 
开发者ID:TheSolidCrafter,项目名称:ASkyBlock-Nukkit,代码行数:5,代码来源:TaskManager.java

示例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();
}
 
开发者ID:TheSolidCrafter,项目名称:ASkyBlock-Nukkit,代码行数:6,代码来源:TaskManager.java

示例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");
}
 
开发者ID:rutgerkok,项目名称:Pokkit,代码行数:5,代码来源:PokkitTask.java

示例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();
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:6,代码来源:NukkitTaskManager.java

示例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();
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:6,代码来源:NukkitTaskManager.java

示例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();
}
 
开发者ID:IntellectualSites,项目名称:PlotSquared,代码行数:6,代码来源:NukkitTaskManager.java

示例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();
}
 
开发者ID:IntellectualSites,项目名称:PlotSquared,代码行数:7,代码来源:NukkitTaskManager.java


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