Skip to content

Commit

Permalink
Cleanup and fix Bolt in newer spigot/paper versions, bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
PrimordialMoros committed Jun 29, 2021
1 parent 42f25dc commit a6be9a0
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 83 deletions.
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
}

group = "me.moros"
version = "1.6.5"
version = "1.6.6"

configure<JavaPluginConvention> {
sourceCompatibility = JavaVersion.VERSION_1_8
Expand All @@ -20,7 +20,7 @@ repositories {

dependencies {
implementation("org.bstats", "bstats-bukkit-lite", "1.7")
compileOnly("org.spigotmc:spigot-api:1.16.3-R0.1-SNAPSHOT")
compileOnly("org.spigotmc:spigot-api:1.16.5-R0.1-SNAPSHOT")
compileOnly("com.github.ProjectKorra:ProjectKorra:v1.9.0")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,9 @@ private void advanceLocation() {
} else {
if (mode == EarthLineMode.MAGMA) {
if(breakBlocks){
collapseWall();
collapseWall();
} else {
remove();
}
return;
}
Expand Down
78 changes: 14 additions & 64 deletions src/main/java/me/moros/hyperion/abilities/firebending/Bolt.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,8 @@
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Creeper;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LightningStrike;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.metadata.FixedMetadataValue;

import java.util.Collections;

Expand All @@ -55,9 +53,7 @@ public class Bolt extends LightningAbility implements AddonAbility {
@Attribute(Attribute.CHARGE_DURATION)
private long chargeTime;

private long strikeTime;
private boolean charged;
private boolean struck;

public Bolt(final Player player) {
super(player);
Expand All @@ -72,7 +68,6 @@ public Bolt(final Player player) {
chargeTime = Hyperion.getPlugin().getConfig().getLong("Abilities.Fire.Bolt.ChargeTime");

charged = chargeTime <= 0;
struck = false;

range = (int) getDayFactor(range, player.getWorld());
damage = getDayFactor(damage, player.getWorld());
Expand All @@ -84,25 +79,17 @@ public Bolt(final Player player) {

@Override
public void progress() {
if (struck) {
if (System.currentTimeMillis() > strikeTime + 500) {
remove();
}
return;
} else {
if (!bPlayer.canBendIgnoreCooldowns(this) || isWater(player.getEyeLocation().getBlock())) {
remove();
return;
}
if (!bPlayer.canBendIgnoreCooldowns(this) || isWater(player.getEyeLocation().getBlock())) {
remove();
return;
}

if (charged) {
if (!struck) {
if (player.isSneaking() && chargeTime != 0) {
CoreMethods.playFocusParticles(player);
} else {
strike();
}
if (player.isSneaking() && chargeTime != 0) {
CoreMethods.playFocusParticles(player);
} else {
strike();
remove();
}
} else {
if (!player.isSneaking()) {
Expand Down Expand Up @@ -183,22 +170,15 @@ private void strike() {
}
location = targetLocation;
player.getWorld().spigot().strikeLightningEffect(location, true);
player.getWorld().spawn(location, LightningStrike.class, entity -> {
entity.setCustomName("Bolt");
entity.setCustomNameVisible(false);
entity.setSilent(true);
entity.setMetadata(CoreMethods.BOLT_KEY, new FixedMetadataValue(Hyperion.getPlugin(), new BoltInfo(this, damage, targetLocation.clone())));
});
player.getWorld().playSound(location, Sound.ENTITY_LIGHTNING_BOLT_THUNDER, 5, 1.2F);
struck = true;
strikeTime = System.currentTimeMillis();
bPlayer.addCooldown(this);
if (!Bolt.isNearbyChannel(location, player)) {
dealDamage(location);
}
}

public static void dealDamage(BoltInfo info) {
Location strikeLocation = info.getLocation();
public void dealDamage(Location strikeLocation) {
boolean enhanced = isWater(strikeLocation.getBlock());

for (final Entity e : GeneralMethods.getEntitiesAroundPoint(strikeLocation, 5)) {
if (e instanceof Creeper) ((Creeper) e).setPowered(true);
if (e instanceof LivingEntity && !(e instanceof ArmorStand)) {
Expand All @@ -213,18 +193,12 @@ public static void dealDamage(BoltInfo info) {
final EarthGuard armorAbility = CoreAbility.getAbility((Player) e, EarthGuard.class);
if (armorAbility.hasActiveArmor() && armorAbility.isMetalArmor()) vulnerable = true;
}

double baseDamage = vulnerable ? info.getDamage() * 2 : info.getDamage();
double baseDamage = vulnerable ? damage * 2 : damage;
double distanceModifier = enhanced ? distance / 3 : distance / 2;
info.getAbility().dealDamage((LivingEntity) e, (distance < 1.5) ? baseDamage : baseDamage - distanceModifier);
DamageHandler.damageEntity(e, (distance < 1.5) ? baseDamage : baseDamage - distanceModifier, this);
AirAbility.breakBreathbendingHold(e);
}
}
info.getAbility().remove();
}

public void dealDamage(LivingEntity ent, double dmg) {
DamageHandler.damageEntity(ent, dmg, this);
}

public static boolean isNearbyChannel(Location location, Player source) {
Expand All @@ -239,28 +213,4 @@ public static boolean isNearbyChannel(Location location, Player source) {
}
return false;
}

public static class BoltInfo {
private final Bolt ability;
private final double damage;
private final Location location;

public BoltInfo(Bolt boltAbility, double boltDamage, Location boltLocation) {
ability = boltAbility;
damage = boltDamage;
location = boltLocation;
}

public double getDamage() {
return damage;
}

public Location getLocation() {
return location;
}

public Bolt getAbility() {
return ability;
}
}
}
15 changes: 0 additions & 15 deletions src/main/java/me/moros/hyperion/listeners/CoreListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
import me.moros.hyperion.abilities.earthbending.EarthGuard;
import me.moros.hyperion.abilities.earthbending.EarthShot;
import me.moros.hyperion.abilities.earthbending.MetalCable;
import me.moros.hyperion.abilities.firebending.Bolt;
import me.moros.hyperion.abilities.firebending.Bolt.BoltInfo;
import me.moros.hyperion.configuration.ConfigManager;
import me.moros.hyperion.methods.CoreMethods;
import me.moros.hyperion.util.BendingFallingBlock;
Expand All @@ -39,7 +37,6 @@
import org.bukkit.entity.Arrow;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.FallingBlock;
import org.bukkit.entity.LightningStrike;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Snowball;
Expand All @@ -51,7 +48,6 @@
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.EntityPickupItemEvent;
import org.bukkit.event.entity.EntitySpawnEvent;
import org.bukkit.event.entity.ItemMergeEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.entity.ProjectileHitEvent;
Expand Down Expand Up @@ -104,17 +100,6 @@ public void onArrowHit(final ProjectileHitEvent event) {
}
}

@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onLightningStrike(final EntitySpawnEvent event) {
if (event.getEntity() instanceof LightningStrike && event.getEntity().hasMetadata(CoreMethods.BOLT_KEY)) {
final BoltInfo boltInfo = (BoltInfo) event.getEntity().getMetadata(CoreMethods.BOLT_KEY).get(0).value();
if (boltInfo != null) {
if (!Bolt.isNearbyChannel(boltInfo.getLocation(), boltInfo.getAbility().getPlayer()))
Bolt.dealDamage(boltInfo);
}
}
}

@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onEntityDamageByEntity(final EntityDamageByEntityEvent event) {
if (event.getDamager() instanceof Arrow && event.getDamager().hasMetadata(CoreMethods.CABLE_KEY)) {
Expand Down
1 change: 0 additions & 1 deletion src/main/java/me/moros/hyperion/methods/CoreMethods.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ public class CoreMethods {
public static final String NO_PICKUP_KEY = "BENDING_HYPERION_NO_PICKUP";
public static final String GLOVE_KEY = "BENDING_HYPERION_EARTH_GLOVE";
public static final String CABLE_KEY = "BENDING_HYPERION_METAL_CABLE_KEY";
public static final String BOLT_KEY = "BENDING_HYPERION_LIGHTNING_KEY";
public static final String SMOKESCREEN_KEY = "BENDING_HYPERION_SMOKESCREEN_KEY";

public static List<Location> getCirclePoints(Location location, int points, double size) {
Expand Down

0 comments on commit a6be9a0

Please sign in to comment.