|
|
|
|
@@ -18,10 +18,12 @@ import net.md_5.bungee.api.event.ServerSwitchEvent;
|
|
|
|
|
import net.md_5.bungee.api.plugin.Command;
|
|
|
|
|
import net.md_5.bungee.api.plugin.Listener;
|
|
|
|
|
import net.md_5.bungee.api.plugin.Plugin;
|
|
|
|
|
import net.md_5.bungee.chat.ComponentSerializer; // Wichtig für JSON
|
|
|
|
|
import net.md_5.bungee.event.EventHandler;
|
|
|
|
|
import net.viper.status.module.Module;
|
|
|
|
|
|
|
|
|
|
import java.io.*;
|
|
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
|
|
import java.nio.file.Files;
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
@@ -31,10 +33,12 @@ import java.util.regex.Pattern;
|
|
|
|
|
/**
|
|
|
|
|
* GlobalChatModule - Integriert Global Chat, Filter, Logs und Support in die StatusAPI.
|
|
|
|
|
* Nutzt die zentrale verify.properties für Chat- und Server-Einstellungen.
|
|
|
|
|
* Sendet Nachrichten via Plugin Channel an Backend-Server, um Signatur-Probleme zu vermeiden.
|
|
|
|
|
*/
|
|
|
|
|
public class GlobalChatModule implements Module, Listener {
|
|
|
|
|
|
|
|
|
|
private static final String CHANNEL_CONTROL = "global:control";
|
|
|
|
|
private static final String CHANNEL_CHAT = "global:chat"; // NEU: Kanal für Chat-Relay
|
|
|
|
|
|
|
|
|
|
private Plugin plugin;
|
|
|
|
|
|
|
|
|
|
@@ -46,9 +50,14 @@ public class GlobalChatModule implements Module, Listener {
|
|
|
|
|
private final Map<UUID, Boolean> playerIsOp = new ConcurrentHashMap<>();
|
|
|
|
|
private final Map<UUID, UUID> lastSupportContact = new ConcurrentHashMap<>();
|
|
|
|
|
private final Set<UUID> suppressJoinQuit = ConcurrentHashMap.newKeySet();
|
|
|
|
|
private final Set<UUID> chatLockPlayers = ConcurrentHashMap.newKeySet(); // Toggle Chat List
|
|
|
|
|
|
|
|
|
|
private List<String> welcomeMessages = new ArrayList<>();
|
|
|
|
|
private Map<String, String> serverDisplayNames = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
// NEU: Map für gruppen-spezifische Formate aus der verify.properties
|
|
|
|
|
private Map<String, String> groupFormats = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String getName() {
|
|
|
|
|
return "GlobalChatModule";
|
|
|
|
|
@@ -58,21 +67,19 @@ public class GlobalChatModule implements Module, Listener {
|
|
|
|
|
public void onEnable(Plugin plugin) {
|
|
|
|
|
this.plugin = plugin;
|
|
|
|
|
|
|
|
|
|
// Konfigurationen laden (Zuerst prüfen wir, ob der Chat überhaupt aktiv ist)
|
|
|
|
|
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) {
|
|
|
|
|
plugin.getLogger().info("§eGlobalChat ist in der verify.properties DEAKTIVIERT.");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Plugin channel registrieren
|
|
|
|
|
// Channels registrieren
|
|
|
|
|
try {
|
|
|
|
|
plugin.getProxy().registerChannel(CHANNEL_CONTROL);
|
|
|
|
|
plugin.getProxy().registerChannel(CHANNEL_CHAT);
|
|
|
|
|
} 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);
|
|
|
|
|
@@ -90,8 +97,9 @@ public class GlobalChatModule implements Module, Listener {
|
|
|
|
|
plugin.getProxy().getPluginManager().registerCommand(plugin, new SupportCommand());
|
|
|
|
|
plugin.getProxy().getPluginManager().registerCommand(plugin, new ReplyCommand());
|
|
|
|
|
plugin.getProxy().getPluginManager().registerCommand(plugin, new InfoCommand());
|
|
|
|
|
plugin.getProxy().getPluginManager().registerCommand(plugin, new ChatToggleCommand());
|
|
|
|
|
|
|
|
|
|
plugin.getLogger().info("§aGlobalChatModule aktiviert (Zensur, Logs, Mute, Support, CustomNames)!");
|
|
|
|
|
plugin.getLogger().info("§aGlobalChatModule aktiviert (Relay-Mode aktiv)!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@@ -99,18 +107,17 @@ public class GlobalChatModule implements Module, Listener {
|
|
|
|
|
plugin.getLogger().info("§cGlobalChatModule deaktiviert!");
|
|
|
|
|
try {
|
|
|
|
|
plugin.getProxy().unregisterChannel(CHANNEL_CONTROL);
|
|
|
|
|
plugin.getProxy().unregisterChannel(CHANNEL_CHAT);
|
|
|
|
|
} catch (Throwable ignored) {}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ===========================
|
|
|
|
|
// Konfiguration laden (Aktivierungsstatus & Namen aus verify.properties)
|
|
|
|
|
// Konfiguration laden
|
|
|
|
|
// ===========================
|
|
|
|
|
private void loadConfig() {
|
|
|
|
|
// ÄNDERUNG: Wir lesen jetzt die 'verify.properties'
|
|
|
|
|
String fileName = "verify.properties";
|
|
|
|
|
File file = new File(plugin.getDataFolder(), fileName);
|
|
|
|
|
|
|
|
|
|
// Datei aus Ressourcen kopieren, falls nicht vorhanden
|
|
|
|
|
if (!file.exists()) {
|
|
|
|
|
plugin.getDataFolder().mkdirs();
|
|
|
|
|
try (InputStream in = plugin.getResourceAsStream(fileName);
|
|
|
|
|
@@ -132,31 +139,35 @@ public class GlobalChatModule implements Module, Listener {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Einlesen
|
|
|
|
|
try {
|
|
|
|
|
Properties props = new Properties();
|
|
|
|
|
try (InputStream in = new FileInputStream(file)) {
|
|
|
|
|
props.load(in);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Aktivierung prüfen
|
|
|
|
|
isChatEnabled = Boolean.parseBoolean(props.getProperty("chat.enabled", "true"));
|
|
|
|
|
|
|
|
|
|
serverDisplayNames.clear();
|
|
|
|
|
// NEU: Gruppen-Formate laden
|
|
|
|
|
groupFormats.clear();
|
|
|
|
|
|
|
|
|
|
for (String key : props.stringPropertyNames()) {
|
|
|
|
|
if (key.startsWith("server.")) {
|
|
|
|
|
String[] parts = key.split("\\.");
|
|
|
|
|
|
|
|
|
|
// WICHTIG: Wir ignorieren Keys mit Unterpunkten (z.B. server.lobby.id oder .secret)
|
|
|
|
|
// Wir wollen nur Keys wie "server.lobby" (parts.length == 2)
|
|
|
|
|
if (parts.length == 2) {
|
|
|
|
|
String serverName = parts[1];
|
|
|
|
|
String displayName = props.getProperty(key);
|
|
|
|
|
serverDisplayNames.put(serverName, displayName);
|
|
|
|
|
}
|
|
|
|
|
} else if (key.startsWith("groupformat.")) {
|
|
|
|
|
// Format: groupformat.Owner = &c[Owner] || &b || &d
|
|
|
|
|
String groupName = key.substring("groupformat.".length());
|
|
|
|
|
String format = props.getProperty(key);
|
|
|
|
|
groupFormats.put(groupName, format);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
plugin.getLogger().info("§eGeladene Server-Displaynames: " + serverDisplayNames.size() + " (Chat aktiv: " + isChatEnabled + ")");
|
|
|
|
|
plugin.getLogger().info("§eGeladene Chat-Formate: " + groupFormats.size());
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
@@ -219,7 +230,7 @@ public class GlobalChatModule implements Module, Listener {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ===========================
|
|
|
|
|
// Chatfilter & Global-Chat
|
|
|
|
|
// Chatfilter & Global-Chat (RELAY MODE)
|
|
|
|
|
// ===========================
|
|
|
|
|
@EventHandler
|
|
|
|
|
public void onChat(ChatEvent e) {
|
|
|
|
|
@@ -227,6 +238,13 @@ public class GlobalChatModule implements Module, Listener {
|
|
|
|
|
if (e.isCommand()) return;
|
|
|
|
|
|
|
|
|
|
ProxiedPlayer player = (ProxiedPlayer) e.getSender();
|
|
|
|
|
|
|
|
|
|
// ==================== CHAT LOCK / TOGGLE CHECK ====================
|
|
|
|
|
if (chatLockPlayers.contains(player.getUniqueId())) {
|
|
|
|
|
return; // Nachricht geht direkt zum Server (z.B. für Lands/Quests)
|
|
|
|
|
}
|
|
|
|
|
// ========================================================================
|
|
|
|
|
|
|
|
|
|
String originalMsg = e.getMessage();
|
|
|
|
|
|
|
|
|
|
if (suppressJoinQuit.contains(player.getUniqueId()) &&
|
|
|
|
|
@@ -250,37 +268,54 @@ public class GlobalChatModule implements Module, Listener {
|
|
|
|
|
censoredMsg = censoredMsg.replaceAll("(?i)" + Pattern.quote(bad), repeat("*", bad.length()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Event canceln (Wichtig, damit nicht doppelt angezeigt wird)
|
|
|
|
|
e.setCancelled(true);
|
|
|
|
|
|
|
|
|
|
String serverName = player.getServer().getInfo().getName();
|
|
|
|
|
String serverDisplay = getDisplayName(serverName);
|
|
|
|
|
|
|
|
|
|
// Index 0: Prefix (Rang), Index 1: Suffix, Index 2: Spielername Farbe, Index 3: Chat Farbe
|
|
|
|
|
String[] ps = getPrefixSuffix(player);
|
|
|
|
|
String prefix = ps[0] == null ? "" : ps[0].trim();
|
|
|
|
|
String suffix = ps[1] == null ? "" : ps[1].trim();
|
|
|
|
|
String prefix = ps[0];
|
|
|
|
|
String playerColor = ps[2];
|
|
|
|
|
String chatColor = ps[3];
|
|
|
|
|
|
|
|
|
|
String displayTag = "";
|
|
|
|
|
if (!prefix.isEmpty()) {
|
|
|
|
|
displayTag = prefix;
|
|
|
|
|
} else if (!suffix.isEmpty()) {
|
|
|
|
|
displayTag = suffix;
|
|
|
|
|
} else if (!ps[1].isEmpty()) {
|
|
|
|
|
displayTag = ps[1];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!displayTag.isEmpty() && !displayTag.endsWith(" ")) displayTag = displayTag + " ";
|
|
|
|
|
|
|
|
|
|
StringBuilder out = new StringBuilder();
|
|
|
|
|
out.append("§7[").append(serverDisplay).append("] ");
|
|
|
|
|
out.append("§7[").append(serverDisplay).append("§r§7] "); // FIX: Reset vor der Klammer
|
|
|
|
|
if (!displayTag.isEmpty()) out.append(displayTag);
|
|
|
|
|
out.append(player.getName());
|
|
|
|
|
out.append("§f: ").append(censoredMsg);
|
|
|
|
|
|
|
|
|
|
// Spielername mit eigener Farbe
|
|
|
|
|
out.append(playerColor).append(player.getName());
|
|
|
|
|
|
|
|
|
|
out.append("§f: ").append(chatColor).append(censoredMsg); // Chatnachricht mit eigener Farbe
|
|
|
|
|
|
|
|
|
|
String chatOut = out.toString();
|
|
|
|
|
|
|
|
|
|
for (ProxiedPlayer p : plugin.getProxy().getPlayers()) {
|
|
|
|
|
p.sendMessage(new TextComponent(chatOut));
|
|
|
|
|
// NEU: Nachricht erstellen und an alle Server senden
|
|
|
|
|
TextComponent chatComponent = new TextComponent(chatOut);
|
|
|
|
|
String jsonMessage = ComponentSerializer.toString(chatComponent);
|
|
|
|
|
|
|
|
|
|
for (ServerInfo server : plugin.getProxy().getServers().values()) {
|
|
|
|
|
// Wir senden nur an Server, die Spieler haben (Performance)
|
|
|
|
|
if (server.getPlayers().isEmpty()) continue;
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
server.sendData(CHANNEL_CHAT, jsonMessage.getBytes(StandardCharsets.UTF_8));
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
plugin.getLogger().warning("Konnte Chat-Nachricht nicht an Server " + server.getName() + " senden.");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Log unzensiert (Originalnamen für saubere Logs)
|
|
|
|
|
// Loggen (lokal auf Bungee)
|
|
|
|
|
String logEntry = "[" + serverName + "] " +
|
|
|
|
|
(displayTag.isEmpty() ? "" : stripColor(displayTag) + " ") +
|
|
|
|
|
player.getName() +
|
|
|
|
|
@@ -339,9 +374,10 @@ public class GlobalChatModule implements Module, Listener {
|
|
|
|
|
String toName = to.getName();
|
|
|
|
|
String toDisplay = getDisplayName(toName);
|
|
|
|
|
|
|
|
|
|
// Hier nutzen wir nur das Prefix (Index 0), nicht die Chatfarbe oder Spielerfarbe
|
|
|
|
|
String[] ps = getPrefixSuffix(player);
|
|
|
|
|
String prefix = ps[0] == null ? "" : ps[0].trim();
|
|
|
|
|
String suffix = ps[1] == null ? "" : ps[1].trim();
|
|
|
|
|
String prefix = ps[0];
|
|
|
|
|
String suffix = ps[1];
|
|
|
|
|
|
|
|
|
|
String displayTag = "";
|
|
|
|
|
if (!prefix.isEmpty()) displayTag = prefix;
|
|
|
|
|
@@ -350,19 +386,30 @@ public class GlobalChatModule implements Module, Listener {
|
|
|
|
|
if (!displayTag.isEmpty() && !displayTag.endsWith(" ")) displayTag = displayTag + " ";
|
|
|
|
|
|
|
|
|
|
StringBuilder msg = new StringBuilder();
|
|
|
|
|
msg.append("§7[").append(toDisplay).append("] ");
|
|
|
|
|
msg.append("§7[").append(toDisplay).append("§r§7] "); // FIX: Reset vor der Klammer
|
|
|
|
|
if (!displayTag.isEmpty()) msg.append(displayTag);
|
|
|
|
|
|
|
|
|
|
// Switch Nachricht: Spielername weiß oder Standard
|
|
|
|
|
msg.append(player.getName());
|
|
|
|
|
|
|
|
|
|
msg.append(" §7hat den Server gewechselt: §e")
|
|
|
|
|
.append(fromDisplay).append(" §7→ §e").append(toDisplay).append("§7.");
|
|
|
|
|
|
|
|
|
|
String finalMsg = msg.toString();
|
|
|
|
|
|
|
|
|
|
for (ProxiedPlayer p : plugin.getProxy().getPlayers()) {
|
|
|
|
|
p.sendMessage(new TextComponent(finalMsg));
|
|
|
|
|
// NEU: Switch Nachricht auch über Relay senden
|
|
|
|
|
TextComponent switchComponent = new TextComponent(finalMsg);
|
|
|
|
|
String jsonMessage = ComponentSerializer.toString(switchComponent);
|
|
|
|
|
|
|
|
|
|
for (ServerInfo server : plugin.getProxy().getServers().values()) {
|
|
|
|
|
if (server.getPlayers().isEmpty()) continue;
|
|
|
|
|
try {
|
|
|
|
|
server.sendData(CHANNEL_CHAT, jsonMessage.getBytes(StandardCharsets.UTF_8));
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
plugin.getLogger().warning("Konnte Switch-Nachricht nicht senden.");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Log unzensiert (Originalnamen)
|
|
|
|
|
String logEntry = "[" + toName + "] " +
|
|
|
|
|
(displayTag.isEmpty() ? "" : stripColor(displayTag) + " ") +
|
|
|
|
|
player.getName() + " hat den Server gewechselt: " + fromName + " -> " + toName + ".";
|
|
|
|
|
@@ -388,46 +435,112 @@ public class GlobalChatModule implements Module, Listener {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ===========================
|
|
|
|
|
// Prefix/Suffix via LuckPerms
|
|
|
|
|
// Prefix/Suffix via LuckPerms & Properties (ROBUST + CHAT COLOR + PLAYER COLOR)
|
|
|
|
|
// ===========================
|
|
|
|
|
private String[] getPrefixSuffix(ProxiedPlayer player) {
|
|
|
|
|
String prefix = "";
|
|
|
|
|
String suffix = "";
|
|
|
|
|
String playerColor = "§f"; // Standard Weiß für Spielername
|
|
|
|
|
String chatColor = "§f"; // Standard Weiß für Chat
|
|
|
|
|
|
|
|
|
|
// Standard Gruppe falls nichts gefunden wird
|
|
|
|
|
String groupName = "Spieler";
|
|
|
|
|
|
|
|
|
|
// 1. Versuch: Gruppe von LuckPerms holen
|
|
|
|
|
try {
|
|
|
|
|
LuckPerms lp = LuckPermsProvider.get();
|
|
|
|
|
if (lp != null) {
|
|
|
|
|
User user = lp.getUserManager().getUser(player.getUniqueId());
|
|
|
|
|
|
|
|
|
|
if (user == null) {
|
|
|
|
|
try {
|
|
|
|
|
// User synchron laden
|
|
|
|
|
user = lp.getUserManager().loadUser(player.getUniqueId()).join();
|
|
|
|
|
} catch (Exception ignored) {
|
|
|
|
|
user = null;
|
|
|
|
|
} catch (Exception ignored) {}
|
|
|
|
|
}
|
|
|
|
|
if (user != null) {
|
|
|
|
|
String lpGroup = user.getPrimaryGroup();
|
|
|
|
|
if (lpGroup != null && !lpGroup.isEmpty() && !lpGroup.equalsIgnoreCase("default")) {
|
|
|
|
|
groupName = lpGroup;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch (Throwable ignored) {}
|
|
|
|
|
|
|
|
|
|
// 2. FALLBACK: Permission-Check (Funktioniert auch OHNE LuckPerms Datenbank)
|
|
|
|
|
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 if (player.hasPermission("group.spieler")) groupName = "Spieler";
|
|
|
|
|
else groupName = "Spieler";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 3. Farben aus verify.properties anwenden (Höchste Priorität)
|
|
|
|
|
if (groupName != null && groupFormats.containsKey(groupName)) {
|
|
|
|
|
String rawFormat = groupFormats.get(groupName);
|
|
|
|
|
|
|
|
|
|
// NEU: Check auf " || " für Spielername Farbe UND Chat Farbe
|
|
|
|
|
if (rawFormat.contains(" || ")) {
|
|
|
|
|
String[] parts = rawFormat.split(" \\|\\| ");
|
|
|
|
|
// Syntax: Prefix || PlayerColor || ChatColor
|
|
|
|
|
|
|
|
|
|
// Teil 1: Prefix (Rang)
|
|
|
|
|
prefix = ChatColor.translateAlternateColorCodes('&', parts[0]);
|
|
|
|
|
|
|
|
|
|
// Teil 2: Spieler Name Farbe
|
|
|
|
|
playerColor = ChatColor.translateAlternateColorCodes('&', parts[1]);
|
|
|
|
|
|
|
|
|
|
// Teil 3: Chat Farbe
|
|
|
|
|
chatColor = ChatColor.translateAlternateColorCodes('&', parts[2]);
|
|
|
|
|
|
|
|
|
|
suffix = "";
|
|
|
|
|
}
|
|
|
|
|
// ALTER FALLBACK (Kompatibilität): Check auf ": "
|
|
|
|
|
else if (rawFormat.contains(": ")) {
|
|
|
|
|
String[] parts = rawFormat.split(": ", 2);
|
|
|
|
|
// Teil 1: Prefix
|
|
|
|
|
prefix = ChatColor.translateAlternateColorCodes('&', parts[0]);
|
|
|
|
|
// Teil 2: Chat Farbe
|
|
|
|
|
chatColor = ChatColor.translateAlternateColorCodes('&', parts[1]);
|
|
|
|
|
// Spielername bleibt Standard Weiß
|
|
|
|
|
playerColor = "§f";
|
|
|
|
|
suffix = "";
|
|
|
|
|
} else {
|
|
|
|
|
// Kein Separator gefunden -> Nur Prefix
|
|
|
|
|
prefix = ChatColor.translateAlternateColorCodes('&', rawFormat);
|
|
|
|
|
suffix = "";
|
|
|
|
|
playerColor = "§f";
|
|
|
|
|
chatColor = "§f";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new String[]{prefix, suffix, playerColor, chatColor};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 4. Wenn nichts in Properties gefunden wurde, Fallback auf LuckPerms Meta
|
|
|
|
|
try {
|
|
|
|
|
LuckPerms lp = LuckPermsProvider.get();
|
|
|
|
|
if (lp != null) {
|
|
|
|
|
User user = lp.getUserManager().getUser(player.getUniqueId());
|
|
|
|
|
if (user == null) {
|
|
|
|
|
try { user = lp.getUserManager().loadUser(player.getUniqueId()).join(); } catch (Exception ignored) {}
|
|
|
|
|
}
|
|
|
|
|
if (user != null) {
|
|
|
|
|
CachedMetaData meta = user.getCachedData().getMetaData();
|
|
|
|
|
if (meta != null) {
|
|
|
|
|
String p = meta.getPrefix();
|
|
|
|
|
String s = meta.getSuffix();
|
|
|
|
|
if (p != null) prefix = p;
|
|
|
|
|
if (s != null) suffix = s;
|
|
|
|
|
if (p != null) prefix = ChatColor.translateAlternateColorCodes('&', p);
|
|
|
|
|
if (s != null) suffix = ChatColor.translateAlternateColorCodes('&', s);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} 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);
|
|
|
|
|
} catch (Throwable ignored) {}
|
|
|
|
|
|
|
|
|
|
if (prefix == null) prefix = "";
|
|
|
|
|
if (suffix == null) suffix = "";
|
|
|
|
|
|
|
|
|
|
return new String[]{prefix, suffix};
|
|
|
|
|
return new String[]{prefix, suffix, playerColor, chatColor};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String stripColor(String s) {
|
|
|
|
|
@@ -535,7 +648,7 @@ public class GlobalChatModule implements Module, Listener {
|
|
|
|
|
@Override
|
|
|
|
|
public void execute(CommandSender sender, String[] args) {
|
|
|
|
|
loadFilter();
|
|
|
|
|
loadConfig(); // Konfiguration neu laden
|
|
|
|
|
loadConfig();
|
|
|
|
|
sender.sendMessage(new TextComponent("§aFilter und Chat-Konfiguration wurden neu geladen!"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@@ -569,11 +682,10 @@ public class GlobalChatModule implements Module, Listener {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String msg = String.join(" ", args);
|
|
|
|
|
|
|
|
|
|
// WICHTIG: Server Name umwandeln in Display Name
|
|
|
|
|
String serverRaw = player.getServer().getInfo().getName();
|
|
|
|
|
String serverDisplay = getDisplayName(serverRaw);
|
|
|
|
|
|
|
|
|
|
// Support-Nachricht geht nur ans Team, nicht über den Global Chat Relay
|
|
|
|
|
TextComponent supportMsg = new TextComponent("§7[Support] §b" + player.getName() + " §7vom Server §e" + serverDisplay + " §7: §f" + msg);
|
|
|
|
|
supportMsg.setHoverEvent(new HoverEvent(Action.SHOW_TEXT, new ComponentBuilder("Klicke, um /reply " + player.getName() + " zu schreiben").create()));
|
|
|
|
|
supportMsg.setClickEvent(new net.md_5.bungee.api.chat.ClickEvent(net.md_5.bungee.api.chat.ClickEvent.Action.SUGGEST_COMMAND, "/reply " + player.getName() + " "));
|
|
|
|
|
@@ -627,9 +739,35 @@ public class GlobalChatModule implements Module, Listener {
|
|
|
|
|
sender.sendMessage(new TextComponent("§8§m------------------------------"));
|
|
|
|
|
sender.sendMessage(new TextComponent("§6§lGlobalChat Info"));
|
|
|
|
|
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("§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."));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|