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


Java Task.cancel方法代码示例

本文整理汇总了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();
	}
}
 
开发者ID:FabioZumbi12,项目名称:UltimateChat,代码行数:22,代码来源:MuteCountDown.java

示例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();
    }
}
 
开发者ID:BadgeUp,项目名称:badgeup-sponge-client,代码行数:25,代码来源:FireworkConsumer.java

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

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

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

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

示例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);
        }
    });
}
 
开发者ID:MinecraftMarket,项目名称:MinecraftMarket-Plugin,代码行数:37,代码来源:MCMarket.java

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

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

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

示例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();
    }
}
 
开发者ID:BadgeUp,项目名称:badgeup-sponge-client,代码行数:11,代码来源:SoundEffectConsumer.java

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

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

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

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


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