Search in sources :

Example 1 with GameModeData

use of org.spongepowered.api.data.manipulator.mutable.entity.GameModeData in project LanternServer by LanternPowered.

the class SelectorResolver method addGamemodeFilters.

private void addGamemodeFilters(List<Predicate<Entity>> filters) {
    Selector sel = this.selector;
    Optional<GameMode> gamemode = sel.get(ArgumentTypes.GAME_MODE);
    // If the game mode is NOT_SET, that means accept any
    if (gamemode.isPresent() && gamemode.get() != GameModes.NOT_SET) {
        final GameMode actualMode = gamemode.get();
        filters.add(input -> {
            Optional<GameModeData> mode = input.get(GameModeData.class);
            return mode.isPresent() && mode.get() == actualMode;
        });
    }
}
Also used : GameMode(org.spongepowered.api.entity.living.player.gamemode.GameMode) GameModeData(org.spongepowered.api.data.manipulator.mutable.entity.GameModeData) Selector(org.spongepowered.api.text.selector.Selector)

Example 2 with GameModeData

use of org.spongepowered.api.data.manipulator.mutable.entity.GameModeData in project SpongeCommon by SpongePowered.

the class SelectorResolver method addGamemodeFilters.

private void addGamemodeFilters(List<Predicate<Entity>> filters) {
    Selector sel = this.selector;
    Optional<GameMode> gamemode = sel.get(ArgumentTypes.GAME_MODE);
    // If the gamemode is NOT_SET, that means accept any
    if (gamemode.isPresent() && gamemode.get() != GameModes.NOT_SET) {
        final GameMode actualMode = gamemode.get();
        filters.add(input -> {
            Optional<GameModeData> mode = input.get(GameModeData.class);
            return mode.isPresent() && mode.get() == actualMode;
        });
    }
}
Also used : GameMode(org.spongepowered.api.entity.living.player.gamemode.GameMode) GameModeData(org.spongepowered.api.data.manipulator.mutable.entity.GameModeData) Selector(org.spongepowered.api.text.selector.Selector)

Aggregations

GameModeData (org.spongepowered.api.data.manipulator.mutable.entity.GameModeData)2 GameMode (org.spongepowered.api.entity.living.player.gamemode.GameMode)2 Selector (org.spongepowered.api.text.selector.Selector)2