Synchronizes master with wip and fixes debug command (#1066)

## Fixes
* Fixes the `/pk debug` command causing `ClassNotFoundException` and `NoClassDefFoundError` due to missing hook dependencies in the compiled jar.

## Copy Pasted
Credit goes to the authors of all of the changes below. I simply copy-pasted them so that they can be directly committed to master rather than have to re-align the wip and master branches due to them not being synched.

* e4f2f4fc8f
* 3cc64a2246
* b153748741
* 964de778d9
This commit is contained in:
Vahagn Tovmasian 2020-07-17 22:27:41 -07:00 committed by GitHub
parent ca2bb791ea
commit bd5c1fb45c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 76 additions and 45 deletions

View file

@ -1994,7 +1994,8 @@ public class GeneralMethods {
final ClassLoader loader = ProjectKorra.class.getClassLoader(); final ClassLoader loader = ProjectKorra.class.getClassLoader();
try { try {
for (final ClassPath.ClassInfo info : ClassPath.from(loader).getTopLevelClasses()) { for (final ClassPath.ClassInfo info : ClassPath.from(loader).getTopLevelClasses()) {
if (info.getName().startsWith("com.projectkorra.")) { if (info.getName().startsWith("com.projectkorra.") && !info.getName().contains("hooks")) {
try {
final Class<?> clazz = info.load(); final Class<?> clazz = info.load();
for (final Field field : clazz.getDeclaredFields()) { for (final Field field : clazz.getDeclaredFields()) {
final String simpleName = clazz.getSimpleName(); final String simpleName = clazz.getSimpleName();
@ -2010,6 +2011,10 @@ public class GeneralMethods {
} }
} }
} catch (Exception e) {
continue;
}
} }
} }
} catch (final IOException e) { } catch (final IOException e) {

View file

@ -61,6 +61,7 @@ import org.bukkit.event.inventory.InventoryPickupItemEvent;
import org.bukkit.event.player.AsyncPlayerChatEvent; import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerBucketEmptyEvent; import org.bukkit.event.player.PlayerBucketEmptyEvent;
import org.bukkit.event.player.PlayerChangedWorldEvent; import org.bukkit.event.player.PlayerChangedWorldEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerGameModeChangeEvent; import org.bukkit.event.player.PlayerGameModeChangeEvent;
import org.bukkit.event.player.PlayerInteractAtEntityEvent; import org.bukkit.event.player.PlayerInteractAtEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
@ -197,6 +198,7 @@ public class PKListener implements Listener {
private static final HashMap<Player, String> BENDING_PLAYER_DEATH = new HashMap<>(); // Player killed by Bending. private static final HashMap<Player, String> BENDING_PLAYER_DEATH = new HashMap<>(); // Player killed by Bending.
private static final List<UUID> RIGHT_CLICK_INTERACT = new ArrayList<UUID>(); // Player right click block. private static final List<UUID> RIGHT_CLICK_INTERACT = new ArrayList<UUID>(); // Player right click block.
private static final ArrayList<UUID> TOGGLED_OUT = new ArrayList<>(); // Stands for toggled = false while logging out. private static final ArrayList<UUID> TOGGLED_OUT = new ArrayList<>(); // Stands for toggled = false while logging out.
private static final List<Player> PLAYER_DROPPED_ITEM = new ArrayList<>(); // Player dropped an item.
private static final Map<Player, Integer> JUMPS = new HashMap<>(); private static final Map<Player, Integer> JUMPS = new HashMap<>();
private static MCTiming TimingPhysicsWaterManipulationCheck, TimingPhysicsEarthPassiveCheck, TimingPhysicsIlluminationTorchCheck, TimingPhysicsEarthAbilityCheck, TimingPhysicsAirTempBlockBelowFallingBlockCheck; private static MCTiming TimingPhysicsWaterManipulationCheck, TimingPhysicsEarthPassiveCheck, TimingPhysicsIlluminationTorchCheck, TimingPhysicsEarthAbilityCheck, TimingPhysicsAirTempBlockBelowFallingBlockCheck;
@ -1062,6 +1064,24 @@ public class PKListener implements Listener {
} }
} }
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPlayerItemDrop(PlayerDropItemEvent event) {
Player player = event.getPlayer();
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
if (event.isCancelled())
return;
if (bPlayer == null)
return;
if (bPlayer.getBoundAbility() == null)
return;
if (!PLAYER_DROPPED_ITEM.contains(player))
PLAYER_DROPPED_ITEM.add(player);
}
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPlayerInteraction(final PlayerInteractEvent event) { public void onPlayerInteraction(final PlayerInteractEvent event) {
final Player player = event.getPlayer(); final Player player = event.getPlayer();
@ -1588,6 +1608,11 @@ public class PKListener implements Listener {
@EventHandler(priority = EventPriority.NORMAL) @EventHandler(priority = EventPriority.NORMAL)
public void onPlayerSwing(final PlayerInteractEvent event) { public void onPlayerSwing(final PlayerInteractEvent event) {
final Player player = event.getPlayer(); final Player player = event.getPlayer();
if (PLAYER_DROPPED_ITEM.contains(player)) {
PLAYER_DROPPED_ITEM.remove(player);
return;
}
if (event.getHand() != EquipmentSlot.HAND) { if (event.getHand() != EquipmentSlot.HAND) {
return; return;
} }

View file

@ -330,10 +330,12 @@ public class AirBlast extends AirAbility {
if (bf == face) { if (bf == face) {
if (!door.isOpen()) { if (!door.isOpen()) {
this.remove();
return; return;
} }
} else if (bf.getOppositeFace() == face) { } else if (bf.getOppositeFace() == face) {
if (door.isOpen()) { if (door.isOpen()) {
this.remove();
return; return;
} }
} }
@ -350,10 +352,12 @@ public class AirBlast extends AirAbility {
if (this.origin.getY() < block.getY()) { if (this.origin.getY() < block.getY()) {
if (!tDoor.isOpen()) { if (!tDoor.isOpen()) {
this.remove();
return; return;
} }
} else { } else {
if (tDoor.isOpen()) { if (tDoor.isOpen()) {
this.remove();
return; return;
} }
} }

View file

@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -149,7 +150,7 @@ public class Suffocate extends AirAbility {
public void progress() { public void progress() {
for (int i = 0; i < this.targets.size(); i++) { for (int i = 0; i < this.targets.size(); i++) {
final LivingEntity target = this.targets.get(i); final LivingEntity target = this.targets.get(i);
if (target.isDead() || !target.getWorld().equals(this.player.getWorld()) || target.getLocation().distanceSquared(this.player.getEyeLocation()) > this.range * this.range || GeneralMethods.isRegionProtectedFromBuild(this, target.getLocation())) { if (target.isDead() || !target.getWorld().equals(this.player.getWorld()) || target.getLocation().distanceSquared(this.player.getEyeLocation()) > this.range * this.range || GeneralMethods.isRegionProtectedFromBuild(this, target.getLocation()) || target instanceof ArmorStand) {
this.breakSuffocateLocal(target); this.breakSuffocateLocal(target);
i--; i--;
} else if (target instanceof Player) { } else if (target instanceof Player) {
@ -190,8 +191,7 @@ public class Suffocate extends AirAbility {
return; return;
} else if (!this.started) { } else if (!this.started) {
this.started = true; this.started = true;
for (final LivingEntity targ : this.targets) { for (final LivingEntity target : this.targets) {
final LivingEntity target = targ;
final BukkitRunnable br1 = new BukkitRunnable() { final BukkitRunnable br1 = new BukkitRunnable() {
@Override @Override
public void run() { public void run() {
@ -220,7 +220,10 @@ public class Suffocate extends AirAbility {
} }
} }
this.animate(); for (final LivingEntity target : this.targets) {
this.animate(target);
}
if (!this.player.isSneaking()) { if (!this.player.isSneaking()) {
this.remove(); this.remove();
return; return;
@ -290,7 +293,7 @@ public class Suffocate extends AirAbility {
* specific time (dt) the ability will create a different set of * specific time (dt) the ability will create a different set of
* SuffocationSpirals. * SuffocationSpirals.
*/ */
public void animate() { public void animate(final LivingEntity target) {
final int steps = 8 * this.particleCount; final int steps = 8 * this.particleCount;
final long curTime = System.currentTimeMillis(); final long curTime = System.currentTimeMillis();
final long dt = curTime - this.getStartTime() - this.chargeTime; final long dt = curTime - this.getStartTime() - this.chargeTime;
@ -299,8 +302,6 @@ public class Suffocate extends AirAbility {
final long t2 = (long) (2500 * this.animationSpeed); final long t2 = (long) (2500 * this.animationSpeed);
final long t3 = (long) (5000 * this.animationSpeed); final long t3 = (long) (5000 * this.animationSpeed);
final long t4 = (long) (6000 * this.animationSpeed); final long t4 = (long) (6000 * this.animationSpeed);
for (final LivingEntity lent : this.targets) {
final LivingEntity target = lent;
if (dt < t1) { if (dt < t1) {
new SuffocateSpiral(target, steps, this.radius, delay, 0, 0.25 - (0.25 * dt / t1), 0, SpiralType.HORIZONTAL1); new SuffocateSpiral(target, steps, this.radius, delay, 0, 0.25 - (0.25 * dt / t1), 0, SpiralType.HORIZONTAL1);
new SuffocateSpiral(target, steps, this.radius, delay, 0, 0.25 - (0.25 * dt / t1), 0, SpiralType.HORIZONTAL2); new SuffocateSpiral(target, steps, this.radius, delay, 0, 0.25 - (0.25 * dt / t1), 0, SpiralType.HORIZONTAL2);
@ -322,7 +323,6 @@ public class Suffocate extends AirAbility {
new SuffocateSpiral(target, steps, this.radius - (this.radius * 3.0 / 4.0), delay, 0, 0, 0, SpiralType.VERTICAL2); new SuffocateSpiral(target, steps, this.radius - (this.radius * 3.0 / 4.0), delay, 0, 0, 0, SpiralType.VERTICAL2);
} }
} }
}
/** Stops an entity from being suffocated **/ /** Stops an entity from being suffocated **/
public void breakSuffocateLocal(final Entity entity) { public void breakSuffocateLocal(final Entity entity) {

View file

@ -9,8 +9,6 @@ import com.projectkorra.projectkorra.BendingPlayer;
import com.projectkorra.projectkorra.Element; import com.projectkorra.projectkorra.Element;
import com.projectkorra.projectkorra.ProjectKorra; import com.projectkorra.projectkorra.ProjectKorra;
import com.projectkorra.projectkorra.ability.CoreAbility; import com.projectkorra.projectkorra.ability.CoreAbility;
import com.projectkorra.projectkorra.configuration.ConfigManager;
import me.clip.placeholderapi.expansion.PlaceholderExpansion; import me.clip.placeholderapi.expansion.PlaceholderExpansion;
public class PlaceholderAPIHook extends PlaceholderExpansion { public class PlaceholderAPIHook extends PlaceholderExpansion {

View file

@ -3,7 +3,6 @@ package com.projectkorra.projectkorra.hooks;
import com.sk89q.worldguard.WorldGuard; import com.sk89q.worldguard.WorldGuard;
import com.sk89q.worldguard.protection.flags.StateFlag; import com.sk89q.worldguard.protection.flags.StateFlag;
import com.sk89q.worldguard.protection.flags.registry.FlagRegistry; import com.sk89q.worldguard.protection.flags.registry.FlagRegistry;
import com.projectkorra.projectkorra.ProjectKorra; import com.projectkorra.projectkorra.ProjectKorra;
public class WorldGuardFlag { public class WorldGuardFlag {

View file

@ -178,7 +178,7 @@ public class WaterArmsSpear extends WaterAbility {
return; return;
} }
new TempBlock(this.location.getBlock(), Material.WATER, GeneralMethods.getWaterData(0)); new TempBlock(this.location.getBlock(), Material.WATER);
getIceBlocks().put(this.location.getBlock(), System.currentTimeMillis() + 600L); getIceBlocks().put(this.location.getBlock(), System.currentTimeMillis() + 600L);
final Vector direction = GeneralMethods.getDirection(this.initLocation, GeneralMethods.getTargetedLocation(this.player, this.spearRange, getTransparentMaterials())).normalize(); final Vector direction = GeneralMethods.getDirection(this.initLocation, GeneralMethods.getTargetedLocation(this.player, this.spearRange, getTransparentMaterials())).normalize();
@ -256,7 +256,7 @@ public class WaterArmsSpear extends WaterAbility {
private boolean canPlaceBlock(final Block block) { private boolean canPlaceBlock(final Block block) {
if (!isTransparent(this.player, block) && !((isWater(block) || this.isIcebendable(block)) && (TempBlock.isTempBlock(block) && !getIceBlocks().containsKey(block)))) { if (!isTransparent(this.player, block) && !((isWater(block) || this.isIcebendable(block)) && (TempBlock.isTempBlock(block) && !getIceBlocks().containsKey(block)))) {
return false; return false;
} else if (GeneralMethods.isRegionProtectedFromBuild(this, block.getLocation())) { } else if (GeneralMethods.isRegionProtectedFromBuild(this, block.getLocation()) || GeneralMethods.isSolid(block)) {
return false; return false;
} else if (WaterArms.isUnbreakable(block) && !isWater(block)) { } else if (WaterArms.isUnbreakable(block) && !isWater(block)) {
return false; return false;