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; 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() { public static boolean hasItems() {
return Bukkit.getServer().getPluginManager().getPlugin("ProjectKorraItems") != null; return Bukkit.getServer().getPluginManager().getPlugin("ProjectKorraItems") != null;

View file

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

View file

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

View file

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

View file

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

View file

@ -38,7 +38,6 @@ public class QuickStrike extends ChiAbility {
remove(); remove();
return; return;
} }
DamageHandler.damageEntity(target, damage, this); DamageHandler.damageEntity(target, damage, this);
bPlayer.addCooldown(this); bPlayer.addCooldown(this);
if (target instanceof Player && ChiPassive.willChiBlock(player, (Player) target)) { 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.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.util.Vector; import org.bukkit.util.Vector;
@ -76,7 +77,7 @@ public class EarthTunnel extends EarthAbility {
remove(); remove();
return; return;
} else { } else {
while (!isEarthbendable(block)) { while ((!isEarth(block) && !isSand(block))) {
if (!isTransparent(block)) { if (!isTransparent(block)) {
remove(); remove();
return; return;
@ -108,6 +109,16 @@ public class EarthTunnel extends EarthAbility {
block.setType(Material.AIR); block.setType(Material.AIR);
} else { } else {
airBlocks.put(new TempBlock(block, Material.AIR, (byte) 0), System.currentTimeMillis()); 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 { } else {
block.setType(Material.AIR); block.setType(Material.AIR);

View file

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