Compare commits
23 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 422cb9c352 | |||
| e60bff9c6d | |||
| 59944ece4e | |||
| b29f2e2db3 | |||
| f37cff83fc | |||
| 2384178a3a | |||
| 5558b237bb | |||
| e13342a767 | |||
| 2dc4f8dd38 | |||
| 503474a991 | |||
| e3a0ea6682 | |||
| b8e8f75f90 | |||
| 12fc2b82c4 | |||
| 5706d3a446 | |||
| aa5b1a2572 | |||
| 27ac00308a | |||
| c0ea8c0cd8 | |||
| a5d54b8141 | |||
| 52ae8c8c5a | |||
| fba27d6c6f | |||
| af7c86ef49 | |||
| 81c6991d49 | |||
| 2a4b8d6bce |
@@ -1,7 +1,7 @@
|
||||
# StatusAPI
|
||||
|
||||

|
||||

|
||||

|
||||
|
||||
Ein modulares und mächtiges Plugin für BungeeCord, das einen zentralen JSON-Status, ein globales Chat-System, WordPress-Verifizierung und dynamische Server-Navigation bereitstellt.
|
||||
|
||||
@@ -78,14 +78,14 @@ server.skyblock.secret=GeheimesWortFuerSkyBlock
|
||||
|
||||
## 💻 Befehle
|
||||
|
||||
Die meisten Befehle werden dynamisch basierend auf deiner `verify.properties` erstellt.
|
||||
|
||||
| Befehl | Beschreibung | Permission |
|
||||
|--------|--------------|------------|
|
||||
| `/verify <token>` | Verifiziert den Spieler mit der WordPress-Seite | - |
|
||||
| `/survival` / `/lobby` | Führt dich auf den entsprechenden Server um (wird dynamisch erstellt) | - |
|
||||
| `/globalmute` | Aktiviert oder deaktiviert den globalen Chat | `globalchat.mute` |
|
||||
| `/globalreload` | Lädt Filter und Konfigurationen neu | `globalchat.reload` |
|
||||
| `/clearchat, cc` | Löscht den Chatverlauf | `globalchat.clear` |
|
||||
| `/togglechat` | schaltet für den Spieler den Chat ab | - |
|
||||
| `/support <msg>` | Sendet eine Nachricht an das Online-Team | - |
|
||||
| `/reply <msg>` | Antwortet auf eine Support-Anfrage | - |
|
||||
| `/info` | Zeigt Plugin-Informationen an | - |
|
||||
@@ -136,6 +136,7 @@ moduleManager.registerModule(new MeinModul());
|
||||
- `globalchat.mute` - Erlaubt das Stummschalten des Chats
|
||||
- `globalchat.bypass` - Erlaubt das Schreiben, auch wenn der Chat gemuted ist
|
||||
- `globalchat.reload` - Erlaubt das Neuladen der Konfiguration
|
||||
- `globalchat.clear` - Löscht den Kompletten Chatverlauf
|
||||
|
||||
## 🤝 Credits
|
||||
|
||||
|
||||
102
pom.xml
102
pom.xml
@@ -1,52 +1,52 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
|
||||
https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>net.viper.bungee</groupId>
|
||||
<artifactId>StatusAPI</artifactId>
|
||||
<version>4.0.0</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>StatusAPI</name>
|
||||
<description>BungeeCord Status API Plugin</description>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<!-- BungeeCord API -->
|
||||
<dependency>
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-api</artifactId>
|
||||
<version>1.20</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- LuckPerms API (Optional) -->
|
||||
<dependency>
|
||||
<groupId>net.luckperms</groupId>
|
||||
<artifactId>api</artifactId>
|
||||
<version>5.4</version>
|
||||
<scope>provided</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>StatusAPI</finalName>
|
||||
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>false</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
|
||||
https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>net.viper.bungee</groupId>
|
||||
<artifactId>StatusAPI</artifactId>
|
||||
<version>4.0.5</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>StatusAPI</name>
|
||||
<description>BungeeCord Status API Plugin</description>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<!-- BungeeCord API -->
|
||||
<dependency>
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-api</artifactId>
|
||||
<version>1.20</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- LuckPerms API (Optional) -->
|
||||
<dependency>
|
||||
<groupId>net.luckperms</groupId>
|
||||
<artifactId>api</artifactId>
|
||||
<version>5.4</version>
|
||||
<scope>provided</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>StatusAPI</finalName>
|
||||
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>false</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
@@ -1,310 +1,552 @@
|
||||
package net.viper.status;
|
||||
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.config.ListenerInfo;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
import net.viper.status.module.ModuleManager;
|
||||
import net.viper.status.stats.PlayerStats;
|
||||
import net.viper.status.stats.StatsModule;
|
||||
import net.viper.status.modules.verify.VerifyModule;
|
||||
import net.viper.status.modules.globalchat.GlobalChatModule;
|
||||
import net.viper.status.modules.navigation.NavigationModule;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.net.ServerSocket;
|
||||
import java.net.Socket;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class StatusAPI extends Plugin implements Runnable {
|
||||
|
||||
private Thread thread;
|
||||
private int port = 9191;
|
||||
|
||||
// Das neue Modul-System
|
||||
private ModuleManager moduleManager;
|
||||
|
||||
// Alte Komponenten (UpdateChecker/FileDownloader bleiben hier, da sie Core-Updates steuern)
|
||||
private UpdateChecker updateChecker;
|
||||
private FileDownloader fileDownloader;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
getLogger().info("StatusAPI Core wird initialisiert...");
|
||||
|
||||
// 1. Ordner sicherstellen
|
||||
if (!getDataFolder().exists()) {
|
||||
getDataFolder().mkdirs();
|
||||
}
|
||||
|
||||
// 2. Modul-System starten
|
||||
moduleManager = new ModuleManager();
|
||||
|
||||
// 3. MODULE REGISTRIEREN (Hier erweiterst du die API in Zukunft!)
|
||||
// Um ein neues Feature hinzuzufügen, erstelle eine Klasse, die 'Module' implementiert
|
||||
// und füge hier eine Zeile hinzu: moduleManager.registerModule(new MeinNeuesModul());
|
||||
|
||||
moduleManager.registerModule(new StatsModule()); // Statistik System laden
|
||||
|
||||
moduleManager.registerModule(new VerifyModule()); // Verify Modul
|
||||
|
||||
moduleManager.registerModule(new GlobalChatModule()); // GlobalChat
|
||||
|
||||
moduleManager.registerModule(new NavigationModule()); //Server Switcher
|
||||
|
||||
// 4. Alle Module aktivieren
|
||||
moduleManager.enableAll(this);
|
||||
|
||||
// 5. WebServer Thread starten
|
||||
getLogger().info("Starte Web-Server auf Port " + port + "...");
|
||||
thread = new Thread(this, "StatusAPI-HTTP-Server");
|
||||
thread.start();
|
||||
|
||||
// 6. Update System Initialisieren
|
||||
String currentVersion = getDescription() != null ? getDescription().getVersion() : "0.0.0";
|
||||
updateChecker = new UpdateChecker(this, currentVersion, 6);
|
||||
fileDownloader = new FileDownloader(this);
|
||||
|
||||
File pluginFile = getFile();
|
||||
File backupFile = new File(pluginFile.getParentFile(), "StatusAPI.jar.bak");
|
||||
|
||||
// Backup Cleanup
|
||||
if (backupFile.exists()) {
|
||||
ProxyServer.getInstance().getScheduler().schedule(this, () -> {
|
||||
if (backupFile.exists()) backupFile.delete();
|
||||
}, 1, TimeUnit.MINUTES);
|
||||
}
|
||||
|
||||
// Sofortiger Check
|
||||
checkAndMaybeUpdate();
|
||||
// Regelmäßiger Check
|
||||
ProxyServer.getInstance().getScheduler().schedule(this, this::checkAndMaybeUpdate, 6, 6, TimeUnit.HOURS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
getLogger().info("Stoppe Module...");
|
||||
if (moduleManager != null) {
|
||||
moduleManager.disableAll(this);
|
||||
}
|
||||
|
||||
getLogger().info("Stoppe Web-Server...");
|
||||
if (thread != null) {
|
||||
thread.interrupt();
|
||||
try { thread.join(1000); } catch (InterruptedException ignored) {}
|
||||
}
|
||||
}
|
||||
|
||||
// --- Update Logik (unverändert) ---
|
||||
private void checkAndMaybeUpdate() {
|
||||
try {
|
||||
updateChecker.checkNow();
|
||||
String currentVersion = getDescription() != null ? getDescription().getVersion() : "0.0.0";
|
||||
|
||||
if (updateChecker.isUpdateAvailable(currentVersion)) {
|
||||
String newVersion = updateChecker.getLatestVersion();
|
||||
String url = updateChecker.getLatestUrl();
|
||||
getLogger().warning("----------------------------------------");
|
||||
getLogger().warning("Neue Version verfügbar: " + newVersion);
|
||||
getLogger().warning("Starte automatisches Update...");
|
||||
getLogger().warning("----------------------------------------");
|
||||
|
||||
File pluginFile = getFile();
|
||||
File newFile = new File(pluginFile.getParentFile(), "StatusAPI.jar.new");
|
||||
|
||||
fileDownloader.downloadFile(url, newFile, () -> triggerUpdateScript(pluginFile, newFile));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
getLogger().severe("Fehler beim Update-Check: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private void triggerUpdateScript(File currentFile, File newFile) {
|
||||
try {
|
||||
File pluginsFolder = currentFile.getParentFile();
|
||||
File rootFolder = pluginsFolder.getParentFile();
|
||||
File batFile = new File(rootFolder, "StatusAPI_Update_" + System.currentTimeMillis() + ".bat");
|
||||
|
||||
String batContent = "@echo off\n" +
|
||||
"echo Bitte warten, der Server fährt herunter...\n" +
|
||||
"timeout /t 5 /nobreak >nul\n" +
|
||||
"cd /d \"" + pluginsFolder.getAbsolutePath().replace("\\", "/") + "\"\n" +
|
||||
"echo Fuehre Datei-Tausch durch...\n" +
|
||||
"if exist StatusAPI.jar.bak del StatusAPI.jar.bak\n" +
|
||||
"if exist StatusAPI.jar (\n" +
|
||||
" ren StatusAPI.jar StatusAPI.jar.bak\n" +
|
||||
")\n" +
|
||||
"if exist StatusAPI.new.jar (\n" +
|
||||
" ren StatusAPI.new.jar StatusAPI.jar\n" +
|
||||
" echo Update erfolgreich!\n" +
|
||||
") else (\n" +
|
||||
" echo FEHLER: StatusAPI.new.jar nicht gefunden!\n" +
|
||||
" pause\n" +
|
||||
")\n" +
|
||||
"del \"%~f0\"";
|
||||
|
||||
try (PrintWriter out = new PrintWriter(batFile)) { out.println(batContent); }
|
||||
|
||||
for (ProxiedPlayer p : ProxyServer.getInstance().getPlayers()) {
|
||||
p.disconnect("§cServer fährt für ein Update neu herunter. Bitte etwas warten.");
|
||||
}
|
||||
|
||||
getLogger().info("Starte Update-Skript...");
|
||||
Runtime.getRuntime().exec("cmd /c start \"Update_Proc\" \"" + batFile.getAbsolutePath() + "\"");
|
||||
ProxyServer.getInstance().stop();
|
||||
|
||||
} catch (Exception e) {
|
||||
getLogger().severe("Fehler beim Vorbereiten des Updates: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// --- WebServer & JSON ---
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try (ServerSocket serverSocket = new ServerSocket(port)) {
|
||||
serverSocket.setSoTimeout(1000);
|
||||
while (!Thread.interrupted()) {
|
||||
try {
|
||||
Socket clientSocket = serverSocket.accept();
|
||||
handleConnection(clientSocket);
|
||||
} catch (java.net.SocketTimeoutException e) {}
|
||||
catch (IOException e) {
|
||||
getLogger().warning("Fehler beim Akzeptieren einer Verbindung: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
getLogger().severe("Konnte ServerSocket nicht starten: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private void handleConnection(Socket clientSocket) {
|
||||
try (BufferedReader in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream(), "UTF-8"));
|
||||
OutputStream out = clientSocket.getOutputStream()) {
|
||||
|
||||
String inputLine = in.readLine();
|
||||
if (inputLine != null && inputLine.startsWith("GET")) {
|
||||
Map<String, Object> data = new LinkedHashMap<>();
|
||||
data.put("online", true);
|
||||
|
||||
// Version & Info
|
||||
String versionRaw = ProxyServer.getInstance().getVersion();
|
||||
String versionClean = (versionRaw != null && versionRaw.contains(":")) ? versionRaw.split(":")[2].trim() : versionRaw;
|
||||
data.put("version", versionClean);
|
||||
data.put("max_players", String.valueOf(ProxyServer.getInstance().getConfig().getPlayerLimit()));
|
||||
|
||||
String motd = "BungeeCord";
|
||||
try {
|
||||
Iterator<ListenerInfo> it = ProxyServer.getInstance().getConfig().getListeners().iterator();
|
||||
if (it.hasNext()) motd = it.next().getMotd();
|
||||
} catch (Exception ignored) {}
|
||||
data.put("motd", motd);
|
||||
|
||||
// StatsModul holen (Service Locator)
|
||||
StatsModule statsModule = (StatsModule) moduleManager.getModule("StatsModule");
|
||||
|
||||
boolean luckPermsEnabled = ProxyServer.getInstance().getPluginManager().getPlugin("LuckPerms") != null;
|
||||
List<Map<String, Object>> playersList = new ArrayList<>();
|
||||
|
||||
for (ProxiedPlayer p : ProxyServer.getInstance().getPlayers()) {
|
||||
Map<String, Object> playerInfo = new LinkedHashMap<>();
|
||||
playerInfo.put("name", p.getName());
|
||||
try { playerInfo.put("uuid", p.getUniqueId().toString()); } catch (Exception ignored) {}
|
||||
|
||||
String prefix = "";
|
||||
if (luckPermsEnabled) {
|
||||
try {
|
||||
Class<?> providerClass = Class.forName("net.luckperms.api.LuckPermsProvider");
|
||||
Object luckPermsApi = providerClass.getMethod("get").invoke(null);
|
||||
Object userManager = luckPermsApi.getClass().getMethod("getUserManager").invoke(luckPermsApi);
|
||||
Object user = userManager.getClass().getMethod("getUser", UUID.class).invoke(userManager, p.getUniqueId());
|
||||
if (user != null) {
|
||||
Class<?> queryOptionsClass = Class.forName("net.luckperms.api.query.QueryOptions");
|
||||
Object queryOptions = queryOptionsClass.getMethod("defaultContextualOptions").invoke(null);
|
||||
Object cachedData = user.getClass().getMethod("getCachedData").invoke(user);
|
||||
Object metaData = cachedData.getClass().getMethod("getMetaData", queryOptionsClass).invoke(cachedData, queryOptions);
|
||||
Object result = metaData.getClass().getMethod("getPrefix").invoke(metaData);
|
||||
if (result != null) prefix = (String) result;
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
playerInfo.put("prefix", prefix);
|
||||
|
||||
// Stats Integration via Modul
|
||||
if (statsModule != null) {
|
||||
PlayerStats ps = statsModule.getManager().getIfPresent(p.getUniqueId());
|
||||
if (ps != null) {
|
||||
playerInfo.put("playtime", ps.getPlaytimeWithCurrentSession());
|
||||
playerInfo.put("joins", ps.joins);
|
||||
playerInfo.put("first_seen", ps.firstSeen);
|
||||
playerInfo.put("last_seen", ps.lastSeen);
|
||||
}
|
||||
}
|
||||
playersList.add(playerInfo);
|
||||
}
|
||||
data.put("players", playersList);
|
||||
|
||||
String json = buildJsonString(data);
|
||||
byte[] jsonBytes = json.getBytes("UTF-8");
|
||||
StringBuilder response = new StringBuilder();
|
||||
response.append("HTTP/1.1 200 OK\r\n");
|
||||
response.append("Content-Type: application/json; charset=UTF-8\r\n");
|
||||
response.append("Access-Control-Allow-Origin: *\r\n");
|
||||
response.append("Content-Length: ").append(jsonBytes.length).append("\r\n");
|
||||
response.append("Connection: close\r\n\r\n");
|
||||
out.write(response.toString().getBytes("UTF-8"));
|
||||
out.write(jsonBytes);
|
||||
out.flush();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
getLogger().severe("Fehler beim Verarbeiten der Anfrage: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private String buildJsonString(Map<String, Object> data) {
|
||||
StringBuilder sb = new StringBuilder("{");
|
||||
boolean first = true;
|
||||
for (Map.Entry<String, Object> entry : data.entrySet()) {
|
||||
if (!first) sb.append(",");
|
||||
first = false;
|
||||
sb.append("\"").append(escapeJson(entry.getKey())).append("\":").append(valueToString(entry.getValue()));
|
||||
}
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private String valueToString(Object value) {
|
||||
if (value == null) return "null";
|
||||
else if (value instanceof Boolean) return value.toString();
|
||||
else if (value instanceof Number) return value.toString();
|
||||
else if (value instanceof Map) {
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> m = (Map<String, Object>) value;
|
||||
return buildJsonString(m);
|
||||
} else if (value instanceof List) {
|
||||
StringBuilder sb = new StringBuilder("[");
|
||||
List<?> list = (List<?>) value;
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
if (i > 0) sb.append(",");
|
||||
Object item = list.get(i);
|
||||
if (item instanceof Map) sb.append(buildJsonString((Map<String, Object>) item));
|
||||
else if (item instanceof Number) sb.append(item.toString());
|
||||
else sb.append("\"").append(escapeJson(String.valueOf(item))).append("\"");
|
||||
}
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
else return "\"" + escapeJson(String.valueOf(value)) + "\"";
|
||||
}
|
||||
|
||||
private String escapeJson(String s) {
|
||||
if (s == null) return "";
|
||||
return s.replace("\\", "\\\\").replace("\"", "\\\"").replace("\n", "\\n").replace("\r", "\\r");
|
||||
}
|
||||
package net.viper.status;
|
||||
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.config.ListenerInfo;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
import net.viper.status.module.ModuleManager;
|
||||
import net.viper.status.stats.PlayerStats;
|
||||
import net.viper.status.stats.StatsModule;
|
||||
import net.viper.status.modules.verify.VerifyModule;
|
||||
import net.viper.status.modules.globalchat.GlobalChatModule;
|
||||
import net.viper.status.modules.navigation.NavigationModule;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.net.ServerSocket;
|
||||
import java.net.Socket;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* StatusAPI - zentraler Bungee HTTP-Status- und Broadcast-Endpunkt
|
||||
*
|
||||
* Ergänzungen:
|
||||
* - BroadcastModule Registrierung
|
||||
* - POST /broadcast UND POST / (Root) werden als Broadcasts behandelt
|
||||
* - Unterstützung für prefix, prefixColor, messageColor Felder in JSON-Payload
|
||||
* - Unterstützung für bracketColor (neu)
|
||||
* - Unterstützung für scheduleTime (ms oder s), recur, clientScheduleId
|
||||
* - API-Key Header (X-Api-Key) wird an BroadcastModule weitergereicht
|
||||
*/
|
||||
public class StatusAPI extends Plugin implements Runnable {
|
||||
|
||||
private Thread thread;
|
||||
private int port = 9191;
|
||||
|
||||
// Das neue Modul-System
|
||||
private ModuleManager moduleManager;
|
||||
|
||||
// Alte Komponenten (UpdateChecker/FileDownloader bleiben hier, da sie Core-Updates steuern)
|
||||
private UpdateChecker updateChecker;
|
||||
private FileDownloader fileDownloader;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
getLogger().info("StatusAPI Core wird initialisiert...");
|
||||
|
||||
// 1. Ordner sicherstellen
|
||||
if (!getDataFolder().exists()) {
|
||||
getDataFolder().mkdirs();
|
||||
}
|
||||
|
||||
// 2. Modul-System starten
|
||||
moduleManager = new ModuleManager();
|
||||
|
||||
// 3. MODULE REGISTRIEREN
|
||||
moduleManager.registerModule(new StatsModule()); // Statistik System laden
|
||||
moduleManager.registerModule(new VerifyModule()); // Verify Modul
|
||||
moduleManager.registerModule(new GlobalChatModule()); // GlobalChat
|
||||
moduleManager.registerModule(new NavigationModule()); //Server Switcher
|
||||
// Broadcast Modul registrieren (neu)
|
||||
moduleManager.registerModule(new net.viper.status.modules.broadcast.BroadcastModule());
|
||||
|
||||
// 4. Alle Module aktivieren
|
||||
moduleManager.enableAll(this);
|
||||
|
||||
// 5. WebServer Thread starten
|
||||
getLogger().info("Starte Web-Server auf Port " + port + "...");
|
||||
thread = new Thread(this, "StatusAPI-HTTP-Server");
|
||||
thread.start();
|
||||
|
||||
// 6. Update System Initialisieren
|
||||
String currentVersion = getDescription() != null ? getDescription().getVersion() : "0.0.0";
|
||||
updateChecker = new UpdateChecker(this, currentVersion, 6);
|
||||
fileDownloader = new FileDownloader(this);
|
||||
|
||||
File pluginFile = getFile();
|
||||
File backupFile = new File(pluginFile.getParentFile(), "StatusAPI.jar.bak");
|
||||
|
||||
// Backup Cleanup
|
||||
if (backupFile.exists()) {
|
||||
ProxyServer.getInstance().getScheduler().schedule(this, () -> {
|
||||
if (backupFile.exists()) backupFile.delete();
|
||||
},1, TimeUnit.MINUTES);
|
||||
}
|
||||
|
||||
// Sofortiger Check
|
||||
checkAndMaybeUpdate();
|
||||
// Regelmäßiger Check
|
||||
ProxyServer.getInstance().getScheduler().schedule(this, this::checkAndMaybeUpdate, 6, 6, TimeUnit.HOURS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
getLogger().info("Stoppe Module...");
|
||||
if (moduleManager != null) {
|
||||
moduleManager.disableAll(this);
|
||||
}
|
||||
|
||||
getLogger().info("Stoppe Web-Server...");
|
||||
if (thread != null) {
|
||||
thread.interrupt();
|
||||
try { thread.join(1000); } catch (InterruptedException ignored) {}
|
||||
}
|
||||
}
|
||||
|
||||
// --- Update Logik (unverändert) ---
|
||||
private void checkAndMaybeUpdate() {
|
||||
try {
|
||||
updateChecker.checkNow();
|
||||
String currentVersion = getDescription() != null ? getDescription().getVersion() : "0.0.0";
|
||||
|
||||
if (updateChecker.isUpdateAvailable(currentVersion)) {
|
||||
String newVersion = updateChecker.getLatestVersion();
|
||||
String url = updateChecker.getLatestUrl();
|
||||
getLogger().warning("----------------------------------------");
|
||||
getLogger().warning("Neue Version verfügbar: " + newVersion);
|
||||
getLogger().warning("Starte automatisches Update...");
|
||||
getLogger().warning("----------------------------------------");
|
||||
|
||||
File pluginFile = getFile();
|
||||
File newFile = new File(pluginFile.getParentFile(), "StatusAPI.jar.new");
|
||||
|
||||
fileDownloader.downloadFile(url, newFile, () -> triggerUpdateScript(pluginFile, newFile));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
getLogger().severe("Fehler beim Update-Check: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private void triggerUpdateScript(File currentFile, File newFile) {
|
||||
try {
|
||||
File pluginsFolder = currentFile.getParentFile();
|
||||
File rootFolder = pluginsFolder.getParentFile();
|
||||
File batFile = new File(rootFolder, "StatusAPI_Update_" + System.currentTimeMillis() + ".bat");
|
||||
|
||||
String batContent = "@echo off\n" +
|
||||
"echo Bitte warten, der Server fährt herunter...\n" +
|
||||
"timeout /t 5 /nobreak >nul\n" +
|
||||
"cd /d \"" + pluginsFolder.getAbsolutePath().replace("\\", "/") + "\"\n" +
|
||||
"echo Fuehre Datei-Tausch durch...\n" +
|
||||
"if exist StatusAPI.jar.bak del StatusAPI.jar.bak\n" +
|
||||
"if exist StatusAPI.jar (\n" +
|
||||
" ren StatusAPI.jar StatusAPI.jar.bak\n" +
|
||||
")\n" +
|
||||
"if exist StatusAPI.new.jar (\n" +
|
||||
" ren StatusAPI.new.jar StatusAPI.jar\n" +
|
||||
" echo Update erfolgreich!\n" +
|
||||
") else (\n" +
|
||||
" echo FEHLER: StatusAPI.new.jar nicht gefunden!\n" +
|
||||
" pause\n" +
|
||||
")\n" +
|
||||
"del \"%~f0\"";
|
||||
|
||||
try (PrintWriter out = new PrintWriter(batFile)) { out.println(batContent); }
|
||||
|
||||
for (ProxiedPlayer p : ProxyServer.getInstance().getPlayers()) {
|
||||
p.disconnect("§cServer fährt für ein Update neu herunter. Bitte etwas warten.");
|
||||
}
|
||||
|
||||
getLogger().info("Starte Update-Skript...");
|
||||
Runtime.getRuntime().exec("cmd /c start \"Update_Proc\" \"" + batFile.getAbsolutePath() + "\"");
|
||||
ProxyServer.getInstance().stop();
|
||||
|
||||
} catch (Exception e) {
|
||||
getLogger().severe("Fehler beim Vorbereiten des Updates: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// --- WebServer & JSON ---
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try (ServerSocket serverSocket = new ServerSocket(port)) {
|
||||
serverSocket.setSoTimeout(1000);
|
||||
while (!Thread.interrupted()) {
|
||||
try {
|
||||
Socket clientSocket = serverSocket.accept();
|
||||
handleConnection(clientSocket);
|
||||
} catch (java.net.SocketTimeoutException e) {}
|
||||
catch (IOException e) {
|
||||
getLogger().warning("Fehler beim Akzeptieren einer Verbindung: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
getLogger().severe("Konnte ServerSocket nicht starten: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Erweiterter HTTP-Handler:
|
||||
* - GET weiterhin liefert Status JSON wie bisher
|
||||
* - POST an /broadcast oder POST an / (Root) wird als Broadcast verarbeitet
|
||||
* (Payload JSON mit message, type, prefix, prefixColor, bracketColor, messageColor)
|
||||
* - Wenn Feld scheduleTime (ms oder s) vorhanden ist, wird Nachricht als geplante Nachricht registriert
|
||||
* und an BroadcastModule.scheduleBroadcast weitergegeben.
|
||||
* - POST /broadcast/cancel erwartet clientScheduleId im Body und ruft cancelScheduled(clientScheduleId) auf.
|
||||
*/
|
||||
private void handleConnection(Socket clientSocket) {
|
||||
try (BufferedReader in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream(), "UTF-8"));
|
||||
OutputStream out = clientSocket.getOutputStream()) {
|
||||
|
||||
String inputLine = in.readLine();
|
||||
if (inputLine == null) return;
|
||||
|
||||
// Request-Line zerlegen: METHOD PATH HTTP/VERSION
|
||||
String[] reqParts = inputLine.split(" ");
|
||||
if (reqParts.length < 2) return;
|
||||
String method = reqParts[0].trim();
|
||||
String path = reqParts[1].trim();
|
||||
|
||||
// Header einlesen (case-insensitive keys)
|
||||
Map<String, String> headers = new HashMap<>();
|
||||
String line;
|
||||
while ((line = in.readLine()) != null && !line.isEmpty()) {
|
||||
int idx = line.indexOf(':');
|
||||
if (idx > 0) {
|
||||
String key = line.substring(0, idx).trim().toLowerCase(Locale.ROOT);
|
||||
String val = line.substring(idx + 1).trim();
|
||||
headers.put(key, val);
|
||||
}
|
||||
}
|
||||
|
||||
// --- POST /broadcast/cancel (optional) ---
|
||||
if ("POST".equalsIgnoreCase(method) && (path.equalsIgnoreCase("/broadcast/cancel") || path.equalsIgnoreCase("/cancel"))) {
|
||||
int contentLength = 0;
|
||||
if (headers.containsKey("content-length")) {
|
||||
try { contentLength = Integer.parseInt(headers.get("content-length")); } catch (NumberFormatException ignored) {}
|
||||
}
|
||||
char[] bodyChars = new char[Math.max(0, contentLength)];
|
||||
if (contentLength > 0) {
|
||||
int read = 0;
|
||||
while (read < contentLength) {
|
||||
int r = in.read(bodyChars, read, contentLength - read);
|
||||
if (r == -1) break;
|
||||
read += r;
|
||||
}
|
||||
}
|
||||
String body = new String(bodyChars);
|
||||
String clientScheduleId = extractJsonString(body, "clientScheduleId");
|
||||
if (clientScheduleId == null || clientScheduleId.isEmpty()) {
|
||||
sendHttpResponse(out, "{\"success\":false,\"error\":\"missing_clientScheduleId\"}", 400);
|
||||
return;
|
||||
}
|
||||
Object mod = moduleManager.getModule("BroadcastModule");
|
||||
if (mod instanceof net.viper.status.modules.broadcast.BroadcastModule) {
|
||||
boolean ok = ((net.viper.status.modules.broadcast.BroadcastModule) mod).cancelScheduled(clientScheduleId);
|
||||
if (ok) sendHttpResponse(out, "{\"success\":true}", 200);
|
||||
else sendHttpResponse(out, "{\"success\":false,\"error\":\"not_found\"}", 404);
|
||||
return;
|
||||
} else {
|
||||
sendHttpResponse(out, "{\"success\":false,\"error\":\"no_broadcast_module\"}", 500);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// --- POST /broadcast oder POST / (Root) für register/send ---
|
||||
if ("POST".equalsIgnoreCase(method) && ("/broadcast".equalsIgnoreCase(path) || "/".equals(path) || path.isEmpty())) {
|
||||
int contentLength = 0;
|
||||
if (headers.containsKey("content-length")) {
|
||||
try { contentLength = Integer.parseInt(headers.get("content-length")); } catch (NumberFormatException ignored) {}
|
||||
}
|
||||
|
||||
char[] bodyChars = new char[Math.max(0, contentLength)];
|
||||
if (contentLength > 0) {
|
||||
int read = 0;
|
||||
while (read < contentLength) {
|
||||
int r = in.read(bodyChars, read, contentLength - read);
|
||||
if (r == -1) break;
|
||||
read += r;
|
||||
}
|
||||
}
|
||||
String body = new String(bodyChars);
|
||||
|
||||
// Header X-Api-Key (case-insensitive)
|
||||
String apiKeyHeader = headers.getOrDefault("x-api-key", headers.getOrDefault("x-apikey", ""));
|
||||
|
||||
// parse minimal JSON fields we need
|
||||
String message = extractJsonString(body, "message");
|
||||
String type = extractJsonString(body, "type");
|
||||
String prefix = extractJsonString(body, "prefix");
|
||||
String prefixColor = extractJsonString(body, "prefixColor");
|
||||
String bracketColor = extractJsonString(body, "bracketColor"); // HINZUGEFÜGT
|
||||
String messageColor = extractJsonString(body, "messageColor");
|
||||
String sourceName = extractJsonString(body, "source");
|
||||
String scheduleTimeStr = extractJsonString(body, "scheduleTime"); // expecting millis OR seconds
|
||||
String recur = extractJsonString(body, "recur");
|
||||
String clientScheduleId = extractJsonString(body, "clientScheduleId");
|
||||
|
||||
if (sourceName == null || sourceName.isEmpty()) sourceName = "PulseCast";
|
||||
if (type == null || type.isEmpty()) type = "global";
|
||||
|
||||
// if scheduleTime present -> register schedule with BroadcastModule
|
||||
if (scheduleTimeStr != null && !scheduleTimeStr.trim().isEmpty()) {
|
||||
long scheduleMillis = 0L;
|
||||
try {
|
||||
// scheduleTime may be numeric string (ms or s)
|
||||
scheduleMillis = Long.parseLong(scheduleTimeStr.trim());
|
||||
// if looks like seconds (less than 1e12), convert to ms
|
||||
if (scheduleMillis < 1_000_000_000_000L) scheduleMillis = scheduleMillis * 1000L;
|
||||
} catch (NumberFormatException ignored) {
|
||||
// try to parse as double then convert
|
||||
try {
|
||||
double d = Double.parseDouble(scheduleTimeStr.trim());
|
||||
long v = (long) d;
|
||||
if (v < 1_000_000_000_000L) v = v * 1000L;
|
||||
scheduleMillis = v;
|
||||
} catch (Exception ex) {
|
||||
sendHttpResponse(out, "{\"success\":false,\"error\":\"bad_scheduleTime\"}", 400);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// BroadcastModule: scheduleBroadcast(timestampMillis, sourceName, message, type, apiKeyHeader, prefix, prefixColor, bracketColor, messageColor, recur, clientId)
|
||||
try {
|
||||
Object mod = moduleManager.getModule("BroadcastModule");
|
||||
if (mod instanceof net.viper.status.modules.broadcast.BroadcastModule) {
|
||||
net.viper.status.modules.broadcast.BroadcastModule bm =
|
||||
(net.viper.status.modules.broadcast.BroadcastModule) mod;
|
||||
|
||||
boolean ok = bm.scheduleBroadcast(scheduleMillis, sourceName, message, type, apiKeyHeader,
|
||||
prefix, prefixColor, bracketColor, messageColor, (recur == null ? "none" : recur), (clientScheduleId == null ? null : clientScheduleId)); // bracketColor HINZUGEFÜGT
|
||||
|
||||
if (ok) {
|
||||
sendHttpResponse(out, "{\"success\":true}", 200);
|
||||
} else {
|
||||
sendHttpResponse(out, "{\"success\":false,\"error\":\"rejected\"}", 403);
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
sendHttpResponse(out, "{\"success\":false,\"error\":\"no_broadcast_module\"}", 500);
|
||||
return;
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
sendHttpResponse(out, "{\"success\":false,\"error\":\"internal\"}", 500);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// If no scheduleTime -> immediate broadcast
|
||||
if (message == null || message.isEmpty()) {
|
||||
String resp = "{\"success\":false,\"error\":\"missing_message\"}";
|
||||
sendHttpResponse(out, resp, 400);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
Object mod = moduleManager.getModule("BroadcastModule");
|
||||
if (mod instanceof net.viper.status.modules.broadcast.BroadcastModule) {
|
||||
net.viper.status.modules.broadcast.BroadcastModule bm =
|
||||
(net.viper.status.modules.broadcast.BroadcastModule) mod;
|
||||
|
||||
boolean ok = bm.handleBroadcast(sourceName, message, type, apiKeyHeader, prefix, prefixColor, bracketColor, messageColor); // bracketColor HINZUGEFÜGT
|
||||
|
||||
if (ok) sendHttpResponse(out, "{\"success\":true}", 200);
|
||||
else sendHttpResponse(out, "{\"success\":false,\"error\":\"rejected\"}", 403);
|
||||
return;
|
||||
} else {
|
||||
sendHttpResponse(out, "{\"success\":false,\"error\":\"no_broadcast_module\"}", 500);
|
||||
return;
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
sendHttpResponse(out, "{\"success\":false,\"error\":\"internal\"}", 500);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// --- bisheriger GET-Handler (unverändert) ---
|
||||
if (inputLine != null && inputLine.startsWith("GET")) {
|
||||
Map<String, Object> data = new LinkedHashMap<>();
|
||||
data.put("online", true);
|
||||
|
||||
// Version & Info
|
||||
String versionRaw = ProxyServer.getInstance().getVersion();
|
||||
String versionClean = (versionRaw != null && versionRaw.contains(":")) ? versionRaw.split(":")[2].trim() : versionRaw;
|
||||
data.put("version", versionClean);
|
||||
data.put("max_players", String.valueOf(ProxyServer.getInstance().getConfig().getPlayerLimit()));
|
||||
|
||||
String motd = "BungeeCord";
|
||||
try {
|
||||
Iterator<ListenerInfo> it = ProxyServer.getInstance().getConfig().getListeners().iterator();
|
||||
if (it.hasNext()) motd = it.next().getMotd();
|
||||
} catch (Exception ignored) {}
|
||||
data.put("motd", motd);
|
||||
|
||||
// StatsModul holen (Service Locator)
|
||||
StatsModule statsModule = (StatsModule) moduleManager.getModule("StatsModule");
|
||||
|
||||
boolean luckPermsEnabled = ProxyServer.getInstance().getPluginManager().getPlugin("LuckPerms") != null;
|
||||
List<Map<String, Object>> playersList = new ArrayList<>();
|
||||
|
||||
for (ProxiedPlayer p : ProxyServer.getInstance().getPlayers()) {
|
||||
Map<String, Object> playerInfo = new LinkedHashMap<>();
|
||||
playerInfo.put("name", p.getName());
|
||||
try { playerInfo.put("uuid", p.getUniqueId().toString()); } catch (Exception ignored) {}
|
||||
|
||||
String prefix = "";
|
||||
if (luckPermsEnabled) {
|
||||
try {
|
||||
Class<?> providerClass = Class.forName("net.luckperms.api.LuckPermsProvider");
|
||||
Object luckPermsApi = providerClass.getMethod("get").invoke(null);
|
||||
Object userManager = luckPermsApi.getClass().getMethod("getUserManager").invoke(luckPermsApi);
|
||||
Object user = userManager.getClass().getMethod("getUser", UUID.class).invoke(userManager, p.getUniqueId());
|
||||
if (user != null) {
|
||||
Class<?> queryOptionsClass = Class.forName("net.luckperms.api.query.QueryOptions");
|
||||
Object queryOptions = queryOptionsClass.getMethod("defaultContextualOptions").invoke(null);
|
||||
Object cachedData = user.getClass().getMethod("getCachedData").invoke(user);
|
||||
Object metaData = cachedData.getClass().getMethod("getMetaData", queryOptionsClass).invoke(cachedData, queryOptions);
|
||||
Object result = metaData.getClass().getMethod("getPrefix").invoke(metaData);
|
||||
if (result != null) prefix = (String) result;
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
playerInfo.put("prefix", prefix);
|
||||
|
||||
// Stats Integration via Modul
|
||||
if (statsModule != null) {
|
||||
PlayerStats ps = statsModule.getManager().getIfPresent(p.getUniqueId());
|
||||
if (ps != null) {
|
||||
playerInfo.put("playtime", ps.getPlaytimeWithCurrentSession());
|
||||
playerInfo.put("joins", ps.joins);
|
||||
playerInfo.put("first_seen", ps.firstSeen);
|
||||
playerInfo.put("last_seen", ps.lastSeen);
|
||||
}
|
||||
}
|
||||
playersList.add(playerInfo);
|
||||
}
|
||||
data.put("players", playersList);
|
||||
|
||||
String json = buildJsonString(data);
|
||||
byte[] jsonBytes = json.getBytes("UTF-8");
|
||||
StringBuilder response = new StringBuilder();
|
||||
response.append("HTTP/1.1 200 OK\r\n");
|
||||
response.append("Content-Type: application/json; charset=UTF-8\r\n");
|
||||
response.append("Access-Control-Allow-Origin: *\r\n");
|
||||
response.append("Content-Length: ").append(jsonBytes.length).append("\r\n");
|
||||
response.append("Connection: close\r\n\r\n");
|
||||
out.write(response.toString().getBytes("UTF-8"));
|
||||
out.write(jsonBytes);
|
||||
out.flush();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
getLogger().severe("Fehler beim Verarbeiten der Anfrage: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Minimaler JSON-String-Extractor (robust genug für einfache Payloads).
|
||||
* Liefert null, wenn Schlüssel nicht gefunden oder kein String-Wert.
|
||||
*/
|
||||
private String extractJsonString(String json, String key) {
|
||||
if (json == null || key == null) return null;
|
||||
String search = "\"" + key + "\"";
|
||||
int idx = json.indexOf(search);
|
||||
if (idx < 0) return null;
|
||||
int colon = json.indexOf(':', idx + search.length());
|
||||
if (colon < 0) return null;
|
||||
int i = colon + 1;
|
||||
// skip spaces
|
||||
while (i < json.length() && Character.isWhitespace(json.charAt(i))) i++;
|
||||
if (i >= json.length()) return null;
|
||||
char c = json.charAt(i);
|
||||
if (c == '"') {
|
||||
i++; // skip opening quote
|
||||
StringBuilder sb = new StringBuilder();
|
||||
boolean escape = false;
|
||||
while (i < json.length()) {
|
||||
char ch = json.charAt(i++);
|
||||
if (escape) {
|
||||
sb.append(ch);
|
||||
escape = false;
|
||||
} else {
|
||||
if (ch == '\\') escape = true;
|
||||
else if (ch == '"') break;
|
||||
else sb.append(ch);
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
} else {
|
||||
// not a quoted string -> read until comma or }
|
||||
StringBuilder sb = new StringBuilder();
|
||||
while (i < json.length()) {
|
||||
char ch = json.charAt(i);
|
||||
if (ch == ',' || ch == '}' || ch == '\n' || ch == '\r') break;
|
||||
sb.append(ch);
|
||||
i++;
|
||||
}
|
||||
return sb.toString().trim();
|
||||
}
|
||||
}
|
||||
|
||||
private void sendHttpResponse(OutputStream out, String json, int code) throws IOException {
|
||||
byte[] jsonBytes = json.getBytes(StandardCharsets.UTF_8);
|
||||
StringBuilder response = new StringBuilder();
|
||||
response.append("HTTP/1.1 ").append(code).append(" ").append(code == 200 ? "OK" : "ERROR").append("\r\n");
|
||||
response.append("Content-Type: application/json; charset=UTF-8\r\n");
|
||||
response.append("Access-Control-Allow-Origin: *\r\n");
|
||||
response.append("Content-Length: ").append(jsonBytes.length).append("\r\n");
|
||||
response.append("Connection: close\r\n\r\n");
|
||||
out.write(response.toString().getBytes(StandardCharsets.UTF_8));
|
||||
out.write(jsonBytes);
|
||||
out.flush();
|
||||
}
|
||||
|
||||
private String buildJsonString(Map<String, Object> data) {
|
||||
StringBuilder sb = new StringBuilder("{");
|
||||
boolean first = true;
|
||||
for (Map.Entry<String, Object> entry : data.entrySet()) {
|
||||
if (!first) sb.append(",");
|
||||
first = false;
|
||||
sb.append("\"").append(escapeJson(entry.getKey())).append("\":").append(valueToString(entry.getValue()));
|
||||
}
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private String valueToString(Object value) {
|
||||
if (value == null) return "null";
|
||||
else if (value instanceof Boolean) return value.toString();
|
||||
else if (value instanceof Number) return value.toString();
|
||||
else if (value instanceof Map) {
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> m = (Map<String, Object>) value;
|
||||
return buildJsonString(m);
|
||||
} else if (value instanceof List) {
|
||||
StringBuilder sb = new StringBuilder("[");
|
||||
List<?> list = (List<?>) value;
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
if (i > 0) sb.append(",");
|
||||
Object item = list.get(i);
|
||||
if (item instanceof Map) sb.append(buildJsonString((Map<String, Object>) item));
|
||||
else if (item instanceof Number) sb.append(item.toString());
|
||||
else sb.append("\"").append(escapeJson(String.valueOf(item))).append("\"");
|
||||
}
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
else return "\"" + escapeJson(String.valueOf(value)) + "\"";
|
||||
}
|
||||
|
||||
private String escapeJson(String s) {
|
||||
if (s == null) return "";
|
||||
return s.replace("\\", "\\\\").replace("\"", "\\\"").replace("\n", "\\n").replace("\r", "\\r");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,381 @@
|
||||
package net.viper.status.modules.broadcast;
|
||||
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.api.plugin.Listener;
|
||||
import net.viper.status.module.Module;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* BroadcastModule
|
||||
*
|
||||
* Speichert geplante Broadcasts jetzt persistent in 'broadcasts.schedules'.
|
||||
* Beim Neustart werden diese automatisch wieder geladen.
|
||||
*/
|
||||
public class BroadcastModule implements Module, Listener {
|
||||
|
||||
private Plugin plugin;
|
||||
private boolean enabled = true;
|
||||
private String requiredApiKey = "";
|
||||
private String format = "%prefix% %message%";
|
||||
private String fallbackPrefix = "[Broadcast]";
|
||||
private String fallbackPrefixColor = "&c";
|
||||
private String fallbackBracketColor = "&8"; // Neu
|
||||
private String fallbackMessageColor = "&f";
|
||||
|
||||
private final Map<String, ScheduledBroadcast> scheduledByClientId = new ConcurrentHashMap<>();
|
||||
private File schedulesFile;
|
||||
private final SimpleDateFormat dateFormat;
|
||||
|
||||
public BroadcastModule() {
|
||||
dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
|
||||
dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "BroadcastModule";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable(Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
schedulesFile = new File(plugin.getDataFolder(), "broadcasts.schedules");
|
||||
loadConfig();
|
||||
|
||||
if (!enabled) {
|
||||
plugin.getLogger().info("[BroadcastModule] deaktiviert via verify.properties (broadcast.enabled=false)");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
plugin.getProxy().getPluginManager().registerListener(plugin, this);
|
||||
} catch (Throwable ignored) {}
|
||||
|
||||
plugin.getLogger().info("[BroadcastModule] aktiviert. Format: " + format);
|
||||
loadSchedules();
|
||||
plugin.getProxy().getScheduler().schedule(plugin, this::processScheduled, 1, 1, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable(Plugin plugin) {
|
||||
plugin.getLogger().info("[BroadcastModule] deaktiviert.");
|
||||
saveSchedules();
|
||||
scheduledByClientId.clear();
|
||||
}
|
||||
|
||||
private void loadConfig() {
|
||||
File file = new File(plugin.getDataFolder(), "verify.properties");
|
||||
if (!file.exists()) {
|
||||
enabled = true;
|
||||
requiredApiKey = "";
|
||||
format = "%prefix% %message%";
|
||||
fallbackPrefix = "[Broadcast]";
|
||||
fallbackPrefixColor = "&c";
|
||||
fallbackBracketColor = "&8"; // Neu
|
||||
fallbackMessageColor = "&f";
|
||||
return;
|
||||
}
|
||||
|
||||
try (InputStream in = new FileInputStream(file)) {
|
||||
Properties props = new Properties();
|
||||
props.load(new InputStreamReader(in, StandardCharsets.UTF_8));
|
||||
enabled = Boolean.parseBoolean(props.getProperty("broadcast.enabled", "true"));
|
||||
requiredApiKey = props.getProperty("broadcast.api_key", "").trim();
|
||||
format = props.getProperty("broadcast.format", format).trim();
|
||||
if (format.isEmpty()) format = "%prefix% %message%";
|
||||
fallbackPrefix = props.getProperty("broadcast.prefix", fallbackPrefix).trim();
|
||||
fallbackPrefixColor = props.getProperty("broadcast.prefix-color", fallbackPrefixColor).trim();
|
||||
fallbackBracketColor = props.getProperty("broadcast.bracket-color", fallbackBracketColor).trim(); // Neu
|
||||
fallbackMessageColor = props.getProperty("broadcast.message-color", fallbackMessageColor).trim();
|
||||
} catch (IOException e) {
|
||||
plugin.getLogger().warning("[BroadcastModule] Fehler beim Laden von verify.properties: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean handleBroadcast(String sourceName, String message, String type, String apiKeyHeader,
|
||||
String prefix, String prefixColor, String bracketColor, String messageColor) {
|
||||
loadConfig();
|
||||
|
||||
if (!enabled) {
|
||||
plugin.getLogger().info("[BroadcastModule] Broadcast abgelehnt: Modul ist deaktiviert.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (requiredApiKey != null && !requiredApiKey.isEmpty()) {
|
||||
if (apiKeyHeader == null || !requiredApiKey.equals(apiKeyHeader)) {
|
||||
plugin.getLogger().warning("[BroadcastModule] Broadcast abgelehnt: API-Key fehlt oder inkorrekt.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (message == null) message = "";
|
||||
if (sourceName == null || sourceName.isEmpty()) sourceName = "System";
|
||||
if (type == null) type = "global";
|
||||
|
||||
String usedPrefix = (prefix != null && !prefix.trim().isEmpty()) ? prefix.trim() : fallbackPrefix;
|
||||
String usedPrefixColor = (prefixColor != null && !prefixColor.trim().isEmpty()) ? prefixColor.trim() : fallbackPrefixColor;
|
||||
String usedBracketColor = (bracketColor != null && !bracketColor.trim().isEmpty()) ? bracketColor.trim() : fallbackBracketColor; // Neu
|
||||
String usedMessageColor = (messageColor != null && !messageColor.trim().isEmpty()) ? messageColor.trim() : fallbackMessageColor;
|
||||
|
||||
String prefixColorCode = normalizeColorCode(usedPrefixColor);
|
||||
String bracketColorCode = normalizeColorCode(usedBracketColor); // Neu
|
||||
String messageColorCode = normalizeColorCode(usedMessageColor);
|
||||
|
||||
// --- KLAMMER LOGIK ---
|
||||
String finalPrefix;
|
||||
|
||||
// Wenn eine Klammerfarbe gesetzt ist, bauen wir den Prefix neu zusammen
|
||||
// Format: [BracketColor][ [PrefixColor]Text [BracketColor]]
|
||||
if (!bracketColorCode.isEmpty()) {
|
||||
String textContent = usedPrefix;
|
||||
// Entferne manuelle Klammern, falls der User [Broadcast] in das Textfeld geschrieben hat
|
||||
if (textContent.startsWith("[")) textContent = textContent.substring(1);
|
||||
if (textContent.endsWith("]")) textContent = textContent.substring(0, textContent.length() - 1);
|
||||
|
||||
finalPrefix = bracketColorCode + "[" + prefixColorCode + textContent + bracketColorCode + "]" + ChatColor.RESET;
|
||||
} else {
|
||||
// Altes Verhalten: Ganzen String einfärben
|
||||
finalPrefix = prefixColorCode + usedPrefix + ChatColor.RESET;
|
||||
}
|
||||
// ---------------------
|
||||
|
||||
String coloredMessage = (messageColorCode.isEmpty() ? "" : messageColorCode) + message;
|
||||
|
||||
String out = format.replace("%name%", sourceName)
|
||||
.replace("%prefix%", finalPrefix) // Neu verwendete Variable
|
||||
.replace("%prefixColored%", finalPrefix) // Fallback
|
||||
.replace("%message%", message)
|
||||
.replace("%messageColored%", coloredMessage)
|
||||
.replace("%type%", type);
|
||||
|
||||
if (!out.contains("%prefixColored%") && !out.contains("%messageColored%") && !out.contains("%prefix%") && !out.contains("%message%")) {
|
||||
out = finalPrefix + " " + coloredMessage;
|
||||
}
|
||||
|
||||
TextComponent tc = new TextComponent(out);
|
||||
int sent = 0;
|
||||
for (ProxiedPlayer p : plugin.getProxy().getPlayers()) {
|
||||
try { p.sendMessage(tc); sent++; } catch (Throwable ignored) {}
|
||||
}
|
||||
|
||||
plugin.getLogger().info("[BroadcastModule] Broadcast gesendet (Empfänger=" + sent + "): " + message);
|
||||
return true;
|
||||
}
|
||||
|
||||
private String normalizeColorCode(String code) {
|
||||
if (code == null) return "";
|
||||
code = code.trim();
|
||||
if (code.isEmpty()) return "";
|
||||
return code.contains("&") ? ChatColor.translateAlternateColorCodes('&', code) : code;
|
||||
}
|
||||
|
||||
private void saveSchedules() {
|
||||
Properties props = new Properties();
|
||||
for (Map.Entry<String, ScheduledBroadcast> entry : scheduledByClientId.entrySet()) {
|
||||
String id = entry.getKey();
|
||||
ScheduledBroadcast sb = entry.getValue();
|
||||
props.setProperty(id + ".nextRunMillis", String.valueOf(sb.nextRunMillis));
|
||||
props.setProperty(id + ".sourceName", sb.sourceName);
|
||||
props.setProperty(id + ".message", sb.message);
|
||||
props.setProperty(id + ".type", sb.type);
|
||||
props.setProperty(id + ".prefix", sb.prefix);
|
||||
props.setProperty(id + ".prefixColor", sb.prefixColor);
|
||||
props.setProperty(id + ".bracketColor", sb.bracketColor); // Neu
|
||||
props.setProperty(id + ".messageColor", sb.messageColor);
|
||||
props.setProperty(id + ".recur", sb.recur);
|
||||
}
|
||||
|
||||
try (OutputStream out = new FileOutputStream(schedulesFile)) {
|
||||
props.store(out, "PulseCast Scheduled Broadcasts");
|
||||
} catch (IOException e) {
|
||||
plugin.getLogger().severe("[BroadcastModule] Konnte Schedules nicht speichern: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private void loadSchedules() {
|
||||
if (!schedulesFile.exists()) {
|
||||
plugin.getLogger().info("[BroadcastModule] Keine bestehenden Schedules gefunden (Neustart).");
|
||||
return;
|
||||
}
|
||||
|
||||
Properties props = new Properties();
|
||||
try (InputStream in = new FileInputStream(schedulesFile)) {
|
||||
props.load(in);
|
||||
} catch (IOException e) {
|
||||
plugin.getLogger().severe("[BroadcastModule] Konnte Schedules nicht laden: " + e.getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
Map<String, ScheduledBroadcast> loaded = new HashMap<>();
|
||||
for (String key : props.stringPropertyNames()) {
|
||||
if (!key.contains(".")) continue;
|
||||
String[] parts = key.split("\\.");
|
||||
if (parts.length != 2) continue;
|
||||
|
||||
String id = parts[0];
|
||||
String field = parts[1];
|
||||
String value = props.getProperty(key);
|
||||
|
||||
ScheduledBroadcast sb = loaded.get(id);
|
||||
if (sb == null) {
|
||||
sb = new ScheduledBroadcast(id, 0, "", "", "", "", "", "", "", ""); // Ein leerer String mehr für Bracket
|
||||
loaded.put(id, sb);
|
||||
}
|
||||
|
||||
switch (field) {
|
||||
case "nextRunMillis":
|
||||
try { sb.nextRunMillis = Long.parseLong(value); } catch (NumberFormatException ignored) {}
|
||||
break;
|
||||
case "sourceName": sb.sourceName = value; break;
|
||||
case "message": sb.message = value; break;
|
||||
case "type": sb.type = value; break;
|
||||
case "prefix": sb.prefix = value; break;
|
||||
case "prefixColor": sb.prefixColor = value; break;
|
||||
case "bracketColor": sb.bracketColor = value; break; // Neu
|
||||
case "messageColor": sb.messageColor = value; break;
|
||||
case "recur": sb.recur = value; break;
|
||||
}
|
||||
}
|
||||
scheduledByClientId.putAll(loaded);
|
||||
plugin.getLogger().info("[BroadcastModule] " + loaded.size() + " geplante Broadcasts aus Datei wiederhergestellt.");
|
||||
}
|
||||
|
||||
public boolean scheduleBroadcast(long timestampMillis, String sourceName, String message, String type,
|
||||
String apiKeyHeader, String prefix, String prefixColor, String bracketColor, String messageColor,
|
||||
String recur, String clientScheduleId) {
|
||||
loadConfig();
|
||||
|
||||
if (!enabled) {
|
||||
plugin.getLogger().info("[BroadcastModule] schedule abgelehnt: Modul deaktiviert.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (requiredApiKey != null && !requiredApiKey.isEmpty()) {
|
||||
if (apiKeyHeader == null || !requiredApiKey.equals(apiKeyHeader)) {
|
||||
plugin.getLogger().warning("[BroadcastModule] schedule abgelehnt: API-Key fehlt oder inkorrekt.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (message == null) message = "";
|
||||
if (sourceName == null || sourceName.isEmpty()) sourceName = "System";
|
||||
if (type == null) type = "global";
|
||||
if (recur == null) recur = "none";
|
||||
|
||||
String id = (clientScheduleId != null && !clientScheduleId.trim().isEmpty()) ? clientScheduleId.trim() : UUID.randomUUID().toString();
|
||||
|
||||
long now = System.currentTimeMillis();
|
||||
String scheduledTimeStr = dateFormat.format(new Date(timestampMillis));
|
||||
|
||||
plugin.getLogger().info("[BroadcastModule] Neue geplante Nachricht registriert: " + id + " @ " + scheduledTimeStr);
|
||||
|
||||
if (timestampMillis <= now) {
|
||||
plugin.getLogger().warning("[BroadcastModule] Geplante Zeit liegt in der Vergangenheit -> sende sofort!");
|
||||
return handleBroadcast(sourceName, message, type, apiKeyHeader, prefix, prefixColor, bracketColor, messageColor);
|
||||
}
|
||||
|
||||
ScheduledBroadcast sb = new ScheduledBroadcast(id, timestampMillis, sourceName, message, type, prefix, prefixColor, bracketColor, messageColor, recur);
|
||||
scheduledByClientId.put(id, sb);
|
||||
saveSchedules();
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean cancelScheduled(String clientScheduleId) {
|
||||
if (clientScheduleId == null || clientScheduleId.trim().isEmpty()) return false;
|
||||
ScheduledBroadcast removed = scheduledByClientId.remove(clientScheduleId);
|
||||
if (removed != null) {
|
||||
plugin.getLogger().info("[BroadcastModule] Geplante Nachricht abgebrochen: id=" + clientScheduleId);
|
||||
saveSchedules();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void processScheduled() {
|
||||
if (scheduledByClientId.isEmpty()) return;
|
||||
|
||||
long now = System.currentTimeMillis();
|
||||
List<String> toRemove = new ArrayList<>();
|
||||
boolean changed = false;
|
||||
|
||||
for (Map.Entry<String, ScheduledBroadcast> entry : scheduledByClientId.entrySet()) {
|
||||
ScheduledBroadcast sb = entry.getValue();
|
||||
|
||||
if (sb.nextRunMillis <= now) {
|
||||
String timeStr = dateFormat.format(new Date(sb.nextRunMillis));
|
||||
plugin.getLogger().info("[BroadcastModule] ⏰ Sende geplante Nachricht (ID: " + entry.getKey() + ", Zeit: " + timeStr + ")");
|
||||
|
||||
handleBroadcast(sb.sourceName, sb.message, sb.type, "", sb.prefix, sb.prefixColor, sb.bracketColor, sb.messageColor);
|
||||
|
||||
if (!"none".equalsIgnoreCase(sb.recur)) {
|
||||
long next = computeNextMillis(sb.nextRunMillis, sb.recur);
|
||||
if (next > 0) {
|
||||
sb.nextRunMillis = next;
|
||||
String nextTimeStr = dateFormat.format(new Date(next));
|
||||
plugin.getLogger().info("[BroadcastModule] Nächste Wiederholung (" + sb.recur + "): " + nextTimeStr);
|
||||
changed = true;
|
||||
} else {
|
||||
toRemove.add(entry.getKey());
|
||||
changed = true;
|
||||
}
|
||||
} else {
|
||||
toRemove.add(entry.getKey());
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (changed || !toRemove.isEmpty()) {
|
||||
for (String k : toRemove) {
|
||||
scheduledByClientId.remove(k);
|
||||
plugin.getLogger().info("[BroadcastModule] Schedule entfernt: " + k);
|
||||
}
|
||||
saveSchedules();
|
||||
}
|
||||
}
|
||||
|
||||
private long computeNextMillis(long currentMillis, String recur) {
|
||||
switch (recur.toLowerCase(Locale.ROOT)) {
|
||||
case "hourly": return currentMillis + TimeUnit.HOURS.toMillis(1);
|
||||
case "daily": return currentMillis + TimeUnit.DAYS.toMillis(1);
|
||||
case "weekly": return currentMillis + TimeUnit.DAYS.toMillis(7);
|
||||
default: return -1L;
|
||||
}
|
||||
}
|
||||
|
||||
private static class ScheduledBroadcast {
|
||||
final String clientId;
|
||||
long nextRunMillis;
|
||||
String sourceName;
|
||||
String message;
|
||||
String type;
|
||||
String prefix;
|
||||
String prefixColor;
|
||||
String bracketColor; // Neu
|
||||
String messageColor;
|
||||
String recur;
|
||||
|
||||
ScheduledBroadcast(String clientId, long nextRunMillis, String sourceName, String message, String type,
|
||||
String prefix, String prefixColor, String bracketColor, String messageColor, String recur) {
|
||||
this.clientId = clientId;
|
||||
this.nextRunMillis = nextRunMillis;
|
||||
this.sourceName = sourceName;
|
||||
this.message = message;
|
||||
this.type = type;
|
||||
this.prefix = prefix;
|
||||
this.prefixColor = prefixColor;
|
||||
this.bracketColor = bracketColor; // Neu
|
||||
this.messageColor = messageColor;
|
||||
this.recur = (recur == null ? "none" : recur);
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,56 +1,56 @@
|
||||
name: StatusAPI
|
||||
main: net.viper.status.StatusAPI
|
||||
version: 4.0.0
|
||||
author: M_Viper
|
||||
description: StatusAPI für BungeeCord inkl. Update-Checker und Modul-System
|
||||
|
||||
softdepend:
|
||||
- LuckPerms
|
||||
|
||||
commands:
|
||||
# Verify Modul Befehle
|
||||
verify:
|
||||
description: Verifiziere dich mit einem Token
|
||||
usage: /verify <token>
|
||||
|
||||
# GlobalChat Modul Befehle
|
||||
globalreload:
|
||||
description: Lädt den Chat-Filter neu
|
||||
usage: /globalreload
|
||||
permission: globalchat.reload
|
||||
|
||||
globalmute:
|
||||
description: Schaltet den globalen Chat an/aus
|
||||
usage: /globalmute
|
||||
permission: globalchat.mute
|
||||
|
||||
support:
|
||||
description: Sendet eine Support-Nachricht an das Team
|
||||
usage: /support <Nachricht>
|
||||
|
||||
reply:
|
||||
description: Antwortet auf eine Support-Nachricht
|
||||
usage: /reply <Nachricht>
|
||||
|
||||
info:
|
||||
description: Zeigt Plugin-Informationen an
|
||||
usage: /info
|
||||
|
||||
permissions:
|
||||
# StatusAPI Core Permissions
|
||||
statusapi.update.notify:
|
||||
description: 'Erlaubt Update-Benachrichtigungen'
|
||||
default: op
|
||||
|
||||
# GlobalChat Permissions
|
||||
globalchat.reload:
|
||||
description: Erlaubt das Neuladen des Chat-Filters
|
||||
default: op
|
||||
|
||||
globalchat.mute:
|
||||
description: Erlaubt das Aktivieren/Deaktivieren des globalen Mutes
|
||||
default: op
|
||||
|
||||
globalchat.bypass:
|
||||
description: Umgeht den globalen Mute
|
||||
name: StatusAPI
|
||||
main: net.viper.status.StatusAPI
|
||||
version: 4.0.5
|
||||
author: M_Viper
|
||||
description: StatusAPI für BungeeCord inkl. Update-Checker und Modul-System
|
||||
|
||||
softdepend:
|
||||
- LuckPerms
|
||||
|
||||
commands:
|
||||
# Verify Modul Befehle
|
||||
verify:
|
||||
description: Verifiziere dich mit einem Token
|
||||
usage: /verify <token>
|
||||
|
||||
# GlobalChat Modul Befehle
|
||||
globalreload:
|
||||
description: Lädt den Chat-Filter neu
|
||||
usage: /globalreload
|
||||
permission: globalchat.reload
|
||||
|
||||
globalmute:
|
||||
description: Schaltet den globalen Chat an/aus
|
||||
usage: /globalmute
|
||||
permission: globalchat.mute
|
||||
|
||||
support:
|
||||
description: Sendet eine Support-Nachricht an das Team
|
||||
usage: /support <Nachricht>
|
||||
|
||||
reply:
|
||||
description: Antwortet auf eine Support-Nachricht
|
||||
usage: /reply <Nachricht>
|
||||
|
||||
info:
|
||||
description: Zeigt Plugin-Informationen an
|
||||
usage: /info
|
||||
|
||||
permissions:
|
||||
# StatusAPI Core Permissions
|
||||
statusapi.update.notify:
|
||||
description: 'Erlaubt Update-Benachrichtigungen'
|
||||
default: op
|
||||
|
||||
# GlobalChat Permissions
|
||||
globalchat.reload:
|
||||
description: Erlaubt das Neuladen des Chat-Filters
|
||||
default: op
|
||||
|
||||
globalchat.mute:
|
||||
description: Erlaubt das Aktivieren/Deaktivieren des globalen Mutes
|
||||
default: op
|
||||
|
||||
globalchat.bypass:
|
||||
description: Umgeht den globalen Mute
|
||||
default: op
|
||||
@@ -1,39 +1,76 @@
|
||||
# ===========================
|
||||
# GLOBALCHAT AKTIVIERUNG
|
||||
# ===========================
|
||||
chat.enabled=false
|
||||
|
||||
# ===========================
|
||||
# NAVIGATION / SERVER SWITCHER
|
||||
# ===========================
|
||||
# Hier kannst du das interne Navigationssystem aktivieren/deaktivieren.
|
||||
# Wenn aktiviert, erstellt das Plugin automatisch Befehle basierend auf den Servernamen (z.B. /lobby, /survival).
|
||||
navigation.enabled=false
|
||||
|
||||
# ===========================
|
||||
# WORDPRESS / VERIFY EINSTELLUNGEN
|
||||
# ===========================
|
||||
wp_verify_url=https://deine-wp-domain.tld
|
||||
|
||||
# ===========================
|
||||
# SERVER KONFIGURATION
|
||||
# ===========================
|
||||
# Hier legst du für jeden Server alles fest:
|
||||
# 1. Den Anzeigenamen für den Chat (z.B. &bLobby)
|
||||
# 2. Die Server ID für WordPress (z.B. id=1)
|
||||
# 3. Das Secret für WordPress (z.B. secret=...)
|
||||
|
||||
# Server 1: Lobby
|
||||
server.lobby=&bLobby
|
||||
server.lobby.id=1
|
||||
server.lobby.secret=GeheimesWortFuerLobby123
|
||||
|
||||
# Server 2: Survival
|
||||
server.survival=&aSurvival
|
||||
server.survival.id=2
|
||||
server.survival.secret=GeheimesWortFuerSurvival456
|
||||
|
||||
# Server 3: SkyBlock
|
||||
server.skyblock=&dSkyBlock
|
||||
server.skyblock.id=3
|
||||
server.skyblock.secret=GeheimesWortFuerSkyBlock789
|
||||
# ===========================
|
||||
# GLOBALCHAT AKTIVIERUNG
|
||||
# ===========================
|
||||
chat.enabled=false
|
||||
|
||||
# ------------------------------
|
||||
# Broadcast
|
||||
# ------------------------------
|
||||
|
||||
broadcast.enabled=false
|
||||
broadcast.prefix=[Broadcast]
|
||||
broadcast.prefix-color=&c
|
||||
broadcast.message-color=&f
|
||||
broadcast.format=%prefixColored% %messageColored%
|
||||
# broadcast.format kann angepasst werden; nutze Platzhalter: %name%, %prefix%, %prefixColored%, %message%, %messageColored%, %type%
|
||||
|
||||
# ===========================
|
||||
# NAVIGATION / SERVER SWITCHER
|
||||
# ===========================
|
||||
# Hier kannst du das interne Navigationssystem aktivieren/deaktivieren.
|
||||
# Wenn aktiviert, erstellt das Plugin automatisch Befehle basierend auf den Servernamen (z.B. /lobby, /survival).
|
||||
navigation.enabled=false
|
||||
|
||||
# ===========================
|
||||
# WORDPRESS / VERIFY EINSTELLUNGEN
|
||||
# ===========================
|
||||
wp_verify_url=https://deine-wp-domain.tld
|
||||
|
||||
# ===========================
|
||||
# SERVER KONFIGURATION
|
||||
# ===========================
|
||||
# Hier legst du für jeden Server alles fest:
|
||||
# 1. Den Anzeigenamen für den Chat (z.B. &bLobby)
|
||||
# 2. Die Server ID für WordPress (z.B. id=1)
|
||||
# 3. Das Secret für WordPress (z.B. secret=...)
|
||||
|
||||
# Server 1: Lobby
|
||||
server.lobby=&bLobby
|
||||
server.lobby.id=1
|
||||
server.lobby.secret=GeheimesWortFuerLobby123
|
||||
|
||||
# Server 2: Survival
|
||||
server.survival=&aSurvival
|
||||
server.survival.id=2
|
||||
server.survival.secret=GeheimesWortFuerSurvival456
|
||||
|
||||
# Server 3: SkyBlock
|
||||
server.skyblock=&dSkyBlock
|
||||
server.skyblock.id=3
|
||||
server.skyblock.secret=GeheimesWortFuerSkyBlock789
|
||||
|
||||
# ===========================
|
||||
# Manuelle Ränge (Overrides)
|
||||
# ===========================
|
||||
# Syntax: override.<Spieler-UUID> = <Gruppenname>
|
||||
# WICHTIG: Die Gruppe (z.B. Owner) muss unten bei groupformat definiert sein!
|
||||
|
||||
# Beispiel: Deinen UUID hier einfügen
|
||||
override.uuid-hier-einfügen = Owner
|
||||
override.uuid-hier-einfügen = Admin
|
||||
override.uuid-hier-einfügen = Developer
|
||||
|
||||
# ===========================
|
||||
# Chat-Formate für Gruppen
|
||||
# ===========================
|
||||
|
||||
# Der Name hinter dem Punkt (z.B. Owner) muss exakt mit der LuckPerms Gruppe übereinstimmen.
|
||||
# Nutze & für Farbcodes.
|
||||
|
||||
# Ränge mit neuer Syntax: Rank || Spielerfarbe || Chatfarbe
|
||||
# Beispiel: Rot (Rang) || Blau (Name) || Lila (Chat)
|
||||
groupformat.owner=&c[Owner] || &b || &d
|
||||
groupformat.admin=&4[Admin] || &9 || &c
|
||||
groupformat.developer=&b[Dev] || &3 || &a
|
||||
groupformat.premium=&6[Premium] || &e || &7
|
||||
groupformat.spieler=&f[Spieler] || &7 || &8
|
||||
Reference in New Issue
Block a user