From 83eb9bfa13cc1afbdbda2754de7d0cb69705efb8 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Fri, 7 Oct 2022 17:30:49 +0200 Subject: [PATCH] Fix ClickAnalyzer Signed-off-by: Lixfel --- .../src/de/steamwar/fightsystem/FightSystem.java | 2 ++ .../fightsystem/listener/ClickAnalyzer.java | 13 +++++++++++-- .../de/steamwar/fightsystem/listener/Recording.java | 2 -- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java b/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java index fb9ee97..1a94778 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java @@ -90,6 +90,7 @@ public class FightSystem extends JavaPlugin { new ArrowPickup(); new BlockFadeListener(); new LeaveableArena(); + new ClickAnalyzer(); new HotbarKit.HotbarKitListener(); new OneShotStateDependent(ArenaMode.All, FightState.PreSchemSetup, () -> Fight.playSound(SWSound.BLOCK_NOTE_PLING.getSound(), 100.0f, 2.0f)); @@ -161,6 +162,7 @@ public class FightSystem extends JavaPlugin { @Override public void onDisable() { GlobalRecorder.getInstance().close(); + ClickAnalyzer.close(); } public static void setSpectateState(FightTeam winFightTeam, String winreason, String subtitle, Object... params) { diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/listener/ClickAnalyzer.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/ClickAnalyzer.java index dbc5b07..bf0ea32 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/listener/ClickAnalyzer.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/ClickAnalyzer.java @@ -19,6 +19,7 @@ package de.steamwar.fightsystem.listener; +import com.comphenix.tinyprotocol.TinyProtocol; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.utils.CraftbukkitWrapper; import org.bukkit.entity.Player; @@ -26,7 +27,6 @@ import org.bukkit.entity.Player; import java.io.*; public class ClickAnalyzer { - private ClickAnalyzer() {} private static final PrintStream output; @@ -38,7 +38,16 @@ public class ClickAnalyzer { } } - public static void onBlockPlace(Player player) { + public ClickAnalyzer() { + TinyProtocol.instance.addFilter(Recording.blockPlacePacket, this::onBlockPlace); + } + + public Object onBlockPlace(Player player, Object packet) { output.println(player.getName() + "," + System.nanoTime() + "," + CraftbukkitWrapper.impl.headRotation(player) + "," + player.getLocation().getPitch()); + return packet; + } + + public static void close() { + output.close(); } } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/listener/Recording.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/Recording.java index 202b4fd..ca3c654 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/listener/Recording.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/Recording.java @@ -133,8 +133,6 @@ public class Recording implements Listener { public static final Class blockPlacePacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayInBlockPlace"); private Object blockPlace(Player p, Object packet) { - ClickAnalyzer.onBlockPlace(p); - boolean mainHand = BountifulWrapper.impl.mainHand(packet); if(!isNotSent(p) && BountifulWrapper.impl.bowInHand(mainHand, p)) GlobalRecorder.getInstance().bowSpan(p, true, !mainHand);