use of org.spongepowered.api.util.Color in project Skree by Skelril.
the class SkyWarsInstance method giveTeamHoods.
private void giveTeamHoods(Player player) {
player.getInventory().clear();
for (Color teamColor : colorNameMapping.keySet()) {
ItemStack teamHood = newItemStack(ItemTypes.LEATHER_HELMET);
teamHood.offer(Keys.DISPLAY_NAME, Text.of(TextColors.WHITE, "Sky Hood"));
teamHood.offer(Keys.COLOR, teamColor);
player.getInventory().offer(teamHood);
}
}
use of org.spongepowered.api.util.Color 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[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());
}
}
use of org.spongepowered.api.util.Color in project HuskyCrates-Sponge by codeHusky.
the class PhysicalCrate method runParticles.
public void runParticles() {
try {
createHologram();
double time = randomTimeOffset + (Sponge.getServer().getRunningTimeTicks() * 0.25);
double size = 0.8;
double x = Math.sin(time) * size;
double y = Math.sin(time * 2) * 0.2 - 0.45;
double z = Math.cos(time) * size;
Color clr1 = Color.ofRgb(100, 100, 100);
Color clr2 = Color.ofRgb(255, 0, 0);
if (vc.getOptions().containsKey("clr1")) {
clr1 = (Color) vc.getOptions().get("clr1");
}
if (vc.getOptions().containsKey("clr2")) {
clr2 = (Color) vc.getOptions().get("clr2");
}
as.getWorld().spawnParticles(ParticleEffect.builder().type(ParticleTypes.REDSTONE_DUST).option(ParticleOptions.COLOR, clr1).build(), as.getLocation().getPosition().add(x, y, z));
x = Math.cos(time + 10) * size;
y = Math.sin(time * 2 + 10) * 0.2 - 0.55;
z = Math.sin(time + 10) * size;
as.getWorld().spawnParticles(ParticleEffect.builder().type(ParticleTypes.REDSTONE_DUST).option(ParticleOptions.COLOR, clr2).build(), as.getLocation().getPosition().add(x, y, z));
} catch (Exception e) {
}
}
use of org.spongepowered.api.util.Color in project Skree by Skelril.
the class SkyWarsInstance method smartStart.
private void smartStart() {
HashMap<Player, Color> colorMapping = new HashMap<>();
for (Player player : getPlayers(PlayerClassifier.PARTICIPANT)) {
Optional<ItemStack> optHelmet = player.getHelmet();
if (!optHelmet.isPresent()) {
return;
}
ItemStack helmet = optHelmet.get();
Optional<Color> optColor = helmet.get(Keys.COLOR);
if (!optColor.isPresent()) {
return;
}
colorMapping.put(player, optColor.get());
}
// Reset the team mapping as it may have been corrupted by a bad run
teams = createTeamsMapping();
for (Map.Entry<Player, Color> entry : colorMapping.entrySet()) {
Color color = entry.getValue();
Set<Player> team = teams.get(color);
if (team == null) {
return;
}
Player player = entry.getKey();
// Update team mapping
team.add(player);
SkyWarsPlayerData playerData = playerDataMapping.get(player);
playerData.setTeam(team);
// Give player team equipment
giveTeamEquipment(player, color);
// Throw player
launchPlayer(player, 1);
playerData.stopPushBack();
}
if (getWinner().isPresent()) {
return;
}
getPlayerMessageChannel(PlayerClassifier.SPECTATOR).send(Text.of(TextColors.RED, "Fight!"));
state = SkyWarsState.IN_PROGRESS;
showStartingPlatform(false);
}
Aggregations