From 93a738f74c7db29431a6667bba747eccfcc30f4b Mon Sep 17 00:00:00 2001 From: Benford Date: Mon, 28 Dec 2015 16:38:58 -0500 Subject: [PATCH] Fix EarthArmor and PlantArmor - Fixed EarthArmor and PlantArmor dropping the armor on death --- .../projectkorra/projectkorra/PKListener.java | 34 +++++++++++++++++++ .../projectkorra/earthbending/EarthArmor.java | 4 +++ .../projectkorra/waterbending/PlantArmor.java | 6 +++- 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/src/com/projectkorra/projectkorra/PKListener.java b/src/com/projectkorra/projectkorra/PKListener.java index 32db2ff0..2cc2b308 100644 --- a/src/com/projectkorra/projectkorra/PKListener.java +++ b/src/com/projectkorra/projectkorra/PKListener.java @@ -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 drops = event.getDrops(); + List 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 drops = event.getDrops(); + List 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) diff --git a/src/com/projectkorra/projectkorra/earthbending/EarthArmor.java b/src/com/projectkorra/projectkorra/earthbending/EarthArmor.java index 9217a16a..c0d22c07 100644 --- a/src/com/projectkorra/projectkorra/earthbending/EarthArmor.java +++ b/src/com/projectkorra/projectkorra/earthbending/EarthArmor.java @@ -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())) { diff --git a/src/com/projectkorra/projectkorra/waterbending/PlantArmor.java b/src/com/projectkorra/projectkorra/waterbending/PlantArmor.java index 7d877805..9970093b 100644 --- a/src/com/projectkorra/projectkorra/waterbending/PlantArmor.java +++ b/src/com/projectkorra/projectkorra/waterbending/PlantArmor.java @@ -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) {