Search in sources :

Example 1 with Firework

use of org.spongepowered.api.entity.projectile.Firework in project Skree by Skelril.

the class JungleRaidEffectListener method handleLoss.

private void handleLoss(JungleRaidInstance inst, Player player) {
    FlagEffectData data = inst.getFlagData();
    boolean isTitanEnabled = inst.isFlagEnabled(JungleRaidFlag.TITAN_MODE);
    boolean isTitan = player.getUniqueId().equals(data.titan);
    // Normal Jungle Raid fireworks and stuff
    Color killerColor = Color.WHITE;
    Color teamColor = inst.getTeamColor(player).orElse(Color.WHITE);
    Optional<Player> optKiller = inst.getLastAttacker(player);
    if (optKiller.isPresent()) {
        Player killer = optKiller.get();
        killerColor = inst.getTeamColor(killer).orElse(Color.WHITE);
        if (isTitanEnabled) {
            if (isTitan) {
                data.titan = killer.getUniqueId();
                ItemStack teamHood = newItemStack(ItemTypes.LEATHER_HELMET);
                teamHood.offer(Keys.DISPLAY_NAME, Text.of(TextColors.WHITE, "Titan Hood"));
                teamHood.offer(Keys.COLOR, Color.BLACK);
                // playerEquipment.set(EquipmentTypes.HEADWEAR, teamHood);
                tf(killer).inventory.armorInventory.set(3, tf(teamHood));
            } else if (killer.getUniqueId().equals(data.titan)) {
                killerColor = Color.BLACK;
            }
        }
    }
    if (isTitan && data.titan.equals(player.getUniqueId())) {
        data.titan = null;
    }
    if (!inst.isFlagEnabled(JungleRaidFlag.DEATH_ROCKETS)) {
        return;
    }
    Location<World> playerLoc = player.getLocation();
    Color finalKillerColor = killerColor;
    for (int i = 0; i < 12; i++) {
        Task.builder().delayTicks(i * 4).execute(() -> {
            Firework firework = (Firework) inst.getRegion().getExtent().createEntity(EntityTypes.FIREWORK, playerLoc.getPosition());
            FireworkEffect fireworkEffect = FireworkEffect.builder().flicker(Probability.getChance(2)).trail(Probability.getChance(2)).color(teamColor).fade(finalKillerColor).shape(FireworkShapes.CREEPER).build();
            firework.offer(Keys.FIREWORK_EFFECTS, Lists.newArrayList(fireworkEffect));
            firework.offer(Keys.FIREWORK_FLIGHT_MODIFIER, Probability.getRangedRandom(2, 5));
            inst.getRegion().getExtent().spawnEntity(firework, Cause.source(SpawnCause.builder().type(SpawnTypes.PLUGIN).build()).build());
        }).submit(SkreePlugin.inst());
    }
}
Also used : Player(org.spongepowered.api.entity.living.player.Player) TextColor(org.spongepowered.api.text.format.TextColor) Color(org.spongepowered.api.util.Color) Firework(org.spongepowered.api.entity.projectile.Firework) ItemStack(org.spongepowered.api.item.inventory.ItemStack) ItemStackFactory.newItemStack(com.skelril.nitro.item.ItemStackFactory.newItemStack) World(org.spongepowered.api.world.World) FireworkEffect(org.spongepowered.api.item.FireworkEffect)

Aggregations

ItemStackFactory.newItemStack (com.skelril.nitro.item.ItemStackFactory.newItemStack)1 Player (org.spongepowered.api.entity.living.player.Player)1 Firework (org.spongepowered.api.entity.projectile.Firework)1 FireworkEffect (org.spongepowered.api.item.FireworkEffect)1 ItemStack (org.spongepowered.api.item.inventory.ItemStack)1 TextColor (org.spongepowered.api.text.format.TextColor)1 Color (org.spongepowered.api.util.Color)1 World (org.spongepowered.api.world.World)1