SteamWar/FightSystem
Archiviert
13
1

Simple click logger #342

Zusammengeführt
Lixfel hat 1 Commits von clickAnalyzer nach master 2022-03-24 13:08:18 +01:00 zusammengeführt
2 geänderte Dateien mit 50 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -93,6 +93,7 @@ public class FightSystem extends JavaPlugin {
new ArrowPickup(); new ArrowPickup();
new BlockFadeListener(); new BlockFadeListener();
new LeaveableArena(); new LeaveableArena();
new ClickAnalyzer();
new EnterHandler(); new EnterHandler();
new TechHider(); new TechHider();

Datei anzeigen

@ -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 <https://www.gnu.org/licenses/>.
*/
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;
}
}