From c622e8b4f6757a1a4bce42ef571edb38092f0569 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sun, 28 Jan 2024 22:44:09 +0100 Subject: [PATCH] AI recordings Signed-off-by: Lixfel --- .../src/de/steamwar/fightsystem/ai/AI.java | 3 +++ .../de/steamwar/fightsystem/ai/lixfel/LixfelAI.java | 1 - .../de/steamwar/fightsystem/listener/Recording.java | 11 ++++++----- .../src/de/steamwar/fightsystem/record/Recorder.java | 2 +- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/ai/AI.java b/FightSystem_Core/src/de/steamwar/fightsystem/ai/AI.java index d151921..e27bc0d 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/ai/AI.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/ai/AI.java @@ -27,6 +27,7 @@ import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.fight.JoinRequest; import de.steamwar.fightsystem.listener.Chat; +import de.steamwar.fightsystem.record.GlobalRecorder; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.OneShotStateDependent; import de.steamwar.fightsystem.utils.Region; @@ -236,6 +237,8 @@ public abstract class AI { if(!entity.teleport(target, PlayerTeleportEvent.TeleportCause.PLUGIN)) FightSystem.getPlugin().getLogger().log(Level.INFO, "Entity not teleported: " + entity.isValid()); + + GlobalRecorder.getInstance().entityMoves(entity); } }); } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/ai/lixfel/LixfelAI.java b/FightSystem_Core/src/de/steamwar/fightsystem/ai/lixfel/LixfelAI.java index ec02e75..5513ccc 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/ai/lixfel/LixfelAI.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/ai/lixfel/LixfelAI.java @@ -50,7 +50,6 @@ public class LixfelAI extends AI { public LixfelAI(FightTeam team) { super(team, SteamwarUser.get("Lixfel.AI")); getEntity().setGlowing(true); - //TODO AI Replay } @Override diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/listener/Recording.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/Recording.java index f77c190..889c3c1 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/listener/Recording.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/Recording.java @@ -43,6 +43,7 @@ import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; +import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -70,7 +71,7 @@ public class Recording implements Listener { return stack; } - public static boolean isNotSent(Player p){ + public static boolean isNotSent(LivingEntity p){ FightPlayer fp = Fight.getFightPlayer(p); return fp == null || !fp.isLiving() || FightState.getFightState() == FightState.SPECTATE; } @@ -193,10 +194,10 @@ public class Recording implements Listener { @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onEntityDamage(EntityDamageEvent e) { - if(e.getEntityType() != EntityType.PLAYER) + if(!e.getEntityType().isAlive()) return; - Player p = (Player) e.getEntity(); + LivingEntity p = (LivingEntity) e.getEntity(); if(isNotSent(p)) return; @@ -208,10 +209,10 @@ public class Recording implements Listener { @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onEntityCombust(EntityCombustEvent e) { - if(e.getEntityType() != EntityType.PLAYER) + if(!e.getEntityType().isAlive()) return; - Player p = (Player) e.getEntity(); + LivingEntity p = (LivingEntity) e.getEntity(); if(isNotSent(p)) return; diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/record/Recorder.java b/FightSystem_Core/src/de/steamwar/fightsystem/record/Recorder.java index d57a29b..73821e6 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/record/Recorder.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/record/Recorder.java @@ -204,7 +204,7 @@ public interface Recorder { write(0x0a, e.getEntityId(), start, offHand); } - default void damageAnimation(Player p) { + default void damageAnimation(LivingEntity p) { write(0x0b, p.getEntityId()); }