mirror of
https://github.com/taoneill/war.git
synced 2024-12-02 15:13:39 +01:00
Option to drop inventory on kill
Closes #711, closes #13, closes #11. Items only drop on kill to prevent players from farming items. Warzone makers must design their warzone items to fit with this feature if they choose to enable it. E.g. a warzone might include items that must be found and then can be stolen on kill. Thanks to @dylanhansch for testing.
This commit is contained in:
parent
9281ad5c4d
commit
33add7df0d
@ -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<Integer, ItemStack> defaultLoadout = new HashMap<Integer, ItemStack>();
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user