Fix EarthArmor and PlantArmor

- Fixed EarthArmor and PlantArmor dropping the armor on death
This commit is contained in:
Benford 2015-12-28 16:38:58 -05:00
parent fc81f6e3a4
commit 93a738f74c
3 changed files with 43 additions and 1 deletions

View file

@ -495,6 +495,40 @@ public class PKListener implements Listener {
event.getDrops().addAll(newdrops);
MetalClips.clipped.remove(event.getEntity());
}
if (EarthArmor.instances.containsKey(event.getEntity())) {
List<ItemStack> drops = event.getDrops();
List<ItemStack> newdrops = new ArrayList<>();
for (int i = 0; i < drops.size(); i++) {
if (!(drops.get(i).getType() == Material.LEATHER_BOOTS || drops.get(i).getType() == Material.LEATHER_CHESTPLATE || drops.get(i).getType() == Material.LEATHER_HELMET || drops.get(i).getType() == Material.LEATHER_LEGGINGS || drops.get(i).getType() == Material.AIR)) {
newdrops.add(drops.get(i));
}
}
for (int i = 0; i < 4; i++) {
newdrops.add(EarthArmor.instances.get(event.getEntity()).getOriginalArmor(i));
}
event.getDrops().clear();
event.getDrops().addAll(newdrops);
EarthArmor.instances.remove(event.getEntity());
}
if (PlantArmor.instances.containsKey(event.getEntity())) {
List<ItemStack> drops = event.getDrops();
List<ItemStack> newdrops = new ArrayList<>();
for (int i = 0; i < drops.size(); i++) {
if (!(drops.get(i).getType() == Material.LEATHER_BOOTS || drops.get(i).getType() == Material.LEATHER_CHESTPLATE || drops.get(i).getType() == PlantArmor.instances.get(event.getEntity()).blocktype || drops.get(i).getType() == Material.LEATHER_LEGGINGS || drops.get(i).getType() == Material.AIR)) {
newdrops.add(drops.get(i));
}
}
for (int i = 0; i < 4; i++) {
newdrops.add(PlantArmor.instances.get(event.getEntity()).getOriginalArmor(i));
}
event.getDrops().clear();
event.getDrops().addAll(newdrops);
PlantArmor.instances.remove(event.getEntity());
}
}
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)

View file

@ -75,6 +75,10 @@ public class EarthArmor {
instances.put(player, this);
}
}
public ItemStack getOriginalArmor(int i) {
return oldarmor[i];
}
private boolean moveBlocks() {
if (!player.getWorld().equals(headblock.getWorld())) {

View file

@ -37,7 +37,7 @@ public class PlantArmor {
public boolean hadEffect;
private double range = RANGE;
private long duration = DURATION;
private Material blocktype;
public Material blocktype;
public PlantArmor(Player player) {
if (instances.containsKey(player)) {
@ -85,6 +85,10 @@ public class PlantArmor {
return true;
}
public ItemStack getOriginalArmor(int i) {
return oldarmor[i];
}
private void playEffect() {
if (!formed) {