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
|
# 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.
|
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
|
## 💻 Befehle
|
||||||
|
|
||||||
Die meisten Befehle werden dynamisch basierend auf deiner `verify.properties` erstellt.
|
|
||||||
|
|
||||||
| Befehl | Beschreibung | Permission |
|
| Befehl | Beschreibung | Permission |
|
||||||
|--------|--------------|------------|
|
|--------|--------------|------------|
|
||||||
| `/verify <token>` | Verifiziert den Spieler mit der WordPress-Seite | - |
|
| `/verify <token>` | Verifiziert den Spieler mit der WordPress-Seite | - |
|
||||||
| `/survival` / `/lobby` | Führt dich auf den entsprechenden Server um (wird dynamisch erstellt) | - |
|
| `/survival` / `/lobby` | Führt dich auf den entsprechenden Server um (wird dynamisch erstellt) | - |
|
||||||
| `/globalmute` | Aktiviert oder deaktiviert den globalen Chat | `globalchat.mute` |
|
| `/globalmute` | Aktiviert oder deaktiviert den globalen Chat | `globalchat.mute` |
|
||||||
| `/globalreload` | Lädt Filter und Konfigurationen neu | `globalchat.reload` |
|
| `/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 | - |
|
| `/support <msg>` | Sendet eine Nachricht an das Online-Team | - |
|
||||||
| `/reply <msg>` | Antwortet auf eine Support-Anfrage | - |
|
| `/reply <msg>` | Antwortet auf eine Support-Anfrage | - |
|
||||||
| `/info` | Zeigt Plugin-Informationen an | - |
|
| `/info` | Zeigt Plugin-Informationen an | - |
|
||||||
@@ -136,6 +136,7 @@ moduleManager.registerModule(new MeinModul());
|
|||||||
- `globalchat.mute` - Erlaubt das Stummschalten des Chats
|
- `globalchat.mute` - Erlaubt das Stummschalten des Chats
|
||||||
- `globalchat.bypass` - Erlaubt das Schreiben, auch wenn der Chat gemuted ist
|
- `globalchat.bypass` - Erlaubt das Schreiben, auch wenn der Chat gemuted ist
|
||||||
- `globalchat.reload` - Erlaubt das Neuladen der Konfiguration
|
- `globalchat.reload` - Erlaubt das Neuladen der Konfiguration
|
||||||
|
- `globalchat.clear` - Löscht den Kompletten Chatverlauf
|
||||||
|
|
||||||
## 🤝 Credits
|
## 🤝 Credits
|
||||||
|
|
||||||
|
|||||||
102
pom.xml
102
pom.xml
@@ -1,52 +1,52 @@
|
|||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
|
||||||
https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<groupId>net.viper.bungee</groupId>
|
<groupId>net.viper.bungee</groupId>
|
||||||
<artifactId>StatusAPI</artifactId>
|
<artifactId>StatusAPI</artifactId>
|
||||||
<version>4.0.0</version>
|
<version>4.0.5</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>StatusAPI</name>
|
<name>StatusAPI</name>
|
||||||
<description>BungeeCord Status API Plugin</description>
|
<description>BungeeCord Status API Plugin</description>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>8</maven.compiler.source>
|
<maven.compiler.source>8</maven.compiler.source>
|
||||||
<maven.compiler.target>8</maven.compiler.target>
|
<maven.compiler.target>8</maven.compiler.target>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<!-- BungeeCord API -->
|
<!-- BungeeCord API -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.md-5</groupId>
|
<groupId>net.md-5</groupId>
|
||||||
<artifactId>bungeecord-api</artifactId>
|
<artifactId>bungeecord-api</artifactId>
|
||||||
<version>1.20</version>
|
<version>1.20</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- LuckPerms API (Optional) -->
|
<!-- LuckPerms API (Optional) -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.luckperms</groupId>
|
<groupId>net.luckperms</groupId>
|
||||||
<artifactId>api</artifactId>
|
<artifactId>api</artifactId>
|
||||||
<version>5.4</version>
|
<version>5.4</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<finalName>StatusAPI</finalName>
|
<finalName>StatusAPI</finalName>
|
||||||
|
|
||||||
<resources>
|
<resources>
|
||||||
<resource>
|
<resource>
|
||||||
<directory>src/main/resources</directory>
|
<directory>src/main/resources</directory>
|
||||||
<filtering>false</filtering>
|
<filtering>false</filtering>
|
||||||
</resource>
|
</resource>
|
||||||
</resources>
|
</resources>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
@@ -1,310 +1,552 @@
|
|||||||
package net.viper.status;
|
package net.viper.status;
|
||||||
|
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
import net.md_5.bungee.api.config.ListenerInfo;
|
import net.md_5.bungee.api.config.ListenerInfo;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
import net.md_5.bungee.api.plugin.Plugin;
|
import net.md_5.bungee.api.plugin.Plugin;
|
||||||
import net.viper.status.module.ModuleManager;
|
import net.viper.status.module.ModuleManager;
|
||||||
import net.viper.status.stats.PlayerStats;
|
import net.viper.status.stats.PlayerStats;
|
||||||
import net.viper.status.stats.StatsModule;
|
import net.viper.status.stats.StatsModule;
|
||||||
import net.viper.status.modules.verify.VerifyModule;
|
import net.viper.status.modules.verify.VerifyModule;
|
||||||
import net.viper.status.modules.globalchat.GlobalChatModule;
|
import net.viper.status.modules.globalchat.GlobalChatModule;
|
||||||
import net.viper.status.modules.navigation.NavigationModule;
|
import net.viper.status.modules.navigation.NavigationModule;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.net.ServerSocket;
|
import java.net.ServerSocket;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.util.*;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
public class StatusAPI extends Plugin implements Runnable {
|
|
||||||
|
/**
|
||||||
private Thread thread;
|
* StatusAPI - zentraler Bungee HTTP-Status- und Broadcast-Endpunkt
|
||||||
private int port = 9191;
|
*
|
||||||
|
* Ergänzungen:
|
||||||
// Das neue Modul-System
|
* - BroadcastModule Registrierung
|
||||||
private ModuleManager moduleManager;
|
* - POST /broadcast UND POST / (Root) werden als Broadcasts behandelt
|
||||||
|
* - Unterstützung für prefix, prefixColor, messageColor Felder in JSON-Payload
|
||||||
// Alte Komponenten (UpdateChecker/FileDownloader bleiben hier, da sie Core-Updates steuern)
|
* - Unterstützung für bracketColor (neu)
|
||||||
private UpdateChecker updateChecker;
|
* - Unterstützung für scheduleTime (ms oder s), recur, clientScheduleId
|
||||||
private FileDownloader fileDownloader;
|
* - API-Key Header (X-Api-Key) wird an BroadcastModule weitergereicht
|
||||||
|
*/
|
||||||
@Override
|
public class StatusAPI extends Plugin implements Runnable {
|
||||||
public void onEnable() {
|
|
||||||
getLogger().info("StatusAPI Core wird initialisiert...");
|
private Thread thread;
|
||||||
|
private int port = 9191;
|
||||||
// 1. Ordner sicherstellen
|
|
||||||
if (!getDataFolder().exists()) {
|
// Das neue Modul-System
|
||||||
getDataFolder().mkdirs();
|
private ModuleManager moduleManager;
|
||||||
}
|
|
||||||
|
// Alte Komponenten (UpdateChecker/FileDownloader bleiben hier, da sie Core-Updates steuern)
|
||||||
// 2. Modul-System starten
|
private UpdateChecker updateChecker;
|
||||||
moduleManager = new ModuleManager();
|
private FileDownloader fileDownloader;
|
||||||
|
|
||||||
// 3. MODULE REGISTRIEREN (Hier erweiterst du die API in Zukunft!)
|
@Override
|
||||||
// Um ein neues Feature hinzuzufügen, erstelle eine Klasse, die 'Module' implementiert
|
public void onEnable() {
|
||||||
// und füge hier eine Zeile hinzu: moduleManager.registerModule(new MeinNeuesModul());
|
getLogger().info("StatusAPI Core wird initialisiert...");
|
||||||
|
|
||||||
moduleManager.registerModule(new StatsModule()); // Statistik System laden
|
// 1. Ordner sicherstellen
|
||||||
|
if (!getDataFolder().exists()) {
|
||||||
moduleManager.registerModule(new VerifyModule()); // Verify Modul
|
getDataFolder().mkdirs();
|
||||||
|
}
|
||||||
moduleManager.registerModule(new GlobalChatModule()); // GlobalChat
|
|
||||||
|
// 2. Modul-System starten
|
||||||
moduleManager.registerModule(new NavigationModule()); //Server Switcher
|
moduleManager = new ModuleManager();
|
||||||
|
|
||||||
// 4. Alle Module aktivieren
|
// 3. MODULE REGISTRIEREN
|
||||||
moduleManager.enableAll(this);
|
moduleManager.registerModule(new StatsModule()); // Statistik System laden
|
||||||
|
moduleManager.registerModule(new VerifyModule()); // Verify Modul
|
||||||
// 5. WebServer Thread starten
|
moduleManager.registerModule(new GlobalChatModule()); // GlobalChat
|
||||||
getLogger().info("Starte Web-Server auf Port " + port + "...");
|
moduleManager.registerModule(new NavigationModule()); //Server Switcher
|
||||||
thread = new Thread(this, "StatusAPI-HTTP-Server");
|
// Broadcast Modul registrieren (neu)
|
||||||
thread.start();
|
moduleManager.registerModule(new net.viper.status.modules.broadcast.BroadcastModule());
|
||||||
|
|
||||||
// 6. Update System Initialisieren
|
// 4. Alle Module aktivieren
|
||||||
String currentVersion = getDescription() != null ? getDescription().getVersion() : "0.0.0";
|
moduleManager.enableAll(this);
|
||||||
updateChecker = new UpdateChecker(this, currentVersion, 6);
|
|
||||||
fileDownloader = new FileDownloader(this);
|
// 5. WebServer Thread starten
|
||||||
|
getLogger().info("Starte Web-Server auf Port " + port + "...");
|
||||||
File pluginFile = getFile();
|
thread = new Thread(this, "StatusAPI-HTTP-Server");
|
||||||
File backupFile = new File(pluginFile.getParentFile(), "StatusAPI.jar.bak");
|
thread.start();
|
||||||
|
|
||||||
// Backup Cleanup
|
// 6. Update System Initialisieren
|
||||||
if (backupFile.exists()) {
|
String currentVersion = getDescription() != null ? getDescription().getVersion() : "0.0.0";
|
||||||
ProxyServer.getInstance().getScheduler().schedule(this, () -> {
|
updateChecker = new UpdateChecker(this, currentVersion, 6);
|
||||||
if (backupFile.exists()) backupFile.delete();
|
fileDownloader = new FileDownloader(this);
|
||||||
}, 1, TimeUnit.MINUTES);
|
|
||||||
}
|
File pluginFile = getFile();
|
||||||
|
File backupFile = new File(pluginFile.getParentFile(), "StatusAPI.jar.bak");
|
||||||
// Sofortiger Check
|
|
||||||
checkAndMaybeUpdate();
|
// Backup Cleanup
|
||||||
// Regelmäßiger Check
|
if (backupFile.exists()) {
|
||||||
ProxyServer.getInstance().getScheduler().schedule(this, this::checkAndMaybeUpdate, 6, 6, TimeUnit.HOURS);
|
ProxyServer.getInstance().getScheduler().schedule(this, () -> {
|
||||||
}
|
if (backupFile.exists()) backupFile.delete();
|
||||||
|
},1, TimeUnit.MINUTES);
|
||||||
@Override
|
}
|
||||||
public void onDisable() {
|
|
||||||
getLogger().info("Stoppe Module...");
|
// Sofortiger Check
|
||||||
if (moduleManager != null) {
|
checkAndMaybeUpdate();
|
||||||
moduleManager.disableAll(this);
|
// Regelmäßiger Check
|
||||||
}
|
ProxyServer.getInstance().getScheduler().schedule(this, this::checkAndMaybeUpdate, 6, 6, TimeUnit.HOURS);
|
||||||
|
}
|
||||||
getLogger().info("Stoppe Web-Server...");
|
|
||||||
if (thread != null) {
|
@Override
|
||||||
thread.interrupt();
|
public void onDisable() {
|
||||||
try { thread.join(1000); } catch (InterruptedException ignored) {}
|
getLogger().info("Stoppe Module...");
|
||||||
}
|
if (moduleManager != null) {
|
||||||
}
|
moduleManager.disableAll(this);
|
||||||
|
}
|
||||||
// --- Update Logik (unverändert) ---
|
|
||||||
private void checkAndMaybeUpdate() {
|
getLogger().info("Stoppe Web-Server...");
|
||||||
try {
|
if (thread != null) {
|
||||||
updateChecker.checkNow();
|
thread.interrupt();
|
||||||
String currentVersion = getDescription() != null ? getDescription().getVersion() : "0.0.0";
|
try { thread.join(1000); } catch (InterruptedException ignored) {}
|
||||||
|
}
|
||||||
if (updateChecker.isUpdateAvailable(currentVersion)) {
|
}
|
||||||
String newVersion = updateChecker.getLatestVersion();
|
|
||||||
String url = updateChecker.getLatestUrl();
|
// --- Update Logik (unverändert) ---
|
||||||
getLogger().warning("----------------------------------------");
|
private void checkAndMaybeUpdate() {
|
||||||
getLogger().warning("Neue Version verfügbar: " + newVersion);
|
try {
|
||||||
getLogger().warning("Starte automatisches Update...");
|
updateChecker.checkNow();
|
||||||
getLogger().warning("----------------------------------------");
|
String currentVersion = getDescription() != null ? getDescription().getVersion() : "0.0.0";
|
||||||
|
|
||||||
File pluginFile = getFile();
|
if (updateChecker.isUpdateAvailable(currentVersion)) {
|
||||||
File newFile = new File(pluginFile.getParentFile(), "StatusAPI.jar.new");
|
String newVersion = updateChecker.getLatestVersion();
|
||||||
|
String url = updateChecker.getLatestUrl();
|
||||||
fileDownloader.downloadFile(url, newFile, () -> triggerUpdateScript(pluginFile, newFile));
|
getLogger().warning("----------------------------------------");
|
||||||
}
|
getLogger().warning("Neue Version verfügbar: " + newVersion);
|
||||||
} catch (Exception e) {
|
getLogger().warning("Starte automatisches Update...");
|
||||||
getLogger().severe("Fehler beim Update-Check: " + e.getMessage());
|
getLogger().warning("----------------------------------------");
|
||||||
}
|
|
||||||
}
|
File pluginFile = getFile();
|
||||||
|
File newFile = new File(pluginFile.getParentFile(), "StatusAPI.jar.new");
|
||||||
private void triggerUpdateScript(File currentFile, File newFile) {
|
|
||||||
try {
|
fileDownloader.downloadFile(url, newFile, () -> triggerUpdateScript(pluginFile, newFile));
|
||||||
File pluginsFolder = currentFile.getParentFile();
|
}
|
||||||
File rootFolder = pluginsFolder.getParentFile();
|
} catch (Exception e) {
|
||||||
File batFile = new File(rootFolder, "StatusAPI_Update_" + System.currentTimeMillis() + ".bat");
|
getLogger().severe("Fehler beim Update-Check: " + e.getMessage());
|
||||||
|
}
|
||||||
String batContent = "@echo off\n" +
|
}
|
||||||
"echo Bitte warten, der Server fährt herunter...\n" +
|
|
||||||
"timeout /t 5 /nobreak >nul\n" +
|
private void triggerUpdateScript(File currentFile, File newFile) {
|
||||||
"cd /d \"" + pluginsFolder.getAbsolutePath().replace("\\", "/") + "\"\n" +
|
try {
|
||||||
"echo Fuehre Datei-Tausch durch...\n" +
|
File pluginsFolder = currentFile.getParentFile();
|
||||||
"if exist StatusAPI.jar.bak del StatusAPI.jar.bak\n" +
|
File rootFolder = pluginsFolder.getParentFile();
|
||||||
"if exist StatusAPI.jar (\n" +
|
File batFile = new File(rootFolder, "StatusAPI_Update_" + System.currentTimeMillis() + ".bat");
|
||||||
" ren StatusAPI.jar StatusAPI.jar.bak\n" +
|
|
||||||
")\n" +
|
String batContent = "@echo off\n" +
|
||||||
"if exist StatusAPI.new.jar (\n" +
|
"echo Bitte warten, der Server fährt herunter...\n" +
|
||||||
" ren StatusAPI.new.jar StatusAPI.jar\n" +
|
"timeout /t 5 /nobreak >nul\n" +
|
||||||
" echo Update erfolgreich!\n" +
|
"cd /d \"" + pluginsFolder.getAbsolutePath().replace("\\", "/") + "\"\n" +
|
||||||
") else (\n" +
|
"echo Fuehre Datei-Tausch durch...\n" +
|
||||||
" echo FEHLER: StatusAPI.new.jar nicht gefunden!\n" +
|
"if exist StatusAPI.jar.bak del StatusAPI.jar.bak\n" +
|
||||||
" pause\n" +
|
"if exist StatusAPI.jar (\n" +
|
||||||
")\n" +
|
" ren StatusAPI.jar StatusAPI.jar.bak\n" +
|
||||||
"del \"%~f0\"";
|
")\n" +
|
||||||
|
"if exist StatusAPI.new.jar (\n" +
|
||||||
try (PrintWriter out = new PrintWriter(batFile)) { out.println(batContent); }
|
" ren StatusAPI.new.jar StatusAPI.jar\n" +
|
||||||
|
" echo Update erfolgreich!\n" +
|
||||||
for (ProxiedPlayer p : ProxyServer.getInstance().getPlayers()) {
|
") else (\n" +
|
||||||
p.disconnect("§cServer fährt für ein Update neu herunter. Bitte etwas warten.");
|
" echo FEHLER: StatusAPI.new.jar nicht gefunden!\n" +
|
||||||
}
|
" pause\n" +
|
||||||
|
")\n" +
|
||||||
getLogger().info("Starte Update-Skript...");
|
"del \"%~f0\"";
|
||||||
Runtime.getRuntime().exec("cmd /c start \"Update_Proc\" \"" + batFile.getAbsolutePath() + "\"");
|
|
||||||
ProxyServer.getInstance().stop();
|
try (PrintWriter out = new PrintWriter(batFile)) { out.println(batContent); }
|
||||||
|
|
||||||
} catch (Exception e) {
|
for (ProxiedPlayer p : ProxyServer.getInstance().getPlayers()) {
|
||||||
getLogger().severe("Fehler beim Vorbereiten des Updates: " + e.getMessage());
|
p.disconnect("§cServer fährt für ein Update neu herunter. Bitte etwas warten.");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
getLogger().info("Starte Update-Skript...");
|
||||||
// --- WebServer & JSON ---
|
Runtime.getRuntime().exec("cmd /c start \"Update_Proc\" \"" + batFile.getAbsolutePath() + "\"");
|
||||||
|
ProxyServer.getInstance().stop();
|
||||||
@Override
|
|
||||||
public void run() {
|
} catch (Exception e) {
|
||||||
try (ServerSocket serverSocket = new ServerSocket(port)) {
|
getLogger().severe("Fehler beim Vorbereiten des Updates: " + e.getMessage());
|
||||||
serverSocket.setSoTimeout(1000);
|
}
|
||||||
while (!Thread.interrupted()) {
|
}
|
||||||
try {
|
|
||||||
Socket clientSocket = serverSocket.accept();
|
// --- WebServer & JSON ---
|
||||||
handleConnection(clientSocket);
|
|
||||||
} catch (java.net.SocketTimeoutException e) {}
|
@Override
|
||||||
catch (IOException e) {
|
public void run() {
|
||||||
getLogger().warning("Fehler beim Akzeptieren einer Verbindung: " + e.getMessage());
|
try (ServerSocket serverSocket = new ServerSocket(port)) {
|
||||||
}
|
serverSocket.setSoTimeout(1000);
|
||||||
}
|
while (!Thread.interrupted()) {
|
||||||
} catch (IOException e) {
|
try {
|
||||||
getLogger().severe("Konnte ServerSocket nicht starten: " + e.getMessage());
|
Socket clientSocket = serverSocket.accept();
|
||||||
}
|
handleConnection(clientSocket);
|
||||||
}
|
} catch (java.net.SocketTimeoutException e) {}
|
||||||
|
catch (IOException e) {
|
||||||
private void handleConnection(Socket clientSocket) {
|
getLogger().warning("Fehler beim Akzeptieren einer Verbindung: " + e.getMessage());
|
||||||
try (BufferedReader in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream(), "UTF-8"));
|
}
|
||||||
OutputStream out = clientSocket.getOutputStream()) {
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
String inputLine = in.readLine();
|
getLogger().severe("Konnte ServerSocket nicht starten: " + e.getMessage());
|
||||||
if (inputLine != null && inputLine.startsWith("GET")) {
|
}
|
||||||
Map<String, Object> data = new LinkedHashMap<>();
|
}
|
||||||
data.put("online", true);
|
|
||||||
|
/**
|
||||||
// Version & Info
|
* Erweiterter HTTP-Handler:
|
||||||
String versionRaw = ProxyServer.getInstance().getVersion();
|
* - GET weiterhin liefert Status JSON wie bisher
|
||||||
String versionClean = (versionRaw != null && versionRaw.contains(":")) ? versionRaw.split(":")[2].trim() : versionRaw;
|
* - POST an /broadcast oder POST an / (Root) wird als Broadcast verarbeitet
|
||||||
data.put("version", versionClean);
|
* (Payload JSON mit message, type, prefix, prefixColor, bracketColor, messageColor)
|
||||||
data.put("max_players", String.valueOf(ProxyServer.getInstance().getConfig().getPlayerLimit()));
|
* - Wenn Feld scheduleTime (ms oder s) vorhanden ist, wird Nachricht als geplante Nachricht registriert
|
||||||
|
* und an BroadcastModule.scheduleBroadcast weitergegeben.
|
||||||
String motd = "BungeeCord";
|
* - POST /broadcast/cancel erwartet clientScheduleId im Body und ruft cancelScheduled(clientScheduleId) auf.
|
||||||
try {
|
*/
|
||||||
Iterator<ListenerInfo> it = ProxyServer.getInstance().getConfig().getListeners().iterator();
|
private void handleConnection(Socket clientSocket) {
|
||||||
if (it.hasNext()) motd = it.next().getMotd();
|
try (BufferedReader in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream(), "UTF-8"));
|
||||||
} catch (Exception ignored) {}
|
OutputStream out = clientSocket.getOutputStream()) {
|
||||||
data.put("motd", motd);
|
|
||||||
|
String inputLine = in.readLine();
|
||||||
// StatsModul holen (Service Locator)
|
if (inputLine == null) return;
|
||||||
StatsModule statsModule = (StatsModule) moduleManager.getModule("StatsModule");
|
|
||||||
|
// Request-Line zerlegen: METHOD PATH HTTP/VERSION
|
||||||
boolean luckPermsEnabled = ProxyServer.getInstance().getPluginManager().getPlugin("LuckPerms") != null;
|
String[] reqParts = inputLine.split(" ");
|
||||||
List<Map<String, Object>> playersList = new ArrayList<>();
|
if (reqParts.length < 2) return;
|
||||||
|
String method = reqParts[0].trim();
|
||||||
for (ProxiedPlayer p : ProxyServer.getInstance().getPlayers()) {
|
String path = reqParts[1].trim();
|
||||||
Map<String, Object> playerInfo = new LinkedHashMap<>();
|
|
||||||
playerInfo.put("name", p.getName());
|
// Header einlesen (case-insensitive keys)
|
||||||
try { playerInfo.put("uuid", p.getUniqueId().toString()); } catch (Exception ignored) {}
|
Map<String, String> headers = new HashMap<>();
|
||||||
|
String line;
|
||||||
String prefix = "";
|
while ((line = in.readLine()) != null && !line.isEmpty()) {
|
||||||
if (luckPermsEnabled) {
|
int idx = line.indexOf(':');
|
||||||
try {
|
if (idx > 0) {
|
||||||
Class<?> providerClass = Class.forName("net.luckperms.api.LuckPermsProvider");
|
String key = line.substring(0, idx).trim().toLowerCase(Locale.ROOT);
|
||||||
Object luckPermsApi = providerClass.getMethod("get").invoke(null);
|
String val = line.substring(idx + 1).trim();
|
||||||
Object userManager = luckPermsApi.getClass().getMethod("getUserManager").invoke(luckPermsApi);
|
headers.put(key, val);
|
||||||
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);
|
// --- POST /broadcast/cancel (optional) ---
|
||||||
Object cachedData = user.getClass().getMethod("getCachedData").invoke(user);
|
if ("POST".equalsIgnoreCase(method) && (path.equalsIgnoreCase("/broadcast/cancel") || path.equalsIgnoreCase("/cancel"))) {
|
||||||
Object metaData = cachedData.getClass().getMethod("getMetaData", queryOptionsClass).invoke(cachedData, queryOptions);
|
int contentLength = 0;
|
||||||
Object result = metaData.getClass().getMethod("getPrefix").invoke(metaData);
|
if (headers.containsKey("content-length")) {
|
||||||
if (result != null) prefix = (String) result;
|
try { contentLength = Integer.parseInt(headers.get("content-length")); } catch (NumberFormatException ignored) {}
|
||||||
}
|
}
|
||||||
} catch (Exception ignored) {}
|
char[] bodyChars = new char[Math.max(0, contentLength)];
|
||||||
}
|
if (contentLength > 0) {
|
||||||
playerInfo.put("prefix", prefix);
|
int read = 0;
|
||||||
|
while (read < contentLength) {
|
||||||
// Stats Integration via Modul
|
int r = in.read(bodyChars, read, contentLength - read);
|
||||||
if (statsModule != null) {
|
if (r == -1) break;
|
||||||
PlayerStats ps = statsModule.getManager().getIfPresent(p.getUniqueId());
|
read += r;
|
||||||
if (ps != null) {
|
}
|
||||||
playerInfo.put("playtime", ps.getPlaytimeWithCurrentSession());
|
}
|
||||||
playerInfo.put("joins", ps.joins);
|
String body = new String(bodyChars);
|
||||||
playerInfo.put("first_seen", ps.firstSeen);
|
String clientScheduleId = extractJsonString(body, "clientScheduleId");
|
||||||
playerInfo.put("last_seen", ps.lastSeen);
|
if (clientScheduleId == null || clientScheduleId.isEmpty()) {
|
||||||
}
|
sendHttpResponse(out, "{\"success\":false,\"error\":\"missing_clientScheduleId\"}", 400);
|
||||||
}
|
return;
|
||||||
playersList.add(playerInfo);
|
}
|
||||||
}
|
Object mod = moduleManager.getModule("BroadcastModule");
|
||||||
data.put("players", playersList);
|
if (mod instanceof net.viper.status.modules.broadcast.BroadcastModule) {
|
||||||
|
boolean ok = ((net.viper.status.modules.broadcast.BroadcastModule) mod).cancelScheduled(clientScheduleId);
|
||||||
String json = buildJsonString(data);
|
if (ok) sendHttpResponse(out, "{\"success\":true}", 200);
|
||||||
byte[] jsonBytes = json.getBytes("UTF-8");
|
else sendHttpResponse(out, "{\"success\":false,\"error\":\"not_found\"}", 404);
|
||||||
StringBuilder response = new StringBuilder();
|
return;
|
||||||
response.append("HTTP/1.1 200 OK\r\n");
|
} else {
|
||||||
response.append("Content-Type: application/json; charset=UTF-8\r\n");
|
sendHttpResponse(out, "{\"success\":false,\"error\":\"no_broadcast_module\"}", 500);
|
||||||
response.append("Access-Control-Allow-Origin: *\r\n");
|
return;
|
||||||
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);
|
// --- POST /broadcast oder POST / (Root) für register/send ---
|
||||||
out.flush();
|
if ("POST".equalsIgnoreCase(method) && ("/broadcast".equalsIgnoreCase(path) || "/".equals(path) || path.isEmpty())) {
|
||||||
}
|
int contentLength = 0;
|
||||||
} catch (Exception e) {
|
if (headers.containsKey("content-length")) {
|
||||||
getLogger().severe("Fehler beim Verarbeiten der Anfrage: " + e.getMessage());
|
try { contentLength = Integer.parseInt(headers.get("content-length")); } catch (NumberFormatException ignored) {}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
char[] bodyChars = new char[Math.max(0, contentLength)];
|
||||||
private String buildJsonString(Map<String, Object> data) {
|
if (contentLength > 0) {
|
||||||
StringBuilder sb = new StringBuilder("{");
|
int read = 0;
|
||||||
boolean first = true;
|
while (read < contentLength) {
|
||||||
for (Map.Entry<String, Object> entry : data.entrySet()) {
|
int r = in.read(bodyChars, read, contentLength - read);
|
||||||
if (!first) sb.append(",");
|
if (r == -1) break;
|
||||||
first = false;
|
read += r;
|
||||||
sb.append("\"").append(escapeJson(entry.getKey())).append("\":").append(valueToString(entry.getValue()));
|
}
|
||||||
}
|
}
|
||||||
sb.append("}");
|
String body = new String(bodyChars);
|
||||||
return sb.toString();
|
|
||||||
}
|
// Header X-Api-Key (case-insensitive)
|
||||||
|
String apiKeyHeader = headers.getOrDefault("x-api-key", headers.getOrDefault("x-apikey", ""));
|
||||||
private String valueToString(Object value) {
|
|
||||||
if (value == null) return "null";
|
// parse minimal JSON fields we need
|
||||||
else if (value instanceof Boolean) return value.toString();
|
String message = extractJsonString(body, "message");
|
||||||
else if (value instanceof Number) return value.toString();
|
String type = extractJsonString(body, "type");
|
||||||
else if (value instanceof Map) {
|
String prefix = extractJsonString(body, "prefix");
|
||||||
@SuppressWarnings("unchecked")
|
String prefixColor = extractJsonString(body, "prefixColor");
|
||||||
Map<String, Object> m = (Map<String, Object>) value;
|
String bracketColor = extractJsonString(body, "bracketColor"); // HINZUGEFÜGT
|
||||||
return buildJsonString(m);
|
String messageColor = extractJsonString(body, "messageColor");
|
||||||
} else if (value instanceof List) {
|
String sourceName = extractJsonString(body, "source");
|
||||||
StringBuilder sb = new StringBuilder("[");
|
String scheduleTimeStr = extractJsonString(body, "scheduleTime"); // expecting millis OR seconds
|
||||||
List<?> list = (List<?>) value;
|
String recur = extractJsonString(body, "recur");
|
||||||
for (int i = 0; i < list.size(); i++) {
|
String clientScheduleId = extractJsonString(body, "clientScheduleId");
|
||||||
if (i > 0) sb.append(",");
|
|
||||||
Object item = list.get(i);
|
if (sourceName == null || sourceName.isEmpty()) sourceName = "PulseCast";
|
||||||
if (item instanceof Map) sb.append(buildJsonString((Map<String, Object>) item));
|
if (type == null || type.isEmpty()) type = "global";
|
||||||
else if (item instanceof Number) sb.append(item.toString());
|
|
||||||
else sb.append("\"").append(escapeJson(String.valueOf(item))).append("\"");
|
// if scheduleTime present -> register schedule with BroadcastModule
|
||||||
}
|
if (scheduleTimeStr != null && !scheduleTimeStr.trim().isEmpty()) {
|
||||||
sb.append("]");
|
long scheduleMillis = 0L;
|
||||||
return sb.toString();
|
try {
|
||||||
}
|
// scheduleTime may be numeric string (ms or s)
|
||||||
else return "\"" + escapeJson(String.valueOf(value)) + "\"";
|
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;
|
||||||
private String escapeJson(String s) {
|
} catch (NumberFormatException ignored) {
|
||||||
if (s == null) return "";
|
// try to parse as double then convert
|
||||||
return s.replace("\\", "\\\\").replace("\"", "\\\"").replace("\n", "\\n").replace("\r", "\\r");
|
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
|
name: StatusAPI
|
||||||
main: net.viper.status.StatusAPI
|
main: net.viper.status.StatusAPI
|
||||||
version: 4.0.0
|
version: 4.0.5
|
||||||
author: M_Viper
|
author: M_Viper
|
||||||
description: StatusAPI für BungeeCord inkl. Update-Checker und Modul-System
|
description: StatusAPI für BungeeCord inkl. Update-Checker und Modul-System
|
||||||
|
|
||||||
softdepend:
|
softdepend:
|
||||||
- LuckPerms
|
- LuckPerms
|
||||||
|
|
||||||
commands:
|
commands:
|
||||||
# Verify Modul Befehle
|
# Verify Modul Befehle
|
||||||
verify:
|
verify:
|
||||||
description: Verifiziere dich mit einem Token
|
description: Verifiziere dich mit einem Token
|
||||||
usage: /verify <token>
|
usage: /verify <token>
|
||||||
|
|
||||||
# GlobalChat Modul Befehle
|
# GlobalChat Modul Befehle
|
||||||
globalreload:
|
globalreload:
|
||||||
description: Lädt den Chat-Filter neu
|
description: Lädt den Chat-Filter neu
|
||||||
usage: /globalreload
|
usage: /globalreload
|
||||||
permission: globalchat.reload
|
permission: globalchat.reload
|
||||||
|
|
||||||
globalmute:
|
globalmute:
|
||||||
description: Schaltet den globalen Chat an/aus
|
description: Schaltet den globalen Chat an/aus
|
||||||
usage: /globalmute
|
usage: /globalmute
|
||||||
permission: globalchat.mute
|
permission: globalchat.mute
|
||||||
|
|
||||||
support:
|
support:
|
||||||
description: Sendet eine Support-Nachricht an das Team
|
description: Sendet eine Support-Nachricht an das Team
|
||||||
usage: /support <Nachricht>
|
usage: /support <Nachricht>
|
||||||
|
|
||||||
reply:
|
reply:
|
||||||
description: Antwortet auf eine Support-Nachricht
|
description: Antwortet auf eine Support-Nachricht
|
||||||
usage: /reply <Nachricht>
|
usage: /reply <Nachricht>
|
||||||
|
|
||||||
info:
|
info:
|
||||||
description: Zeigt Plugin-Informationen an
|
description: Zeigt Plugin-Informationen an
|
||||||
usage: /info
|
usage: /info
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
# StatusAPI Core Permissions
|
# StatusAPI Core Permissions
|
||||||
statusapi.update.notify:
|
statusapi.update.notify:
|
||||||
description: 'Erlaubt Update-Benachrichtigungen'
|
description: 'Erlaubt Update-Benachrichtigungen'
|
||||||
default: op
|
default: op
|
||||||
|
|
||||||
# GlobalChat Permissions
|
# GlobalChat Permissions
|
||||||
globalchat.reload:
|
globalchat.reload:
|
||||||
description: Erlaubt das Neuladen des Chat-Filters
|
description: Erlaubt das Neuladen des Chat-Filters
|
||||||
default: op
|
default: op
|
||||||
|
|
||||||
globalchat.mute:
|
globalchat.mute:
|
||||||
description: Erlaubt das Aktivieren/Deaktivieren des globalen Mutes
|
description: Erlaubt das Aktivieren/Deaktivieren des globalen Mutes
|
||||||
default: op
|
default: op
|
||||||
|
|
||||||
globalchat.bypass:
|
globalchat.bypass:
|
||||||
description: Umgeht den globalen Mute
|
description: Umgeht den globalen Mute
|
||||||
default: op
|
default: op
|
||||||
@@ -1,39 +1,76 @@
|
|||||||
# ===========================
|
# ===========================
|
||||||
# GLOBALCHAT AKTIVIERUNG
|
# GLOBALCHAT AKTIVIERUNG
|
||||||
# ===========================
|
# ===========================
|
||||||
chat.enabled=false
|
chat.enabled=false
|
||||||
|
|
||||||
# ===========================
|
# ------------------------------
|
||||||
# NAVIGATION / SERVER SWITCHER
|
# Broadcast
|
||||||
# ===========================
|
# ------------------------------
|
||||||
# Hier kannst du das interne Navigationssystem aktivieren/deaktivieren.
|
|
||||||
# Wenn aktiviert, erstellt das Plugin automatisch Befehle basierend auf den Servernamen (z.B. /lobby, /survival).
|
broadcast.enabled=false
|
||||||
navigation.enabled=false
|
broadcast.prefix=[Broadcast]
|
||||||
|
broadcast.prefix-color=&c
|
||||||
# ===========================
|
broadcast.message-color=&f
|
||||||
# WORDPRESS / VERIFY EINSTELLUNGEN
|
broadcast.format=%prefixColored% %messageColored%
|
||||||
# ===========================
|
# broadcast.format kann angepasst werden; nutze Platzhalter: %name%, %prefix%, %prefixColored%, %message%, %messageColored%, %type%
|
||||||
wp_verify_url=https://deine-wp-domain.tld
|
|
||||||
|
# ===========================
|
||||||
# ===========================
|
# NAVIGATION / SERVER SWITCHER
|
||||||
# SERVER KONFIGURATION
|
# ===========================
|
||||||
# ===========================
|
# Hier kannst du das interne Navigationssystem aktivieren/deaktivieren.
|
||||||
# Hier legst du für jeden Server alles fest:
|
# Wenn aktiviert, erstellt das Plugin automatisch Befehle basierend auf den Servernamen (z.B. /lobby, /survival).
|
||||||
# 1. Den Anzeigenamen für den Chat (z.B. &bLobby)
|
navigation.enabled=false
|
||||||
# 2. Die Server ID für WordPress (z.B. id=1)
|
|
||||||
# 3. Das Secret für WordPress (z.B. secret=...)
|
# ===========================
|
||||||
|
# WORDPRESS / VERIFY EINSTELLUNGEN
|
||||||
# Server 1: Lobby
|
# ===========================
|
||||||
server.lobby=&bLobby
|
wp_verify_url=https://deine-wp-domain.tld
|
||||||
server.lobby.id=1
|
|
||||||
server.lobby.secret=GeheimesWortFuerLobby123
|
# ===========================
|
||||||
|
# SERVER KONFIGURATION
|
||||||
# Server 2: Survival
|
# ===========================
|
||||||
server.survival=&aSurvival
|
# Hier legst du für jeden Server alles fest:
|
||||||
server.survival.id=2
|
# 1. Den Anzeigenamen für den Chat (z.B. &bLobby)
|
||||||
server.survival.secret=GeheimesWortFuerSurvival456
|
# 2. Die Server ID für WordPress (z.B. id=1)
|
||||||
|
# 3. Das Secret für WordPress (z.B. secret=...)
|
||||||
# Server 3: SkyBlock
|
|
||||||
server.skyblock=&dSkyBlock
|
# Server 1: Lobby
|
||||||
server.skyblock.id=3
|
server.lobby=&bLobby
|
||||||
server.skyblock.secret=GeheimesWortFuerSkyBlock789
|
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