From 72b03aa83261d350e10e1f4c74a2e7dd5ee4ed0c Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sun, 10 Apr 2022 18:58:36 +0200 Subject: [PATCH] Fix SpectralCraftArrow-Cast Signed-off-by: Lixfel --- .../steamwar/fightsystem/utils/WorldOfColorWrapper12.java | 7 +++++-- .../steamwar/fightsystem/utils/WorldOfColorWrapper8.java | 4 ++-- .../src/de/steamwar/fightsystem/listener/ArrowStopper.java | 6 +++--- .../de/steamwar/fightsystem/utils/WorldOfColorWrapper.java | 4 ++-- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/FightSystem_12/src/de/steamwar/fightsystem/utils/WorldOfColorWrapper12.java b/FightSystem_12/src/de/steamwar/fightsystem/utils/WorldOfColorWrapper12.java index 876feb8..b4be805 100644 --- a/FightSystem_12/src/de/steamwar/fightsystem/utils/WorldOfColorWrapper12.java +++ b/FightSystem_12/src/de/steamwar/fightsystem/utils/WorldOfColorWrapper12.java @@ -25,6 +25,7 @@ import org.bukkit.Sound; import org.bukkit.SoundCategory; import org.bukkit.entity.Arrow; import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; import org.bukkit.scoreboard.Team; public class WorldOfColorWrapper12 implements WorldOfColorWrapper { @@ -34,8 +35,10 @@ public class WorldOfColorWrapper12 implements WorldOfColorWrapper { } @Override - public boolean isInBlock(Arrow e) { - return e.isInBlock(); + public boolean isInBlock(Projectile e) { + if(e instanceof Arrow) + return ((Arrow) e).isInBlock(); + return false; } @Override diff --git a/FightSystem_8/src/de/steamwar/fightsystem/utils/WorldOfColorWrapper8.java b/FightSystem_8/src/de/steamwar/fightsystem/utils/WorldOfColorWrapper8.java index 68e4f66..4ddc684 100644 --- a/FightSystem_8/src/de/steamwar/fightsystem/utils/WorldOfColorWrapper8.java +++ b/FightSystem_8/src/de/steamwar/fightsystem/utils/WorldOfColorWrapper8.java @@ -22,8 +22,8 @@ package de.steamwar.fightsystem.utils; import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.Sound; -import org.bukkit.entity.Arrow; import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; import org.bukkit.scoreboard.Team; public class WorldOfColorWrapper8 implements WorldOfColorWrapper { @@ -33,7 +33,7 @@ public class WorldOfColorWrapper8 implements WorldOfColorWrapper { } @Override - public boolean isInBlock(Arrow e) { + public boolean isInBlock(Projectile e) { return false; } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/listener/ArrowStopper.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/ArrowStopper.java index 61317ea..e7b4d01 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/listener/ArrowStopper.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/ArrowStopper.java @@ -27,8 +27,8 @@ import de.steamwar.fightsystem.utils.WorldOfColorWrapper; import org.bukkit.Location; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; -import org.bukkit.entity.Arrow; import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; import org.bukkit.projectiles.ProjectileSource; import org.bukkit.util.Vector; @@ -44,7 +44,7 @@ public class ArrowStopper { private static final Class entityArrow = Reflection.getClass("{nms.world.entity.projectile}.EntityArrow"); private void run() { Recording.iterateOverEntities(entityArrow::isInstance, entity -> { - Arrow arrow = (Arrow) entity; + Projectile arrow = (Projectile) entity; if (invalidEntity(arrow)) return; @@ -88,7 +88,7 @@ public class ArrowStopper { return Config.HiddenBlocks.contains(block.getType().name().toLowerCase()); } - private boolean invalidEntity(Arrow entity) { + private boolean invalidEntity(Projectile entity) { Location location = entity.getLocation(); boolean teamFrom = entity.getVelocity().getZ() > 0; boolean overMid = location.getZ() > Config.SpecSpawn.getZ(); diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/utils/WorldOfColorWrapper.java b/FightSystem_Core/src/de/steamwar/fightsystem/utils/WorldOfColorWrapper.java index 3e074e5..e69b4d2 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/utils/WorldOfColorWrapper.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/utils/WorldOfColorWrapper.java @@ -24,15 +24,15 @@ import de.steamwar.fightsystem.FightSystem; import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.Sound; -import org.bukkit.entity.Arrow; import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; import org.bukkit.scoreboard.Team; public interface WorldOfColorWrapper { WorldOfColorWrapper impl = VersionDependent.getVersionImpl(FightSystem.getPlugin()); void setTeamColor(Team team, ChatColor color); - boolean isInBlock(Arrow e); + boolean isInBlock(Projectile e); void playSound(Location location, Sound sound, String soundCategory, float volume, float pitch);