Fix various bugs

- Changed Airblast to compensate for AirBurst
- Fixed Lavaflow bugs (spam click and plants)
- Fixed being able to bend while using a fishing rod
- Added feature to IceWave: While the ability is progressing the ice
will thaw as the player gets farther away from the created ice sphere
- Added new options to config
This commit is contained in:
Benford 2016-04-03 14:38:42 -04:00
parent 79edcc49d2
commit 9a487adc35
5 changed files with 98 additions and 45 deletions

View file

@ -1452,6 +1452,8 @@ public class PKListener implements Listener {
} else if (GeneralMethods.isInteractable(player.getTargetBlock((Set<Material>)null, 5))) { } else if (GeneralMethods.isInteractable(player.getTargetBlock((Set<Material>)null, 5))) {
event.setCancelled(true); event.setCancelled(true);
return; return;
} else if (player.getItemInHand().getType() == Material.FISHING_ROD) {
return;
} }
BlockSource.update(player, ClickType.LEFT_CLICK); BlockSource.update(player, ClickType.LEFT_CLICK);

View file

@ -24,6 +24,7 @@ import com.projectkorra.projectkorra.BendingPlayer;
import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.ProjectKorra; import com.projectkorra.projectkorra.ProjectKorra;
import com.projectkorra.projectkorra.ability.AirAbility; import com.projectkorra.projectkorra.ability.AirAbility;
import com.projectkorra.projectkorra.ability.CoreAbility;
import com.projectkorra.projectkorra.avatar.AvatarState; import com.projectkorra.projectkorra.avatar.AvatarState;
import com.projectkorra.projectkorra.command.Commands; import com.projectkorra.projectkorra.command.Commands;
import com.projectkorra.projectkorra.object.HorizontalVelocityTracker; import com.projectkorra.projectkorra.object.HorizontalVelocityTracker;
@ -237,12 +238,11 @@ public class AirBlast extends AirAbility {
GeneralMethods.setVelocity(entity, velocity); GeneralMethods.setVelocity(entity, velocity);
if (source != null) { if (source != null) {
new HorizontalVelocityTracker(entity, player, 200l, this); new HorizontalVelocityTracker(entity, player, 200l, CoreAbility.getAbility("AirBurst"));
} else { } else {
new HorizontalVelocityTracker(entity, player, 200l, this); new HorizontalVelocityTracker(entity, player, 200l, this);
} }
entity.setFallDistance(0);
if (!isUser && entity instanceof Player) { if (!isUser && entity instanceof Player) {
new Flight((Player) entity, player); new Flight((Player) entity, player);
} }
@ -254,7 +254,7 @@ public class AirBlast extends AirAbility {
breakBreathbendingHold(entity); breakBreathbendingHold(entity);
if (source != null && (this.damage > 0 && entity instanceof LivingEntity && !entity.equals(player) && !affectedEntities.contains(entity))) { if (source != null && (this.damage > 0 && entity instanceof LivingEntity && !entity.equals(player) && !affectedEntities.contains(entity))) {
DamageHandler.damageEntity((LivingEntity) entity, damage, this); DamageHandler.damageEntity((LivingEntity) entity, damage, CoreAbility.getAbility("AirBurst"));
affectedEntities.add(entity); affectedEntities.add(entity);
} else if (source == null && (damage > 0 && entity instanceof LivingEntity && !entity.equals(player) && !affectedEntities.contains(entity))) { } else if (source == null && (damage > 0 && entity instanceof LivingEntity && !entity.equals(player) && !affectedEntities.contains(entity))) {
DamageHandler.damageEntity((LivingEntity) entity, damage, this); DamageHandler.damageEntity((LivingEntity) entity, damage, this);

View file

@ -775,6 +775,7 @@ public class ConfigManager {
config.addDefault("Abilities.Water.WaterCombo.IceWave.Enabled", true); config.addDefault("Abilities.Water.WaterCombo.IceWave.Enabled", true);
config.addDefault("Abilities.Water.WaterCombo.IceWave.Damage", 4); config.addDefault("Abilities.Water.WaterCombo.IceWave.Damage", 4);
config.addDefault("Abilities.Water.WaterCombo.IceWave.Cooldown", 6000); config.addDefault("Abilities.Water.WaterCombo.IceWave.Cooldown", 6000);
config.addDefault("Abilities.Water.WaterCombo.IceWave.ThawRadius", 10);
config.addDefault("Abilities.Water.WaterCombo.IceBullet.Enabled", true); config.addDefault("Abilities.Water.WaterCombo.IceBullet.Enabled", true);
config.addDefault("Abilities.Water.WaterCombo.IceBullet.Damage", 2); config.addDefault("Abilities.Water.WaterCombo.IceBullet.Damage", 2);
config.addDefault("Abilities.Water.WaterCombo.IceBullet.Radius", 2.5); config.addDefault("Abilities.Water.WaterCombo.IceBullet.Radius", 2.5);
@ -858,6 +859,7 @@ public class ConfigManager {
config.addDefault("Abilities.Earth.LavaFlow.DownwardFlow", 4); config.addDefault("Abilities.Earth.LavaFlow.DownwardFlow", 4);
config.addDefault("Abilities.Earth.LavaFlow.AllowNaturalFlow", false); config.addDefault("Abilities.Earth.LavaFlow.AllowNaturalFlow", false);
config.addDefault("Abilities.Earth.LavaFlow.ParticleDensity", 0.11); config.addDefault("Abilities.Earth.LavaFlow.ParticleDensity", 0.11);
config.addDefault("Abilities.Earth.LavaFlow.RevertMaterial", "STONE");
config.addDefault("Abilities.Earth.EarthSmash.Enabled", true); config.addDefault("Abilities.Earth.EarthSmash.Enabled", true);
config.addDefault("Abilities.Earth.EarthSmash.AllowGrab", true); config.addDefault("Abilities.Earth.EarthSmash.AllowGrab", true);

View file

@ -2,6 +2,7 @@ package com.projectkorra.projectkorra.earthbending;
import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.ProjectKorra; import com.projectkorra.projectkorra.ProjectKorra;
import com.projectkorra.projectkorra.ability.CoreAbility;
import com.projectkorra.projectkorra.ability.LavaAbility; import com.projectkorra.projectkorra.ability.LavaAbility;
import com.projectkorra.projectkorra.avatar.AvatarState; import com.projectkorra.projectkorra.avatar.AvatarState;
import com.projectkorra.projectkorra.util.BlockSource; import com.projectkorra.projectkorra.util.BlockSource;
@ -12,11 +13,13 @@ import com.projectkorra.projectkorra.util.TempBlock;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Random; import java.util.Random;
import java.util.concurrent.ConcurrentHashMap;
public class LavaFlow extends LavaAbility { public class LavaFlow extends LavaAbility {
@ -24,9 +27,8 @@ public class LavaFlow extends LavaAbility {
SHIFT, CLICK SHIFT, CLICK
} }
private static final Material REVERT_MATERIAL = Material.STONE; private static final ConcurrentHashMap<Block, TempBlock> TEMP_LAVA_BLOCKS = new ConcurrentHashMap<>();
private static final ArrayList<TempBlock> TEMP_LAVA_BLOCKS = new ArrayList<TempBlock>(); private static final ConcurrentHashMap<Block, TempBlock> TEMP_LAND_BLOCKS = new ConcurrentHashMap<>();
private static final ArrayList<TempBlock> TEMP_LAND_BLOCKS = new ArrayList<TempBlock>();
private boolean removing; private boolean removing;
private boolean makeLava; private boolean makeLava;
@ -61,6 +63,7 @@ public class LavaFlow extends LavaAbility {
private Location origin; private Location origin;
private ArrayList<TempBlock> affectedBlocks; private ArrayList<TempBlock> affectedBlocks;
private ArrayList<BukkitRunnable> tasks; private ArrayList<BukkitRunnable> tasks;
private Material revertMaterial;
/** /**
* Creates a new LavaFlow ability and initializes all of the variables and * Creates a new LavaFlow ability and initializes all of the variables and
@ -87,6 +90,7 @@ public class LavaFlow extends LavaAbility {
this.clickIsFinished = false; this.clickIsFinished = false;
this.affectedBlocks = new ArrayList<TempBlock>(); this.affectedBlocks = new ArrayList<TempBlock>();
this.tasks = new ArrayList<BukkitRunnable>(); this.tasks = new ArrayList<BukkitRunnable>();
this.revertMaterial = Material.getMaterial(getConfig().getString("Abilities.Earth.LavaFlow.RevertMaterial"));
this.shiftCooldown = getConfig().getLong("Abilities.Earth.LavaFlow.ShiftCooldown"); this.shiftCooldown = getConfig().getLong("Abilities.Earth.LavaFlow.ShiftCooldown");
this.shiftPlatformRadius = getConfig().getDouble("Abilities.Earth.LavaFlow.ShiftPlatformRadius"); this.shiftPlatformRadius = getConfig().getDouble("Abilities.Earth.LavaFlow.ShiftPlatformRadius");
@ -138,7 +142,7 @@ public class LavaFlow extends LavaAbility {
} }
} }
if (bPlayer.isOnCooldown("LavaFlowShift")) { if (bPlayer.isOnCooldown("LavaFlow")) {
remove(); remove();
return; return;
} }
@ -153,23 +157,11 @@ public class LavaFlow extends LavaAbility {
long cooldown = makeLava ? clickLavaCooldown : clickLandCooldown; long cooldown = makeLava ? clickLavaCooldown : clickLandCooldown;
origin = sourceBlock.getLocation(); origin = sourceBlock.getLocation();
makeLava = !isLava(sourceBlock); makeLava = !isLava(sourceBlock);
if (bPlayer.isOnCooldown("LavaFlow")) {
if (makeLava) { remove();
if (bPlayer.isOnCooldown("LavaFlowMakeLava")) { return;
remove(); } else {
return; bPlayer.addCooldown("LavaFlow", cooldown);
} else {
bPlayer.addCooldown("LavaFlowMakeLava", cooldown);
}
}
if (!makeLava) {
if (bPlayer.isOnCooldown("LavaFlowMakeLand")) {
remove();
return;
} else {
bPlayer.addCooldown("LavaFlowMakeLand", cooldown);
}
} }
start(); start();
} }
@ -203,7 +195,7 @@ public class LavaFlow extends LavaAbility {
if (affectedBlocks.size() > 0) { if (affectedBlocks.size() > 0) {
removeOnDelay(); removeOnDelay();
removing = true; removing = true;
bPlayer.addCooldown("LavaFlowShift", shiftCooldown); bPlayer.addCooldown("LavaFlow", shiftCooldown);
} else { } else {
remove(); remove();
} }
@ -230,10 +222,35 @@ public class LavaFlow extends LavaAbility {
} }
double dSquared = distanceSquaredXZ(block.getLocation(), origin); double dSquared = distanceSquaredXZ(block.getLocation(), origin);
if (!isLava(block) && dSquared > Math.pow(shiftPlatformRadius, 2)) { if (dSquared > Math.pow(shiftPlatformRadius, 2)) {
if (dSquared < Math.pow(currentRadius, 2) && !GeneralMethods.isRegionProtectedFromBuild(this, block.getLocation())) { if (dSquared < Math.pow(currentRadius, 2) && !GeneralMethods.isRegionProtectedFromBuild(this, block.getLocation())) {
if (dSquared < shiftPlatformRadius * 4 || getAdjacentLavaBlocks(block.getLocation()).size() > 0) { if (dSquared < shiftPlatformRadius * 4 || getAdjacentLavaBlocks(block.getLocation()).size() > 0) {
createLava(block); if (!isLava(block)) {
if (isPlant(block)) {
Block lower = block.getRelative(BlockFace.DOWN);
if (isPlant(lower)) {
Block lower2 = lower.getRelative(BlockFace.DOWN);
if (!isEarth(lower2) && !isSand(lower2) && !isMetal(lower2)) {
continue;
}
block.breakNaturally();
lower.breakNaturally();
createLava(lower2);
} else {
if (!isEarth(lower) && !isSand(lower) && !isMetal(lower)) {
continue;
}
block.breakNaturally();
createLava(lower);
}
} else {
if (!isEarth(block) && !isSand(block) && !isMetal(block)) {
continue;
}
createLava(block);
}
}
} }
} else if (Math.random() < particleDensity } else if (Math.random() < particleDensity
&& dSquared < Math.pow(currentRadius + particleDensity, 2) && dSquared < Math.pow(currentRadius + particleDensity, 2)
@ -315,7 +332,31 @@ public class LavaFlow extends LavaAbility {
if (makeLava && !isLava(tempBlock)) { if (makeLava && !isLava(tempBlock)) {
clickIsFinished = false; clickIsFinished = false;
if (Math.random() < lavaCreateSpeed) { if (Math.random() < lavaCreateSpeed) {
createLava(tempBlock); if (!isLava(tempBlock)) {
if (isPlant(tempBlock)) {
Block lower = tempBlock.getRelative(BlockFace.DOWN);
if (isPlant(lower)) {
Block lower2 = lower.getRelative(BlockFace.DOWN);
if (!isEarth(lower2) && !isSand(lower2) && !isMetal(lower2)) {
continue;
}
tempBlock.breakNaturally();
lower.breakNaturally();
createLava(lower2);
} else {
if (!isEarth(lower) && !isSand(lower) && !isMetal(lower)) {
continue;
}
tempBlock.breakNaturally();
createLava(lower);
}
} else {
if (!isEarth(tempBlock) && !isSand(tempBlock) && !isMetal(tempBlock)) {
continue;
}
createLava(tempBlock);
}
}
} else { } else {
if (random.nextInt(4) == 0) { if (random.nextInt(4) == 0) {
ParticleEffect.LAVA.display(loc, (float) Math.random(), (float) Math.random(), (float) Math.random(), 0, 1); ParticleEffect.LAVA.display(loc, (float) Math.random(), (float) Math.random(), (float) Math.random(), 0, 1);
@ -345,9 +386,9 @@ public class LavaFlow extends LavaAbility {
* @param block the block that will be turned to lava * @param block the block that will be turned to lava
*/ */
public void createLava(Block block) { public void createLava(Block block) {
if (isEarthbendable(block)) { if (isEarth(block) || isSand(block) || isMetal(block)) {
TempBlock tblock = new TempBlock(block, Material.STATIONARY_LAVA, (byte) 0); TempBlock tblock = new TempBlock(block, Material.STATIONARY_LAVA, (byte) 0);
TEMP_LAVA_BLOCKS.add(tblock); TEMP_LAVA_BLOCKS.put(block, tblock);
affectedBlocks.add(tblock); affectedBlocks.add(tblock);
if (allowNaturalFlow) { if (allowNaturalFlow) {
@ -363,21 +404,17 @@ public class LavaFlow extends LavaAbility {
*/ */
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public void removeLava(Block testBlock) { public void removeLava(Block testBlock) {
for (int i = 0; i < TEMP_LAVA_BLOCKS.size(); i++) { if (TEMP_LAVA_BLOCKS.containsKey(testBlock)) {
TempBlock tblock = TEMP_LAVA_BLOCKS.get(i); TempBlock tb = TEMP_LAVA_BLOCKS.get(testBlock);
Block block = tblock.getBlock(); tb.revertBlock();
TEMP_LAVA_BLOCKS.remove(testBlock);
if (block.equals(testBlock)) { affectedBlocks.remove(tb);
tblock.revertBlock(); return;
TEMP_LAVA_BLOCKS.remove(i);
affectedBlocks.remove(tblock);
return;
}
} }
TempBlock tblock = new TempBlock(testBlock, REVERT_MATERIAL, testBlock.getData()); TempBlock tblock = new TempBlock(testBlock, revertMaterial, testBlock.getData());
affectedBlocks.add(tblock); affectedBlocks.add(tblock);
TEMP_LAND_BLOCKS.add(tblock); TEMP_LAND_BLOCKS.put(testBlock, tblock);
} }
/** /**
@ -534,14 +571,17 @@ public class LavaFlow extends LavaAbility {
} }
public static Material getRevertMaterial() { public static Material getRevertMaterial() {
return REVERT_MATERIAL; Material m = Material.STONE;
LavaFlow lf = (LavaFlow) CoreAbility.getAbility("LavaFlow");
m = lf.revertMaterial;
return m;
} }
public static ArrayList<TempBlock> getTempLandBlocks() { public static ConcurrentHashMap<Block, TempBlock> getTempLandBlocks() {
return TEMP_LAND_BLOCKS; return TEMP_LAND_BLOCKS;
} }
public static ArrayList<TempBlock> getTempLavaBlocks() { public static ConcurrentHashMap<Block, TempBlock> getTempLavaBlocks() {
return TEMP_LAVA_BLOCKS; return TEMP_LAVA_BLOCKS;
} }

View file

@ -47,6 +47,7 @@ public class WaterSpoutWave extends WaterAbility {
private double chargeTime; private double chargeTime;
private double flightTime; private double flightTime;
private double waveRadius; private double waveRadius;
private double thawRadius;
private double damage; private double damage;
private double animationSpeed; private double animationSpeed;
private AbilityType type; private AbilityType type;
@ -67,6 +68,7 @@ public class WaterSpoutWave extends WaterAbility {
this.plant = getConfig().getBoolean("Abilities.Water.WaterSpout.Wave.AllowPlantSource"); this.plant = getConfig().getBoolean("Abilities.Water.WaterSpout.Wave.AllowPlantSource");
this.radius = getConfig().getDouble("Abilities.Water.WaterSpout.Wave.Radius"); this.radius = getConfig().getDouble("Abilities.Water.WaterSpout.Wave.Radius");
this.waveRadius = getConfig().getDouble("Abilities.Water.WaterSpout.Wave.WaveRadius"); this.waveRadius = getConfig().getDouble("Abilities.Water.WaterSpout.Wave.WaveRadius");
this.thawRadius = getConfig().getDouble("Abilities.Water.WaterCombo.IceWave.ThawRadius");
this.animationSpeed = getConfig().getDouble("Abilities.Water.WaterSpout.Wave.AnimationSpeed"); this.animationSpeed = getConfig().getDouble("Abilities.Water.WaterSpout.Wave.AnimationSpeed");
this.selectRange = getConfig().getDouble("Abilities.Water.WaterSpout.Wave.SelectRange"); this.selectRange = getConfig().getDouble("Abilities.Water.WaterSpout.Wave.SelectRange");
this.speed = getConfig().getDouble("Abilities.Water.WaterSpout.Wave.Speed"); this.speed = getConfig().getDouble("Abilities.Water.WaterSpout.Wave.Speed");
@ -268,6 +270,13 @@ public class WaterSpoutWave extends WaterAbility {
}.runTaskLater(ProjectKorra.plugin, 6); }.runTaskLater(ProjectKorra.plugin, 6);
} }
} }
for (Block block : FROZEN_BLOCKS.keySet()) {
TempBlock tBlock = FROZEN_BLOCKS.get(block);
if (tBlock.getLocation().distance(player.getLocation()) >= thawRadius) {
tBlock.revertBlock();
FROZEN_BLOCKS.remove(block);
}
}
} }
} }
} }