Various Fixes with LavaFlow and EarthTunnel plus some Extra (#669)

* Various Changes

* Remove Debug Message.

* Fix Immobilize.
This commit is contained in:
Christopher Martin 2017-01-02 02:33:08 -08:00 committed by GitHub
parent 7a046e793a
commit f4a367837d
8 changed files with 92 additions and 52 deletions

View file

@ -1139,6 +1139,23 @@ public class GeneralMethods {
return blockHolder;
}
public static ArrayList<Element> getElementsWithNoWeaponBending() {
ArrayList<Element> elements = new ArrayList<Element>();
if (!plugin.getConfig().getBoolean("Properties.Air.CanBendWithWeapons"))
elements.add(Element.AIR);
if (!plugin.getConfig().getBoolean("Properties.Water.CanBendWithWeapons"))
elements.add(Element.WATER);
if (!plugin.getConfig().getBoolean("Properties.Earth.CanBendWithWeapons"))
elements.add(Element.EARTH);
if (!plugin.getConfig().getBoolean("Properties.Fire.CanBendWithWeapons"))
elements.add(Element.FIRE);
if (!plugin.getConfig().getBoolean("Properties.Chi.CanBendWithWeapons"))
elements.add(Element.CHI);
return elements;
}
public static boolean hasItems() {
return Bukkit.getServer().getPluginManager().getPlugin("ProjectKorraItems") != null;

View file

@ -8,7 +8,6 @@ import java.util.Map;
import java.util.Set;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Location;
@ -1025,10 +1024,12 @@ public class PKListener implements Listener {
}.runTaskLater(plugin, 5);
if (event.getHand() == EquipmentSlot.HAND) {
if (event.getClickedBlock() != null) {
ComboManager.addComboAbility(player, ClickType.RIGHT_CLICK_BLOCK);
} else {
ComboManager.addComboAbility(player, ClickType.RIGHT_CLICK);
if (!GeneralMethods.isWeapon(player.getInventory().getItemInMainHand().getType()) && GeneralMethods.getElementsWithNoWeaponBending().contains(bPlayer.getBoundAbility().getElement())) {
if (event.getClickedBlock() != null) {
ComboManager.addComboAbility(player, ClickType.RIGHT_CLICK_BLOCK);
} else {
ComboManager.addComboAbility(player, ClickType.RIGHT_CLICK);
}
}
}
@ -1050,8 +1051,10 @@ public class PKListener implements Listener {
Player player = event.getPlayer();
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
ComboManager.addComboAbility(player, ClickType.RIGHT_CLICK_ENTITY);
if (!GeneralMethods.isWeapon(player.getInventory().getItemInMainHand().getType()) && GeneralMethods.getElementsWithNoWeaponBending().contains(bPlayer.getBoundAbility().getElement())) {
ComboManager.addComboAbility(player, ClickType.RIGHT_CLICK_ENTITY);
}
if (Paralyze.isParalyzed(player) || ChiCombo.isParalyzed(player) || Bloodbending.isBloodbent(player)
|| Suffocate.isBreathbent(player)) {
@ -1258,11 +1261,13 @@ public class PKListener implements Listener {
event.setCancelled(true);
return;
}
if (player.isSneaking()) {
ComboManager.addComboAbility(player, ClickType.SHIFT_UP);
} else {
if (!GeneralMethods.isWeapon(player.getInventory().getItemInMainHand().getType()) && GeneralMethods.getElementsWithNoWeaponBending().contains(bPlayer.getBoundAbility().getElement())) {
if (player.isSneaking()) {
ComboManager.addComboAbility(player, ClickType.SHIFT_UP);
} else {
ComboManager.addComboAbility(player, ClickType.SHIFT_DOWN);
}
}
String abilName = bPlayer.getBoundAbilityName();
@ -1460,11 +1465,14 @@ public class PKListener implements Listener {
}
Entity target = GeneralMethods.getTargetedEntity(player, 3);
if (target != null && !(target.equals(player)) && target instanceof LivingEntity) {
ComboManager.addComboAbility(player, ClickType.LEFT_CLICK_ENTITY);
if(!GeneralMethods.isWeapon(player.getInventory().getItemInMainHand().getType()) && GeneralMethods.getElementsWithNoWeaponBending().contains(bPlayer.getBoundAbility().getElement())) {
if (target != null && !(target.equals(player)) && target instanceof LivingEntity) {
ComboManager.addComboAbility(player, ClickType.LEFT_CLICK_ENTITY);
} else {
ComboManager.addComboAbility(player, ClickType.LEFT_CLICK);
} else {
ComboManager.addComboAbility(player, ClickType.LEFT_CLICK);
}
}
if (Suffocate.isBreathbent(player)) {

View file

@ -272,7 +272,6 @@ public class ComboManager {
break;
}
}
if (isValid) {
return customAbility;
}

View file

@ -190,7 +190,7 @@ public class ChiCombo extends ChiAbility implements ComboAbility {
this.name = name;
}
public class Immobilize extends ChiCombo {
public static class Immobilize extends ChiCombo {
public Immobilize(Player player) {
super(player, "Immobilize");

View file

@ -43,7 +43,6 @@ public class HighJump extends ChiAbility {
remove();
return;
}
jump(player);
WaterArmsWhip waw = WaterArmsWhip.getGrabbedEntities().get(player);
if (waw != null) {

View file

@ -38,7 +38,6 @@ public class QuickStrike extends ChiAbility {
remove();
return;
}
DamageHandler.damageEntity(target, damage, this);
bPlayer.addCooldown(this);
if (target instanceof Player && ChiPassive.willChiBlock(player, (Player) target)) {

View file

@ -9,6 +9,7 @@ import java.util.concurrent.ConcurrentHashMap;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
@ -76,7 +77,7 @@ public class EarthTunnel extends EarthAbility {
remove();
return;
} else {
while (!isEarthbendable(block)) {
while ((!isEarth(block) && !isSand(block))) {
if (!isTransparent(block)) {
remove();
return;
@ -108,6 +109,16 @@ public class EarthTunnel extends EarthAbility {
block.setType(Material.AIR);
} else {
airBlocks.put(new TempBlock(block, Material.AIR, (byte) 0), System.currentTimeMillis());
if(isPlant(block.getRelative(BlockFace.UP)) || isSnow(block.getRelative(BlockFace.UP))){
Block above = block.getRelative(BlockFace.UP);
Block above2 = above.getRelative(BlockFace.UP);
if (isPlant(above) || isSnow(above)) {
airBlocks.put(new TempBlock(above, Material.AIR, (byte) 0), System.currentTimeMillis());
if (isPlant(above2) && above2.getType().equals(Material.DOUBLE_PLANT)) {
airBlocks.put(new TempBlock(above2, Material.AIR, (byte) 0), System.currentTimeMillis());
}
}
}
}
} else {
block.setType(Material.AIR);

View file

@ -146,14 +146,14 @@ public class LavaFlow extends LavaAbility {
}
if (bPlayer.isOnCooldown("LavaFlow")) {
remove();
removeSlowly();
return;
}
start();
} else if (type == AbilityType.CLICK) {
Block sourceBlock = BlockSource.getEarthOrLavaSourceBlock(player, clickRange, ClickType.LEFT_CLICK);
if (sourceBlock == null) {
remove();
removeSlowly();
return;
}
@ -161,7 +161,7 @@ public class LavaFlow extends LavaAbility {
origin = sourceBlock.getLocation();
makeLava = !isLava(sourceBlock);
if (bPlayer.isOnCooldown("LavaFlow")) {
remove();
removeSlowly();
return;
} else {
bPlayer.addCooldown("LavaFlow", cooldown);
@ -178,12 +178,12 @@ public class LavaFlow extends LavaAbility {
@Override
public void progress() {
if (shiftCounter > 0 && type == AbilityType.SHIFT) {
remove();
removeSlowly();
return;
} else if (removing) {
return;
} else if (player.isDead() || !player.isOnline()) {
remove();
removeSlowly();
return;
}
@ -191,7 +191,7 @@ public class LavaFlow extends LavaAbility {
if (type == AbilityType.SHIFT) {
if (System.currentTimeMillis() - time > shiftRemoveDelay) {
remove();
removeSlowly();
return;
}
if (!player.isSneaking() && !removing) {
@ -200,18 +200,18 @@ public class LavaFlow extends LavaAbility {
removing = true;
bPlayer.addCooldown("LavaFlow", shiftCooldown);
} else {
remove();
removeSlowly();
}
return;
}
if (!bPlayer.canBendIgnoreCooldowns(this)) {
remove();
removeSlowly();
return;
} else if (origin == null) {
origin = player.getLocation().clone().add(0, -1, 0);
if (!isEarthbendable(origin.getBlock()) && origin.getBlock().getType() != Material.GLOWSTONE) {
remove();
removeSlowly();
return;
}
}
@ -229,9 +229,9 @@ public class LavaFlow extends LavaAbility {
if (dSquared < Math.pow(currentRadius, 2) && !GeneralMethods.isRegionProtectedFromBuild(this, block.getLocation())) {
if (dSquared < shiftPlatformRadius * 4 || getAdjacentLavaBlocks(block.getLocation()).size() > 0) {
if (!isLava(block)) {
if (isPlant(block)) {
if (isPlant(block) || isSnow(block)) {
Block lower = block.getRelative(BlockFace.DOWN);
if (isPlant(lower)) {
if (isPlant(lower) || isSnow(lower)) {
Block lower2 = lower.getRelative(BlockFace.DOWN);
if (!isEarth(lower2) && !isSand(lower2) && !isMetal(lower2)) {
continue;
@ -284,10 +284,10 @@ public class LavaFlow extends LavaAbility {
double delay = makeLava ? clickLavaDelay : clickLandDelay;
if (makeLava && curTime > clickLavaCleanupDelay) {
remove();
removeSlowly();
return;
} else if (!makeLava && curTime > clickLandCleanupDelay) {
remove();
removeSlowly();
return;
} else if (!makeLava && curTime < delay) {
return;
@ -296,10 +296,12 @@ public class LavaFlow extends LavaAbility {
for (double z = -clickLavaRadius; z <= clickLavaRadius; z++) {
Location loc = origin.clone().add(x, 0, z);
Block tempBlock = GeneralMethods.getTopBlock(loc, upwardFlow, downwardFlow);
if (tempBlock != null && !isLava(tempBlock) && Math.random() < particleDensity && tempBlock.getLocation().distanceSquared(origin) <= Math.pow(clickLavaRadius, 2)) {
if (random.nextInt(3) == 0) {
ParticleEffect.LAVA.display(loc, (float) Math.random(), (float) Math.random(), (float) Math.random(), 0, 1);
if (!isWater(tempBlock)) {
if (tempBlock != null && !isLava(tempBlock) && Math.random() < particleDensity && tempBlock
.getLocation().distanceSquared(origin) <= Math.pow(clickLavaRadius, 2)) {
if (random.nextInt(3) == 0) {
ParticleEffect.LAVA.display(loc, (float) Math.random(), (float) Math.random(),(float) Math.random(), 0, 1);
}
}
}
}
@ -333,10 +335,10 @@ public class LavaFlow extends LavaAbility {
if (makeLava && !isLava(tempBlock)) {
clickIsFinished = false;
if (Math.random() < lavaCreateSpeed) {
if (!isLava(tempBlock)) {
if (isPlant(tempBlock)) {
if (!isLava(tempBlock) || isSnow(tempBlock)) {
if (isPlant(tempBlock) || isSnow(tempBlock)) {
Block lower = tempBlock.getRelative(BlockFace.DOWN);
if (isPlant(lower)) {
if (isPlant(lower) || isSnow(lower)) {
Block lower2 = lower.getRelative(BlockFace.DOWN);
if (!isEarth(lower2) && !isSand(lower2) && !isMetal(lower2)) {
continue;
@ -357,7 +359,12 @@ public class LavaFlow extends LavaAbility {
}
} else {
if (random.nextInt(4) == 0) {
ParticleEffect.LAVA.display(loc, (float) Math.random(), (float) Math.random(), (float) Math.random(), 0, 1);
Block block = loc.getBlock();
Block above = block.getRelative(BlockFace.UP);
Block above2 = above.getRelative(BlockFace.UP);
if (!isWater(block) && !isWater(above) && !isWater(above2)) {
ParticleEffect.LAVA.display(loc, (float) Math.random(), (float) Math.random(), (float) Math.random(), 0, 1);
}
}
}
} else if (!makeLava && isLava(tempBlock)) {
@ -385,17 +392,18 @@ public class LavaFlow extends LavaAbility {
*/
public void createLava(Block block) {
if (isEarth(block) || isSand(block) || isMetal(block)) {
if (isPlant(block.getRelative(BlockFace.UP))) {
if (isPlant(block.getRelative(BlockFace.UP)) || isSnow(block.getRelative(BlockFace.UP))) {
Block above = block.getRelative(BlockFace.UP);
Block above2 = above.getRelative(BlockFace.UP);
if (isPlant(above) && above.getType() == Material.DOUBLE_PLANT) {
TempBlock tb = new TempBlock(above, Material.AIR, (byte) 0);
TEMP_AIR_BLOCKS.put(above, tb);
affectedBlocks.add(tb);
} else if (!isPlant(above2)) {
if (isPlant(above) || isSnow(above)) {
TempBlock tb = new TempBlock(above, Material.AIR, (byte) 0);
TEMP_AIR_BLOCKS.put(above, tb);
affectedBlocks.add(tb);
if (isPlant(above2) && above2.getType().equals(Material.DOUBLE_PLANT)) {
TempBlock tb2 = new TempBlock(above2, Material.AIR, (byte) 0);
TEMP_AIR_BLOCKS.put(above2, tb2);
affectedBlocks.add(tb);
}
} else
return;
}
@ -404,7 +412,6 @@ public class LavaFlow extends LavaAbility {
affectedBlocks.add(tblock);
if (allowNaturalFlow) {
// ProjectKorra.plugin.getLogger().info("Flow free!");
TempBlock.removeBlock(block);
}
}
@ -439,7 +446,7 @@ public class LavaFlow extends LavaAbility {
BukkitRunnable br = new BukkitRunnable() {
@Override
public void run() {
remove();
removeSlowly();
}
};
br.runTaskLater(ProjectKorra.plugin, (long) (shiftRemoveDelay / 1000.0 * 20.0));
@ -453,8 +460,7 @@ public class LavaFlow extends LavaAbility {
* This version of remove will create tasks that remove each lava block with
* an animation.
*/
@Override
public void remove() {
public void removeSlowly() {
super.remove();
for (int i = affectedBlocks.size() - 1; i > -1; i--) {
final TempBlock tblock = affectedBlocks.get(i);
@ -495,7 +501,8 @@ public class LavaFlow extends LavaAbility {
* Removes this ability instance instantly. This method does not cause any
* block animation, it just removes everything.
*/
public void removeInstantly() {
@Override
public void remove() {
super.remove();
for (int i = affectedBlocks.size() - 1; i > -1; i--) {
final TempBlock tblock = affectedBlocks.get(i);