|
|
|
@@ -1,9 +1,5 @@
|
|
|
|
package net.viper.status.modules.globalchat;
|
|
|
|
package net.viper.status.modules.globalchat;
|
|
|
|
|
|
|
|
|
|
|
|
import net.luckperms.api.LuckPerms;
|
|
|
|
|
|
|
|
import net.luckperms.api.LuckPermsProvider;
|
|
|
|
|
|
|
|
import net.luckperms.api.model.user.User;
|
|
|
|
|
|
|
|
import net.luckperms.api.cacheddata.CachedMetaData;
|
|
|
|
|
|
|
|
import net.md_5.bungee.api.ChatColor;
|
|
|
|
import net.md_5.bungee.api.ChatColor;
|
|
|
|
import net.md_5.bungee.api.CommandSender;
|
|
|
|
import net.md_5.bungee.api.CommandSender;
|
|
|
|
import net.md_5.bungee.api.chat.ComponentBuilder;
|
|
|
|
import net.md_5.bungee.api.chat.ComponentBuilder;
|
|
|
|
@@ -13,15 +9,21 @@ import net.md_5.bungee.api.chat.HoverEvent.Action;
|
|
|
|
import net.md_5.bungee.api.config.ServerInfo;
|
|
|
|
import net.md_5.bungee.api.config.ServerInfo;
|
|
|
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
|
|
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
|
|
|
import net.md_5.bungee.api.event.ChatEvent;
|
|
|
|
import net.md_5.bungee.api.event.ChatEvent;
|
|
|
|
|
|
|
|
import net.md_5.bungee.api.event.PostLoginEvent;
|
|
|
|
|
|
|
|
import net.md_5.bungee.api.event.PlayerDisconnectEvent;
|
|
|
|
import net.md_5.bungee.api.event.ServerConnectEvent;
|
|
|
|
import net.md_5.bungee.api.event.ServerConnectEvent;
|
|
|
|
import net.md_5.bungee.api.event.ServerSwitchEvent;
|
|
|
|
import net.md_5.bungee.api.event.ServerSwitchEvent;
|
|
|
|
import net.md_5.bungee.api.plugin.Command;
|
|
|
|
import net.md_5.bungee.api.plugin.Command;
|
|
|
|
import net.md_5.bungee.api.plugin.Listener;
|
|
|
|
import net.md_5.bungee.api.plugin.Listener;
|
|
|
|
import net.md_5.bungee.api.plugin.Plugin;
|
|
|
|
import net.md_5.bungee.api.plugin.Plugin;
|
|
|
|
|
|
|
|
import net.md_5.bungee.chat.ComponentSerializer;
|
|
|
|
import net.md_5.bungee.event.EventHandler;
|
|
|
|
import net.md_5.bungee.event.EventHandler;
|
|
|
|
import net.viper.status.module.Module;
|
|
|
|
import net.viper.status.module.Module;
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.*;
|
|
|
|
import java.io.*;
|
|
|
|
|
|
|
|
import java.lang.Class;
|
|
|
|
|
|
|
|
import java.lang.reflect.Method;
|
|
|
|
|
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
|
import java.nio.file.Files;
|
|
|
|
import java.nio.file.Files;
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
import java.util.*;
|
|
|
|
import java.util.*;
|
|
|
|
@@ -31,24 +33,35 @@ import java.util.regex.Pattern;
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* GlobalChatModule - Integriert Global Chat, Filter, Logs und Support in die StatusAPI.
|
|
|
|
* GlobalChatModule - Integriert Global Chat, Filter, Logs und Support in die StatusAPI.
|
|
|
|
* Nutzt die zentrale verify.properties für Chat- und Server-Einstellungen.
|
|
|
|
* Nutzt die zentrale verify.properties für Chat- und Server-Einstellungen.
|
|
|
|
|
|
|
|
* Ermöglicht manuelle Ränge über UUID-Overrides.
|
|
|
|
|
|
|
|
* Nutzt REFLECTION für LuckPerms (Optional).
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public class GlobalChatModule implements Module, Listener {
|
|
|
|
public class GlobalChatModule implements Module, Listener {
|
|
|
|
|
|
|
|
|
|
|
|
private static final String CHANNEL_CONTROL = "global:control";
|
|
|
|
private static final String CHANNEL_CONTROL = "global:control";
|
|
|
|
|
|
|
|
private static final String CHANNEL_CHAT = "global:chat";
|
|
|
|
|
|
|
|
|
|
|
|
private Plugin plugin;
|
|
|
|
private Plugin plugin;
|
|
|
|
|
|
|
|
|
|
|
|
private List<String> badWords = new ArrayList<>();
|
|
|
|
private List<String> badWords = new ArrayList<>();
|
|
|
|
private File logFolder;
|
|
|
|
private File logFolder;
|
|
|
|
private boolean chatMuted = false;
|
|
|
|
private boolean chatMuted = false;
|
|
|
|
private boolean isChatEnabled = true; // Status ob der Chat aktiv ist
|
|
|
|
private boolean isChatEnabled = true;
|
|
|
|
|
|
|
|
|
|
|
|
private final Map<UUID, Boolean> playerIsOp = new ConcurrentHashMap<>();
|
|
|
|
private final Map<UUID, Boolean> playerIsOp = new ConcurrentHashMap<>();
|
|
|
|
private final Map<UUID, UUID> lastSupportContact = new ConcurrentHashMap<>();
|
|
|
|
private final Map<UUID, UUID> lastSupportContact = new ConcurrentHashMap<>();
|
|
|
|
private final Set<UUID> suppressJoinQuit = ConcurrentHashMap.newKeySet();
|
|
|
|
private final Set<UUID> suppressJoinQuit = ConcurrentHashMap.newKeySet();
|
|
|
|
|
|
|
|
private final Set<UUID> chatLockPlayers = ConcurrentHashMap.newKeySet();
|
|
|
|
|
|
|
|
|
|
|
|
private List<String> welcomeMessages = new ArrayList<>();
|
|
|
|
private List<String> welcomeMessages = new ArrayList<>();
|
|
|
|
private Map<String, String> serverDisplayNames = new HashMap<>();
|
|
|
|
private Map<String, String> serverDisplayNames = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Map für gruppen-spezifische Formate aus der verify.properties
|
|
|
|
|
|
|
|
private Map<String, String> groupFormats = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// NEU: Map für manuelle Ränge aus der verify.properties (Override)
|
|
|
|
|
|
|
|
private final Map<UUID, String> manualRanks = new ConcurrentHashMap<>();
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public String getName() {
|
|
|
|
public String getName() {
|
|
|
|
return "GlobalChatModule";
|
|
|
|
return "GlobalChatModule";
|
|
|
|
@@ -58,25 +71,22 @@ public class GlobalChatModule implements Module, Listener {
|
|
|
|
public void onEnable(Plugin plugin) {
|
|
|
|
public void onEnable(Plugin plugin) {
|
|
|
|
this.plugin = plugin;
|
|
|
|
this.plugin = plugin;
|
|
|
|
|
|
|
|
|
|
|
|
// Konfigurationen laden (Zuerst prüfen wir, ob der Chat überhaupt aktiv ist)
|
|
|
|
|
|
|
|
loadConfig();
|
|
|
|
loadConfig();
|
|
|
|
|
|
|
|
|
|
|
|
// WICHTIG: Wenn der Chat deaktiviert ist, machen wir sofort gar nichts mehr.
|
|
|
|
|
|
|
|
// Keine Listener, keine Commands, keine Logs. Andere Plugins können ungestört laufen.
|
|
|
|
|
|
|
|
if (!isChatEnabled) {
|
|
|
|
if (!isChatEnabled) {
|
|
|
|
plugin.getLogger().info("§eGlobalChat ist in der verify.properties DEAKTIVIERT.");
|
|
|
|
plugin.getLogger().info("§eGlobalChat ist in der verify.properties DEAKTIVERT.");
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Plugin channel registrieren
|
|
|
|
// Channels registrieren
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
plugin.getProxy().registerChannel(CHANNEL_CONTROL);
|
|
|
|
plugin.getProxy().registerChannel(CHANNEL_CONTROL);
|
|
|
|
|
|
|
|
plugin.getProxy().registerChannel(CHANNEL_CHAT);
|
|
|
|
} catch (Throwable ignored) {
|
|
|
|
} catch (Throwable ignored) {
|
|
|
|
plugin.getLogger().warning("Konnte Kanal " + CHANNEL_CONTROL + " nicht registrieren.");
|
|
|
|
plugin.getLogger().warning("Konnte Channels nicht registrieren.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
plugin.getProxy().getPluginManager().registerListener(plugin, this);
|
|
|
|
plugin.getProxy().getPluginManager().registerListener(plugin, this);
|
|
|
|
|
|
|
|
|
|
|
|
loadFilter();
|
|
|
|
loadFilter();
|
|
|
|
loadWelcomeMessages();
|
|
|
|
loadWelcomeMessages();
|
|
|
|
|
|
|
|
|
|
|
|
@@ -90,8 +100,12 @@ public class GlobalChatModule implements Module, Listener {
|
|
|
|
plugin.getProxy().getPluginManager().registerCommand(plugin, new SupportCommand());
|
|
|
|
plugin.getProxy().getPluginManager().registerCommand(plugin, new SupportCommand());
|
|
|
|
plugin.getProxy().getPluginManager().registerCommand(plugin, new ReplyCommand());
|
|
|
|
plugin.getProxy().getPluginManager().registerCommand(plugin, new ReplyCommand());
|
|
|
|
plugin.getProxy().getPluginManager().registerCommand(plugin, new InfoCommand());
|
|
|
|
plugin.getProxy().getPluginManager().registerCommand(plugin, new InfoCommand());
|
|
|
|
|
|
|
|
plugin.getProxy().getPluginManager().registerCommand(plugin, new ChatToggleCommand());
|
|
|
|
|
|
|
|
|
|
|
|
plugin.getLogger().info("§aGlobalChatModule aktiviert (Zensur, Logs, Mute, Support, CustomNames)!");
|
|
|
|
// NEU: ClearChat Befehl registrieren
|
|
|
|
|
|
|
|
plugin.getProxy().getPluginManager().registerCommand(plugin, new ClearChatCommand());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
plugin.getLogger().info("§aGlobalChatModule aktiviert (Mit Manuellen Rang-Overrides)!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
@@ -99,18 +113,17 @@ public class GlobalChatModule implements Module, Listener {
|
|
|
|
plugin.getLogger().info("§cGlobalChatModule deaktiviert!");
|
|
|
|
plugin.getLogger().info("§cGlobalChatModule deaktiviert!");
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
plugin.getProxy().unregisterChannel(CHANNEL_CONTROL);
|
|
|
|
plugin.getProxy().unregisterChannel(CHANNEL_CONTROL);
|
|
|
|
|
|
|
|
plugin.getProxy().unregisterChannel(CHANNEL_CHAT);
|
|
|
|
} catch (Throwable ignored) {}
|
|
|
|
} catch (Throwable ignored) {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ===========================
|
|
|
|
// ===========================
|
|
|
|
// Konfiguration laden (Aktivierungsstatus & Namen aus verify.properties)
|
|
|
|
// Konfiguration laden
|
|
|
|
// ===========================
|
|
|
|
// ===========================
|
|
|
|
private void loadConfig() {
|
|
|
|
private void loadConfig() {
|
|
|
|
// ÄNDERUNG: Wir lesen jetzt die 'verify.properties'
|
|
|
|
|
|
|
|
String fileName = "verify.properties";
|
|
|
|
String fileName = "verify.properties";
|
|
|
|
File file = new File(plugin.getDataFolder(), fileName);
|
|
|
|
File file = new File(plugin.getDataFolder(), fileName);
|
|
|
|
|
|
|
|
|
|
|
|
// Datei aus Ressourcen kopieren, falls nicht vorhanden
|
|
|
|
|
|
|
|
if (!file.exists()) {
|
|
|
|
if (!file.exists()) {
|
|
|
|
plugin.getDataFolder().mkdirs();
|
|
|
|
plugin.getDataFolder().mkdirs();
|
|
|
|
try (InputStream in = plugin.getResourceAsStream(fileName);
|
|
|
|
try (InputStream in = plugin.getResourceAsStream(fileName);
|
|
|
|
@@ -132,31 +145,50 @@ public class GlobalChatModule implements Module, Listener {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Einlesen
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
Properties props = new Properties();
|
|
|
|
Properties props = new Properties();
|
|
|
|
try (InputStream in = new FileInputStream(file)) {
|
|
|
|
try (InputStream in = new FileInputStream(file)) {
|
|
|
|
props.load(in);
|
|
|
|
props.load(in);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Aktivierung prüfen
|
|
|
|
|
|
|
|
isChatEnabled = Boolean.parseBoolean(props.getProperty("chat.enabled", "true"));
|
|
|
|
isChatEnabled = Boolean.parseBoolean(props.getProperty("chat.enabled", "true"));
|
|
|
|
|
|
|
|
|
|
|
|
serverDisplayNames.clear();
|
|
|
|
serverDisplayNames.clear();
|
|
|
|
for (String key : props.stringPropertyNames()) {
|
|
|
|
groupFormats.clear();
|
|
|
|
if (key.startsWith("server.")) {
|
|
|
|
manualRanks.clear(); // NEU
|
|
|
|
String[] parts = key.split("\\.");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// WICHTIG: Wir ignorieren Keys mit Unterpunkten (z.B. server.lobby.id oder .secret)
|
|
|
|
for (String key : props.stringPropertyNames()) {
|
|
|
|
// Wir wollen nur Keys wie "server.lobby" (parts.length == 2)
|
|
|
|
// 1. Manuelle Overrides laden (Höchste Priorität!)
|
|
|
|
|
|
|
|
if (key.startsWith("override.")) {
|
|
|
|
|
|
|
|
String uuidStr = key.substring("override.".length());
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
UUID uuid = UUID.fromString(uuidStr);
|
|
|
|
|
|
|
|
String groupName = props.getProperty(key);
|
|
|
|
|
|
|
|
manualRanks.put(uuid, groupName);
|
|
|
|
|
|
|
|
plugin.getLogger().info("Manueller Override geladen: " + uuidStr + " -> " + groupName);
|
|
|
|
|
|
|
|
} catch (IllegalArgumentException ex) {
|
|
|
|
|
|
|
|
plugin.getLogger().warning("Ungültige UUID in override: " + uuidStr);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// 2. Server Aliase
|
|
|
|
|
|
|
|
else if (key.startsWith("server.")) {
|
|
|
|
|
|
|
|
String[] parts = key.split("\\.");
|
|
|
|
if (parts.length == 2) {
|
|
|
|
if (parts.length == 2) {
|
|
|
|
String serverName = parts[1];
|
|
|
|
String serverName = parts[1];
|
|
|
|
String displayName = props.getProperty(key);
|
|
|
|
String displayName = props.getProperty(key);
|
|
|
|
serverDisplayNames.put(serverName, displayName);
|
|
|
|
serverDisplayNames.put(serverName, displayName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 3. Group Formate
|
|
|
|
|
|
|
|
else if (key.startsWith("groupformat.")) {
|
|
|
|
|
|
|
|
String groupName = key.substring("groupformat.".length());
|
|
|
|
|
|
|
|
String format = props.getProperty(key);
|
|
|
|
|
|
|
|
groupFormats.put(groupName.toLowerCase(), format);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
plugin.getLogger().info("§eGeladene Server-Displaynames: " + serverDisplayNames.size() + " (Chat aktiv: " + isChatEnabled + ")");
|
|
|
|
plugin.getLogger().info("§eGeladene Server-Displaynames: " + serverDisplayNames.size() + " (Chat aktiv: " + isChatEnabled + ")");
|
|
|
|
|
|
|
|
plugin.getLogger().info("§eGeladene Chat-Formate: " + groupFormats.size());
|
|
|
|
|
|
|
|
plugin.getLogger().info("§eGeladene Manuelle Overrides: " + manualRanks.size());
|
|
|
|
} catch (IOException e) {
|
|
|
|
} catch (IOException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@@ -209,17 +241,27 @@ public class GlobalChatModule implements Module, Listener {
|
|
|
|
|
|
|
|
|
|
|
|
private void sendRandomWelcomeMessage(ProxiedPlayer player) {
|
|
|
|
private void sendRandomWelcomeMessage(ProxiedPlayer player) {
|
|
|
|
if (welcomeMessages.isEmpty()) return;
|
|
|
|
if (welcomeMessages.isEmpty()) return;
|
|
|
|
|
|
|
|
|
|
|
|
Random rand = new Random();
|
|
|
|
Random rand = new Random();
|
|
|
|
String message = welcomeMessages.get(rand.nextInt(welcomeMessages.size()));
|
|
|
|
String message = welcomeMessages.get(rand.nextInt(welcomeMessages.size()));
|
|
|
|
message = message.replace("%player%", player.getName());
|
|
|
|
message = message.replace("%player%", player.getName());
|
|
|
|
message = ChatColor.translateAlternateColorCodes('&', message);
|
|
|
|
message = ChatColor.translateAlternateColorCodes('&', message);
|
|
|
|
|
|
|
|
|
|
|
|
player.sendMessage(new TextComponent(message));
|
|
|
|
player.sendMessage(new TextComponent(message));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ===========================
|
|
|
|
// ===========================
|
|
|
|
// Chatfilter & Global-Chat
|
|
|
|
// Global Broadcast Helper
|
|
|
|
|
|
|
|
// ===========================
|
|
|
|
|
|
|
|
private void broadcastGlobal(TextComponent component) {
|
|
|
|
|
|
|
|
if (!isChatEnabled) return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Korrektur: statt PluginChannel-Relay senden wir System/Plugin-Nachrichten an alle Spieler.
|
|
|
|
|
|
|
|
for (ProxiedPlayer p : plugin.getProxy().getPlayers()) {
|
|
|
|
|
|
|
|
p.sendMessage(component);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ===========================
|
|
|
|
|
|
|
|
// Chatfilter & Global-Chat (RELAY MODE)
|
|
|
|
// ===========================
|
|
|
|
// ===========================
|
|
|
|
@EventHandler
|
|
|
|
@EventHandler
|
|
|
|
public void onChat(ChatEvent e) {
|
|
|
|
public void onChat(ChatEvent e) {
|
|
|
|
@@ -227,23 +269,27 @@ public class GlobalChatModule implements Module, Listener {
|
|
|
|
if (e.isCommand()) return;
|
|
|
|
if (e.isCommand()) return;
|
|
|
|
|
|
|
|
|
|
|
|
ProxiedPlayer player = (ProxiedPlayer) e.getSender();
|
|
|
|
ProxiedPlayer player = (ProxiedPlayer) e.getSender();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// CHAT LOCK / TOGGLE CHECK
|
|
|
|
|
|
|
|
if (chatLockPlayers.contains(player.getUniqueId())) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
String originalMsg = e.getMessage();
|
|
|
|
String originalMsg = e.getMessage();
|
|
|
|
|
|
|
|
|
|
|
|
if (suppressJoinQuit.contains(player.getUniqueId()) &&
|
|
|
|
if (suppressJoinQuit.contains(player.getUniqueId()) &&
|
|
|
|
(originalMsg.contains("joined the Game") || originalMsg.contains("left the Game"))) {
|
|
|
|
(originalMsg.contains("joined§ Game") || originalMsg.contains("left§ Game"))) {
|
|
|
|
plugin.getLogger().info("Unterdrücke Join-/Quit-Nachricht für " + player.getName());
|
|
|
|
plugin.getLogger().info("Unterdrücke Join-/Quit-Nachricht für " + player.getName());
|
|
|
|
e.setCancelled(true);
|
|
|
|
e.setCancelled(true);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Globaler Mute
|
|
|
|
|
|
|
|
if (chatMuted && !player.hasPermission("globalchat.bypass")) {
|
|
|
|
if (chatMuted && !player.hasPermission("globalchat.bypass")) {
|
|
|
|
player.sendMessage(new TextComponent("§cDer globale Chat ist derzeit deaktiviert!"));
|
|
|
|
player.sendMessage(new TextComponent("§cDer globale Chat ist derzeit deaktiviert!"));
|
|
|
|
e.setCancelled(true);
|
|
|
|
e.setCancelled(true);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Badword-Zensur
|
|
|
|
|
|
|
|
String censoredMsg = originalMsg;
|
|
|
|
String censoredMsg = originalMsg;
|
|
|
|
for (String bad : badWords) {
|
|
|
|
for (String bad : badWords) {
|
|
|
|
if (bad == null || bad.trim().isEmpty()) continue;
|
|
|
|
if (bad == null || bad.trim().isEmpty()) continue;
|
|
|
|
@@ -256,31 +302,27 @@ public class GlobalChatModule implements Module, Listener {
|
|
|
|
String serverDisplay = getDisplayName(serverName);
|
|
|
|
String serverDisplay = getDisplayName(serverName);
|
|
|
|
|
|
|
|
|
|
|
|
String[] ps = getPrefixSuffix(player);
|
|
|
|
String[] ps = getPrefixSuffix(player);
|
|
|
|
String prefix = ps[0] == null ? "" : ps[0].trim();
|
|
|
|
String prefix = ps[0];
|
|
|
|
String suffix = ps[1] == null ? "" : ps[1].trim();
|
|
|
|
String playerColor = ps[2];
|
|
|
|
|
|
|
|
String chatColor = ps[3];
|
|
|
|
|
|
|
|
|
|
|
|
String displayTag = "";
|
|
|
|
String displayTag = "";
|
|
|
|
if (!prefix.isEmpty()) {
|
|
|
|
if (!prefix.isEmpty()) displayTag = prefix;
|
|
|
|
displayTag = prefix;
|
|
|
|
else if (!ps[1].isEmpty()) displayTag = ps[1];
|
|
|
|
} else if (!suffix.isEmpty()) {
|
|
|
|
|
|
|
|
displayTag = suffix;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!displayTag.isEmpty() && !displayTag.endsWith(" ")) displayTag = displayTag + " ";
|
|
|
|
if (!displayTag.isEmpty() && !displayTag.endsWith(" ")) displayTag = displayTag + " ";
|
|
|
|
|
|
|
|
|
|
|
|
StringBuilder out = new StringBuilder();
|
|
|
|
StringBuilder out = new StringBuilder();
|
|
|
|
out.append("§7[").append(serverDisplay).append("] ");
|
|
|
|
out.append("§7[").append(serverDisplay).append("§r§7] ");
|
|
|
|
if (!displayTag.isEmpty()) out.append(displayTag);
|
|
|
|
if (!displayTag.isEmpty()) out.append(displayTag);
|
|
|
|
out.append(player.getName());
|
|
|
|
out.append(playerColor).append(player.getName());
|
|
|
|
out.append("§f: ").append(censoredMsg);
|
|
|
|
out.append("§f: ").append(chatColor).append(censoredMsg);
|
|
|
|
|
|
|
|
|
|
|
|
String chatOut = out.toString();
|
|
|
|
String chatOut = out.toString();
|
|
|
|
|
|
|
|
|
|
|
|
for (ProxiedPlayer p : plugin.getProxy().getPlayers()) {
|
|
|
|
TextComponent chatComponent = new TextComponent(chatOut);
|
|
|
|
p.sendMessage(new TextComponent(chatOut));
|
|
|
|
broadcastGlobal(chatComponent);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Log unzensiert (Originalnamen für saubere Logs)
|
|
|
|
|
|
|
|
String logEntry = "[" + serverName + "] " +
|
|
|
|
String logEntry = "[" + serverName + "] " +
|
|
|
|
(displayTag.isEmpty() ? "" : stripColor(displayTag) + " ") +
|
|
|
|
(displayTag.isEmpty() ? "" : stripColor(displayTag) + " ") +
|
|
|
|
player.getName() +
|
|
|
|
player.getName() +
|
|
|
|
@@ -288,6 +330,58 @@ public class GlobalChatModule implements Module, Listener {
|
|
|
|
logMessage(logEntry);
|
|
|
|
logMessage(logEntry);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ===========================
|
|
|
|
|
|
|
|
// Global Join & Quit Events
|
|
|
|
|
|
|
|
// ===========================
|
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
|
|
|
|
public void onPostLogin(PostLoginEvent e) {
|
|
|
|
|
|
|
|
if (!isChatEnabled) return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ProxiedPlayer player = e.getPlayer();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Willkommensnachricht senden
|
|
|
|
|
|
|
|
sendRandomWelcomeMessage(player);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Formatierung aus verify.properties nutzen
|
|
|
|
|
|
|
|
String[] ps = getPrefixSuffix(player);
|
|
|
|
|
|
|
|
String prefix = ps[0];
|
|
|
|
|
|
|
|
String playerColor = ps[2]; // Namefarbe aus Properties
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String displayTag = "";
|
|
|
|
|
|
|
|
if (!prefix.isEmpty()) displayTag = prefix;
|
|
|
|
|
|
|
|
if (!displayTag.isEmpty() && !displayTag.endsWith(" ")) displayTag = displayTag + " ";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Nachricht: "Spieler xy hat den Server betreten"
|
|
|
|
|
|
|
|
// Der Text "hat den Server betreten" bleibt Grün (Standard), Name und Prefix kommen aus der Config
|
|
|
|
|
|
|
|
TextComponent joinMsg = new TextComponent(displayTag + playerColor + player.getName() + " §a§lhat den Server betreten.");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
broadcastGlobal(joinMsg);
|
|
|
|
|
|
|
|
logMessage("[JOIN] " + player.getName() + " hat den Server betreten.");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
|
|
|
|
public void onPlayerDisconnect(PlayerDisconnectEvent e) {
|
|
|
|
|
|
|
|
if (!isChatEnabled) return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ProxiedPlayer player = e.getPlayer();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Formatierung aus verify.properties nutzen
|
|
|
|
|
|
|
|
String[] ps = getPrefixSuffix(player);
|
|
|
|
|
|
|
|
String prefix = ps[0];
|
|
|
|
|
|
|
|
String playerColor = ps[2]; // Namefarbe aus Properties
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String displayTag = "";
|
|
|
|
|
|
|
|
if (!prefix.isEmpty()) displayTag = prefix;
|
|
|
|
|
|
|
|
if (!displayTag.isEmpty() && !displayTag.endsWith(" ")) displayTag = displayTag + " ";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Nachricht: "Spieler xy hat den Server verlassen"
|
|
|
|
|
|
|
|
// Der Text "hat den Server verlassen" bleibt Rot (Standard), Name und Prefix kommen aus der Config
|
|
|
|
|
|
|
|
TextComponent quitMsg = new TextComponent(displayTag + playerColor + player.getName() + " §c§lhat den Server verlassen.");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
broadcastGlobal(quitMsg);
|
|
|
|
|
|
|
|
logMessage("[QUIT] " + player.getName() + " hat den Server verlassen.");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ===========================
|
|
|
|
// ===========================
|
|
|
|
// Server Connect & Switch
|
|
|
|
// Server Connect & Switch
|
|
|
|
// ===========================
|
|
|
|
// ===========================
|
|
|
|
@@ -306,14 +400,12 @@ public class GlobalChatModule implements Module, Listener {
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
sendSuppressJoinQuit(from, player.getUniqueId());
|
|
|
|
sendSuppressJoinQuit(from, player.getUniqueId());
|
|
|
|
plugin.getLogger().info("Sent suppress quit message for " + player.getName() + " to server " + from.getName());
|
|
|
|
|
|
|
|
} catch (Throwable ex) {
|
|
|
|
} catch (Throwable ex) {
|
|
|
|
plugin.getLogger().warning("Fehler beim Senden der Quit-Unterdrückung: " + ex.getMessage());
|
|
|
|
plugin.getLogger().warning("Fehler beim Senden der Quit-Unterdrückung: " + ex.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
sendSuppressJoinQuit(target, player.getUniqueId());
|
|
|
|
sendSuppressJoinQuit(target, player.getUniqueId());
|
|
|
|
plugin.getLogger().info("Sent suppress join message for " + player.getName() + " to server " + target.getName());
|
|
|
|
|
|
|
|
} catch (Throwable ex) {
|
|
|
|
} catch (Throwable ex) {
|
|
|
|
plugin.getLogger().warning("Fehler beim Senden der Join-Unterdrückung: " + ex.getMessage());
|
|
|
|
plugin.getLogger().warning("Fehler beim Senden der Join-Unterdrückung: " + ex.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@@ -335,34 +427,33 @@ public class GlobalChatModule implements Module, Listener {
|
|
|
|
|
|
|
|
|
|
|
|
String fromName = from.getName();
|
|
|
|
String fromName = from.getName();
|
|
|
|
String fromDisplay = getDisplayName(fromName);
|
|
|
|
String fromDisplay = getDisplayName(fromName);
|
|
|
|
|
|
|
|
|
|
|
|
String toName = to.getName();
|
|
|
|
String toName = to.getName();
|
|
|
|
String toDisplay = getDisplayName(toName);
|
|
|
|
String toDisplay = getDisplayName(toName);
|
|
|
|
|
|
|
|
|
|
|
|
String[] ps = getPrefixSuffix(player);
|
|
|
|
String[] ps = getPrefixSuffix(player);
|
|
|
|
String prefix = ps[0] == null ? "" : ps[0].trim();
|
|
|
|
String prefix = ps[0];
|
|
|
|
String suffix = ps[1] == null ? "" : ps[1].trim();
|
|
|
|
String playerColor = ps[2]; // Namefarbe aus Properties für den Switch
|
|
|
|
|
|
|
|
|
|
|
|
String displayTag = "";
|
|
|
|
String displayTag = "";
|
|
|
|
if (!prefix.isEmpty()) displayTag = prefix;
|
|
|
|
if (!prefix.isEmpty()) displayTag = prefix;
|
|
|
|
else if (!suffix.isEmpty()) displayTag = suffix;
|
|
|
|
// Suffix wird hier ignoriert, da die || Syntax vorausgesetzt wird, aber es schadet nicht
|
|
|
|
|
|
|
|
else if (!ps[1].isEmpty()) displayTag = ps[1];
|
|
|
|
|
|
|
|
|
|
|
|
if (!displayTag.isEmpty() && !displayTag.endsWith(" ")) displayTag = displayTag + " ";
|
|
|
|
if (!displayTag.isEmpty() && !displayTag.endsWith(" ")) displayTag = displayTag + " ";
|
|
|
|
|
|
|
|
|
|
|
|
StringBuilder msg = new StringBuilder();
|
|
|
|
StringBuilder msg = new StringBuilder();
|
|
|
|
msg.append("§7[").append(toDisplay).append("] ");
|
|
|
|
msg.append("§7[").append(toDisplay).append("§r§7] ");
|
|
|
|
if (!displayTag.isEmpty()) msg.append(displayTag);
|
|
|
|
if (!displayTag.isEmpty()) msg.append(displayTag);
|
|
|
|
msg.append(player.getName());
|
|
|
|
// Hier wird die playerColor aus der verify.properties angewendet
|
|
|
|
|
|
|
|
msg.append(playerColor).append(player.getName());
|
|
|
|
msg.append(" §7hat den Server gewechselt: §e")
|
|
|
|
msg.append(" §7hat den Server gewechselt: §e")
|
|
|
|
.append(fromDisplay).append(" §7→ §e").append(toDisplay).append("§7.");
|
|
|
|
.append(fromDisplay).append(" §7→ §e").append(toDisplay).append("§7.");
|
|
|
|
|
|
|
|
|
|
|
|
String finalMsg = msg.toString();
|
|
|
|
String finalMsg = msg.toString();
|
|
|
|
|
|
|
|
|
|
|
|
for (ProxiedPlayer p : plugin.getProxy().getPlayers()) {
|
|
|
|
TextComponent switchComponent = new TextComponent(finalMsg);
|
|
|
|
p.sendMessage(new TextComponent(finalMsg));
|
|
|
|
broadcastGlobal(switchComponent);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Log unzensiert (Originalnamen)
|
|
|
|
|
|
|
|
String logEntry = "[" + toName + "] " +
|
|
|
|
String logEntry = "[" + toName + "] " +
|
|
|
|
(displayTag.isEmpty() ? "" : stripColor(displayTag) + " ") +
|
|
|
|
(displayTag.isEmpty() ? "" : stripColor(displayTag) + " ") +
|
|
|
|
player.getName() + " hat den Server gewechselt: " + fromName + " -> " + toName + ".";
|
|
|
|
player.getName() + " hat den Server gewechselt: " + fromName + " -> " + toName + ".";
|
|
|
|
@@ -388,46 +479,124 @@ public class GlobalChatModule implements Module, Listener {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ===========================
|
|
|
|
// ===========================
|
|
|
|
// Prefix/Suffix via LuckPerms
|
|
|
|
// Prefix/Suffix (Logic: Manual > LP > Perm)
|
|
|
|
// ===========================
|
|
|
|
// ===========================
|
|
|
|
private String[] getPrefixSuffix(ProxiedPlayer player) {
|
|
|
|
private String[] getPrefixSuffix(ProxiedPlayer player) {
|
|
|
|
String prefix = "";
|
|
|
|
String prefix = "";
|
|
|
|
String suffix = "";
|
|
|
|
String suffix = "";
|
|
|
|
|
|
|
|
String playerColor = "§f";
|
|
|
|
|
|
|
|
String chatColor = "§f";
|
|
|
|
|
|
|
|
String groupName = "Spieler";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 0. NEU: HÖCHSTE PRIO - Manueller Override aus verify.properties
|
|
|
|
|
|
|
|
if (manualRanks.containsKey(player.getUniqueId())) {
|
|
|
|
|
|
|
|
groupName = manualRanks.get(player.getUniqueId());
|
|
|
|
|
|
|
|
// plugin.getLogger().info("Nutze manuellen Override für " + player.getName() + ": " + groupName);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// 1. LuckPerms via Reflection (Bungee)
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
String lpGroup = getLuckPermsGroup(player);
|
|
|
|
|
|
|
|
if (lpGroup != null && !lpGroup.isEmpty() && !lpGroup.equalsIgnoreCase("default")) {
|
|
|
|
|
|
|
|
groupName = lpGroup;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 2. FALLBACK: Permission-Check
|
|
|
|
|
|
|
|
if (groupName == null || groupName.equalsIgnoreCase("default") || groupName.equalsIgnoreCase("Spieler")) {
|
|
|
|
|
|
|
|
if (player.hasPermission("group.owner")) groupName = "Owner";
|
|
|
|
|
|
|
|
else if (player.hasPermission("group.admin")) groupName = "Admin";
|
|
|
|
|
|
|
|
else if (player.hasPermission("group.developer")) groupName = "Developer";
|
|
|
|
|
|
|
|
else if (player.hasPermission("group.premium")) groupName = "Premium";
|
|
|
|
|
|
|
|
else groupName = "Spieler";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 3. Farben aus verify.properties anwenden
|
|
|
|
|
|
|
|
if (groupName != null && groupFormats.containsKey(groupName.toLowerCase())) {
|
|
|
|
|
|
|
|
String rawFormat = groupFormats.get(groupName.toLowerCase());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (rawFormat.contains(" || ")) {
|
|
|
|
|
|
|
|
String[] parts = rawFormat.split(" \\|\\| ");
|
|
|
|
|
|
|
|
prefix = ChatColor.translateAlternateColorCodes('&', parts[0]);
|
|
|
|
|
|
|
|
playerColor = ChatColor.translateAlternateColorCodes('&', parts[1]);
|
|
|
|
|
|
|
|
chatColor = ChatColor.translateAlternateColorCodes('&', parts[2]);
|
|
|
|
|
|
|
|
suffix = "";
|
|
|
|
|
|
|
|
} else if (rawFormat.contains(": ")) {
|
|
|
|
|
|
|
|
String[] parts = rawFormat.split(": ", 2);
|
|
|
|
|
|
|
|
prefix = ChatColor.translateAlternateColorCodes('&', parts[0]);
|
|
|
|
|
|
|
|
chatColor = ChatColor.translateAlternateColorCodes('&', parts[1]);
|
|
|
|
|
|
|
|
playerColor = "§f";
|
|
|
|
|
|
|
|
suffix = "";
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
prefix = ChatColor.translateAlternateColorCodes('&', rawFormat);
|
|
|
|
|
|
|
|
suffix = "";
|
|
|
|
|
|
|
|
playerColor = "§f";
|
|
|
|
|
|
|
|
chatColor = "§f";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return new String[]{prefix, suffix, playerColor, chatColor};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 4. LuckPerms Meta Fallback (Nur falls kein Config-Format da war)
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
LuckPerms lp = LuckPermsProvider.get();
|
|
|
|
Class<?> providerClass = Class.forName("net.luckperms.api.LuckPermsProvider");
|
|
|
|
if (lp != null) {
|
|
|
|
Method getMethod = providerClass.getMethod("get");
|
|
|
|
User user = lp.getUserManager().getUser(player.getUniqueId());
|
|
|
|
Object api = getMethod.invoke(null);
|
|
|
|
|
|
|
|
if (api != null) {
|
|
|
|
if (user == null) {
|
|
|
|
Method getUserManagerMethod = api.getClass().getMethod("getUserManager");
|
|
|
|
try {
|
|
|
|
Object userManager = getUserManagerMethod.invoke(api);
|
|
|
|
user = lp.getUserManager().loadUser(player.getUniqueId()).join();
|
|
|
|
Method loadUserMethod = userManager.getClass().getMethod("loadUser", UUID.class);
|
|
|
|
} catch (Exception ignored) {
|
|
|
|
Object userFuture = loadUserMethod.invoke(userManager, player.getUniqueId());
|
|
|
|
user = null;
|
|
|
|
Method joinMethod = userFuture.getClass().getMethod("join");
|
|
|
|
}
|
|
|
|
Object user = joinMethod.invoke(userFuture);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (user != null) {
|
|
|
|
if (user != null) {
|
|
|
|
CachedMetaData meta = user.getCachedData().getMetaData();
|
|
|
|
Class<?> metaClass = Class.forName("net.luckperms.api.cacheddata.CachedMetaData");
|
|
|
|
|
|
|
|
Method getMetaDataMethod = user.getClass().getMethod("getCachedData");
|
|
|
|
|
|
|
|
Object meta = getMetaDataMethod.invoke(user);
|
|
|
|
if (meta != null) {
|
|
|
|
if (meta != null) {
|
|
|
|
String p = meta.getPrefix();
|
|
|
|
Method getPrefixMethod = metaClass.getMethod("getPrefix");
|
|
|
|
String s = meta.getSuffix();
|
|
|
|
Method getSuffixMethod = metaClass.getMethod("getSuffix");
|
|
|
|
if (p != null) prefix = p;
|
|
|
|
Object p = getPrefixMethod.invoke(meta);
|
|
|
|
if (s != null) suffix = s;
|
|
|
|
Object s = getSuffixMethod.invoke(meta);
|
|
|
|
|
|
|
|
if (p != null) prefix = ChatColor.translateAlternateColorCodes('&', p.toString());
|
|
|
|
|
|
|
|
if (s != null) suffix = ChatColor.translateAlternateColorCodes('&', s.toString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (Throwable ignored) {
|
|
|
|
} catch (Throwable ignored) {}
|
|
|
|
// Kein LuckPerms oder Fehler
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (prefix != null && !prefix.isEmpty()) prefix = ChatColor.translateAlternateColorCodes('&', prefix);
|
|
|
|
|
|
|
|
if (suffix != null && !suffix.isEmpty()) suffix = ChatColor.translateAlternateColorCodes('&', suffix);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (prefix == null) prefix = "";
|
|
|
|
if (prefix == null) prefix = "";
|
|
|
|
if (suffix == null) suffix = "";
|
|
|
|
if (suffix == null) suffix = "";
|
|
|
|
|
|
|
|
|
|
|
|
return new String[]{prefix, suffix};
|
|
|
|
return new String[]{prefix, suffix, playerColor, chatColor};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// HELPER: LuckPerms Group via Reflection
|
|
|
|
|
|
|
|
private String getLuckPermsGroup(ProxiedPlayer player) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
if (plugin.getProxy().getPluginManager().getPlugin("LuckPerms") == null) return null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Class<?> providerClass = Class.forName("net.luckperms.api.LuckPermsProvider");
|
|
|
|
|
|
|
|
Method getMethod = providerClass.getMethod("get");
|
|
|
|
|
|
|
|
Object api = getMethod.invoke(null);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (api != null) {
|
|
|
|
|
|
|
|
Method getUserManagerMethod = api.getClass().getMethod("getUserManager");
|
|
|
|
|
|
|
|
Object userManager = getUserManagerMethod.invoke(api);
|
|
|
|
|
|
|
|
Method loadUserMethod = userManager.getClass().getMethod("loadUser", UUID.class);
|
|
|
|
|
|
|
|
Object userFuture = loadUserMethod.invoke(userManager, player.getUniqueId());
|
|
|
|
|
|
|
|
Method joinMethod = userFuture.getClass().getMethod("join");
|
|
|
|
|
|
|
|
Object user = joinMethod.invoke(userFuture);
|
|
|
|
|
|
|
|
if (user != null) {
|
|
|
|
|
|
|
|
Method getPrimaryGroupMethod = user.getClass().getMethod("getPrimaryGroup");
|
|
|
|
|
|
|
|
return (String) getPrimaryGroupMethod.invoke(user);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (ClassNotFoundException e) {
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
plugin.getLogger().warning("Fehler beim Auslesen von LuckPerms (Reflection): " + e.getMessage());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private String stripColor(String s) {
|
|
|
|
private String stripColor(String s) {
|
|
|
|
@@ -435,9 +604,6 @@ public class GlobalChatModule implements Module, Listener {
|
|
|
|
return ChatColor.stripColor(s);
|
|
|
|
return ChatColor.stripColor(s);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ===========================
|
|
|
|
|
|
|
|
// Filter einlesen
|
|
|
|
|
|
|
|
// ===========================
|
|
|
|
|
|
|
|
private void loadFilter() {
|
|
|
|
private void loadFilter() {
|
|
|
|
String fileName = "filter.yml";
|
|
|
|
String fileName = "filter.yml";
|
|
|
|
File file = new File(plugin.getDataFolder(), fileName);
|
|
|
|
File file = new File(plugin.getDataFolder(), fileName);
|
|
|
|
@@ -475,9 +641,6 @@ public class GlobalChatModule implements Module, Listener {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ===========================
|
|
|
|
|
|
|
|
// Logs aufräumen / schreiben
|
|
|
|
|
|
|
|
// ===========================
|
|
|
|
|
|
|
|
private void cleanupOldLogs() {
|
|
|
|
private void cleanupOldLogs() {
|
|
|
|
File[] files = logFolder.listFiles();
|
|
|
|
File[] files = logFolder.listFiles();
|
|
|
|
if (files == null) return;
|
|
|
|
if (files == null) return;
|
|
|
|
@@ -505,9 +668,6 @@ public class GlobalChatModule implements Module, Listener {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ===========================
|
|
|
|
|
|
|
|
// Staff-Check
|
|
|
|
|
|
|
|
// ===========================
|
|
|
|
|
|
|
|
private boolean isStaff(ProxiedPlayer p) {
|
|
|
|
private boolean isStaff(ProxiedPlayer p) {
|
|
|
|
if (p == null) return false;
|
|
|
|
if (p == null) return false;
|
|
|
|
Boolean reportedOp = playerIsOp.get(p.getUniqueId());
|
|
|
|
Boolean reportedOp = playerIsOp.get(p.getUniqueId());
|
|
|
|
@@ -527,6 +687,14 @@ public class GlobalChatModule implements Module, Listener {
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Überladene Methode für CommandSender (für Console/Check)
|
|
|
|
|
|
|
|
private boolean isStaff(CommandSender sender) {
|
|
|
|
|
|
|
|
if (sender instanceof ProxiedPlayer) {
|
|
|
|
|
|
|
|
return isStaff((ProxiedPlayer) sender);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return sender.hasPermission("globalchat.clear"); // Console hat meist Rechte, aber sicher ist sicher
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ===========================
|
|
|
|
// ===========================
|
|
|
|
// Commands (Inner Classes)
|
|
|
|
// Commands (Inner Classes)
|
|
|
|
// ===========================
|
|
|
|
// ===========================
|
|
|
|
@@ -535,7 +703,7 @@ public class GlobalChatModule implements Module, Listener {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void execute(CommandSender sender, String[] args) {
|
|
|
|
public void execute(CommandSender sender, String[] args) {
|
|
|
|
loadFilter();
|
|
|
|
loadFilter();
|
|
|
|
loadConfig(); // Konfiguration neu laden
|
|
|
|
loadConfig();
|
|
|
|
sender.sendMessage(new TextComponent("§aFilter und Chat-Konfiguration wurden neu geladen!"));
|
|
|
|
sender.sendMessage(new TextComponent("§aFilter und Chat-Konfiguration wurden neu geladen!"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@@ -569,8 +737,6 @@ public class GlobalChatModule implements Module, Listener {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
String msg = String.join(" ", args);
|
|
|
|
String msg = String.join(" ", args);
|
|
|
|
|
|
|
|
|
|
|
|
// WICHTIG: Server Name umwandeln in Display Name
|
|
|
|
|
|
|
|
String serverRaw = player.getServer().getInfo().getName();
|
|
|
|
String serverRaw = player.getServer().getInfo().getName();
|
|
|
|
String serverDisplay = getDisplayName(serverRaw);
|
|
|
|
String serverDisplay = getDisplayName(serverRaw);
|
|
|
|
|
|
|
|
|
|
|
|
@@ -627,9 +793,63 @@ public class GlobalChatModule implements Module, Listener {
|
|
|
|
sender.sendMessage(new TextComponent("§8§m------------------------------"));
|
|
|
|
sender.sendMessage(new TextComponent("§8§m------------------------------"));
|
|
|
|
sender.sendMessage(new TextComponent("§6§lGlobalChat Info"));
|
|
|
|
sender.sendMessage(new TextComponent("§6§lGlobalChat Info"));
|
|
|
|
sender.sendMessage(new TextComponent("§ePlugin-Name: §bStatusAPI (GlobalChat Module)"));
|
|
|
|
sender.sendMessage(new TextComponent("§ePlugin-Name: §bStatusAPI (GlobalChat Module)"));
|
|
|
|
sender.sendMessage(new TextComponent("§eVersion: §b1.4"));
|
|
|
|
sender.sendMessage(new TextComponent("§eVersion: §b2.0 (Relay)"));
|
|
|
|
sender.sendMessage(new TextComponent("§eErsteller: §bM_Viper"));
|
|
|
|
sender.sendMessage(new TextComponent("§eErsteller: §bM_Viper"));
|
|
|
|
sender.sendMessage(new TextComponent("§8§m------------------------------"));
|
|
|
|
sender.sendMessage(new TextComponent("§8§m------------------------------"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class ChatToggleCommand extends Command {
|
|
|
|
|
|
|
|
public ChatToggleCommand() { super("togglechat"); }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void execute(CommandSender sender, String[] args) {
|
|
|
|
|
|
|
|
if (!(sender instanceof ProxiedPlayer)) {
|
|
|
|
|
|
|
|
sender.sendMessage(new TextComponent("§cNur Spieler können den Chat-Modus ändern."));
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ProxiedPlayer player = (ProxiedPlayer) sender;
|
|
|
|
|
|
|
|
UUID uuid = player.getUniqueId();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (chatLockPlayers.contains(uuid)) {
|
|
|
|
|
|
|
|
chatLockPlayers.remove(uuid);
|
|
|
|
|
|
|
|
player.sendMessage(new TextComponent("§aGlobalChat aktiviert."));
|
|
|
|
|
|
|
|
player.sendMessage(new TextComponent("§7Deine Nachrichten werden nun wieder global gesendet."));
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
chatLockPlayers.add(uuid);
|
|
|
|
|
|
|
|
player.sendMessage(new TextComponent("§cGlobalChat deaktiviert."));
|
|
|
|
|
|
|
|
player.sendMessage(new TextComponent("§7Deine Nachrichten gehen nur noch an den Server (z.B. für Lands oder Quests)."));
|
|
|
|
|
|
|
|
player.sendMessage(new TextComponent("§7Nutze erneut /togglechat, um den globalen Chat zu aktivieren."));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class ClearChatCommand extends Command {
|
|
|
|
|
|
|
|
public ClearChatCommand() {
|
|
|
|
|
|
|
|
super("clearchat", "globalchat.clear", "cc");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void execute(CommandSender sender, String[] args) {
|
|
|
|
|
|
|
|
// Prüfen, ob der Sender OP / Team ist
|
|
|
|
|
|
|
|
// Wir nutzen hier die überladene isStaff Methode für CommandSender
|
|
|
|
|
|
|
|
if (!isStaff(sender)) {
|
|
|
|
|
|
|
|
sender.sendMessage(new TextComponent("§cKeine Berechtigung!"));
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 100 leere Zeilen senden zum Leeren
|
|
|
|
|
|
|
|
TextComponent emptyLine = new TextComponent(" ");
|
|
|
|
|
|
|
|
for (int i = 0; i < 100; i++) {
|
|
|
|
|
|
|
|
broadcastGlobal(emptyLine);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Bestätigungsnachricht
|
|
|
|
|
|
|
|
TextComponent clearMsg = new TextComponent("§7[GlobalChat] §cDer Chat wurde von " + sender.getName() + " geleert.");
|
|
|
|
|
|
|
|
broadcastGlobal(clearMsg);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sender.sendMessage(new TextComponent("§aChat wurde geleert."));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|