## Additions
* Adds support for Minecraft 1.17!
* Adds vanished player support to the `/pk who <Player>` command.
  * Should work with most common vanishing plugins, tested using Essentials vanish.
  * Affects `/pk who` and `/pk who <Player>`.
* Adds new `"Abilities.Earth.EarthSmash.Lift.Knockup"` configuration option to control the velocity applied to players standing where an EarthSmash is created.
* Adds new `"Abilities.Earth.EarthSmash.Lift.Range"` configuration option to control the range in which entities need to be standing in relation to where an EarthSmash is created to get the Knockup applied.

## Fixes
* Fixes players sometimes "falling through" their EarthSmash if they try to create it underneath themselves.
  * Reduces the overall push so it feels more natural.
  * Expands the push radius so it can affect entities within one block of the location.
* Fixes IceWave activating sometimes when PhaseChange wasn't clicked.
* Fixes IceWave users getting stuck on their ice midair.
* Fixes the display command showing hidden combos and passives
* Fixes an error caused by adding attribute modifiers to abilities sometimes.
* Fixes an error preventing the plugin from working on Minecraft 1.17.
  * ClassDefNotFoundError resulting from EntityHuman being moved during the 1.17 Minecraft update. We no longer rely on NMS for this area as a proper API has been introduced. As such, GeneralMethods and EarthArmor have been updated to reflect these changes.
This commit is contained in:
Christopher Martin 2021-06-15 09:49:50 -07:00 committed by GitHub
parent 787b303c9f
commit 75c4f41be5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 1058 additions and 1050 deletions

View file

@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>com.projectkorra</groupId> <groupId>com.projectkorra</groupId>
<artifactId>projectkorra</artifactId> <artifactId>projectkorra</artifactId>
<version>1.9.1</version> <version>1.9.2</version>
<name>ProjectKorra</name> <name>ProjectKorra</name>
<repositories> <repositories>
<!-- local jar files, add more using: mvn install:install-file -Dfile=aaa.jar -DgroupId=aaa -DartifactId=aaa -Dversion=aaa -Dpackaging=jar -DlocalRepositoryPath=path/to/ProjectKorra/localrepo/ --> <!-- local jar files, add more using: mvn install:install-file -Dfile=aaa.jar -DgroupId=aaa -DartifactId=aaa -Dversion=aaa -Dpackaging=jar -DlocalRepositoryPath=path/to/ProjectKorra/localrepo/ -->

View file

@ -119,8 +119,6 @@ import com.projectkorra.projectkorra.util.BlockCacheElement;
import com.projectkorra.projectkorra.util.ColoredParticle; import com.projectkorra.projectkorra.util.ColoredParticle;
import com.projectkorra.projectkorra.util.MovementHandler; import com.projectkorra.projectkorra.util.MovementHandler;
import com.projectkorra.projectkorra.util.ParticleEffect; import com.projectkorra.projectkorra.util.ParticleEffect;
import com.projectkorra.projectkorra.util.ReflectionHandler;
import com.projectkorra.projectkorra.util.ReflectionHandler.PackageType;
import com.projectkorra.projectkorra.util.TempArmor; import com.projectkorra.projectkorra.util.TempArmor;
import com.projectkorra.projectkorra.util.TempArmorStand; import com.projectkorra.projectkorra.util.TempArmorStand;
import com.projectkorra.projectkorra.util.TempBlock; import com.projectkorra.projectkorra.util.TempBlock;
@ -149,20 +147,8 @@ public class GeneralMethods {
private static final ArrayList<Ability> INVINCIBLE = new ArrayList<>(); private static final ArrayList<Ability> INVINCIBLE = new ArrayList<>();
private static ProjectKorra plugin; private static ProjectKorra plugin;
private static Method getAbsorption;
private static Method setAbsorption;
private static Method getHandle;
public GeneralMethods(final ProjectKorra plugin) { public GeneralMethods(final ProjectKorra plugin) {
GeneralMethods.plugin = plugin; GeneralMethods.plugin = plugin;
try {
getAbsorption = ReflectionHandler.getMethod("EntityHuman", PackageType.MINECRAFT_SERVER, "getAbsorptionHearts");
setAbsorption = ReflectionHandler.getMethod("EntityHuman", PackageType.MINECRAFT_SERVER, "setAbsorptionHearts", Float.class);
getHandle = ReflectionHandler.getMethod("CraftPlayer", PackageType.CRAFTBUKKIT_ENTITY, "getHandle");
} catch (final Exception e) {
e.printStackTrace();
}
} }
/** /**
@ -675,26 +661,25 @@ public class GeneralMethods {
ActionBar.sendActionBar(displayedMessage, player); ActionBar.sendActionBar(displayedMessage, player);
} }
/**
* Gets the number of absorption hearts of a specified {@link Player}.
* @param player the {@link Player} to get the absorption hearts of.
* @deprecated Use {@link Player#getAbsorptionAmount()}.
*/
@Deprecated
public static float getAbsorbationHealth(final Player player) { public static float getAbsorbationHealth(final Player player) {
return (float) player.getAbsorptionAmount();
try {
final Object entityplayer = getHandle.invoke(player);
final Object hearts = getAbsorption.invoke(entityplayer);
return (float) hearts;
} catch (final Exception e) {
e.printStackTrace();
}
return 0;
} }
/**
* Sets the number of absorption hearts of a specified {@link Player}.
* @param player the {@link Player} to set the absorption hearts of.
* @param hearts a float representing the number of hearts to set.
* @deprecated Use {@link Player#setAbsorptionAmount(double)}
*/
@Deprecated
public static void setAbsorbationHealth(final Player player, final float hearts) { public static void setAbsorbationHealth(final Player player, final float hearts) {
player.setAbsorptionAmount(hearts);
try {
final Object entityplayer = getHandle.invoke(player);
setAbsorption.invoke(entityplayer, hearts);
} catch (final Exception e) {
e.printStackTrace();
}
} }
public static int getArmorTier(Material mat) { public static int getArmorTier(Material mat) {

View file

@ -3,46 +3,46 @@ package com.projectkorra.projectkorra.attribute;
public enum AttributeModifier { public enum AttributeModifier {
ADDITION((oldValue, modifier) -> { ADDITION((oldValue, modifier) -> {
if (oldValue instanceof Double || modifier instanceof Double) { if (oldValue instanceof Double) {
return oldValue.doubleValue() + modifier.doubleValue(); return oldValue.doubleValue() + modifier.doubleValue();
} else if (oldValue instanceof Float || modifier instanceof Float) { } else if (oldValue instanceof Float) {
return oldValue.floatValue() + modifier.floatValue(); return oldValue.floatValue() + modifier.floatValue();
} else if (oldValue instanceof Long || modifier instanceof Long) { } else if (oldValue instanceof Long) {
return oldValue.longValue() + modifier.longValue(); return oldValue.longValue() + modifier.longValue();
} else if (oldValue instanceof Integer || modifier instanceof Integer) { } else if (oldValue instanceof Integer) {
return oldValue.intValue() + modifier.intValue(); return oldValue.intValue() + modifier.intValue();
} }
return 0; return 0;
}), SUBTRACTION((oldValue, modifier) -> { }), SUBTRACTION((oldValue, modifier) -> {
if (oldValue instanceof Double || modifier instanceof Double) { if (oldValue instanceof Double) {
return oldValue.doubleValue() - modifier.doubleValue(); return oldValue.doubleValue() - modifier.doubleValue();
} else if (oldValue instanceof Float || modifier instanceof Float) { } else if (oldValue instanceof Float) {
return oldValue.floatValue() - modifier.floatValue(); return oldValue.floatValue() - modifier.floatValue();
} else if (oldValue instanceof Long || modifier instanceof Long) { } else if (oldValue instanceof Long) {
return oldValue.longValue() - modifier.longValue(); return oldValue.longValue() - modifier.longValue();
} else if (oldValue instanceof Integer || modifier instanceof Integer) { } else if (oldValue instanceof Integer) {
return oldValue.intValue() - modifier.intValue(); return oldValue.intValue() - modifier.intValue();
} }
return 0; return 0;
}), MULTIPLICATION((oldValue, modifier) -> { }), MULTIPLICATION((oldValue, modifier) -> {
if (oldValue instanceof Double || modifier instanceof Double) { if (oldValue instanceof Double) {
return oldValue.doubleValue() * modifier.doubleValue(); return oldValue.doubleValue() * modifier.doubleValue();
} else if (oldValue instanceof Float || modifier instanceof Float) { } else if (oldValue instanceof Float) {
return oldValue.floatValue() * modifier.floatValue(); return oldValue.floatValue() * modifier.floatValue();
} else if (oldValue instanceof Long || modifier instanceof Long) { } else if (oldValue instanceof Long) {
return oldValue.longValue() * modifier.longValue(); return oldValue.longValue() * modifier.longValue();
} else if (oldValue instanceof Integer || modifier instanceof Integer) { } else if (oldValue instanceof Integer) {
return oldValue.intValue() * modifier.intValue(); return oldValue.intValue() * modifier.intValue();
} }
return 0; return 0;
}), DIVISION((oldValue, modifier) -> { }), DIVISION((oldValue, modifier) -> {
if (oldValue instanceof Double || modifier instanceof Double) { if (oldValue instanceof Double) {
return oldValue.doubleValue() / modifier.doubleValue(); return oldValue.doubleValue() / modifier.doubleValue();
} else if (oldValue instanceof Float || modifier instanceof Float) { } else if (oldValue instanceof Float) {
return oldValue.floatValue() / modifier.floatValue(); return oldValue.floatValue() / modifier.floatValue();
} else if (oldValue instanceof Long || modifier instanceof Long) { } else if (oldValue instanceof Long) {
return oldValue.longValue() / modifier.longValue(); return oldValue.longValue() / modifier.longValue();
} else if (oldValue instanceof Integer || modifier instanceof Integer) { } else if (oldValue instanceof Integer) {
return oldValue.intValue() / modifier.intValue(); return oldValue.intValue() / modifier.intValue();
} }
return 0; return 0;

View file

@ -96,9 +96,11 @@ public class DisplayCommand extends PKCommand {
} }
final CoreAbility coreAbil = CoreAbility.getAbility(comboAbil); final CoreAbility coreAbil = CoreAbility.getAbility(comboAbil);
if (coreAbil != null) { if (coreAbil == null || coreAbil.isHiddenAbility()) {
comboColor = coreAbil.getElement().getColor(); continue;
} }
comboColor = coreAbil.getElement().getColor();
String message = (comboColor + comboAbil); String message = (comboColor + comboAbil);
if (coreAbil instanceof AddonAbility) { if (coreAbil instanceof AddonAbility) {
@ -127,9 +129,10 @@ public class DisplayCommand extends PKCommand {
} }
final CoreAbility coreAbil = CoreAbility.getAbility(comboMove); final CoreAbility coreAbil = CoreAbility.getAbility(comboMove);
if (coreAbil != null) { if (coreAbil == null || coreAbil.isHiddenAbility()) {
comboColor = coreAbil.getElement().getColor(); continue;
} }
comboColor = coreAbil.getElement().getColor();
String message = (comboColor + comboMove); String message = (comboColor + comboMove);
@ -157,9 +160,11 @@ public class DisplayCommand extends PKCommand {
} }
final CoreAbility coreAbil = CoreAbility.getAbility(passiveAbil); final CoreAbility coreAbil = CoreAbility.getAbility(passiveAbil);
if (coreAbil != null) { if (coreAbil == null || coreAbil.isHiddenAbility()) {
passiveColor = coreAbil.getElement().getColor(); continue;
} }
passiveColor = coreAbil.getElement().getColor();
String message = (passiveColor + passiveAbil); String message = (passiveColor + passiveAbil);
if (coreAbil instanceof AddonAbility) { if (coreAbil instanceof AddonAbility) {
@ -188,9 +193,11 @@ public class DisplayCommand extends PKCommand {
} }
final CoreAbility coreAbil = CoreAbility.getAbility(passiveAbil); final CoreAbility coreAbil = CoreAbility.getAbility(passiveAbil);
if (coreAbil != null) { if (coreAbil == null || coreAbil.isHiddenAbility()) {
passiveColor = coreAbil.getElement().getColor(); continue;
} }
passiveColor = coreAbil.getElement().getColor();
sender.sendMessage(passiveColor + passiveAbil); sender.sendMessage(passiveColor + passiveAbil);
} }
return; return;

View file

@ -94,6 +94,10 @@ public class WhoCommand extends PKCommand {
} }
final List<String> players = new ArrayList<String>(); final List<String> players = new ArrayList<String>();
for (final Player player : Bukkit.getOnlinePlayers()) { for (final Player player : Bukkit.getOnlinePlayers()) {
if (sender instanceof Player && !((Player) sender).canSee(player)) {
continue;
}
final String playerName = player.getName(); final String playerName = player.getName();
String result = ""; String result = "";
BendingPlayer bp = BendingPlayer.getBendingPlayer(playerName); BendingPlayer bp = BendingPlayer.getBendingPlayer(playerName);
@ -150,13 +154,14 @@ public class WhoCommand extends PKCommand {
GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + "Player not found!"); GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + "Player not found!");
return; return;
} }
if (!player.isOnline() && !BendingPlayer.getPlayers().containsKey(player.getUniqueId())) {
GeneralMethods.sendBrandingMessage(sender, ChatColor.GRAY + this.playerOffline.replace("{player}", ChatColor.WHITE + player.getName() + ChatColor.GRAY).replace("{target}", ChatColor.WHITE + player.getName() + ChatColor.GRAY));
}
final Player player_ = (Player) (player.isOnline() ? player : null); final Player player_ = (Player) (player.isOnline() ? player : null);
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player); BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
if ((!player.isOnline() && !BendingPlayer.getPlayers().containsKey(player.getUniqueId())) || (sender instanceof Player && player_ != null && !((Player) sender).canSee(player_))) {
GeneralMethods.sendBrandingMessage(sender, ChatColor.GRAY + this.playerOffline.replace("{player}", ChatColor.WHITE + player.getName() + ChatColor.GRAY).replace("{target}", ChatColor.WHITE + player.getName() + ChatColor.GRAY));
}
if (bPlayer == null) { if (bPlayer == null) {
GeneralMethods.createBendingPlayer(player.getUniqueId(), playerName); GeneralMethods.createBendingPlayer(player.getUniqueId(), playerName);
final BukkitRunnable runnable = new BukkitRunnable() { final BukkitRunnable runnable = new BukkitRunnable() {

View file

@ -1290,6 +1290,8 @@ public class ConfigManager {
config.addDefault("Abilities.Earth.EarthSmash.Damage", 5); config.addDefault("Abilities.Earth.EarthSmash.Damage", 5);
config.addDefault("Abilities.Earth.EarthSmash.Knockback", 3.5); config.addDefault("Abilities.Earth.EarthSmash.Knockback", 3.5);
config.addDefault("Abilities.Earth.EarthSmash.Knockup", 0.15); config.addDefault("Abilities.Earth.EarthSmash.Knockup", 0.15);
config.addDefault("Abilities.Earth.EarthSmash.Lift.Knockup", 1.1);
config.addDefault("Abilities.Earth.EarthSmash.Lift.Range", 3.5);
config.addDefault("Abilities.Earth.EarthSmash.Flight.Enabled", true); config.addDefault("Abilities.Earth.EarthSmash.Flight.Enabled", true);
config.addDefault("Abilities.Earth.EarthSmash.Flight.Speed", 0.72); config.addDefault("Abilities.Earth.EarthSmash.Flight.Speed", 0.72);
config.addDefault("Abilities.Earth.EarthSmash.Flight.Duration", 3000); config.addDefault("Abilities.Earth.EarthSmash.Flight.Duration", 3000);

View file

@ -45,7 +45,7 @@ public class EarthArmor extends EarthAbility {
private Location legsBlockLocation; private Location legsBlockLocation;
private boolean active; private boolean active;
private PotionEffect oldAbsorbtion = null; private PotionEffect oldAbsorbtion = null;
private float goldHearts; private double goldHearts;
@Attribute("GoldHearts") @Attribute("GoldHearts")
private int maxGoldHearts; private int maxGoldHearts;
private TempArmor armor; private TempArmor armor;
@ -145,7 +145,7 @@ public class EarthArmor extends EarthAbility {
this.player.addPotionEffect(new PotionEffect(PotionEffectType.ABSORPTION, Integer.MAX_VALUE, level, true, false)); this.player.addPotionEffect(new PotionEffect(PotionEffectType.ABSORPTION, Integer.MAX_VALUE, level, true, false));
this.goldHearts = this.maxGoldHearts * 2; this.goldHearts = this.maxGoldHearts * 2;
GeneralMethods.setAbsorbationHealth(this.player, this.goldHearts); this.player.setAbsorptionAmount(this.goldHearts);
} }
private boolean inPosition() { private boolean inPosition() {
@ -249,7 +249,7 @@ public class EarthArmor extends EarthAbility {
if (this.formed) { if (this.formed) {
if (!this.player.hasPotionEffect(PotionEffectType.ABSORPTION)) { if (!this.player.hasPotionEffect(PotionEffectType.ABSORPTION)) {
this.player.addPotionEffect(new PotionEffect(PotionEffectType.ABSORPTION, Integer.MAX_VALUE, 1, true, false)); this.player.addPotionEffect(new PotionEffect(PotionEffectType.ABSORPTION, Integer.MAX_VALUE, 1, true, false));
GeneralMethods.setAbsorbationHealth(this.player, this.goldHearts); this.player.setAbsorptionAmount(this.goldHearts);
} }
if (!this.active) { if (!this.active) {
@ -301,7 +301,7 @@ public class EarthArmor extends EarthAbility {
new BukkitRunnable() { new BukkitRunnable() {
@Override @Override
public void run() { public void run() {
abil.goldHearts = GeneralMethods.getAbsorbationHealth(EarthArmor.this.player); abil.goldHearts = EarthArmor.this.player.getAbsorptionAmount();
if (abil.formed && abil.goldHearts < 0.9F) { if (abil.formed && abil.goldHearts < 0.9F) {
abil.bPlayer.addCooldown(abil); abil.bPlayer.addCooldown(abil);
@ -601,7 +601,7 @@ public class EarthArmor extends EarthAbility {
this.cooldown = cooldown; this.cooldown = cooldown;
} }
public float getGoldHearts() { public double getGoldHearts() {
return this.goldHearts; return this.goldHearts;
} }
@ -609,7 +609,7 @@ public class EarthArmor extends EarthAbility {
return this.maxGoldHearts; return this.maxGoldHearts;
} }
public void setGoldHearts(final float goldHearts) { public void setGoldHearts(final double goldHearts) {
this.goldHearts = goldHearts; this.goldHearts = goldHearts;
} }

View file

@ -64,6 +64,8 @@ public class EarthSmash extends EarthAbility {
private double knockback; private double knockback;
@Attribute(Attribute.KNOCKUP) @Attribute(Attribute.KNOCKUP)
private double knockup; private double knockup;
private double liftKnockup;
private double liftRange;
@Attribute(Attribute.SPEED) @Attribute(Attribute.SPEED)
private double flightSpeed; private double flightSpeed;
private double grabbedDistance; private double grabbedDistance;
@ -157,6 +159,8 @@ public class EarthSmash extends EarthAbility {
this.damage = getConfig().getDouble("Abilities.Earth.EarthSmash.Damage"); this.damage = getConfig().getDouble("Abilities.Earth.EarthSmash.Damage");
this.knockback = getConfig().getDouble("Abilities.Earth.EarthSmash.Knockback"); this.knockback = getConfig().getDouble("Abilities.Earth.EarthSmash.Knockback");
this.knockup = getConfig().getDouble("Abilities.Earth.EarthSmash.Knockup"); this.knockup = getConfig().getDouble("Abilities.Earth.EarthSmash.Knockup");
this.liftKnockup = getConfig().getDouble("Abilities.Earth.EarthSmash.Lift.Knockup");
this.liftRange = getConfig().getDouble("Abilities.Earth.EarthSmash.Lift.Range");
this.flightSpeed = getConfig().getDouble("Abilities.Earth.EarthSmash.Flight.Speed"); this.flightSpeed = getConfig().getDouble("Abilities.Earth.EarthSmash.Flight.Speed");
this.chargeTime = getConfig().getLong("Abilities.Earth.EarthSmash.ChargeTime"); this.chargeTime = getConfig().getLong("Abilities.Earth.EarthSmash.ChargeTime");
this.cooldown = getConfig().getLong("Abilities.Earth.EarthSmash.Cooldown"); this.cooldown = getConfig().getLong("Abilities.Earth.EarthSmash.Cooldown");
@ -398,13 +402,14 @@ public class EarthSmash extends EarthAbility {
*/ */
this.location.add(0, -1, 0); this.location.add(0, -1, 0);
}
// Move any entities that are above the rock. // Move any entities that are above the rock.
final List<Entity> entities = GeneralMethods.getEntitiesAroundPoint(this.location, 2.5); final List<Entity> entities = GeneralMethods.getEntitiesAroundPoint(this.location, this.liftRange);
for (final Entity entity : entities) { for (final Entity entity : entities) {
final org.bukkit.util.Vector velocity = entity.getVelocity(); final org.bukkit.util.Vector velocity = entity.getVelocity();
GeneralMethods.setVelocity(this, entity, velocity.add(new Vector(0, 0.36, 0))); entity.setVelocity(velocity.add(new Vector(0, this.liftKnockup, 0)));
} }
}
this.location.getWorld().playEffect(this.location, Effect.GHAST_SHOOT, 0, 7); this.location.getWorld().playEffect(this.location, Effect.GHAST_SHOOT, 0, 7);
this.draw(); this.draw();
} else { } else {

View file

@ -371,7 +371,7 @@ public class WaterSpoutWave extends WaterAbility {
final BukkitRunnable br = new BukkitRunnable() { final BukkitRunnable br = new BukkitRunnable() {
@Override @Override
public void run() { public void run() {
WaterSpoutWave.this.createBlock(block, mat); WaterSpoutWave.this.createBlock(block, block.getLocation().distance(player.getLocation()) >= 1.6 ? mat : Material.WATER);
} }
}; };
br.runTaskLater(ProjectKorra.plugin, delay); br.runTaskLater(ProjectKorra.plugin, delay);

View file

@ -27,6 +27,10 @@ public class IceWave extends IceAbility implements ComboAbility {
public IceWave(final Player player) { public IceWave(final Player player) {
super(player); super(player);
if (!hasAbility(player, WaterSpoutWave.class)) {
return;
}
if (!this.bPlayer.canBendIgnoreBindsCooldowns(this)) { if (!this.bPlayer.canBendIgnoreBindsCooldowns(this)) {
return; return;
} }