本文整理汇总了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();
}
示例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();
}
示例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;
}
示例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();
}
示例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;
}
示例6: getSyncExecutorService
import org.spongepowered.api.scheduler.SpongeExecutorService; //导入依赖的package包/类
public SpongeExecutorService getSyncExecutorService() {
return this.syncExecutorService;
}
示例7: getAsyncExecutorService
import org.spongepowered.api.scheduler.SpongeExecutorService; //导入依赖的package包/类
public SpongeExecutorService getAsyncExecutorService() {
return this.asyncExecutorService;
}
示例8: getThreadAsync
import org.spongepowered.api.scheduler.SpongeExecutorService; //导入依赖的package包/类
@Override
public SpongeExecutorService getThreadAsync() {
return this.threadAsync;
}
示例9: getThreadSync
import org.spongepowered.api.scheduler.SpongeExecutorService; //导入依赖的package包/类
public SpongeExecutorService getThreadSync() {
return this.threadSync;
}
示例10: getThreadAsync
import org.spongepowered.api.scheduler.SpongeExecutorService; //导入依赖的package包/类
public SpongeExecutorService getThreadAsync() {
return this.getEverAPI().getThreadAsync();
}
示例11: getThreadSync
import org.spongepowered.api.scheduler.SpongeExecutorService; //导入依赖的package包/类
public SpongeExecutorService getThreadSync() {
return this.getEverAPI().getThreadSync();
}
示例12: getSyncExecutorService
import org.spongepowered.api.scheduler.SpongeExecutorService; //导入依赖的package包/类
public static SpongeExecutorService getSyncExecutorService() {
return LanternGame.game.getSyncExecutorService();
}
示例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"));
}
示例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"));
}
示例15: get
import org.spongepowered.api.scheduler.SpongeExecutorService; //导入依赖的package包/类
@Override
public SpongeExecutorService get() {
return this.scheduler.createSyncExecutor(this.container);
}