mirror of
https://github.com/TotalFreedomMC/TF-ProjectKorra.git
synced 2024-05-16 01:41:22 +00:00
c12e0daebb
For Spigot 1.14.4+ ## General Gameplay ### Additions - Added default Suffocate cooldown: 6.5 seconds - Added kinetic damage tracker to AirSweep - Added self and others push strength options for AirSuction - Added config option for multiple blocks to be changed per EarthTunnel run, allowing for much faster earth tunnels - Added config to ignore ores completely for EarthTunnel (good for mining) - Added AllowSnow config option for IceBlast - Added AvatarStateCooldown config options for IceBlast and IceBullet - Added config option for ice trapping abilities to not place blocks in players head or feet ### Fixes - Fixed preset command not allowing page numbers higher than 1 - Fixed Catapult and MetalClips not respecting /b invincible - Fixed Charged FireBlast radius and cooldown - Fixed Suffocate being usable through walls - Fixed FireBlast ignoring particle radius options - Fixed FireBurst fragmenting (not looking like a single burst) - Fixed AirSweep knockback to be more consistent (lessened friction) - Fixed AirBlast knockback using wrong push options - Fixed EarthSmash using nonexistent AvatarState options - Fixed error when switching worlds with PhaseChange active - Fixed server crash when hitting falling blocks with high-velocity abilities - Fixed server crash when using EarthGrab over the void - Fixed EarthTunnel not using configurable revert time - Fixed EarthPillars persisting when no entities were around ### Changes - Improved pathing for EarthBlast; works more consistently and can be used from ceilings - Improved aiming for EarthBlast and IceBlast - Changed AirSwipe and AirSweep to originate from the player’s main hand - Changed AirBlast knockback calculations; made the push options affect knockback more directly - Changed EarthTunnel to use tempblocks properly - Moved core combo instructions to config ### Removals - Removed being able to use Lightning while using FireJet - Removed jukeboxes being tempblocks - Removed bending.command.import permission from plugin.yml ## API ### Additions - Added GeneralMethods#getMainHandLocation(Player) - Added GeneralMethods#getClosestEntity(Location, double) - Added GeneralMethods#getClosestLivingEntity(Location, double) - Added "large" abilities collision with each other - Added specific timings for hot spots in the code that should help server owners diagnose lag from PK + player move event + physics event + bending manager - Created local folder repo and update pom for local jar files, this is necessary to use the maven shade plugin. - Added check for concrete powder in move earth - Added PlaceholderAPI support (hopefully more to come) + %projectkorra_slot<1-9>% ability on slot <1-9> + %projectkorra_element% element of the player + %projectkorra_elementcolor% color of the player’s element + %projectkorra_elements% elements the player has - Added "bending" WorldGuard flag. + Used for allowing or denying bending in worldguard regions. Will fall back to the old method of the build flag if the custom flag fails to register or isn't set ### Fixes - Fixed calls to CoreAbility#isEnabled() causing NullPointerExceptions when a CoreAbility is not enabled ### Changes - Changed CoreAbility#getAbility(..) Javadocs to state when it returns null - Formatted codebase - Changed GeneralMethods#getEntitiesAroundPoint() use spigot method for entities around point, should be more optimized - Optimizations to water and air spout to not continually set flying - Optimized revertchecker to not use block.getChunk; this will load the chunk on the server and instead use hashmap of coords - Optimized revertchecker to use paperlib to allow servers running paperspigot to load the chunk for a revert block async - Optimized tempblock revert to load chunk async before updating stateOptimize move event to ignore head movements without directional movement - Optimized physics event to check for air prior to checking for tempblocks - Optimized tempblock set/revert to not apply physics for blocks that don't emit light - Optimize isWater to check for actual water blocks first - Optimize PhaseChange list check, hot spot due to being called in physics event ### Removals - Removed BindChangeEvent; never called or used - Removed HorizontalVelocityTracker that has lasted over 30 seconds, also don't create a tracker for non-living entities
196 lines
6.3 KiB
Java
196 lines
6.3 KiB
Java
package com.projectkorra.projectkorra.airbending.combo;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import org.bukkit.Location;
|
|
import org.bukkit.block.Block;
|
|
import org.bukkit.entity.Entity;
|
|
import org.bukkit.entity.Player;
|
|
import org.bukkit.util.Vector;
|
|
|
|
import com.projectkorra.projectkorra.GeneralMethods;
|
|
import com.projectkorra.projectkorra.ability.AirAbility;
|
|
import com.projectkorra.projectkorra.ability.ComboAbility;
|
|
import com.projectkorra.projectkorra.ability.util.ComboManager.AbilityInformation;
|
|
import com.projectkorra.projectkorra.attribute.Attribute;
|
|
import com.projectkorra.projectkorra.command.Commands;
|
|
import com.projectkorra.projectkorra.util.ClickType;
|
|
|
|
public class Twister extends AirAbility implements ComboAbility {
|
|
|
|
public static enum AbilityState {
|
|
TWISTER_MOVING, TWISTER_STATIONARY
|
|
}
|
|
|
|
@Attribute(Attribute.COOLDOWN)
|
|
private long cooldown;
|
|
private long time;
|
|
@Attribute(Attribute.DAMAGE)
|
|
private double damage;
|
|
@Attribute(Attribute.SPEED)
|
|
private double speed;
|
|
@Attribute(Attribute.RANGE)
|
|
private double range;
|
|
@Attribute(Attribute.HEIGHT)
|
|
private double twisterHeight;
|
|
@Attribute(Attribute.RADIUS)
|
|
private double twisterRadius;
|
|
private double twisterDegreeParticles;
|
|
private double twisterHeightParticles;
|
|
private double twisterRemoveDelay;
|
|
private AbilityState state;
|
|
private Location origin;
|
|
private Location currentLoc;
|
|
private Location destination;
|
|
private Vector direction;
|
|
private ArrayList<Entity> affectedEntities;
|
|
|
|
public Twister(final Player player) {
|
|
super(player);
|
|
|
|
this.affectedEntities = new ArrayList<>();
|
|
|
|
if (!this.bPlayer.canBendIgnoreBindsCooldowns(this)) {
|
|
return;
|
|
}
|
|
|
|
if (this.bPlayer.isOnCooldown(this)) {
|
|
return;
|
|
}
|
|
|
|
this.range = getConfig().getDouble("Abilities.Air.Twister.Range");
|
|
this.speed = getConfig().getDouble("Abilities.Air.Twister.Speed");
|
|
this.cooldown = getConfig().getLong("Abilities.Air.Twister.Cooldown");
|
|
this.twisterHeight = getConfig().getDouble("Abilities.Air.Twister.Height");
|
|
this.twisterRadius = getConfig().getDouble("Abilities.Air.Twister.Radius");
|
|
this.twisterDegreeParticles = getConfig().getDouble("Abilities.Air.Twister.DegreesPerParticle");
|
|
this.twisterHeightParticles = getConfig().getDouble("Abilities.Air.Twister.HeightPerParticle");
|
|
this.twisterRemoveDelay = getConfig().getLong("Abilities.Air.Twister.RemoveDelay");
|
|
|
|
if (this.bPlayer.isAvatarState()) {
|
|
this.cooldown = 0;
|
|
this.damage = getConfig().getDouble("Abilities.Avatar.AvatarState.Air.Twister.Damage");
|
|
this.range = getConfig().getDouble("Abilities.Avatar.AvatarState.Air.Twister.Range");
|
|
}
|
|
|
|
this.bPlayer.addCooldown(this);
|
|
this.start();
|
|
}
|
|
|
|
@Override
|
|
public String getName() {
|
|
return "Twister";
|
|
}
|
|
|
|
@Override
|
|
public void progress() {
|
|
if (this.player.isDead() || !this.player.isOnline()) {
|
|
this.remove();
|
|
return;
|
|
} else if (this.currentLoc != null && GeneralMethods.isRegionProtectedFromBuild(this, this.currentLoc)) {
|
|
this.remove();
|
|
return;
|
|
}
|
|
|
|
if (this.destination == null) {
|
|
this.state = AbilityState.TWISTER_MOVING;
|
|
this.direction = this.player.getEyeLocation().getDirection().clone().normalize();
|
|
this.direction.setY(0);
|
|
this.origin = this.player.getLocation().add(this.direction.clone().multiply(2));
|
|
this.destination = this.player.getLocation().add(this.direction.clone().multiply(this.range));
|
|
this.currentLoc = this.origin.clone();
|
|
}
|
|
if (this.origin.distanceSquared(this.currentLoc) < this.origin.distanceSquared(this.destination) && this.state == AbilityState.TWISTER_MOVING) {
|
|
this.currentLoc.add(this.direction.clone().multiply(this.speed));
|
|
} else if (this.state == AbilityState.TWISTER_MOVING) {
|
|
this.state = AbilityState.TWISTER_STATIONARY;
|
|
this.time = System.currentTimeMillis();
|
|
} else if (System.currentTimeMillis() - this.time >= this.twisterRemoveDelay) {
|
|
this.remove();
|
|
return;
|
|
} else if (GeneralMethods.isRegionProtectedFromBuild(this, this.currentLoc)) {
|
|
this.remove();
|
|
return;
|
|
}
|
|
|
|
final Block topBlock = GeneralMethods.getTopBlock(this.currentLoc, 3, -3);
|
|
if (topBlock == null) {
|
|
this.remove();
|
|
return;
|
|
}
|
|
this.currentLoc.setY(topBlock.getLocation().getY());
|
|
|
|
final double height = this.twisterHeight;
|
|
final double radius = this.twisterRadius;
|
|
for (double y = 0; y < height; y += this.twisterHeightParticles) {
|
|
final double animRadius = ((radius / height) * y);
|
|
for (double i = -180; i <= 180; i += this.twisterDegreeParticles) {
|
|
final Vector animDir = GeneralMethods.rotateXZ(new Vector(1, 0, 1), i);
|
|
final Location animLoc = this.currentLoc.clone().add(animDir.multiply(animRadius));
|
|
animLoc.add(0, y, 0);
|
|
playAirbendingParticles(animLoc, 1, 0, 0, 0);
|
|
}
|
|
}
|
|
playAirbendingSound(this.currentLoc);
|
|
|
|
for (int i = 0; i < height; i += 3) {
|
|
for (final Entity entity : GeneralMethods.getEntitiesAroundPoint(this.currentLoc.clone().add(0, i, 0), radius * 0.75)) {
|
|
if (!this.affectedEntities.contains(entity) && !entity.equals(this.player)) {
|
|
this.affectedEntities.add(entity);
|
|
}
|
|
}
|
|
}
|
|
|
|
for (final Entity entity : this.affectedEntities) {
|
|
if (GeneralMethods.isRegionProtectedFromBuild(this, entity.getLocation()) || ((entity instanceof Player) && Commands.invincible.contains(((Player) entity).getName()))) {
|
|
continue;
|
|
}
|
|
final Vector forceDir = GeneralMethods.getDirection(entity.getLocation(), this.currentLoc.clone().add(0, height, 0));
|
|
entity.setVelocity(forceDir.clone().normalize().multiply(0.3));
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public boolean isSneakAbility() {
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
public boolean isHarmlessAbility() {
|
|
return false;
|
|
}
|
|
|
|
@Override
|
|
public long getCooldown() {
|
|
return this.cooldown;
|
|
}
|
|
|
|
public void setCooldown(final long cooldown) {
|
|
this.cooldown = cooldown;
|
|
}
|
|
|
|
@Override
|
|
public Location getLocation() {
|
|
return this.origin;
|
|
}
|
|
|
|
public void setLocation(final Location location) {
|
|
this.origin = location;
|
|
}
|
|
|
|
@Override
|
|
public Object createNewComboInstance(final Player player) {
|
|
return new Twister(player);
|
|
}
|
|
|
|
@Override
|
|
public ArrayList<AbilityInformation> getCombination() {
|
|
final ArrayList<AbilityInformation> twister = new ArrayList<>();
|
|
twister.add(new AbilityInformation("AirShield", ClickType.SHIFT_DOWN));
|
|
twister.add(new AbilityInformation("AirShield", ClickType.SHIFT_UP));
|
|
twister.add(new AbilityInformation("Tornado", ClickType.SHIFT_DOWN));
|
|
twister.add(new AbilityInformation("AirBlast", ClickType.LEFT_CLICK));
|
|
return twister;
|
|
}
|
|
}
|