diff --git a/war/src/main/java/com/tommytony/war/War.java b/war/src/main/java/com/tommytony/war/War.java index 1259d52..29d19f7 100644 --- a/war/src/main/java/com/tommytony/war/War.java +++ b/war/src/main/java/com/tommytony/war/War.java @@ -234,6 +234,7 @@ public class War extends JavaPlugin { teamDefaultConfig.put(TeamConfig.PLACEBLOCK, true); teamDefaultConfig.put(TeamConfig.APPLYPOTION, ""); teamDefaultConfig.put(TeamConfig.ECOREWARD, 0.0); + teamDefaultConfig.put(TeamConfig.INVENTORYDROP, false); this.getDefaultInventories().clearLoadouts(); HashMap defaultLoadout = new HashMap(); diff --git a/war/src/main/java/com/tommytony/war/config/TeamConfig.java b/war/src/main/java/com/tommytony/war/config/TeamConfig.java index 314acc1..25b4f86 100644 --- a/war/src/main/java/com/tommytony/war/config/TeamConfig.java +++ b/war/src/main/java/com/tommytony/war/config/TeamConfig.java @@ -19,7 +19,8 @@ public enum TeamConfig { BLOCKWHITELIST (String.class), PLACEBLOCK (Boolean.class), APPLYPOTION(String.class), - ECOREWARD(Double.class); + ECOREWARD(Double.class), + INVENTORYDROP(Boolean.class); private final Class configType; diff --git a/war/src/main/java/com/tommytony/war/event/WarEntityListener.java b/war/src/main/java/com/tommytony/war/event/WarEntityListener.java index b75ebc1..7768be4 100644 --- a/war/src/main/java/com/tommytony/war/event/WarEntityListener.java +++ b/war/src/main/java/com/tommytony/war/event/WarEntityListener.java @@ -32,6 +32,7 @@ import org.bukkit.event.entity.ExplosionPrimeEvent; import org.bukkit.event.entity.FoodLevelChangeEvent; import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.entity.ProjectileLaunchEvent; +import org.bukkit.inventory.ItemStack; import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.scoreboard.Objective; import org.bukkit.util.Vector; @@ -59,6 +60,15 @@ import com.tommytony.war.utility.LoadoutSelection; public class WarEntityListener implements Listener { private final Random killSeed = new Random(); + + private void dropItems(Location location, ItemStack[] items) { + for (ItemStack item : items) { + if (item == null || item.getType() == Material.AIR) { + continue; + } + location.getWorld().dropItem(location, item); + } + } /** * Handles PVP-Damage @@ -173,6 +183,10 @@ public class WarEntityListener implements Listener { Objective obj = attackerWarzone.getScoreboard().getObjective("Top kills"); obj.getScore(a).setScore(defenderWarzone.getKillCount(a.getName())); } + if (defenderTeam.getTeamConfig().resolveBoolean(TeamConfig.INVENTORYDROP)) { + dropItems(d.getLocation(), d.getInventory().getContents()); + dropItems(d.getLocation(), d.getInventory().getArmorContents()); + } } WarPlayerDeathEvent event1 = new WarPlayerDeathEvent(defenderWarzone, d, a, event.getCause()); War.war.getServer().getPluginManager().callEvent(event1);