• Fixed MetalClips keeping armor on logout/kick
• Fixed MetalClips breaking when used on more than one target
• Fixed MetalClips/EarthArmor/PlantArmor keeping armor on death when
keepInventory is on
• Fixed MetalClips/EarthArmor/PlantArmor removing all armor peices from
the inventory when you die (instead of just the set you were given)
• Fixed EarthBlast firing wrong block when EarthRevert is off
• Fixed PhaseChange not melting blocks from a distance underwater
• Fixed EarthTunnel revert not functioning with EarthRevert off
This commit is contained in:
StrangeOne101 2016-08-06 20:53:10 +12:00 committed by OmniCypher
parent f3ca5503cd
commit 49216a3da3
6 changed files with 110 additions and 64 deletions

View file

@ -871,74 +871,82 @@ public class PKListener implements Listener {
if (!(event.getEntity() instanceof Player)) { if (!(event.getEntity() instanceof Player)) {
return; return;
} }
Player player = event.getEntity(); Player player = event.getEntity();
EarthArmor earthArmor = CoreAbility.getAbility(player, EarthArmor.class); EarthArmor earthArmor = CoreAbility.getAbility(player, EarthArmor.class);
PlantArmor plantArmor = CoreAbility.getAbility(player, PlantArmor.class); PlantArmor plantArmor = CoreAbility.getAbility(player, PlantArmor.class);
if (earthArmor != null) { if (event.getKeepInventory()) {
List<ItemStack> drops = event.getDrops(); if (earthArmor != null && earthArmor.getOldArmor() != null) {
List<ItemStack> newDrops = new ArrayList<ItemStack>(); player.getInventory().setArmorContents(earthArmor.getOldArmor());
for (int i = 0; i < drops.size(); i++) { } else if (plantArmor != null && plantArmor.getOldArmor() != null) {
Material type = drops.get(i).getType(); player.getInventory().setArmorContents(plantArmor.getOldArmor());
if (!(type == Material.LEATHER_BOOTS || type == Material.LEATHER_CHESTPLATE || type == Material.LEATHER_HELMET || type == Material.LEATHER_LEGGINGS || type == Material.AIR)) { } else if (event.getEntity() instanceof LivingEntity && MetalClips.isControlled(event.getEntity()) && MetalClips.getOriginalArmor(player) != null) {
newDrops.add(drops.get(i)); player.getInventory().setArmorContents(MetalClips.getOriginalArmor(player));
}
} }
if (earthArmor.getOldArmor() != null) { } else {
for (ItemStack is : earthArmor.getOldArmor()) { if (earthArmor != null) {
if (is.getType() != Material.AIR) { List<Material> earthArmorItems = Arrays.asList(new Material[] {Material.LEATHER_BOOTS, Material.LEATHER_LEGGINGS, Material.LEATHER_CHESTPLATE, Material.LEATHER_HELMET});
newDrops.add(is); List<ItemStack> newDrops = new ArrayList<ItemStack>();
if (earthArmor.getOldArmor() != null) {
int size = event.getDrops().size();
for (int i = 0; i < 4; i++) {
//Armor always drops last (items, boots, leggings, chestplate, helmet) so we got to get the last drop items
ItemStack is = event.getDrops().get(size - i - 1);
if (earthArmorItems.contains(is.getType())) {
event.getDrops().remove(is);
newDrops.add(earthArmor.getOldArmor()[i]);
}
} }
} }
event.getDrops().addAll(newDrops);
earthArmor.remove();
} }
event.getDrops().clear();
event.getDrops().addAll(newDrops);
earthArmor.remove();
}
if (plantArmor != null) { if (plantArmor != null) {
List<ItemStack> drops = event.getDrops(); List<Material> plantArmorItems = Arrays.asList(new Material[] {Material.LEATHER_BOOTS, Material.LEATHER_LEGGINGS, Material.LEATHER_CHESTPLATE, Material.LEAVES});
List<ItemStack> newDrops = new ArrayList<>(); List<ItemStack> newDrops = new ArrayList<ItemStack>();
if (plantArmor.getOldArmor() != null) {
for (int i = 0; i < drops.size(); i++) { int size = event.getDrops().size();
Material type = drops.get(i).getType(); for (int i = 0; i < 4; i++) {
if (!(type == Material.LEATHER_BOOTS || type == Material.LEATHER_CHESTPLATE || type == Material.LEAVES || type == Material.LEAVES_2 || type == Material.LEATHER_LEGGINGS || type == Material.AIR)) { ItemStack is = event.getDrops().get(size - i - 1);
newDrops.add(drops.get(i)); if (plantArmorItems.contains(is.getType())) {
} event.getDrops().remove(is);
} newDrops.add(plantArmor.getOldArmor()[i]);
if (plantArmor.getOldArmor() != null) { }
for (ItemStack is : plantArmor.getOldArmor()) {
if (!(is.getType() == Material.AIR)) {
newDrops.add(is);
} }
} }
event.getDrops().addAll(newDrops);
plantArmor.remove();
} }
event.getDrops().clear(); if (event.getEntity() instanceof LivingEntity && MetalClips.isControlled(event.getEntity())) {
event.getDrops().addAll(newDrops);
plantArmor.remove(); List<ItemStack> currentArmor = new ArrayList<ItemStack>();
} for (ItemStack is : Arrays.asList(event.getEntity().getInventory().getArmorContents())) {
if (is.getType() != Material.AIR) { //Remove Air because it won't show in the drops
if (MetalClips.getEntityClipsCount().containsKey(event.getEntity())) { currentArmor.add(is);
List<ItemStack> drops = event.getDrops(); }
List<ItemStack> newdrops = new ArrayList<ItemStack>();
for (int i = 0; i < drops.size(); i++) {
if (!(drops.get(i).getType() == Material.IRON_HELMET || drops.get(i).getType() == Material.IRON_CHESTPLATE || drops.get(i).getType() == Material.IRON_LEGGINGS || drops.get(i).getType() == Material.IRON_BOOTS || drops.get(i).getType() == Material.AIR)) {
newdrops.add(drops.get(i));
} }
List<ItemStack> oldArmor = new ArrayList<ItemStack>();
for (ItemStack is : Arrays.asList(MetalClips.getOriginalArmor(player))) {
if (is.getType() != Material.AIR) { //Shouldn't add air itemstacks to drop list
oldArmor.add(is);
}
}
for (int i = 0; i < currentArmor.size(); i++) { //Remove all armor drops completely, so we can then drop the correct armor.
event.getDrops().remove(event.getDrops().size() - 1);
}
event.getDrops().addAll(oldArmor);
MetalClips.getEntityClipsCount().remove(event.getEntity());
} }
newdrops.add(MetalClips.getOriginalHelmet(event.getEntity()));
newdrops.add(MetalClips.getOriginalChestplate(event.getEntity()));
newdrops.add(MetalClips.getOriginalLeggings(event.getEntity()));
newdrops.add(MetalClips.getOriginalBoots(event.getEntity()));
event.getDrops().clear();
event.getDrops().addAll(newdrops);
MetalClips.getEntityClipsCount().remove(event.getEntity());
} }
if (event.getEntity().getKiller() != null) { if (event.getEntity().getKiller() != null) {
if (BENDING_PLAYER_DEATH.containsKey(event.getEntity())) { if (BENDING_PLAYER_DEATH.containsKey(event.getEntity())) {
String message = ConfigManager.languageConfig.get().getString("DeathMessages.Default"); String message = ConfigManager.languageConfig.get().getString("DeathMessages.Default");
@ -1047,6 +1055,7 @@ public class PKListener implements Listener {
if (event.isCancelled()) { if (event.isCancelled()) {
return; return;
} }
AirFlight.remove(event.getPlayer()); AirFlight.remove(event.getPlayer());
JUMPS.remove(event.getPlayer()); JUMPS.remove(event.getPlayer());
} }
@ -1183,6 +1192,10 @@ public class PKListener implements Listener {
if (metalClips != null) { if (metalClips != null) {
metalClips.remove(); metalClips.remove();
} }
if (MetalClips.isControlled(event.getPlayer())) {
MetalClips.removeControlledEnitity(event.getPlayer());
}
MultiAbilityManager.remove(player); MultiAbilityManager.remove(player);
AirFlight.remove(player); AirFlight.remove(player);
@ -1691,5 +1704,4 @@ public class PKListener implements Listener {
public static Map<Player, Integer> getJumpStatistics() { public static Map<Player, Integer> getJumpStatistics() {
return JUMPS; return JUMPS;
} }
} }

View file

@ -214,11 +214,7 @@ public class EarthBlast extends EarthAbility {
} }
location = location.clone().add(direction); location = location.clone().add(direction);
Block block = location.getBlock(); Block block = location.getBlock();
WaterAbility.removeWaterSpouts(location, player);
AirAbility.removeAirSpouts(location, player);
EarthAbility.removeSandSpouts(location, player);
if (block.getLocation().equals(sourceBlock.getLocation())) { if (block.getLocation().equals(sourceBlock.getLocation())) {
location = location.clone().add(direction); location = location.clone().add(direction);
@ -234,7 +230,7 @@ public class EarthBlast extends EarthAbility {
location = location.clone().subtract(direction); location = location.clone().subtract(direction);
direction = GeneralMethods.getDirection(location, destination).normalize(); direction = GeneralMethods.getDirection(location, destination).normalize();
location = location.clone().add(direction); location = location.clone().add(direction);
WaterAbility.removeWaterSpouts(location, player); WaterAbility.removeWaterSpouts(location, player);
AirAbility.removeAirSpouts(location, player); AirAbility.removeAirSpouts(location, player);
EarthAbility.removeSandSpouts(location, player); EarthAbility.removeSandSpouts(location, player);
@ -303,7 +299,7 @@ public class EarthBlast extends EarthAbility {
block.setType(Material.STONE); block.setType(Material.STONE);
} }
} else { } else {
block.setType(sourceBlock.getType()); block.setType(sourceType);
sourceBlock.setType(Material.AIR); sourceBlock.setType(Material.AIR);
} }

View file

@ -2,6 +2,8 @@ package com.projectkorra.projectkorra.earthbending;
import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.ability.EarthAbility; import com.projectkorra.projectkorra.ability.EarthAbility;
import com.projectkorra.projectkorra.configuration.ConfigManager;
import com.projectkorra.projectkorra.util.TempBlock;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
@ -10,6 +12,8 @@ import org.bukkit.entity.Player;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import java.util.HashSet; import java.util.HashSet;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
public class EarthTunnel extends EarthAbility { public class EarthTunnel extends EarthAbility {
@ -27,6 +31,8 @@ public class EarthTunnel extends EarthAbility {
private Location location; private Location location;
private Vector direction; private Vector direction;
public static Map<TempBlock, Long> airBlocks = new ConcurrentHashMap<TempBlock, Long>();
public EarthTunnel(Player player) { public EarthTunnel(Player player) {
super(player); super(player);
@ -93,7 +99,7 @@ public class EarthTunnel extends EarthAbility {
} }
if (this.revert) { if (this.revert) {
addTempAirBlock(block); airBlocks.put(new TempBlock(block, Material.AIR, (byte) 0), System.currentTimeMillis());
} else { } else {
block.breakNaturally(); block.breakNaturally();
} }
@ -219,4 +225,15 @@ public class EarthTunnel extends EarthAbility {
this.location = location; this.location = location;
} }
public static void revertAirBlocks() {
if (ConfigManager.defaultConfig.get().getBoolean("Abilities.Earth.EarthTunnel.Revert")) {
for (TempBlock tempBlock : EarthTunnel.airBlocks.keySet()) {
if (EarthTunnel.airBlocks.get(tempBlock) + ConfigManager.defaultConfig.get().getLong("Properties.Earth.RevertCheckTime") <= System.currentTimeMillis()) {
tempBlock.revertBlock();
EarthTunnel.airBlocks.remove(tempBlock);
}
}
}
}
} }

View file

@ -19,5 +19,6 @@ public class EarthbendingManager implements Runnable {
RevertChecker.revertEarthBlocks(); RevertChecker.revertEarthBlocks();
Shockwave.progressAll(); Shockwave.progressAll();
Tremorsense.manage(Bukkit.getServer()); Tremorsense.manage(Bukkit.getServer());
EarthTunnel.revertAirBlocks();
} }
} }

View file

@ -1,6 +1,7 @@
package com.projectkorra.projectkorra.earthbending; package com.projectkorra.projectkorra.earthbending;
import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.ability.CoreAbility;
import com.projectkorra.projectkorra.ability.MetalAbility; import com.projectkorra.projectkorra.ability.MetalAbility;
import com.projectkorra.projectkorra.avatar.AvatarState; import com.projectkorra.projectkorra.avatar.AvatarState;
import com.projectkorra.projectkorra.util.DamageHandler; import com.projectkorra.projectkorra.util.DamageHandler;
@ -125,6 +126,14 @@ public class MetalClips extends MetalAbility {
} }
return null; return null;
} }
public static ItemStack[] getOriginalArmor(LivingEntity ent) {
MetalClips clips = TARGET_TO_ABILITY.get(ent);
if (clips != null) {
return clips.oldArmor;
}
return null;
}
public void shootMetal() { public void shootMetal() {
ItemStack is = new ItemStack(Material.IRON_INGOT, 1); ItemStack is = new ItemStack(Material.IRON_INGOT, 1);
@ -405,7 +414,7 @@ public class MetalClips extends MetalAbility {
for (Entity e : GeneralMethods.getEntitiesAroundPoint(ii.getLocation(), 2)) { for (Entity e : GeneralMethods.getEntitiesAroundPoint(ii.getLocation(), 2)) {
if (e instanceof LivingEntity && e.getEntityId() != player.getEntityId()) { if (e instanceof LivingEntity && e.getEntityId() != player.getEntityId()) {
if (e instanceof Player || e instanceof Zombie || e instanceof Skeleton) { if ((e instanceof Player || e instanceof Zombie || e instanceof Skeleton) && targetEntity == null) {
targetEntity = (LivingEntity) e; targetEntity = (LivingEntity) e;
TARGET_TO_ABILITY.put(targetEntity, this); TARGET_TO_ABILITY.put(targetEntity, this);
formArmor(); formArmor();
@ -450,7 +459,7 @@ public class MetalClips extends MetalAbility {
} }
} }
public static boolean isControlled(Player player) { public static boolean isControlled(LivingEntity player) {
return TARGET_TO_ABILITY.containsKey(player); return TARGET_TO_ABILITY.containsKey(player);
} }
@ -466,6 +475,17 @@ public class MetalClips extends MetalAbility {
public static Map<Entity, MetalClips> getTargetToAbility() { public static Map<Entity, MetalClips> getTargetToAbility() {
return TARGET_TO_ABILITY; return TARGET_TO_ABILITY;
} }
public static boolean removeControlledEnitity(LivingEntity entity) {
if (entity == null) return false;
for (MetalClips metalclips : CoreAbility.getAbilities(MetalClips.class)) {
if (metalclips.targetEntity == entity) {
metalclips.remove();
return true;
}
}
return false;
}
@Override @Override
public String getName() { public String getName() {

View file

@ -50,7 +50,7 @@ public class PhaseChangeMelt extends IceAbility {
} }
boolean evaporate = false; boolean evaporate = false;
location = GeneralMethods.getTargetedLocation(player, range); location = GeneralMethods.getTargetedLocation(player, range, 0, 8, 9);
if (isWater(player.getTargetBlock((HashSet<Material>) null, (int) range)) && !(player.getEyeLocation().getBlockY() <= 62)) { if (isWater(player.getTargetBlock((HashSet<Material>) null, (int) range)) && !(player.getEyeLocation().getBlockY() <= 62)) {
evaporate = true; evaporate = true;
radius = (int) getNightFactor(evaporateRadius); radius = (int) getNightFactor(evaporateRadius);