Compare commits
35 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1a23d94417 | |||
| 1b357c0a3d | |||
| 9067103d85 | |||
| 6fabd94c83 | |||
| 9bf5abcb86 | |||
| 287051c2c1 | |||
| ef9154a89e | |||
| d720f295f9 | |||
| 7e1d7cac3f | |||
| f007542534 | |||
| 19a37b51ec | |||
| ef7b94f5a5 | |||
| 645e117cda | |||
| a395eb5ac8 | |||
| 1de5301f71 | |||
| 4d8b7e16ca | |||
| 71b9d85f3c | |||
| 85014a68b7 | |||
| aec2de9305 | |||
| 7ffd227fa4 | |||
| 81f3ba5a5f | |||
| 810649c0a1 | |||
| 99ed66cbab | |||
| d8e6ab016a | |||
| e0292702d7 | |||
| 1042618392 | |||
| 1b863a9786 | |||
| 1d98c4ea5b | |||
| b291b25a55 | |||
| 59c626cde0 | |||
| 268d0ce638 | |||
| 7a32160599 | |||
| c62d1ded12 | |||
| 48638aef6d | |||
| 26a337c392 |
18
LICENSE
18
LICENSE
@@ -1,18 +0,0 @@
|
|||||||
MIT License
|
|
||||||
|
|
||||||
Copyright (c) 2025 M_Viper
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
|
||||||
associated documentation files (the "Software"), to deal in the Software without restriction, including
|
|
||||||
without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the
|
|
||||||
following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all copies or substantial
|
|
||||||
portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
|
||||||
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
|
|
||||||
EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
||||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
||||||
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
88
README.md
88
README.md
@@ -4,15 +4,31 @@ Ein leistungsfähiges BungeeCord-Plugin für globalen Chat, Support-Nachrichten
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## ⚠️ WICHTIGER HINWEIS
|
||||||
|
|
||||||
|
**Die Kernfunktionalität des GlobalChat wurde in die [StatusAPI](https://git.viper.ipv64.net/M_Viper/StatusAPI) integriert.**
|
||||||
|
|
||||||
|
Dieses Plugin (**GlobalChat Suppressor**) dient ab sofort **nur noch als Schnittstelle** für die Unterserver (Spigot/Paper) und leitet die Nachrichten an die StatusAPI weiter. Die Befehle und Funktionen können wie gewohnt weiterverwendet werden.
|
||||||
|
|
||||||
|
### Was bedeutet das?
|
||||||
|
|
||||||
|
- **StatusAPI MUSS installiert sein:** Ohne die [StatusAPI](https://git.viper.ipv64.net/M_Viper/StatusAPI) auf deinem BungeeCord funktioniert der GlobalChat nicht mehr.
|
||||||
|
- **GlobalChat Suppressor:** Dieses Plugin bleibt auf den Unterservern aktiv und kommuniziert mit der StatusAPI.
|
||||||
|
- **Zentrale Verwaltung:** Alle Chat-Funktionen, Badword-Filter und Support-Nachrichten werden nun zentral über die StatusAPI verwaltet.
|
||||||
|
|
||||||
|
**Download StatusAPI:** [https://git.viper.ipv64.net/M_Viper/StatusAPI](https://git.viper.ipv64.net/M_Viper/StatusAPI)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
- Globaler Chat mit Badword-Zensur
|
- Globaler Chat mit Badword-Zensur (über StatusAPI)
|
||||||
- Globaler Mute für den Chat
|
- Globaler Mute für den Chat (über StatusAPI)
|
||||||
- `/support <Nachricht>` – Spieler können Support-Nachrichten an das Team senden
|
- `/support <Nachricht>` – Spieler können Support-Nachrichten an das Team senden
|
||||||
- `/reply <Nachricht>` – Staff kann direkt auf Support-Nachrichten antworten
|
- `/reply <Nachricht>` – Staff kann direkt auf Support-Nachrichten antworten
|
||||||
- `/info` – Anzeige von Plugin-Informationen (Name, Version, Autor)
|
- `/info` – Anzeige von Plugin-Informationen (Name, Version, Autor)
|
||||||
- Einfache Konfiguration der Badwords über `filter.yml`
|
- Einfache Konfiguration der Badwords über `filter.yml` in der StatusAPI
|
||||||
- Logging aller Nachrichten in `logs/`
|
- Logging aller Nachrichten in `logs/` (StatusAPI)
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -20,8 +36,8 @@ Ein leistungsfähiges BungeeCord-Plugin für globalen Chat, Support-Nachrichten
|
|||||||
|
|
||||||
| Befehl | Beschreibung | Berechtigung |
|
| Befehl | Beschreibung | Berechtigung |
|
||||||
|--------------------------|------------------------------------------------------------------|-----------------------|
|
|--------------------------|------------------------------------------------------------------|-----------------------|
|
||||||
| `/globalreload` | Lädt die Badword-Liste neu | `globalchat.reload` |
|
| `/globalreload` | Lädt die Badword-Liste neu (StatusAPI) | `globalchat.reload` |
|
||||||
| `/globalmute` | Schaltet den globalen Chat an/aus | `globalchat.mute` |
|
| `/globalmute` | Schaltet den globalen Chat an/aus (StatusAPI) | `globalchat.mute` |
|
||||||
| `/support <Nachricht>` | Sendet eine Support-Nachricht an das Staff-Team | **Alle Spieler** |
|
| `/support <Nachricht>` | Sendet eine Support-Nachricht an das Staff-Team | **Alle Spieler** |
|
||||||
| `/reply <Nachricht>` | Antwortet auf die letzte Support-Nachricht eines Spielers | Staff |
|
| `/reply <Nachricht>` | Antwortet auf die letzte Support-Nachricht eines Spielers | Staff |
|
||||||
| `/info` | Zeigt Informationen über das Plugin an | **Alle Spieler** |
|
| `/info` | Zeigt Informationen über das Plugin an | **Alle Spieler** |
|
||||||
@@ -30,36 +46,80 @@ Ein leistungsfähiges BungeeCord-Plugin für globalen Chat, Support-Nachrichten
|
|||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
1. Lade die **JAR-Datei** in den `plugins`-Ordner deines BungeeCord-Servers.
|
### Voraussetzung: StatusAPI
|
||||||
2. Starte den Server neu oder lade das Plugin neu.
|
|
||||||
3. Die Datei `filter.yml` wird automatisch erstellt. Bearbeite sie, um Badwords anzupassen.
|
⚠️ **Die [StatusAPI](https://git.viper.ipv64.net/M_Viper/StatusAPI) MUSS auf deinem BungeeCord-Server installiert sein!**
|
||||||
4. Optional: Passe die `bungee.yml` an deine Permissions an.
|
```text
|
||||||
|
BungeeCord/
|
||||||
|
├─ plugins/
|
||||||
|
│ ├─ StatusAPI.jar ← PFLICHT
|
||||||
|
│ └─ GlobalChat-Bungee.jar ← Optional (nur für BungeeCord)
|
||||||
|
```
|
||||||
|
|
||||||
|
### Schritt-für-Schritt
|
||||||
|
|
||||||
|
1. **Installiere die [StatusAPI](https://git.viper.ipv64.net/M_Viper/StatusAPI)** auf deinem BungeeCord-Server.
|
||||||
|
2. Lade die **GlobalChat Suppressor JAR-Datei** in den `plugins`-Ordner deiner **Unterserver** (Spigot/Paper).
|
||||||
|
3. Starte die Server neu oder lade die Plugins neu.
|
||||||
|
4. Die Konfiguration erfolgt nun über die **StatusAPI** im BungeeCord.
|
||||||
|
5. Die Datei `filter.yml` findest du im Ordner der StatusAPI.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Konfiguration
|
## Konfiguration
|
||||||
|
|
||||||
### `filter.yml` Beispiel
|
### `filter.yml` (in der StatusAPI)
|
||||||
|
|
||||||
|
Die Badword-Liste wird nun zentral in der **StatusAPI** verwaltet:
|
||||||
```yaml
|
```yaml
|
||||||
badwords:
|
badwords:
|
||||||
- arsch
|
- arsch
|
||||||
- hurensohn
|
- hurensohn
|
||||||
- scheiße
|
- scheiße
|
||||||
```
|
```
|
||||||
|
|
||||||
Neue Badwords können einfach hinzugefügt werden. Das Plugin muss nach Änderungen neu geladen werden (`/globalreload`).
|
Neue Badwords können einfach hinzugefügt werden. Das Plugin muss nach Änderungen neu geladen werden (`/globalreload`).
|
||||||
|
|
||||||
|
**Speicherort:** `plugins/StatusAPI/filter.yml` auf dem BungeeCord-Server
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Logging
|
## Logging
|
||||||
|
|
||||||
- Alle Chat- und Support-Nachrichten werden in `plugins/GlobalChat/logs/YYYY-MM-DD.log` gespeichert.
|
- Alle Chat- und Support-Nachrichten werden in der **StatusAPI** unter `plugins/StatusAPI/logs/YYYY-MM-DD.log` gespeichert.
|
||||||
- Logs älter als 7 Tage werden automatisch gelöscht.
|
- Logs älter als 7 Tage werden automatisch gelöscht.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## Architektur
|
||||||
|
```text
|
||||||
|
BungeeCord
|
||||||
|
└─ StatusAPI (Hauptlogik, Befehle, Filter, Logs)
|
||||||
|
|
||||||
|
Unterserver (Spigot/Paper)
|
||||||
|
└─ GlobalChat Suppressor (Schnittstelle, leitet an StatusAPI weiter)
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Migration von alter Version
|
||||||
|
|
||||||
|
Wenn du eine ältere Version des GlobalChat verwendest:
|
||||||
|
|
||||||
|
1. Installiere die neue [StatusAPI](https://git.viper.ipv64.net/M_Viper/StatusAPI) auf BungeeCord
|
||||||
|
2. Kopiere deine `filter.yml` in den StatusAPI-Ordner
|
||||||
|
3. Ersetze das alte GlobalChat-Plugin auf den Unterservern mit dem neuen GlobalChat Suppressor
|
||||||
|
4. Starte alle Server neu
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## Lizenz
|
## Lizenz
|
||||||
|
|
||||||
Dieses Plugin ist **proprietär** und darf nicht ohne Erlaubnis des Autors verbreitet oder verändert werden.
|
Dieses Plugin ist **proprietär** und darf nicht ohne Erlaubnis des Autors verbreitet oder verändert werden.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Support & Weitere Informationen
|
||||||
|
|
||||||
|
Für detaillierte Informationen zur StatusAPI und deren Konfiguration:
|
||||||
|
**[https://git.viper.ipv64.net/M_Viper/StatusAPI](https://git.viper.ipv64.net/M_Viper/StatusAPI)**
|
||||||
54
pom.xml
54
pom.xml
@@ -1,64 +1,42 @@
|
|||||||
<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
|
||||||
http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<groupId>de.viper</groupId>
|
<groupId>de.viper.globalchat</groupId>
|
||||||
<artifactId>globalchat</artifactId>
|
<artifactId>GlobalChatSuppressor</artifactId>
|
||||||
<version>1.3-SNAPSHOT</version>
|
<version>1.0.0</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>GlobalChat</name>
|
<name>GlobalChatSuppressor</name>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<java.version>17</java.version>
|
||||||
<maven.compiler.source>1.8</maven.compiler.source>
|
<spigot.version>1.21.1-R0.1-SNAPSHOT</spigot.version>
|
||||||
<maven.compiler.target>1.8</maven.compiler.target>
|
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<!-- BungeeCord API für Minecraft 1.21.x -->
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.md-5</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>bungeecord-api</artifactId>
|
<artifactId>spigot-api</artifactId>
|
||||||
<version>1.21-R0.1-SNAPSHOT</version>
|
<version>${spigot.version}</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
<!-- Compiler Plugin -->
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.8.1</version>
|
<version>3.13.0</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>1.8</source>
|
<source>${java.version}</source>
|
||||||
<target>1.8</target>
|
<target>${java.version}</target>
|
||||||
|
<encoding>UTF-8</encoding>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
<!-- Shade Plugin für fertiges JAR -->
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-shade-plugin</artifactId>
|
|
||||||
<version>3.2.4</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<phase>package</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>shade</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@@ -1,299 +0,0 @@
|
|||||||
package de.viper.globalchat;
|
|
||||||
|
|
||||||
import net.md_5.bungee.api.CommandSender;
|
|
||||||
import net.md_5.bungee.api.chat.ComponentBuilder;
|
|
||||||
import net.md_5.bungee.api.chat.HoverEvent;
|
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
|
||||||
import net.md_5.bungee.api.chat.HoverEvent.Action;
|
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
|
||||||
import net.md_5.bungee.api.event.ChatEvent;
|
|
||||||
import net.md_5.bungee.api.plugin.Command;
|
|
||||||
import net.md_5.bungee.api.plugin.Listener;
|
|
||||||
import net.md_5.bungee.api.plugin.Plugin;
|
|
||||||
import net.md_5.bungee.event.EventHandler;
|
|
||||||
|
|
||||||
import java.io.*;
|
|
||||||
import java.nio.file.*;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
public class GlobalChat extends Plugin implements Listener {
|
|
||||||
|
|
||||||
private List<String> badWords = new ArrayList<>();
|
|
||||||
private File logFolder;
|
|
||||||
private boolean chatMuted = false; // Globaler Mute-Status
|
|
||||||
|
|
||||||
// Spieler-UUID -> isOp (vom Spigot gemeldet)
|
|
||||||
private final Map<UUID, Boolean> playerIsOp = new ConcurrentHashMap<>();
|
|
||||||
|
|
||||||
// Letzte Support-Kontakte für /reply
|
|
||||||
private final Map<UUID, UUID> lastSupportContact = new ConcurrentHashMap<>();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onEnable() {
|
|
||||||
getProxy().getPluginManager().registerListener(this, this);
|
|
||||||
|
|
||||||
// Filter laden
|
|
||||||
loadFilter();
|
|
||||||
|
|
||||||
// Log-Ordner erstellen
|
|
||||||
logFolder = new File(getDataFolder(), "logs");
|
|
||||||
if (!logFolder.exists()) logFolder.mkdirs();
|
|
||||||
cleanupOldLogs();
|
|
||||||
|
|
||||||
// Befehle registrieren (Support & Info sind für alle verfügbar)
|
|
||||||
getProxy().getPluginManager().registerCommand(this, new ReloadCommand());
|
|
||||||
getProxy().getPluginManager().registerCommand(this, new MuteCommand());
|
|
||||||
getProxy().getPluginManager().registerCommand(this, new SupportCommand());
|
|
||||||
getProxy().getPluginManager().registerCommand(this, new ReplyCommand());
|
|
||||||
getProxy().getPluginManager().registerCommand(this, new InfoCommand());
|
|
||||||
|
|
||||||
getLogger().info("§aGlobalChat mit Zensur, Logs, Reload, Mute, Support, Reply & Info aktiviert!");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDisable() {
|
|
||||||
getLogger().info("§cGlobalChat deaktiviert!");
|
|
||||||
}
|
|
||||||
|
|
||||||
// ===========================
|
|
||||||
// Chatfilter & Logging
|
|
||||||
// ===========================
|
|
||||||
@EventHandler
|
|
||||||
public void onChat(ChatEvent e) {
|
|
||||||
if (!(e.getSender() instanceof ProxiedPlayer)) return;
|
|
||||||
if (e.isCommand()) return;
|
|
||||||
|
|
||||||
ProxiedPlayer player = (ProxiedPlayer) e.getSender();
|
|
||||||
String originalMsg = e.getMessage();
|
|
||||||
String censoredMsg = originalMsg;
|
|
||||||
|
|
||||||
// Globaler Mute check
|
|
||||||
if (chatMuted && !player.hasPermission("globalchat.bypass")) {
|
|
||||||
player.sendMessage(new TextComponent("§cDer globale Chat ist derzeit deaktiviert!"));
|
|
||||||
e.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Badword-Zensur
|
|
||||||
for (String bad : badWords) {
|
|
||||||
if (bad == null || bad.trim().isEmpty()) continue;
|
|
||||||
censoredMsg = censoredMsg.replaceAll("(?i)" + Pattern.quote(bad), repeat("*", bad.length()));
|
|
||||||
}
|
|
||||||
|
|
||||||
e.setCancelled(true);
|
|
||||||
|
|
||||||
String serverName = player.getServer().getInfo().getName();
|
|
||||||
String chatOut = "§7[" + serverName + "] §b" + player.getName() + "§f: " + censoredMsg;
|
|
||||||
|
|
||||||
for (ProxiedPlayer p : getProxy().getPlayers()) {
|
|
||||||
p.sendMessage(new TextComponent(chatOut));
|
|
||||||
}
|
|
||||||
|
|
||||||
logMessage("[" + serverName + "] " + player.getName() + ": " + originalMsg);
|
|
||||||
}
|
|
||||||
|
|
||||||
private String repeat(String str, int count) {
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
for (int i = 0; i < count; i++) sb.append(str);
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ===========================
|
|
||||||
// Filter laden
|
|
||||||
// ===========================
|
|
||||||
private void loadFilter() {
|
|
||||||
File file = new File(getDataFolder(), "filter.yml");
|
|
||||||
if (!file.exists()) {
|
|
||||||
try {
|
|
||||||
getDataFolder().mkdirs();
|
|
||||||
file.createNewFile();
|
|
||||||
try (PrintWriter out = new PrintWriter(file)) {
|
|
||||||
out.println("badwords:");
|
|
||||||
out.println(" - arsch");
|
|
||||||
out.println(" - hurensohn");
|
|
||||||
out.println(" - scheiße");
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
List<String> lines = Files.readAllLines(file.toPath());
|
|
||||||
badWords.clear();
|
|
||||||
for (String line : lines) {
|
|
||||||
line = line.trim();
|
|
||||||
if (line.startsWith("-")) badWords.add(line.substring(1).trim());
|
|
||||||
}
|
|
||||||
getLogger().info("§eGeladene Filter-Wörter: " + badWords.size());
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void cleanupOldLogs() {
|
|
||||||
File[] files = logFolder.listFiles();
|
|
||||||
if (files == null) return;
|
|
||||||
|
|
||||||
long now = System.currentTimeMillis();
|
|
||||||
long sevenDays = 1000L * 60 * 60 * 24 * 7;
|
|
||||||
|
|
||||||
for (File f : files) {
|
|
||||||
if (now - f.lastModified() > sevenDays) {
|
|
||||||
f.delete();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void logMessage(String message) {
|
|
||||||
String date = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
|
|
||||||
File logFile = new File(logFolder, date + ".log");
|
|
||||||
|
|
||||||
try (BufferedWriter bw = new BufferedWriter(new FileWriter(logFile, true))) {
|
|
||||||
String time = new SimpleDateFormat("HH:mm:ss").format(new Date());
|
|
||||||
bw.write("[" + time + "] " + message);
|
|
||||||
bw.newLine();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ===========================
|
|
||||||
// Staff-Check
|
|
||||||
// ===========================
|
|
||||||
private boolean isStaff(ProxiedPlayer p) {
|
|
||||||
if (p == null) return false;
|
|
||||||
Boolean reportedOp = playerIsOp.get(p.getUniqueId());
|
|
||||||
if (reportedOp != null && reportedOp) return true;
|
|
||||||
|
|
||||||
if (p.hasPermission("team")) return true;
|
|
||||||
if (p.hasPermission("bungeecord.admin")) return true;
|
|
||||||
if (p.hasPermission("globalchat.op")) return true;
|
|
||||||
if (p.hasPermission("*")) return true;
|
|
||||||
|
|
||||||
if (p.hasPermission("bungeecord.command.alert")) return true;
|
|
||||||
if (p.hasPermission("bungeecord.command.reload")) return true;
|
|
||||||
if (p.hasPermission("bungeecord.command.kick")) return true;
|
|
||||||
if (p.hasPermission("bungeecord.command.send")) return true;
|
|
||||||
if (p.hasPermission("bungeecord.command.perms")) return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ===========================
|
|
||||||
// Commands
|
|
||||||
// ===========================
|
|
||||||
public class ReloadCommand extends Command {
|
|
||||||
public ReloadCommand() { super("globalreload", "globalchat.reload"); }
|
|
||||||
@Override
|
|
||||||
public void execute(CommandSender sender, String[] args) {
|
|
||||||
loadFilter();
|
|
||||||
sender.sendMessage(new TextComponent("§aFilter wurde neu geladen!"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class MuteCommand extends Command {
|
|
||||||
public MuteCommand() { super("globalmute", "globalchat.mute"); }
|
|
||||||
@Override
|
|
||||||
public void execute(CommandSender sender, String[] args) {
|
|
||||||
chatMuted = !chatMuted;
|
|
||||||
String status = chatMuted ? "§caktiviert" : "§aaufgehoben";
|
|
||||||
for (ProxiedPlayer p : getProxy().getPlayers()) {
|
|
||||||
p.sendMessage(new TextComponent("§7[GlobalChat] §eDer globale Chat Mute wurde " + status + "§e!"));
|
|
||||||
}
|
|
||||||
getLogger().info("GlobalMute wurde " + (chatMuted ? "aktiviert" : "deaktiviert") + ".");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class SupportCommand extends Command {
|
|
||||||
// kein Permission-Parameter -> für alle verfügbar
|
|
||||||
public SupportCommand() { super("support"); }
|
|
||||||
@Override
|
|
||||||
public void execute(CommandSender sender, String[] args) {
|
|
||||||
if (!(sender instanceof ProxiedPlayer)) {
|
|
||||||
sender.sendMessage(new TextComponent("§cNur Spieler können Support-Nachrichten senden."));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ProxiedPlayer player = (ProxiedPlayer) sender;
|
|
||||||
if (args.length == 0) {
|
|
||||||
player.sendMessage(new TextComponent("§cBitte eine Nachricht angeben: /support <Nachricht>"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
String msg = String.join(" ", args);
|
|
||||||
String serverName = player.getServer().getInfo().getName();
|
|
||||||
|
|
||||||
TextComponent supportMsg = new TextComponent("§7[Support] §b" + player.getName() +
|
|
||||||
" §7vom Server §e" + serverName + " §7: §f" + msg);
|
|
||||||
|
|
||||||
// Hover-Text
|
|
||||||
supportMsg.setHoverEvent(new HoverEvent(Action.SHOW_TEXT,
|
|
||||||
new ComponentBuilder("Klicke, um /reply " + player.getName() + " zu schreiben").create()));
|
|
||||||
|
|
||||||
// Klick-Event (füllt die Chatbox mit /reply <Name> )
|
|
||||||
supportMsg.setClickEvent(new net.md_5.bungee.api.chat.ClickEvent(
|
|
||||||
net.md_5.bungee.api.chat.ClickEvent.Action.SUGGEST_COMMAND,
|
|
||||||
"/reply " + player.getName() + " "
|
|
||||||
));
|
|
||||||
|
|
||||||
for (ProxiedPlayer p : getProxy().getPlayers()) {
|
|
||||||
if (isStaff(p)) {
|
|
||||||
p.sendMessage(supportMsg);
|
|
||||||
lastSupportContact.put(p.getUniqueId(), player.getUniqueId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
player.sendMessage(new TextComponent("§aDeine Support-Nachricht wurde gesendet."));
|
|
||||||
logMessage("[Support][" + serverName + "] " + player.getName() + ": " + msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class ReplyCommand extends Command {
|
|
||||||
public ReplyCommand() { super("reply"); }
|
|
||||||
@Override
|
|
||||||
public void execute(CommandSender sender, String[] args) {
|
|
||||||
if (!(sender instanceof ProxiedPlayer)) return;
|
|
||||||
|
|
||||||
ProxiedPlayer staff = (ProxiedPlayer) sender;
|
|
||||||
UUID targetId = lastSupportContact.get(staff.getUniqueId());
|
|
||||||
if (targetId == null) {
|
|
||||||
staff.sendMessage(new TextComponent("§cKein Spieler zum Antworten gefunden."));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.length == 0) {
|
|
||||||
staff.sendMessage(new TextComponent("§cBitte eine Nachricht angeben."));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ProxiedPlayer target = getProxy().getPlayer(targetId);
|
|
||||||
if (target == null) {
|
|
||||||
staff.sendMessage(new TextComponent("§cSpieler ist nicht online."));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
String msg = String.join(" ", args);
|
|
||||||
target.sendMessage(new TextComponent("§7[Reply von §b" + staff.getName() + "§7]: §f" + msg));
|
|
||||||
staff.sendMessage(new TextComponent("§aDeine Nachricht wurde an §b" + target.getName() + "§a gesendet."));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class InfoCommand extends Command {
|
|
||||||
// kein Permission-Parameter -> für alle verfügbar
|
|
||||||
public InfoCommand() { super("info"); }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void execute(CommandSender sender, String[] args) {
|
|
||||||
sender.sendMessage(new TextComponent("§8§m------------------------------"));
|
|
||||||
sender.sendMessage(new TextComponent("§6§lGlobalChat Info"));
|
|
||||||
sender.sendMessage(new TextComponent("§ePlugin-Name: §b" + getDescription().getName()));
|
|
||||||
sender.sendMessage(new TextComponent("§eVersion: §b" + getDescription().getVersion()));
|
|
||||||
sender.sendMessage(new TextComponent("§eErsteller: §bM_Viper"));
|
|
||||||
sender.sendMessage(new TextComponent("§8§m------------------------------"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
package de.viper.globalchat.suppressor;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.DataInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class GlobalChatSuppressor extends JavaPlugin implements PluginMessageListener, Listener {
|
||||||
|
|
||||||
|
private static final String CHANNEL = "global:control";
|
||||||
|
private final Set<UUID> suppressJoinQuit = new HashSet<>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEnable() {
|
||||||
|
getServer().getMessenger().registerIncomingPluginChannel(this, CHANNEL, this);
|
||||||
|
getServer().getMessenger().registerOutgoingPluginChannel(this, CHANNEL);
|
||||||
|
getServer().getPluginManager().registerEvents(this, this);
|
||||||
|
getLogger().info("GlobalChatSuppressor aktiviert!");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDisable() {
|
||||||
|
getServer().getMessenger().unregisterIncomingPluginChannel(this, CHANNEL);
|
||||||
|
getServer().getMessenger().unregisterOutgoingPluginChannel(this, CHANNEL);
|
||||||
|
getLogger().info("GlobalChatSuppressor deaktiviert!");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPluginMessageReceived(String channel, Player player, byte[] message) {
|
||||||
|
if (!channel.equals(CHANNEL)) return;
|
||||||
|
|
||||||
|
try (DataInputStream in = new DataInputStream(new ByteArrayInputStream(message))) {
|
||||||
|
String subChannel = in.readUTF();
|
||||||
|
if ("suppress".equalsIgnoreCase(subChannel)) {
|
||||||
|
String uuidStr = in.readUTF();
|
||||||
|
UUID playerUUID = UUID.fromString(uuidStr);
|
||||||
|
suppressJoinQuit.add(playerUUID);
|
||||||
|
getLogger().info("Suppress für Spieler UUID: " + playerUUID + " aktiviert.");
|
||||||
|
// Entferne die Unterdrückung nach 2 Sekunden (synchron mit BungeeCord)
|
||||||
|
getServer().getScheduler().runTaskLater(this, () -> {
|
||||||
|
suppressJoinQuit.remove(playerUUID);
|
||||||
|
getLogger().info("Suppress für Spieler UUID: " + playerUUID + " entfernt.");
|
||||||
|
}, 40L); // 40 Ticks = 2 Sekunden
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
if (suppressJoinQuit.contains(player.getUniqueId())) {
|
||||||
|
event.setJoinMessage(null);
|
||||||
|
getLogger().info("Join-Nachricht für " + player.getName() + " unterdrückt.");
|
||||||
|
suppressJoinQuit.remove(player.getUniqueId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
if (suppressJoinQuit.contains(player.getUniqueId())) {
|
||||||
|
event.setQuitMessage(null);
|
||||||
|
getLogger().info("Quit-Nachricht für " + player.getName() + " unterdrückt.");
|
||||||
|
suppressJoinQuit.remove(player.getUniqueId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package de.viper.globalchat.suppressor;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class SuppressManager {
|
||||||
|
|
||||||
|
private static final Set<UUID> suppressedPlayers = Collections.synchronizedSet(new HashSet<>());
|
||||||
|
|
||||||
|
public static void register(GlobalChatSuppressor plugin) {
|
||||||
|
// Nichts weiter nötig, die Nachrichten werden beim Join/Quit-Event unterdrückt
|
||||||
|
// via AsyncPlayerPreLogin oder PlayerJoin/Leave in Hauptplugin
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void suppress(UUID playerUUID) {
|
||||||
|
suppressedPlayers.add(playerUUID);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void unsuppress(UUID playerUUID) {
|
||||||
|
suppressedPlayers.remove(playerUUID);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isSuppressed(UUID playerUUID) {
|
||||||
|
return suppressedPlayers.contains(playerUUID);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Set<UUID> getSuppressedPlayers() {
|
||||||
|
return suppressedPlayers;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
name: GlobalChat
|
|
||||||
main: de.viper.globalchat.GlobalChat
|
|
||||||
version: 1.0
|
|
||||||
author: M_Viper
|
|
||||||
commands:
|
|
||||||
globalreload:
|
|
||||||
description: Lädt den 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:
|
|
||||||
globalchat.reload:
|
|
||||||
description: Erlaubt das Neuladen des 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,4 +0,0 @@
|
|||||||
badwords:
|
|
||||||
- arsch
|
|
||||||
- hurensohn
|
|
||||||
- scheiße
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
name: GlobalChatSpigot
|
name: GlobalChatSuppressor
|
||||||
main: de.viper.globalchat.GlobalChatSpigot
|
version: 1.0.0
|
||||||
version: 1.0
|
main: de.viper.globalchat.suppressor.GlobalChatSuppressor
|
||||||
api-version: 1.13
|
api-version: 1.21
|
||||||
description: Spigot helper for GlobalChat Bungee (sends coords, handles teleport requests)
|
author: M_Viper
|
||||||
authors: [M_Viper]
|
commands: {}
|
||||||
|
|||||||
Reference in New Issue
Block a user