Upload folder via GUI - src
This commit is contained in:
@@ -0,0 +1,69 @@
|
|||||||
|
package net.viper.status;
|
||||||
|
|
||||||
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
import net.md_5.bungee.api.event.PostLoginEvent;
|
||||||
|
import net.md_5.bungee.api.plugin.Listener;
|
||||||
|
import net.md_5.bungee.api.plugin.Plugin;
|
||||||
|
import net.md_5.bungee.event.EventHandler;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
import java.net.InetSocketAddress;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PlayerLoginLogger – schreibt bei jedem Join UUID, Name und IP
|
||||||
|
* in die Datei plugins/StatusAPI/player-logins.log
|
||||||
|
*/
|
||||||
|
public class PlayerLoginLogger implements Listener {
|
||||||
|
|
||||||
|
private static final DateTimeFormatter FMT =
|
||||||
|
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||||
|
|
||||||
|
private final Plugin plugin;
|
||||||
|
private final File logFile;
|
||||||
|
|
||||||
|
public PlayerLoginLogger(Plugin plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
this.logFile = new File(plugin.getDataFolder(), "player-logins.log");
|
||||||
|
|
||||||
|
// Sicherstellen, dass das Plugin-Verzeichnis existiert
|
||||||
|
if (!plugin.getDataFolder().exists()) {
|
||||||
|
plugin.getDataFolder().mkdirs();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPostLogin(PostLoginEvent event) {
|
||||||
|
ProxiedPlayer player = event.getPlayer();
|
||||||
|
|
||||||
|
String uuid = player.getUniqueId().toString();
|
||||||
|
String name = player.getName();
|
||||||
|
String ip = "unknown";
|
||||||
|
|
||||||
|
try {
|
||||||
|
InetSocketAddress addr = (InetSocketAddress) player.getSocketAddress();
|
||||||
|
if (addr != null && addr.getAddress() != null) {
|
||||||
|
ip = addr.getAddress().getHostAddress();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
plugin.getLogger().warning("[PlayerLoginLogger] Konnte IP nicht lesen: " + e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
String timestamp = LocalDateTime.now().format(FMT);
|
||||||
|
String line = String.format("[%s] UUID=%s | Name=%-16s | IP=%s",
|
||||||
|
timestamp, uuid, name, ip);
|
||||||
|
|
||||||
|
plugin.getLogger().info("[LoginLog] " + line);
|
||||||
|
|
||||||
|
// In Datei schreiben (append)
|
||||||
|
try (PrintWriter pw = new PrintWriter(new FileWriter(logFile, true))) {
|
||||||
|
pw.println(line);
|
||||||
|
} catch (IOException e) {
|
||||||
|
plugin.getLogger().warning("[PlayerLoginLogger] Fehler beim Schreiben: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -65,6 +65,12 @@ public class StatusAPI extends Plugin implements Runnable {
|
|||||||
// Debug-Modus (aus verify.properties)
|
// Debug-Modus (aus verify.properties)
|
||||||
public static boolean DEBUG = false;
|
public static boolean DEBUG = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Login-Logger: UUID, Name und IP bei jedem Join in player-logins.log schreiben.
|
||||||
|
* Vor dem Kompilieren auf true setzen um den Logger zu aktivieren.
|
||||||
|
*/
|
||||||
|
private static final boolean LOGIN_LOGGER_ENABLED = false;
|
||||||
|
|
||||||
/** Gibt eine Info-Meldung nur im Debug-Modus aus */
|
/** Gibt eine Info-Meldung nur im Debug-Modus aus */
|
||||||
public static void debugLog(Plugin plugin, String message) {
|
public static void debugLog(Plugin plugin, String message) {
|
||||||
if (DEBUG) plugin.getLogger().info(message);
|
if (DEBUG) plugin.getLogger().info(message);
|
||||||
@@ -141,6 +147,14 @@ public class StatusAPI extends Plugin implements Runnable {
|
|||||||
// /statusapi reload Befehl registrieren
|
// /statusapi reload Befehl registrieren
|
||||||
ProxyServer.getInstance().getPluginManager().registerCommand(this, new StatusAPICommand(this));
|
ProxyServer.getInstance().getPluginManager().registerCommand(this, new StatusAPICommand(this));
|
||||||
|
|
||||||
|
// PlayerLoginLogger: schreibt UUID, Name und IP bei jedem Join in player-logins.log
|
||||||
|
// Aktivieren: LOGIN_LOGGER_ENABLED = true setzen und neu kompilieren
|
||||||
|
if (LOGIN_LOGGER_ENABLED) {
|
||||||
|
PlayerLoginLogger loginLogger = new PlayerLoginLogger(this);
|
||||||
|
ProxyServer.getInstance().getPluginManager().registerListener(this, loginLogger);
|
||||||
|
getLogger().info("[PlayerLoginLogger] Login-Logging aktiv -> " + getDataFolder() + "/player-logins.log");
|
||||||
|
}
|
||||||
|
|
||||||
// FIX: ScoreboardModule mit NetworkInfoModule verbinden (TPS-Fallback)
|
// FIX: ScoreboardModule mit NetworkInfoModule verbinden (TPS-Fallback)
|
||||||
try {
|
try {
|
||||||
net.viper.status.modules.scoreboard.ScoreboardModule sbMod =
|
net.viper.status.modules.scoreboard.ScoreboardModule sbMod =
|
||||||
|
|||||||
@@ -17,6 +17,13 @@ broadcast.format=%prefixColored% %messageColored%
|
|||||||
# ===========================
|
# ===========================
|
||||||
statusapi.port=9191
|
statusapi.port=9191
|
||||||
|
|
||||||
|
# ===========================
|
||||||
|
# PLAYER LOGIN LOGGER
|
||||||
|
# ===========================
|
||||||
|
# Schreibt UUID, Name und IP jedes Spielers beim Join in player-logins.log
|
||||||
|
# Standardmaessig deaktiviert - nur auf deinem Server auf true setzen
|
||||||
|
login-logger.enabled=false
|
||||||
|
|
||||||
# ===========================
|
# ===========================
|
||||||
# INGAME HILFE
|
# INGAME HILFE
|
||||||
# ===========================
|
# ===========================
|
||||||
|
|||||||
Reference in New Issue
Block a user