From b9b368320cc4d6be8cfc5027add12149cc5cd0c8 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Thu, 24 Mar 2022 14:28:04 +0100 Subject: [PATCH] Fix clickanalyzer Signed-off-by: Lixfel --- .../src/de/steamwar/fightsystem/FightSystem.java | 1 - .../fightsystem/listener/ClickAnalyzer.java | 13 ++++--------- .../de/steamwar/fightsystem/listener/Recording.java | 2 ++ 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java b/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java index ed76cb6..4d6acb8 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java @@ -93,7 +93,6 @@ public class FightSystem extends JavaPlugin { new ArrowPickup(); new BlockFadeListener(); new LeaveableArena(); - new ClickAnalyzer(); new EnterHandler(); new TechHider(); diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/listener/ClickAnalyzer.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/ClickAnalyzer.java index 2db9094..df67914 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/listener/ClickAnalyzer.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/ClickAnalyzer.java @@ -19,22 +19,18 @@ package de.steamwar.fightsystem.listener; -import com.comphenix.tinyprotocol.Reflection; import de.steamwar.fightsystem.utils.CraftbukkitWrapper; -import de.steamwar.fightsystem.utils.ProtocolAPI; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import java.io.*; public class ClickAnalyzer { + private ClickAnalyzer() {} - private static final Class blockPlace = Reflection.getClass("{nms.network.protocol.play}.PacketPlayInBlockPlace"); + private static final PrintStream output; - private final PrintStream output; - - public ClickAnalyzer () { - ProtocolAPI.setIncomingHandler(blockPlace, this::onBlockPlace); + static { try { output = new PrintStream(new BufferedOutputStream(new FileOutputStream(new File(Bukkit.getWorlds().get(0).getWorldFolder(), "clicks.csv")))); } catch (FileNotFoundException e) { @@ -42,8 +38,7 @@ public class ClickAnalyzer { } } - private Object onBlockPlace(Player player, Object packet) { + public static void onBlockPlace(Player player) { output.println(player.getName() + "," + System.nanoTime() + "," + CraftbukkitWrapper.impl.headRotation(player) + "," + player.getLocation().getPitch()); - return packet; } } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/listener/Recording.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/Recording.java index e319c54..b4f5621 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/listener/Recording.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/Recording.java @@ -127,6 +127,8 @@ 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);