mirror of
https://github.com/TotalFreedomMC/TF-ProjectKorra.git
synced 2024-12-22 16:05:01 +00:00
Fixes :D (#529)
• 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:
parent
f3ca5503cd
commit
49216a3da3
6 changed files with 110 additions and 64 deletions
|
@ -871,74 +871,82 @@ public class PKListener implements Listener {
|
|||
if (!(event.getEntity() instanceof Player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Player player = event.getEntity();
|
||||
EarthArmor earthArmor = CoreAbility.getAbility(player, EarthArmor.class);
|
||||
PlantArmor plantArmor = CoreAbility.getAbility(player, PlantArmor.class);
|
||||
|
||||
if (earthArmor != null) {
|
||||
List<ItemStack> drops = event.getDrops();
|
||||
List<ItemStack> newDrops = new ArrayList<ItemStack>();
|
||||
for (int i = 0; i < drops.size(); i++) {
|
||||
Material type = drops.get(i).getType();
|
||||
if (!(type == Material.LEATHER_BOOTS || type == Material.LEATHER_CHESTPLATE || type == Material.LEATHER_HELMET || type == Material.LEATHER_LEGGINGS || type == Material.AIR)) {
|
||||
newDrops.add(drops.get(i));
|
||||
}
|
||||
|
||||
if (event.getKeepInventory()) {
|
||||
if (earthArmor != null && earthArmor.getOldArmor() != null) {
|
||||
player.getInventory().setArmorContents(earthArmor.getOldArmor());
|
||||
} else if (plantArmor != null && plantArmor.getOldArmor() != null) {
|
||||
player.getInventory().setArmorContents(plantArmor.getOldArmor());
|
||||
} else if (event.getEntity() instanceof LivingEntity && MetalClips.isControlled(event.getEntity()) && MetalClips.getOriginalArmor(player) != null) {
|
||||
player.getInventory().setArmorContents(MetalClips.getOriginalArmor(player));
|
||||
}
|
||||
if (earthArmor.getOldArmor() != null) {
|
||||
for (ItemStack is : earthArmor.getOldArmor()) {
|
||||
if (is.getType() != Material.AIR) {
|
||||
newDrops.add(is);
|
||||
} else {
|
||||
if (earthArmor != null) {
|
||||
List<Material> earthArmorItems = Arrays.asList(new Material[] {Material.LEATHER_BOOTS, Material.LEATHER_LEGGINGS, Material.LEATHER_CHESTPLATE, Material.LEATHER_HELMET});
|
||||
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) {
|
||||
List<ItemStack> drops = event.getDrops();
|
||||
List<ItemStack> newDrops = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < drops.size(); i++) {
|
||||
Material type = drops.get(i).getType();
|
||||
if (!(type == Material.LEATHER_BOOTS || type == Material.LEATHER_CHESTPLATE || type == Material.LEAVES || type == Material.LEAVES_2 || type == Material.LEATHER_LEGGINGS || type == Material.AIR)) {
|
||||
newDrops.add(drops.get(i));
|
||||
}
|
||||
}
|
||||
if (plantArmor.getOldArmor() != null) {
|
||||
for (ItemStack is : plantArmor.getOldArmor()) {
|
||||
if (!(is.getType() == Material.AIR)) {
|
||||
newDrops.add(is);
|
||||
if (plantArmor != null) {
|
||||
List<Material> plantArmorItems = Arrays.asList(new Material[] {Material.LEATHER_BOOTS, Material.LEATHER_LEGGINGS, Material.LEATHER_CHESTPLATE, Material.LEAVES});
|
||||
List<ItemStack> newDrops = new ArrayList<ItemStack>();
|
||||
if (plantArmor.getOldArmor() != null) {
|
||||
int size = event.getDrops().size();
|
||||
for (int i = 0; i < 4; i++) {
|
||||
ItemStack is = event.getDrops().get(size - i - 1);
|
||||
if (plantArmorItems.contains(is.getType())) {
|
||||
event.getDrops().remove(is);
|
||||
newDrops.add(plantArmor.getOldArmor()[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
event.getDrops().addAll(newDrops);
|
||||
plantArmor.remove();
|
||||
}
|
||||
|
||||
event.getDrops().clear();
|
||||
event.getDrops().addAll(newDrops);
|
||||
plantArmor.remove();
|
||||
}
|
||||
|
||||
if (MetalClips.getEntityClipsCount().containsKey(event.getEntity())) {
|
||||
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));
|
||||
if (event.getEntity() instanceof LivingEntity && MetalClips.isControlled(event.getEntity())) {
|
||||
|
||||
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
|
||||
currentArmor.add(is);
|
||||
}
|
||||
}
|
||||
|
||||
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 (BENDING_PLAYER_DEATH.containsKey(event.getEntity())) {
|
||||
String message = ConfigManager.languageConfig.get().getString("DeathMessages.Default");
|
||||
|
@ -1047,6 +1055,7 @@ public class PKListener implements Listener {
|
|||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
AirFlight.remove(event.getPlayer());
|
||||
JUMPS.remove(event.getPlayer());
|
||||
}
|
||||
|
@ -1183,6 +1192,10 @@ public class PKListener implements Listener {
|
|||
if (metalClips != null) {
|
||||
metalClips.remove();
|
||||
}
|
||||
|
||||
if (MetalClips.isControlled(event.getPlayer())) {
|
||||
MetalClips.removeControlledEnitity(event.getPlayer());
|
||||
}
|
||||
|
||||
MultiAbilityManager.remove(player);
|
||||
AirFlight.remove(player);
|
||||
|
@ -1691,5 +1704,4 @@ public class PKListener implements Listener {
|
|||
public static Map<Player, Integer> getJumpStatistics() {
|
||||
return JUMPS;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -214,11 +214,7 @@ public class EarthBlast extends EarthAbility {
|
|||
}
|
||||
|
||||
location = location.clone().add(direction);
|
||||
Block block = location.getBlock();
|
||||
|
||||
WaterAbility.removeWaterSpouts(location, player);
|
||||
AirAbility.removeAirSpouts(location, player);
|
||||
EarthAbility.removeSandSpouts(location, player);
|
||||
Block block = location.getBlock();
|
||||
|
||||
if (block.getLocation().equals(sourceBlock.getLocation())) {
|
||||
location = location.clone().add(direction);
|
||||
|
@ -234,7 +230,7 @@ public class EarthBlast extends EarthAbility {
|
|||
location = location.clone().subtract(direction);
|
||||
direction = GeneralMethods.getDirection(location, destination).normalize();
|
||||
location = location.clone().add(direction);
|
||||
|
||||
|
||||
WaterAbility.removeWaterSpouts(location, player);
|
||||
AirAbility.removeAirSpouts(location, player);
|
||||
EarthAbility.removeSandSpouts(location, player);
|
||||
|
@ -303,7 +299,7 @@ public class EarthBlast extends EarthAbility {
|
|||
block.setType(Material.STONE);
|
||||
}
|
||||
} else {
|
||||
block.setType(sourceBlock.getType());
|
||||
block.setType(sourceType);
|
||||
sourceBlock.setType(Material.AIR);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,8 @@ package com.projectkorra.projectkorra.earthbending;
|
|||
|
||||
import com.projectkorra.projectkorra.GeneralMethods;
|
||||
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.Material;
|
||||
|
@ -10,6 +12,8 @@ import org.bukkit.entity.Player;
|
|||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class EarthTunnel extends EarthAbility {
|
||||
|
||||
|
@ -27,6 +31,8 @@ public class EarthTunnel extends EarthAbility {
|
|||
private Location location;
|
||||
private Vector direction;
|
||||
|
||||
public static Map<TempBlock, Long> airBlocks = new ConcurrentHashMap<TempBlock, Long>();
|
||||
|
||||
public EarthTunnel(Player player) {
|
||||
super(player);
|
||||
|
||||
|
@ -93,7 +99,7 @@ public class EarthTunnel extends EarthAbility {
|
|||
}
|
||||
|
||||
if (this.revert) {
|
||||
addTempAirBlock(block);
|
||||
airBlocks.put(new TempBlock(block, Material.AIR, (byte) 0), System.currentTimeMillis());
|
||||
} else {
|
||||
block.breakNaturally();
|
||||
}
|
||||
|
@ -219,4 +225,15 @@ public class EarthTunnel extends EarthAbility {
|
|||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,5 +19,6 @@ public class EarthbendingManager implements Runnable {
|
|||
RevertChecker.revertEarthBlocks();
|
||||
Shockwave.progressAll();
|
||||
Tremorsense.manage(Bukkit.getServer());
|
||||
EarthTunnel.revertAirBlocks();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.projectkorra.projectkorra.earthbending;
|
||||
|
||||
import com.projectkorra.projectkorra.GeneralMethods;
|
||||
import com.projectkorra.projectkorra.ability.CoreAbility;
|
||||
import com.projectkorra.projectkorra.ability.MetalAbility;
|
||||
import com.projectkorra.projectkorra.avatar.AvatarState;
|
||||
import com.projectkorra.projectkorra.util.DamageHandler;
|
||||
|
@ -125,6 +126,14 @@ public class MetalClips extends MetalAbility {
|
|||
}
|
||||
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() {
|
||||
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)) {
|
||||
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;
|
||||
TARGET_TO_ABILITY.put(targetEntity, this);
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -466,6 +475,17 @@ public class MetalClips extends MetalAbility {
|
|||
public static Map<Entity, MetalClips> getTargetToAbility() {
|
||||
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
|
||||
public String getName() {
|
||||
|
|
|
@ -50,7 +50,7 @@ public class PhaseChangeMelt extends IceAbility {
|
|||
}
|
||||
|
||||
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)) {
|
||||
evaporate = true;
|
||||
radius = (int) getNightFactor(evaporateRadius);
|
||||
|
|
Loading…
Reference in a new issue