Search in sources :

Example 1 with DyeColor

use of org.spongepowered.api.data.type.DyeColor in project Skree by Skelril.

the class JungleRaidInstance method smartStart.

public void smartStart() {
    List<Player> ffaList = new ArrayList<>();
    List<Player> redList = new ArrayList<>();
    List<Player> blueList = new ArrayList<>();
    Collection<Player> containedPlayers = getPlayers(PARTICIPANT);
    if (containedPlayers.size() <= 1) {
        return;
    }
    for (Player player : containedPlayers) {
        BlockState state = player.getLocation().add(0, -1, 0).getBlock();
        if (state.getType() != BlockTypes.WOOL) {
            return;
        }
        Optional<?> optColor = state.getTraitValue(EnumTraits.WOOL_COLOR);
        if (optColor.isPresent()) {
            DyeColor color = (DyeColor) optColor.get();
            if (color == DyeColors.RED) {
                redList.add(player);
            } else if (color == DyeColors.BLUE) {
                blueList.add(player);
            } else if (color == DyeColors.WHITE) {
                ffaList.add(player);
            } else {
                return;
            }
        }
    }
    if (getWinner(ffaList, blueList, redList).isPresent()) {
        getPlayerMessageChannel(SPECTATOR).send(Text.of(TextColors.RED, "All players are on one team, the game will not start."));
        return;
    }
    ffaList.stream().forEach(p -> addFFAPlayer(p, classMap.getOrDefault(p, JungleRaidClass.BALANCED)));
    redList.stream().forEach(p -> addRedPlayer(p, classMap.getOrDefault(p, JungleRaidClass.BALANCED)));
    blueList.stream().forEach(p -> addBluePlayer(p, classMap.getOrDefault(p, JungleRaidClass.BALANCED)));
    state = JungleRaidState.INITIALIZE;
    startTime = System.currentTimeMillis();
}
Also used : Player(org.spongepowered.api.entity.living.player.Player) BlockState(org.spongepowered.api.block.BlockState) DyeColor(org.spongepowered.api.data.type.DyeColor)

Example 2 with DyeColor

use of org.spongepowered.api.data.type.DyeColor in project HuskyCrates-Sponge by codeHusky.

the class SpinnerCrateView method confettiBorder.

private ItemStack confettiBorder() {
    DyeColor[] colors = { DyeColors.BLUE, DyeColors.CYAN, DyeColors.GREEN, DyeColors.LIGHT_BLUE, DyeColors.LIME, DyeColors.MAGENTA, DyeColors.ORANGE, DyeColors.PINK, DyeColors.PURPLE, DyeColors.RED, DyeColors.YELLOW };
    ItemStack g = ItemStack.builder().itemType(ItemTypes.STAINED_GLASS_PANE).add(Keys.DYE_COLOR, colors[(int) Math.floor(Math.random() * colors.length)]).build();
    g.offer(Keys.DISPLAY_NAME, Text.of(TextStyles.RESET, "You won an item!"));
    return g;
}
Also used : DyeColor(org.spongepowered.api.data.type.DyeColor) ItemStack(org.spongepowered.api.item.inventory.ItemStack)

Aggregations

DyeColor (org.spongepowered.api.data.type.DyeColor)2 BlockState (org.spongepowered.api.block.BlockState)1 Player (org.spongepowered.api.entity.living.player.Player)1 ItemStack (org.spongepowered.api.item.inventory.ItemStack)1