From c164c7ebfefa6cf7ba5804cc3f4919ec140e8549 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Fri, 27 Aug 2021 22:34:20 +0200 Subject: [PATCH] Hotfix BlockPhysicsEvent sub 1.12 recording Signed-off-by: Lixfel --- .../fightsystem/listener/Recording.java | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/Recording.java b/FightSystem_Main/src/de/steamwar/fightsystem/listener/Recording.java index bb08635..0460e50 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/listener/Recording.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/listener/Recording.java @@ -25,6 +25,7 @@ import com.comphenix.protocol.events.PacketAdapter; import com.comphenix.protocol.events.PacketContainer; import com.comphenix.protocol.events.PacketEvent; import com.comphenix.protocol.wrappers.EnumWrappers; +import de.steamwar.core.Core; import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.fight.Fight; @@ -123,6 +124,22 @@ public class Recording implements Listener { GlobalRecorder.getInstance().entitySpeed(tnt); } }, 1, 1); + if(Core.getVersion() > 12){ + new StateDependentListener(ArenaMode.AntiReplay, FightState.All, new Listener() { + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onBlockPhysics(BlockPhysicsEvent e){ + if(e.getBlock() == e.getSourceBlock() || e.getChangedType() == Material.AIR) + GlobalRecorder.getInstance().blockChange(e.getBlock()); + } + }); + }else{ + new StateDependentListener(ArenaMode.AntiReplay, FightState.All, new Listener() { + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onBlockPhysics(BlockPhysicsEvent e){ + GlobalRecorder.getInstance().blockChange(e.getBlock()); + } + }); + } } @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @@ -198,12 +215,6 @@ public class Recording implements Listener { GlobalRecorder.getInstance().tntSpawn(e.getEntity()); } - @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) - public void onBlockPhysics(BlockPhysicsEvent e){ - if(e.getBlock() == e.getSourceBlock() || e.getChangedType() == Material.AIR) - GlobalRecorder.getInstance().blockChange(e.getBlock()); - } - @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onExplosion(EntityExplodeEvent e){ if(e.getEntityType() != EntityType.PRIMED_TNT)