diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java b/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java index 4d6acb8..ed76cb6 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java @@ -93,6 +93,7 @@ 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 new file mode 100644 index 0000000..2db9094 --- /dev/null +++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/ClickAnalyzer.java @@ -0,0 +1,49 @@ +/* + This file is a part of the SteamWar software. + + Copyright (C) 2022 SteamWar.de-Serverteam + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ + +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 static final Class blockPlace = Reflection.getClass("{nms.network.protocol.play}.PacketPlayInBlockPlace"); + + private final PrintStream output; + + public ClickAnalyzer () { + ProtocolAPI.setIncomingHandler(blockPlace, this::onBlockPlace); + try { + output = new PrintStream(new BufferedOutputStream(new FileOutputStream(new File(Bukkit.getWorlds().get(0).getWorldFolder(), "clicks.csv")))); + } catch (FileNotFoundException e) { + throw new SecurityException(e); + } + } + + private Object onBlockPlace(Player player, Object packet) { + output.println(player.getName() + "," + System.nanoTime() + "," + CraftbukkitWrapper.impl.headRotation(player) + "," + player.getLocation().getPitch()); + return packet; + } +}