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


Java SpongeExecutorService类代码示例

本文整理汇总了Java中org.spongepowered.api.scheduler.SpongeExecutorService的典型用法代码示例。如果您正苦于以下问题:Java SpongeExecutorService类的具体用法?Java SpongeExecutorService怎么用?Java SpongeExecutorService使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SpongeExecutorService类属于org.spongepowered.api.scheduler包,在下文中一共展示了SpongeExecutorService类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: execute

import org.spongepowered.api.scheduler.SpongeExecutorService; //导入依赖的package包/类
@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
    int page = args.<Integer>getOne("page").get();

    Consumer<Collection<PlayerStats>> callback = map -> displayConsole(page, map);
    if (src instanceof Player) {
        UUID uuid = ((Player) src).getUniqueId();
        callback = map -> Sponge.getServer().getPlayer(uuid).ifPresent(player -> display(player, page, map));
    }

    SpongeExecutorService asyncExecutor = Sponge.getScheduler().createAsyncExecutor(plugin);
    SpongeExecutorService syncExecutor = Sponge.getScheduler().createAsyncExecutor(plugin);
    CompletableFuture.supplyAsync(() -> plugin.getDatabaseManager().getTopEntries(page), asyncExecutor)
            .thenAcceptAsync(callback, syncExecutor);

    src.sendMessage(Text.of(TextColors.YELLOW, "Query sent"));
    return CommandResult.success();
}
 
开发者ID:games647,项目名称:TrackMe,代码行数:19,代码来源:TopCommand.java

示例2: execute

import org.spongepowered.api.scheduler.SpongeExecutorService; //导入依赖的package包/类
@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
    String username = args.<String>getOne("account").get();
    if (plugin.isValidName(username)) {
        SpongeExecutorService asyncExecutor = Sponge.getScheduler().createAsyncExecutor(plugin);
        SpongeExecutorService syncExecutor = Sponge.getScheduler().createAsyncExecutor(plugin);

        Optional<UUID> sender = Optional.empty();
        if (src instanceof Player) {
            sender = Optional.of(((Player) src).getUniqueId());
        }

        Optional<UUID> finalSender = sender;
        CompletableFuture.supplyAsync(() -> plugin.getDatabase().loadAccount(username), asyncExecutor)
                                .thenAcceptAsync(optAcc -> onAccLoaded(finalSender, optAcc), syncExecutor);

        return CommandResult.success();
    }

    src.sendMessage(settings.getText().getInvalidUsername());
    return CommandResult.success();
}
 
开发者ID:games647,项目名称:FlexibleLogin,代码行数:23,代码来源:LastLoginCommand.java

示例3: start

import org.spongepowered.api.scheduler.SpongeExecutorService; //导入依赖的package包/类
public static UUID start(SurvivalGame survivalGame, String intervalName, int intervalSeconds) {

        SpongeExecutorService.SpongeFuture future =
                SurvivalGamesPlugin.EXECUTOR.scheduleAtFixedRate(
                        () ->
                                Sponge.getEventManager()
                                        .post(new IntervalEvent(survivalGame, intervalName)),
                        0,
                        intervalSeconds,
                        TimeUnit.SECONDS);

        UUID uuid = UUID.randomUUID();
        FUTURE_MAP.put(uuid, future);
        return uuid;
    }
 
开发者ID:m0pt0pmatt,项目名称:SurvivalGames,代码行数:16,代码来源:ActiveIntervalRepository.java

示例4: start

import org.spongepowered.api.scheduler.SpongeExecutorService; //导入依赖的package包/类
public static UUID start(SurvivalGame survivalGame, MobSpawnArea mobSpawnArea, World world) {
    int millisecondsPerSpawn =
            mobSpawnArea.getSpawnRatePerMinute().map(integer -> 1000 * 60 / integer).orElse(0);

    SpongeExecutorService.SpongeFuture future =
            SurvivalGamesPlugin.EXECUTOR.scheduleAtFixedRate(
                    new MobSpawnRunnable(survivalGame, mobSpawnArea, world),
                    0,
                    millisecondsPerSpawn,
                    TimeUnit.MILLISECONDS);

    FUTURE_MAP.put(mobSpawnArea.getId(), future);

    return mobSpawnArea.getId();
}
 
开发者ID:m0pt0pmatt,项目名称:SurvivalGames,代码行数:16,代码来源:ActiveMobSpawnRepository.java

示例5: getExecutor

import org.spongepowered.api.scheduler.SpongeExecutorService; //导入依赖的package包/类
public SpongeExecutorService getExecutor() {
    if (this.executor == null) {
        this.executor = Sponge.getScheduler().createSyncExecutor(this);
    }
    return this.executor;
}
 
开发者ID:kenzierocks,项目名称:Annointment,代码行数:7,代码来源:APlugin.java

示例6: getSyncExecutorService

import org.spongepowered.api.scheduler.SpongeExecutorService; //导入依赖的package包/类
public SpongeExecutorService getSyncExecutorService() {
    return this.syncExecutorService;
}
 
开发者ID:lucko,项目名称:LuckPerms,代码行数:4,代码来源:LPSpongePlugin.java

示例7: getAsyncExecutorService

import org.spongepowered.api.scheduler.SpongeExecutorService; //导入依赖的package包/类
public SpongeExecutorService getAsyncExecutorService() {
    return this.asyncExecutorService;
}
 
开发者ID:lucko,项目名称:LuckPerms,代码行数:4,代码来源:LPSpongePlugin.java

示例8: getThreadAsync

import org.spongepowered.api.scheduler.SpongeExecutorService; //导入依赖的package包/类
@Override
public SpongeExecutorService getThreadAsync() {
	return this.threadAsync;
}
 
开发者ID:EverCraft,项目名称:EverAPI,代码行数:5,代码来源:EverAPI.java

示例9: getThreadSync

import org.spongepowered.api.scheduler.SpongeExecutorService; //导入依赖的package包/类
public SpongeExecutorService getThreadSync() {
	return this.threadSync;
}
 
开发者ID:EverCraft,项目名称:EverAPI,代码行数:4,代码来源:EverAPI.java

示例10: getThreadAsync

import org.spongepowered.api.scheduler.SpongeExecutorService; //导入依赖的package包/类
public SpongeExecutorService getThreadAsync() {
	return this.getEverAPI().getThreadAsync();
}
 
开发者ID:EverCraft,项目名称:EverAPI,代码行数:4,代码来源:EPlugin.java

示例11: getThreadSync

import org.spongepowered.api.scheduler.SpongeExecutorService; //导入依赖的package包/类
public SpongeExecutorService getThreadSync() {
	return this.getEverAPI().getThreadSync();
}
 
开发者ID:EverCraft,项目名称:EverAPI,代码行数:4,代码来源:EPlugin.java

示例12: getSyncExecutorService

import org.spongepowered.api.scheduler.SpongeExecutorService; //导入依赖的package包/类
public static SpongeExecutorService getSyncExecutorService() {
    return LanternGame.game.getSyncExecutorService();
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:4,代码来源:Lantern.java

示例13: createSyncExecutor

import org.spongepowered.api.scheduler.SpongeExecutorService; //导入依赖的package包/类
@Override
public SpongeExecutorService createSyncExecutor(Object plugin) {
    return new TaskExecutorService(this::createTaskBuilder, this.syncScheduler, checkPlugin(plugin, "plugin"));
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:5,代码来源:LanternScheduler.java

示例14: createAsyncExecutor

import org.spongepowered.api.scheduler.SpongeExecutorService; //导入依赖的package包/类
@Override
public SpongeExecutorService createAsyncExecutor(Object plugin) {
    return new TaskExecutorService(() -> createTaskBuilder().async(), this.asyncScheduler, checkPlugin(plugin, "plugin"));
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:5,代码来源:LanternScheduler.java

示例15: get

import org.spongepowered.api.scheduler.SpongeExecutorService; //导入依赖的package包/类
@Override
public SpongeExecutorService get() {
    return this.scheduler.createSyncExecutor(this.container);
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:5,代码来源:SpongeExecutorServiceProvider.java


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