本文整理汇总了Java中org.spongepowered.api.scheduler.Task.cancel方法的典型用法代码示例。如果您正苦于以下问题:Java Task.cancel方法的具体用法?Java Task.cancel怎么用?Java Task.cancel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.spongepowered.api.scheduler.Task
的用法示例。
在下文中一共展示了Task.cancel方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: accept
import org.spongepowered.api.scheduler.Task; //导入方法依赖的package包/类
@Override
public void accept(Task t) {
if (UChat.get().timeMute.containsKey(p)) {
time = UChat.get().timeMute.get(p)-1;
}
if (UChat.get().mutes.contains(p)){
if (time > 0) {
UChat.get().timeMute.put(p, time);
} else {
UChat.get().timeMute.remove(p);
UChat.get().mutes.remove(p);
UChat.get().unMuteInAllChannels(p);
if (Sponge.getServer().getPlayer(p).isPresent()){
UChat.get().getLang().sendMessage(Sponge.getServer().getPlayer(p).get(), UChat.get().getLang().get("channel.player.unmuted.all"));
}
t.cancel();
}
} else {
t.cancel();
}
}
示例2: accept
import org.spongepowered.api.scheduler.Task; //导入方法依赖的package包/类
@Override
public void accept(Task task) {
List<Color> colors = Lists.newArrayList(Color.BLACK, Color.BLUE, Color.CYAN, Color.DARK_CYAN, Color.DARK_GREEN, Color.DARK_MAGENTA,
Color.GRAY, Color.GREEN, Color.LIME, Color.MAGENTA, Color.NAVY, Color.PINK, Color.PURPLE, Color.RED, Color.WHITE, Color.YELLOW);
Collections.shuffle(colors);
FireworkEffect fireworkEffect = FireworkEffect.builder()
.colors(colors.get(0), colors.get(1), colors.get(2))
.shape(FireworkShapes.STAR)
.build();
Entity firework = this.player.getWorld().createEntity(EntityTypes.FIREWORK, this.player.getLocation().getPosition());
firework.offer(Keys.FIREWORK_EFFECTS, Lists.newArrayList(fireworkEffect));
firework.offer(Keys.FIREWORK_FLIGHT_MODIFIER, 2);
this.player.getWorld().spawnEntity(firework);
this.counter++;
if (this.counter >= this.ITERATIONS) {
task.cancel();
}
}
示例3: unloadWorldData
import org.spongepowered.api.scheduler.Task; //导入方法依赖的package包/类
public void unloadWorldData(WorldProperties worldProperties) {
GPClaimManager claimWorldManager = this.getClaimWorldManager(worldProperties);
for (Claim claim : claimWorldManager.getWorldClaims()) {
((GPClaim) claim).unload();
}
// Task must be cancelled before removing the claimWorldManager reference to avoid a memory leak
Task cleanupTask = cleanupClaimTasks.get(worldProperties.getUniqueId());
if (cleanupTask != null) {
cleanupTask.cancel();
cleanupClaimTasks.remove(worldProperties.getUniqueId());
}
claimWorldManager.unload();
this.claimWorldManagers.remove(worldProperties.getUniqueId());
DataStore.dimensionConfigMap.remove(worldProperties.getUniqueId());
DataStore.worldConfigMap.remove(worldProperties.getUniqueId());
}
示例4: accept
import org.spongepowered.api.scheduler.Task; //导入方法依赖的package包/类
@Override
public void accept(Task task) {
boolean timeOk = endTime > System.currentTimeMillis();
UUID uuid = player.getUniqueId();
if (dataSource.isActive(player) && timeOk)
return;
try {
if (!timeOk) {
InventorySync.getLogger().warn("Loading player " + DataSource.getPlayerString(player)
+ " failed because the previous server did not finish writing the data in time. Will synchronize anyway!");
InventorySync.getLogger().info("Try increasing global.maxWait in the config");
}
synchronized (waitingPlayers) {
waitingPlayers.remove(uuid);
}
loadPlayer(player);
} catch (ClassNotFoundException | IOException | DataFormatException e) {
InventorySync.getLogger().warn("Loading player " + DataSource.getPlayerString(player) + " failed!", e);
} finally {
synchronized (waitingPlayers) {
if (waitingPlayers.containsKey(uuid)) {
waitingPlayers.remove(uuid);
}
}
task.cancel();
}
}
示例5: accept
import org.spongepowered.api.scheduler.Task; //导入方法依赖的package包/类
@Override
public void accept(Task task) {
if (player.isOnline()) {
Location<World> playerCurrentLocation = player.getLocation();
double playerCurrentHealth = player.health().get();
if (!playerCurrentLocation.getExtent().getName().equals(playerPreviousLocation.getExtent().getName())
|| playerCurrentLocation.getPosition().distance(playerPreviousLocation.getPosition()) > 0) {
task.cancel();
Messages.sendWarningMessage(player, Messages.TELEPORT_CANCELLED);
} else if (playerCurrentHealth < playerPreviousHealth) {
task.cancel();
Messages.sendWarningMessage(player, Messages.TELEPORT_CANCELLED);
} else {
if (countdownSeconds <= 0) {
task.cancel();
if (Config.getBoolean(Config.USE_ECONOMY) && !forceNoCurrency) {
double teleportCost = Config.getDouble(Config.TELEPORT_COST);
boolean success = EconomyUtils.withdraw(clanPlayer.getUUID(), teleportCost);
String currencyName = MCClans.getPlugin().getServiceHelper().currency.getDisplayName().toPlain();
if (success) {
teleport(player, clanPlayer, teleportLocation);
if (teleportCost != 0) {
Messages.sendYouWereChargedCurrency(player, teleportCost, currencyName);
}
} else {
Messages.sendYouDoNotHaveEnoughCurrency(player, teleportCost, currencyName);
}
} else {
teleport(player, clanPlayer, teleportLocation);
}
} else {
Messages.sendTeleportingInXSeconds(player, countdownSeconds);
}
playerPreviousLocation = player.getLocation();
countdownSeconds--;
}
} else {
task.cancel();
}
}
示例6: onGameStoppingServerEvent
import org.spongepowered.api.scheduler.Task; //导入方法依赖的package包/类
@Listener
public void onGameStoppingServerEvent(GameStoppingServerEvent e) {
Sponge.getEventManager().unregisterPluginListeners(this);
for (Task task : Sponge.getScheduler().getScheduledTasks(this)) {
task.cancel();
}
i18n.onDisable();
}
示例7: reloadConfigs
import org.spongepowered.api.scheduler.Task; //导入方法依赖的package包/类
public void reloadConfigs(Response<Boolean> response) {
mainConfig = new MainConfig(baseDirectory.toFile());
signsConfig = new SignsConfig(baseDirectory.toFile());
signsLayoutConfig = new SignsLayoutConfig(baseDirectory.toFile());
i18n.updateLocale(mainConfig.getLang());
Sponge.getEventManager().unregisterPluginListeners(this);
for (Task task : Sponge.getScheduler().getScheduledTasks(this)) {
task.cancel();
}
setKey(mainConfig.getApiKey(), false, result -> {
if (mainConfig.isUseSigns()) {
if (signsTask == null) {
signsTask = new SignsTask(this);
}
Sponge.getScheduler().createTaskBuilder().delayTicks(20 * 10).intervalTicks(mainConfig.getCheckInterval() > 0 ? 20 * 60 * mainConfig.getCheckInterval() : 20 * 60).execute(signsTask).submit(this);
Sponge.getEventManager().registerListeners(this, new SignsListener(this));
}
if (purchasesTask == null) {
purchasesTask = new PurchasesTask(this);
}
Sponge.getScheduler().createTaskBuilder().async().delayTicks(20 * 10).intervalTicks(mainConfig.getCheckInterval() > 0 ? 20 * 60 * mainConfig.getCheckInterval() : 20 * 60).execute(purchasesTask).submit(this);
if (result && mainConfig.isStatistics()) {
Optional<PluginContainer> optional = Sponge.getPluginManager().fromInstance(this);
optional.ifPresent(pluginContainer -> new SpongeStats(marketApi, pluginContainer));
}
if (response != null) {
response.done(result);
}
});
}
示例8: onReload
import org.spongepowered.api.scheduler.Task; //导入方法依赖的package包/类
@Listener
public void onReload(GameReloadEvent event) {
cfgLoader = new ConfigLoader(this);
if (cfgLoader.loadConfig()) cclConfig = cfgLoader.getCclConfig();
if (cfgLoader.loadMessages()) messages = cfgLoader.getMessagesConfig();
for (Task task : tasks) {
task.cancel();
}
tasks = new ArrayList<>();
Task.Builder builder = getGame().getScheduler().createTaskBuilder();
tasks.add(builder.execute(new ItemClearer())
.async()
.delay(cclConfig.interval, TimeUnit.MINUTES)
.interval(cclConfig.interval, TimeUnit.MINUTES)
.name("CatClearLag Item Remover")
.submit(this));
cclConfig.warnings.forEach((d) ->
tasks.add(builder.execute(new ItemClearingWarning(((cclConfig.interval * 60) - d)))
.async()
.delay(d, TimeUnit.SECONDS)
.interval(cclConfig.interval, TimeUnit.MINUTES)
.name("CatClearLag Removal Warnings")
.submit(this)));
tasks.add(builder.execute(new EntityChecker())
.async()
.delay(cclConfig.limits.entityCheckInterval, TimeUnit.MINUTES)
.interval(cclConfig.limits.entityCheckInterval, TimeUnit.MINUTES)
.name("CatClearLag hostile checker")
.submit(this));
}
示例9: onStopServer
import org.spongepowered.api.scheduler.Task; //导入方法依赖的package包/类
@Listener
public void onStopServer(GameStoppingServerEvent e) {
cfgs.savePlayersStats();
for (Task task:Sponge.getScheduler().getScheduledTasks(this)){
task.cancel();
}
RULogger.severe("RankUpper disabled.");
}
示例10: reload
import org.spongepowered.api.scheduler.Task; //导入方法依赖的package包/类
public void reload(){
for (Task task:Sponge.getScheduler().getScheduledTasks(this)){
task.cancel();
}
cfgs.savePlayersStats();
cfgs = new RUConfig(this, configDir, defConfig);
RULang.init(this, configDir);
PlayerCounterHandler();
AutoSaveHandler();
registerNucleus();
}
示例11: accept
import org.spongepowered.api.scheduler.Task; //导入方法依赖的package包/类
@Override
public void accept(Task task) {
this.player.playSound(this.soundType, this.player.getLocation().getPosition(), 1);
this.counter++;
if (this.counter >= this.ITERATIONS) {
task.cancel();
}
}
示例12: cancelTask
import org.spongepowered.api.scheduler.Task; //导入方法依赖的package包/类
private void cancelTask(Task task) {
// Don't fire multiple instances.
if (Lantern.getScheduler().getTaskById(task.getUniqueId()).isPresent()) {
Sponge.getEventManager().post(SpongeEventFactory.createChunkPreGenerationEventCancelled(this.cause, this, this.world));
task.cancel();
}
this.isCancelled = true;
unregisterListener();
}
示例13: cancel
import org.spongepowered.api.scheduler.Task; //导入方法依赖的package包/类
@Override
public void cancel(int i) {
Task task = this.tasks.remove(i);
if (task != null) {
task.cancel();
}
}
示例14: onStopServer
import org.spongepowered.api.scheduler.Task; //导入方法依赖的package包/类
@Listener
public void onStopServer(GameStoppingServerEvent e) {
for (Player p:game.getServer().getOnlinePlayers()){
pvhelp.closeInventory(p);
}
rm.saveAll();
rm.unloadAll();
logger.SaveLogs();
for (Task task:Sponge.getScheduler().getScheduledTasks(this)){
task.cancel();
}
logger.severe(container.getName() + " disabled.");
}
示例15: accept
import org.spongepowered.api.scheduler.Task; //导入方法依赖的package包/类
@Override
public void accept(Task task) {
float diff = boss.getPercent() - 0.2f;
if (diff > 0){
boss.setPercent(diff);
} else {
boss.setVisible(false);
boss.removePlayer(boss.getPlayers().stream().findFirst().get());
task.cancel();
}
}