From 0367c92279fe58fccd1656ae726af8308b0e6236 Mon Sep 17 00:00:00 2001 From: Robbie Gorey <59033980+Aztlon@users.noreply.github.com> Date: Fri, 21 Aug 2020 21:16:49 -0400 Subject: [PATCH 1/2] Add config option for Lightning on FireJet (#1083) ## Additions * Added a configurable boolean for Lightning called "AllowOnFireJet" with a default of true, which allows the use of Lightning while on FireJet * Closes #1082 --- .../projectkorra/configuration/ConfigManager.java | 1 + .../projectkorra/firebending/lightning/Lightning.java | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/com/projectkorra/projectkorra/configuration/ConfigManager.java b/src/com/projectkorra/projectkorra/configuration/ConfigManager.java index 389137f6..14ab9d63 100644 --- a/src/com/projectkorra/projectkorra/configuration/ConfigManager.java +++ b/src/com/projectkorra/projectkorra/configuration/ConfigManager.java @@ -1456,6 +1456,7 @@ public class ConfigManager { config.addDefault("Abilities.Fire.Lightning.SelfHitWater", true); config.addDefault("Abilities.Fire.Lightning.SelfHitClose", false); config.addDefault("Abilities.Fire.Lightning.ArcOnIce", false); + config.addDefault("Abilities.Fire.Lightning.AllowOnFireJet", true); config.addDefault("Abilities.Fire.WallOfFire.Enabled", true); config.addDefault("Abilities.Fire.WallOfFire.Range", 3); diff --git a/src/com/projectkorra/projectkorra/firebending/lightning/Lightning.java b/src/com/projectkorra/projectkorra/firebending/lightning/Lightning.java index 93393abc..0250b97f 100644 --- a/src/com/projectkorra/projectkorra/firebending/lightning/Lightning.java +++ b/src/com/projectkorra/projectkorra/firebending/lightning/Lightning.java @@ -35,6 +35,7 @@ public class Lightning extends LightningAbility { private boolean hitIce; private boolean selfHitWater; private boolean selfHitClose; + private boolean allowOnFireJet; @Attribute("ArcOnIce") private boolean arcOnIce; private int waterArcs; @@ -110,6 +111,7 @@ public class Lightning extends LightningAbility { this.waterArcs = getConfig().getInt("Abilities.Fire.Lightning.WaterArcs"); this.chargeTime = getConfig().getLong("Abilities.Fire.Lightning.ChargeTime"); this.cooldown = getConfig().getLong("Abilities.Fire.Lightning.Cooldown"); + this.allowOnFireJet = getConfig().getBoolean("Abilities.Fire.Lightning.AllowOnFireJet"); this.range = this.getDayFactor(this.range); this.subArcChance = this.getDayFactor(this.subArcChance); @@ -182,7 +184,7 @@ public class Lightning extends LightningAbility { } else if (!this.bPlayer.canBendIgnoreCooldowns(this)) { this.remove(); return; - } else if (CoreAbility.hasAbility(player, FireJet.class)){ + } else if (CoreAbility.hasAbility(player, FireJet.class) && !allowOnFireJet){ this.removeWithTasks(); return; } From f39c7f7186ff0e31c1190497d770a3abcc493012 Mon Sep 17 00:00:00 2001 From: Vahagn Tovmasian Date: Fri, 21 Aug 2020 18:18:30 -0700 Subject: [PATCH 2/2] Fine Tuning (#1075) ## Fixes * Fixes #1079 - Netherite weapons not being counted as weapons * Fixes #1034 - Abilities working through walls * Fixes #1057 - Bad wording for toggle command. * Fixes #1080 - IceSpike not working with a bottle source * Fixes #1086 - Torrent not working with a bottle source * Fix Illumination displacing water --- .../projectkorra/GeneralMethods.java | 40 +++++++- .../projectkorra/ability/WaterAbility.java | 2 +- .../projectkorra/airbending/AirSuction.java | 2 +- .../projectkorra/airbending/AirSwipe.java | 95 ++++++++++--------- .../projectkorra/airbending/Suffocate.java | 2 +- .../projectkorra/command/ToggleCommand.java | 2 +- .../configuration/ConfigManager.java | 2 +- .../projectkorra/firebending/FireBlast.java | 58 +++++------ .../firebending/Illumination.java | 4 +- .../projectkorra/waterbending/Torrent.java | 5 +- .../waterbending/ice/IceSpikeBlast.java | 5 +- 11 files changed, 124 insertions(+), 93 deletions(-) diff --git a/src/com/projectkorra/projectkorra/GeneralMethods.java b/src/com/projectkorra/projectkorra/GeneralMethods.java index e00dbd8e..6073360a 100644 --- a/src/com/projectkorra/projectkorra/GeneralMethods.java +++ b/src/com/projectkorra/projectkorra/GeneralMethods.java @@ -1797,7 +1797,45 @@ public class GeneralMethods { } public static boolean isWeapon(final Material mat) { - return mat != null && (mat == Material.WOODEN_AXE || mat == Material.WOODEN_PICKAXE || mat == Material.WOODEN_SHOVEL || mat == Material.WOODEN_SWORD || mat == Material.STONE_AXE || mat == Material.STONE_PICKAXE || mat == Material.STONE_SHOVEL || mat == Material.STONE_SWORD || mat == Material.IRON_AXE || mat == Material.IRON_PICKAXE || mat == Material.IRON_SWORD || mat == Material.IRON_SHOVEL || mat == Material.DIAMOND_AXE || mat == Material.DIAMOND_PICKAXE || mat == Material.DIAMOND_SWORD || mat == Material.DIAMOND_SHOVEL || mat == Material.GOLDEN_AXE || mat == Material.GOLDEN_HOE || mat == Material.GOLDEN_SWORD || mat == Material.GOLDEN_PICKAXE || mat == Material.GOLDEN_SHOVEL || mat == Material.TRIDENT); + + switch(mat) { + case BOW: + case CROSSBOW: + case DIAMOND_AXE: + case DIAMOND_HOE: + case DIAMOND_PICKAXE: + case DIAMOND_SHOVEL: + case DIAMOND_SWORD: + case GOLDEN_AXE: + case GOLDEN_HOE: + case GOLDEN_PICKAXE: + case GOLDEN_SHOVEL: + case GOLDEN_SWORD: + case IRON_AXE: + case IRON_HOE: + case IRON_PICKAXE: + case IRON_SHOVEL: + case IRON_SWORD: + case NETHERITE_AXE: + case NETHERITE_HOE: + case NETHERITE_PICKAXE: + case NETHERITE_SHOVEL: + case NETHERITE_SWORD: + case STONE_AXE: + case STONE_HOE: + case STONE_PICKAXE: + case STONE_SHOVEL: + case STONE_SWORD: + case TRIDENT: + case WOODEN_AXE: + case WOODEN_HOE: + case WOODEN_PICKAXE: + case WOODEN_SHOVEL: + case WOODEN_SWORD: + return true; + default: + return false; + } } public static void loadBendingPlayer(final BendingPlayer pl) { diff --git a/src/com/projectkorra/projectkorra/ability/WaterAbility.java b/src/com/projectkorra/projectkorra/ability/WaterAbility.java index da332392..42cf13ab 100644 --- a/src/com/projectkorra/projectkorra/ability/WaterAbility.java +++ b/src/com/projectkorra/projectkorra/ability/WaterAbility.java @@ -276,7 +276,7 @@ public abstract class WaterAbility extends ElementalAbility { public static boolean isWaterbendable(final Player player, final String abilityName, final Block block) { final BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player); - if (bPlayer == null || !isWaterbendable(block.getType()) || GeneralMethods.isRegionProtectedFromBuild(player, abilityName, block.getLocation())) { + if (bPlayer == null || !isWaterbendable(block.getType())) { return false; } if (TempBlock.isTempBlock(block) && !isBendableWaterTempBlock(block)) { diff --git a/src/com/projectkorra/projectkorra/airbending/AirSuction.java b/src/com/projectkorra/projectkorra/airbending/AirSuction.java index e8669793..802b68a0 100644 --- a/src/com/projectkorra/projectkorra/airbending/AirSuction.java +++ b/src/com/projectkorra/projectkorra/airbending/AirSuction.java @@ -253,7 +253,7 @@ public class AirSuction extends AirAbility { } else if (!bPlayer.canBendIgnoreCooldowns(this)) { remove(); return; - } else if (origin.distanceSquared(player.getEyeLocation()) > getSelectRange() * getSelectRange()) { + } else if (origin.distanceSquared(player.getLocation()) > this.range * this.range) { remove(); return; } diff --git a/src/com/projectkorra/projectkorra/airbending/AirSwipe.java b/src/com/projectkorra/projectkorra/airbending/AirSwipe.java index 0030148d..759bee6a 100644 --- a/src/com/projectkorra/projectkorra/airbending/AirSwipe.java +++ b/src/com/projectkorra/projectkorra/airbending/AirSwipe.java @@ -146,65 +146,75 @@ public class AirSwipe extends AirAbility { for (final Vector direction : this.streams.keySet()) { Location location = this.streams.get(direction); if (direction != null && location != null) { - + BlockIterator blocks = new BlockIterator(this.getLocation().getWorld(), location.toVector(), direction, 0, (int) Math.ceil(direction.clone().multiply(speed).length())); while (blocks.hasNext()) { - if(!blocks.next().isPassable()) { + if(!checkLocation(blocks.next(), direction)) { this.streams.remove(direction); + break; } } + if(!this.streams.containsKey(direction)) { + continue; + } + location = location.clone().add(direction.clone().multiply(this.speed)); this.streams.put(direction, location); - - if (location.distanceSquared(this.origin) > this.range * this.range || GeneralMethods.isRegionProtectedFromBuild(this, location)) { - this.streams.clear(); - } else { - final Block block = location.getBlock(); - if (!ElementalAbility.isTransparent(this.player, block) || !block.isPassable()) { - this.streams.remove(direction); - continue; - } - - for (final Block testblock : GeneralMethods.getBlocksAroundPoint(location, this.radius)) { - if (FireAbility.isFire(testblock.getType())) { - testblock.setType(Material.AIR); - } - } - - if (!isAir(block.getType())) { - if (block.getType().equals(Material.SNOW)) { - continue; - } else if (isPlant(block.getType())) { - block.breakNaturally(); - } else { - this.streams.remove(direction); - } - if (isLava(block)) { - if (LavaFlow.isLavaFlowBlock(block)) { - LavaFlow.removeBlock(block); // TODO: Make more generic for future lava generating moves. - } else if (block.getBlockData() instanceof Levelled && ((Levelled) block.getBlockData()).getLevel() == 0) { - new TempBlock(block, Material.OBSIDIAN); - } else { - new TempBlock(block, Material.COBBLESTONE); - } - } - } else { - playAirbendingParticles(location, this.particles, 0.2F, 0.2F, 0); - if (this.random.nextInt(4) == 0) { - playAirbendingSound(location); - } - this.affectPeople(location, direction); - } + playAirbendingParticles(location, this.particles, 0.2F, 0.2F, 0); + if (this.random.nextInt(4) == 0) { + playAirbendingSound(location); } + this.affectPeople(location, direction); } } if (this.streams.isEmpty()) { this.remove(); } } + public boolean checkLocation(Block block, Vector direction) { + if (GeneralMethods.checkDiagonalWall(block.getLocation(), direction) || !block.isPassable()) { + return false; + } else { + if (block.getLocation().distanceSquared(this.origin) > this.range * this.range || GeneralMethods.isRegionProtectedFromBuild(this, block.getLocation())) { + this.streams.clear(); + } else { + if (!ElementalAbility.isTransparent(this.player, block) || !block.isPassable()) { + return false; + } + for (final Block testblock : GeneralMethods.getBlocksAroundPoint(block.getLocation(), this.radius)) { + if (FireAbility.isFire(testblock.getType())) { + testblock.setType(Material.AIR); + } + } + + if (!isAir(block.getType())) { + if (block.getType().equals(Material.SNOW)) { + return true; + } else if (isPlant(block.getType())) { + block.breakNaturally(); + return false; + } else if (isLava(block)) { + if (LavaFlow.isLavaFlowBlock(block)) { + LavaFlow.removeBlock(block); + return false;// TODO: Make more generic for future lava generating moves. + } else if (block.getBlockData() instanceof Levelled && ((Levelled) block.getBlockData()).getLevel() == 0) { + new TempBlock(block, Material.OBSIDIAN); + return false; + } else { + new TempBlock(block, Material.COBBLESTONE); + return false; + } + } else { + return false; + } + } + } + } + return true; + } private void affectPeople(final Location location, final Vector direction) { final List entities = GeneralMethods.getEntitiesAroundPoint(location, this.radius); final Vector fDirection = direction.clone(); @@ -244,7 +254,6 @@ public class AirSwipe extends AirAbility { AirSwipe.this.affectedEntities.add(entity); } breakBreathbendingHold(entity); - AirSwipe.this.streams.remove(direction); } else if (entity.getEntityId() != AirSwipe.this.player.getEntityId() && !(entity instanceof LivingEntity)) { GeneralMethods.setVelocity(entity, fDirection.multiply(AirSwipe.this.pushFactor)); diff --git a/src/com/projectkorra/projectkorra/airbending/Suffocate.java b/src/com/projectkorra/projectkorra/airbending/Suffocate.java index ad494bd2..21d40f64 100644 --- a/src/com/projectkorra/projectkorra/airbending/Suffocate.java +++ b/src/com/projectkorra/projectkorra/airbending/Suffocate.java @@ -116,7 +116,7 @@ public class Suffocate extends AirAbility { List entities = new ArrayList(); for (int i = 0; i < 6; i++) { final Location location = GeneralMethods.getTargetedLocation(player, i, getTransparentMaterials()); - entities = GeneralMethods.getEntitiesAroundPoint(location, 1.7); + entities = GeneralMethods.getEntitiesAroundPoint(location, .5); if (entities.contains(player)) { entities.remove(player); } diff --git a/src/com/projectkorra/projectkorra/command/ToggleCommand.java b/src/com/projectkorra/projectkorra/command/ToggleCommand.java index 853511d4..b67b0306 100644 --- a/src/com/projectkorra/projectkorra/command/ToggleCommand.java +++ b/src/com/projectkorra/projectkorra/command/ToggleCommand.java @@ -24,7 +24,7 @@ public class ToggleCommand extends PKCommand { private final String toggledOffForAll, toggleOffSelf, toggleOnSelf, toggleOffAll, toggleOnAll, toggledOffSingleElement, toggledOnSingleElement, wrongElementOther, toggledOnOtherElementConfirm, toggledOffOtherElementConfirm, toggledOnOtherElement, toggledOffOtherElement, wrongElement, notFound; public ToggleCommand() { - super("toggle", "/bending toggle [Player]", ConfigManager.languageConfig.get().getString("Commands.Toggle.Description"), new String[] { "toggle", "t" }); + super("toggle", "/bending toggle [Player]", ConfigManager.languageConfig.get().getString("Commands.Toggle.Description"), new String[] { "toggle", "t" }); final FileConfiguration c = ConfigManager.languageConfig.get(); diff --git a/src/com/projectkorra/projectkorra/configuration/ConfigManager.java b/src/com/projectkorra/projectkorra/configuration/ConfigManager.java index 14ab9d63..c4fdeb8d 100644 --- a/src/com/projectkorra/projectkorra/configuration/ConfigManager.java +++ b/src/com/projectkorra/projectkorra/configuration/ConfigManager.java @@ -685,7 +685,7 @@ public class ConfigManager { config.addDefault("Abilities.Avatar.AvatarState.Air.AirSwipe.Damage", 4.5); config.addDefault("Abilities.Avatar.AvatarState.Air.AirSwipe.Push", 1.0); config.addDefault("Abilities.Avatar.AvatarState.Air.AirSwipe.Range", 24); - config.addDefault("Abilities.Avatar.AvatarState.Air.AirSwipe.Radius", 0.75); + config.addDefault("Abilities.Avatar.AvatarState.Air.AirSwipe.Radius", 0.25); config.addDefault("Abilities.Avatar.AvatarState.Air.AirBurst.ChargeTime", 1000); config.addDefault("Abilities.Avatar.AvatarState.Air.AirBurst.Damage", 3); config.addDefault("Abilities.Avatar.AvatarState.Air.AirShield.IsAvatarStateToggle", true); diff --git a/src/com/projectkorra/projectkorra/firebending/FireBlast.java b/src/com/projectkorra/projectkorra/firebending/FireBlast.java index 9aa7c330..c3ea453b 100644 --- a/src/com/projectkorra/projectkorra/firebending/FireBlast.java +++ b/src/com/projectkorra/projectkorra/firebending/FireBlast.java @@ -159,7 +159,6 @@ public class FireBlast extends FireAbility { while (blocks.hasNext() && checkLocation(blocks.next())); this.location.add(this.direction.clone().multiply(speedFactor)); - this.location = this.location.add(this.direction.clone().multiply(this.speedFactor)); if (this.random.nextInt(4) == 0) { playFirebendingSound(this.location); @@ -167,11 +166,34 @@ public class FireBlast extends FireAbility { } public boolean checkLocation(Block block) { - if (GeneralMethods.checkDiagonalWall(block.getLocation(), this.direction) || !block.isPassable()) { + if (!block.isPassable()) { + if (block.getType() == Material.FURNACE && this.powerFurnace) { + final Furnace furnace = (Furnace) block.getState(); + furnace.setBurnTime((short) 800); + furnace.update(); + } else if (block.getType() == Material.SMOKER && this.powerFurnace) { + final Smoker smoker = (Smoker) block.getState(); + smoker.setBurnTime((short) 800); + smoker.update(); + } else if (block.getType() == Material.BLAST_FURNACE && this.powerFurnace) { + final BlastFurnace blastF = (BlastFurnace) block.getState(); + blastF.setBurnTime((short) 800); + blastF.update(); + } else if (block instanceof Campfire) { + final Campfire campfire = (Campfire) block.getBlockData(); + if(!campfire.isLit()) { + if(block.getType() != Material.SOUL_CAMPFIRE || bPlayer.canUseSubElement(SubElement.BLUE_FIRE)) { + campfire.setLit(true); + } + } + } else if (isIgnitable(block.getRelative(BlockFace.UP))) { + if ((this.isFireBurst && this.fireBurstIgnite) || !this.isFireBurst) { + this.ignite(this.location); + } + } this.remove(); return false; } - return true; } private void affect(final Entity entity) { @@ -219,36 +241,6 @@ public class FireBlast extends FireAbility { return; } - final Block block = this.location.getBlock(); - if (GeneralMethods.isSolid(block) || block.isLiquid()) { - if (block.getType() == Material.FURNACE && this.powerFurnace) { - final Furnace furnace = (Furnace) block.getState(); - furnace.setBurnTime((short) 800); - furnace.update(); - } else if (block.getType() == Material.SMOKER && this.powerFurnace) { - final Smoker smoker = (Smoker) block.getState(); - smoker.setBurnTime((short) 800); - smoker.update(); - } else if (block.getType() == Material.BLAST_FURNACE && this.powerFurnace) { - final BlastFurnace blastF = (BlastFurnace) block.getState(); - blastF.setBurnTime((short) 800); - blastF.update(); - } else if (block instanceof Campfire) { - final Campfire campfire = (Campfire) block.getBlockData(); - if(!campfire.isLit()) { - if(block.getType() != Material.SOUL_CAMPFIRE || bPlayer.canUseSubElement(SubElement.BLUE_FIRE)) { - campfire.setLit(true); - } - } - } else if (isIgnitable(block.getRelative(BlockFace.UP))) { - if ((this.isFireBurst && this.fireBurstIgnite) || !this.isFireBurst) { - this.ignite(this.location); - } - } - this.remove(); - return; - } - if (this.location.distanceSquared(this.origin) > this.range * this.range) { this.remove(); return; diff --git a/src/com/projectkorra/projectkorra/firebending/Illumination.java b/src/com/projectkorra/projectkorra/firebending/Illumination.java index 2ea2a505..1c66ecd9 100644 --- a/src/com/projectkorra/projectkorra/firebending/Illumination.java +++ b/src/com/projectkorra/projectkorra/firebending/Illumination.java @@ -12,7 +12,6 @@ import org.bukkit.entity.Player; import com.projectkorra.projectkorra.Element; import com.projectkorra.projectkorra.Element.SubElement; -import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.ability.FireAbility; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.util.TempBlock; @@ -112,8 +111,7 @@ public class Illumination extends FireAbility { private void set() { final Block standingBlock = this.player.getLocation().getBlock(); final Block standBlock = standingBlock.getRelative(BlockFace.DOWN); - - if (!GeneralMethods.isSolid(standBlock)) { + if (!isIgnitable(standingBlock)) { return; } else if (this.block != null && standingBlock.equals(this.block.getBlock())) { return; diff --git a/src/com/projectkorra/projectkorra/waterbending/Torrent.java b/src/com/projectkorra/projectkorra/waterbending/Torrent.java index b6aa7a58..c93e3e83 100644 --- a/src/com/projectkorra/projectkorra/waterbending/Torrent.java +++ b/src/com/projectkorra/projectkorra/waterbending/Torrent.java @@ -171,10 +171,7 @@ public class Torrent extends WaterAbility { if (!this.bPlayer.canBendIgnoreCooldowns(this)) { this.remove(); return; - } else if (!isWaterbendable(this.sourceBlock) && !this.settingUp && !this.forming && !this.formed && !this.launching) { - this.remove(); - return; - } + } if (System.currentTimeMillis() > this.time + this.interval) { this.time = System.currentTimeMillis(); diff --git a/src/com/projectkorra/projectkorra/waterbending/ice/IceSpikeBlast.java b/src/com/projectkorra/projectkorra/waterbending/ice/IceSpikeBlast.java index bd830bc2..a9d86685 100644 --- a/src/com/projectkorra/projectkorra/waterbending/ice/IceSpikeBlast.java +++ b/src/com/projectkorra/projectkorra/waterbending/ice/IceSpikeBlast.java @@ -157,11 +157,8 @@ public class IceSpikeBlast extends IceAbility { } else if (!this.bPlayer.getBoundAbilityName().equals(this.getName()) && this.prepared) { this.remove(); return; - } else if (!isWaterbendable(this.sourceBlock) && !this.progressing && !this.settingUp) { - this.remove(); - return; } - + if (System.currentTimeMillis() < this.time + this.interval) { return; }