From 26f2fb2afdb9c984ea7a9bd90327ca9a360b98cc Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sat, 2 Sep 2023 20:11:47 +0200 Subject: [PATCH] AI and Pathplanning fixes Signed-off-by: Lixfel --- FightSystem_Core/src/de/steamwar/fightsystem/ai/AI.java | 3 ++- .../src/de/steamwar/fightsystem/fight/FightPlayer.java | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/ai/AI.java b/FightSystem_Core/src/de/steamwar/fightsystem/ai/AI.java index 56b3205..6f5cb00 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/ai/AI.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/ai/AI.java @@ -46,6 +46,7 @@ import org.bukkit.entity.EntityType; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.Villager; +import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.scheduler.BukkitTask; import org.bukkit.util.Vector; @@ -212,7 +213,7 @@ public abstract class AI { if(!team.getFightPlayer(entity).canEntern() && !team.getExtendRegion().inRegion(target)) return; - entity.teleport(target); + entity.teleport(target, PlayerTeleportEvent.TeleportCause.COMMAND); } }); } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightPlayer.java b/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightPlayer.java index 1df6ef3..2ea6f58 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightPlayer.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightPlayer.java @@ -89,8 +89,11 @@ public class FightPlayer { } public void ifAI(Consumer function) { - if(!(entity instanceof Player)) - function.accept(AI.getAI(entity.getUniqueId())); + if(entity instanceof Player) + return; + AI ai = AI.getAI(entity.getUniqueId()); + if(ai != null) + function.accept(ai); } public void ifPlayer(Consumer function) {