Skip to content

Commit

Permalink
Merge pull request #104 from TownyAdvanced/feature/death-fireworks
Browse files Browse the repository at this point in the history
Spawn firework rocket when a player dies inside siege zone
  • Loading branch information
Goosius1 authored Feb 5, 2021
2 parents f38bf4c + cf98709 commit 407e6c8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,15 @@
import com.palmergames.bukkit.towny.permissions.TownyPermissionSource;
import com.gmail.goosius.siegewar.settings.Translation;

import org.bukkit.Color;
import org.bukkit.FireworkEffect;
import org.bukkit.block.Banner;
import org.bukkit.entity.Firework;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.Damageable;
import org.bukkit.inventory.meta.FireworkMeta;
import org.bukkit.inventory.meta.ItemMeta;

/**
Expand Down Expand Up @@ -137,6 +142,15 @@ public static void evaluateSiegePlayerDeath(Player deadPlayer, PlayerDeathEvent

//Award penalty points w/ notification if siege is in progress
if(confirmedCandidateSiege.getStatus() == SiegeStatus.IN_PROGRESS) {
if (SiegeWarSettings.getWarSiegeDeathSpawnFireworkEnabled()) {
Firework redFirework = deadPlayer.getWorld().spawn(deadPlayer.getLocation().add(0, 2, 0), Firework.class);
FireworkMeta fireworkMeta = (FireworkMeta) redFirework.getFireworkMeta();
Color bannerColor = ((Banner) confirmedCandidateSiege.getFlagLocation().getBlock().getState()).getBaseColor().getColor();
fireworkMeta.addEffects(FireworkEffect.builder().withColor(Color.RED).withFade(bannerColor).build());
redFirework.setFireworkMeta(fireworkMeta);
redFirework.detonate();
}

if (confirmedCandidateSiegePlayerSide == SiegeSide.DEFENDERS) {
SiegeWarPointsUtil.awardPenaltyPoints(
false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,11 @@ public enum ConfigNodes {
"# A low value will keep battles fast paced.",
"# A high value will slow down battles (as players take time to repair items),",
"# and will also exclude some casual players from war (as they cannot afford to keep repairing/replacing/mending degraded items)"),
WAR_SIEGE_DEATH_SPAWN_FIREWORK(
"war.siege.death.spawn_firework",
"true",
"",
"# If enabled, a firework will get spawned whenever a player dies inside a siege zone."),

PEACEFUL_TOWNS(
"peaceful_towns",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,4 +363,8 @@ public static boolean getWarCommonPeacefulTownsPublicSpawning() {
public static boolean getWarSiegeNationStatisticsEnabled() {
return Settings.getBoolean(ConfigNodes.WAR_SIEGE_NATION_STATISTICS_ENABLED);
}

public static boolean getWarSiegeDeathSpawnFireworkEnabled() {
return Settings.getBoolean(ConfigNodes.WAR_SIEGE_DEATH_SPAWN_FIREWORK);
}
}

0 comments on commit 407e6c8

Please sign in to comment.