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());
}
}
Aggregations