Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3ec1d905dc | ||
|
|
3a8fe5cf66 | ||
|
|
1a75a7db33 | ||
|
|
be78c34222 | ||
|
|
2460691df2 | ||
|
|
46dc0cbe05 | ||
|
|
79fed93d20 | ||
|
|
c3a8f15f6d | ||
|
|
b46af01475 | ||
|
|
8fe8f2b1af | ||
|
|
ce6847e58e | ||
|
|
95b0e2f971 | ||
|
|
045a5f2b1b | ||
|
|
8a2c3b4277 | ||
|
|
38bbba4c8b | ||
|
|
d92d0d5328 | ||
|
|
a27c174daa | ||
|
|
0dddc0dfb5 | ||
|
|
7fe5bd62c7 | ||
|
|
f7f0a0d532 | ||
|
|
35dded973b | ||
|
|
43dac083d4 |
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>de.nexuslobby</groupId>
|
||||
<artifactId>NexusLobby</artifactId>
|
||||
<version>1.1.1</version>
|
||||
<version>2.0</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>NexusLobby</name>
|
||||
|
||||
@@ -0,0 +1,400 @@
|
||||
## 🌐 Mehrsprachigkeit & Texte
|
||||
|
||||
Alle Nachrichten, Hilfetexte und Fehler werden zentral über die Datei `lang.yml` im Ordner `src/main/resources` verwaltet. Dort kannst du für jede Sprache (z.B. Deutsch und Englisch) die Texte pflegen und beliebig erweitern.
|
||||
|
||||
**Beispiel für lang.yml:**
|
||||
|
||||
```yaml
|
||||
welcome:
|
||||
de: "Willkommen auf dem Server!"
|
||||
en: "Welcome to the server!"
|
||||
no_permission:
|
||||
de: "§cKeine Berechtigung."
|
||||
en: "§cNo permission."
|
||||
```
|
||||
|
||||
**Sprache umstellen:**
|
||||
Im Code kann die Sprache mit `LangManager.setLanguage("en")` gewechselt werden. Standard ist Deutsch (`de`).
|
||||
|
||||
**Texte ingame nutzen:**
|
||||
Alle Texte werden im Plugin mit `LangManager.get("key")` abgerufen und sind direkt ingame sichtbar. Änderungen in der lang.yml wirken nach einem Reload sofort.
|
||||
|
||||
**Chat-Prefix anpassen:**
|
||||
Der Prefix vor Plugin-Nachrichten wird in der Server-`config.yml` über `prefix` festgelegt. Farben können mit `&`-Codes angegeben werden:
|
||||
|
||||
```yaml
|
||||
prefix: "&8[&6Nexus&8] "
|
||||
```
|
||||
|
||||
Ändere den Text und die Farben nach Wunsch und lade das Plugin anschließend neu.
|
||||
|
||||
---
|
||||
# NexusLobby
|
||||
|
||||
<p align="center">
|
||||
<img src="https://m-viper.de/img/NexusLobby.png" width="500" alt="NexusLobby">
|
||||
</p>
|
||||
|
||||
Ein umfassendes, modulares Lobby-Plugin für Minecraft Server (Paper/Spigot 1.21+) mit High-End NPC-System, umfangreichen Sicherheitsfunktionen, Soccer-Modul, Parkour-System und voller Konfigurierbarkeit.
|
||||
|
||||

|
||||

|
||||

|
||||

|
||||
|
||||
---
|
||||
|
||||
## 🎯 Lizenz und Nutzungsbedingungen
|
||||
|
||||
**ALLE RECHTE VORBEHALTEN**
|
||||
|
||||
Dieses Plugin ist urheberrechtlich geschützt. Es gelten folgende Bedingungen:
|
||||
|
||||
# Scoreboard ausblenden (Opt-out)
|
||||
|
||||
Spieler können das Scoreboard per Befehl ein-/ausblenden. Standardmäßig wird das Scoreboard beim Join angezeigt. Über die Option
|
||||
|
||||
```yaml
|
||||
scoreboard-default-visible: true
|
||||
```
|
||||
|
||||
in der `config.yml` kann festgelegt werden, ob das Scoreboard für neue Spieler standardmäßig sichtbar ist. Bei `false` ist es für alle Spieler nach dem Join ausgeblendet, bis sie es selbst aktivieren.
|
||||
|
||||
- Die Weitergabe, Verbreitung oder Veröffentlichung des Plugins ist **strengstens untersagt**.
|
||||
- Jegliche Änderung, Modifikation oder Dekompilierung des Codes ist **verboten**.
|
||||
- Das Plugin darf nicht verkauft, vermietet oder anderweitig kommerziell genutzt werden.
|
||||
- Eine Weitergabe an Dritte ist ohne ausdrückliche schriftliche Genehmigung nicht gestattet.
|
||||
|
||||
Bei Verstoß gegen diese Bedingungen behalten wir uns rechtliche Schritte vor.
|
||||
|
||||
---
|
||||
|
||||
## ✨ Features
|
||||
|
||||
### 🤖 High-End NPC & ArmorStand System
|
||||
- **Conversation Manager** - Komplexe Dialoge zwischen NPCs mit Sprechblasen und Sound-Effekten
|
||||
- **Dynamic KI** - NPCs reagieren auf Tageszeit (Fackel nachts) und ziehen bei Annäherung von Spielern das Schwert
|
||||
- **LookAt-Logik** - NPCs verfolgen flüssig die Kopfbewegungen von Spielern in der Nähe
|
||||
- **Command Binding** - Binde Spieler-, Konsolen- oder Bungee-Befehle an NPC-Slots (0-9)
|
||||
- **Status-Backup** - Automatisches Speichern von NPC-Namen via PersistentDataContainer & Tags
|
||||
|
||||
### ⚽ Soccer/Fußball-System
|
||||
- **Interaktiver Soccer-Ball** - Physics-basierter Ball mit realistischer Physik
|
||||
- **Dribbling** - Ball folgt Spielern automatisch in der Nähe
|
||||
- **Kick-Mechanik** - Schieße den Ball durch Schlagen oder Angriff
|
||||
- **Wall-Bounce** - Realistische Wand-Abpraller mit Sound-Effekten
|
||||
- **Partikel-System** - Geschwindigkeits-abhängige Partikel (SONIC_BOOM, CRIT, SMOKE)
|
||||
- **Auto-Respawn** - Automatischer Respawn bei Inaktivität oder Void-Fall
|
||||
- **Anti-Duplikat-System** - Verhindert mehrfache Ball-Instanzen
|
||||
|
||||
### 🏃 Parkour-System
|
||||
- **Unsichtbare Checkpoints** - Partikel-basierte Checkpoint-Markierungen
|
||||
- **Timer-System** - Präzise Zeitmessung mit ActionBar-Anzeige
|
||||
- **Bestenliste** - Persistente Top-10 Bestzeiten-Speicherung
|
||||
- **NPC-Trainer** - Interaktive NPCs zum Starten des Parkours
|
||||
- **Fail-Safe** - Teleport zum letzten Checkpoint bei Fehler
|
||||
|
||||
### 🌍 Lobby-Management
|
||||
- **Spawn-System** - Automatischer Teleport zum Spawn bei Join/Respawn
|
||||
- **Portal-System** - BungeeCord-Portale für nahtlose Server-Wechsel mit Partikel-Effekten
|
||||
- **Build-Modus** - Schnelles Umschalten zwischen Bau- und Spielmodus
|
||||
- **Double-Jump** - Konfigurierbarer Doppelsprung mit Cooldown und Partikeln
|
||||
- **Worldborder** - Unsichtbare Lobby-Begrenzung (Circle/Square)
|
||||
- **Intro-Tour** - Cinematic Kamera-Tour für neue Spieler
|
||||
|
||||
### 🛡️ Sicherheit & Protection
|
||||
- **VPN-Blocker** - Blockiert VPN/Proxy-Verbindungen via proxycheck.io API
|
||||
- **Country-Blocker** - Geo-IP Filter (Whitelist/Blacklist für Länder)
|
||||
- **Maintenance-Modus** - Vollständiger Wartungsmodus mit Whitelist-Funktion
|
||||
- **World-Protection** - Schutz vor Griefing, Hunger, Fallschaden und PvP
|
||||
- **Anti-Grief** - Verhindert Block-Break, Item-Drop und Explosionen
|
||||
- **Security-Module** - Umfassende Sicherheitsprüfungen beim Join
|
||||
|
||||
### 📊 Visuelle Elemente
|
||||
- **Scoreboard** - Vollständig animiert mit PlaceholderAPI-Support
|
||||
- **Tablist** - Dynamische Header/Footer mit Permissions-Anzeige
|
||||
- **BossBar** - Rotierende Nachrichten mit Farb-Effekten
|
||||
- **ActionBar** - Typewriter-Effekt für permanente Status-Anzeigen
|
||||
- **Hologramme** - Text-Displays mit flexibler Positionierung
|
||||
- **MapArt** - Bild-Generator für Item-Frames aus URLs
|
||||
|
||||
### 🎮 Item-System
|
||||
- **Compass** - Server-Switcher GUI
|
||||
- **Player-Hider** - Sichtbarkeits-Toggle für andere Spieler
|
||||
- **Gadgets** - Konfigurierbares Item-System mit Custom-Slots
|
||||
- **Player-Inspector** - Detaillierte Spieler-Informationen per Click
|
||||
|
||||
---
|
||||
|
||||
## 📋 Befehle
|
||||
|
||||
### Haupt-Commands
|
||||
|
||||
| Befehl | Beschreibung | Berechtigung |
|
||||
|--------|--------------|--------------|
|
||||
| `/nexuslobby reload` | Lädt das Plugin neu | `nexuslobby.admin` |
|
||||
| `/nexuslobby setspawn` | Setzt den Lobby-Spawn | `nexuslobby.admin` |
|
||||
| `/nexuslobby silentjoin <on\|off>` | Versteckter Join/Quit | `nexuslobby.admin` |
|
||||
| `/nexuslobby sb <on\|off\|admin\|spieler>` | Scoreboard-Kontrolle | `nexuslobby.admin` |
|
||||
| `/spawn` | Teleport zum Spawn | `nexuslobby.spawn` |
|
||||
|
||||
### NPC & ArmorStand
|
||||
|
||||
| Befehl | Beschreibung | Berechtigung |
|
||||
|--------|--------------|--------------|
|
||||
| `/nexustools` | NPC Editor GUI (Rotation, KI) | `nexuslobby.armorstand.use` |
|
||||
| `/nexuscmd add <slot> <prio> <type> [cmd]` | Bindet Command an NPC | `nexuslobby.armorstand.cmd` |
|
||||
| `/nexuscmd remove <slot\|all>` | Entfernt Commands | `nexuslobby.armorstand.cmd` |
|
||||
| `/nexuscmd conv select1-4` | Wählt NPCs für Dialog | `nexuslobby.armorstand.cmd` |
|
||||
| `/nexuscmd conv link <id>` | Verknüpft Dialog | `nexuslobby.armorstand.cmd` |
|
||||
| `/nexuscmd say <text>` | NPC-Sprechblase | `nexuslobby.armorstand.cmd` |
|
||||
|
||||
### Parkour
|
||||
|
||||
| Befehl | Beschreibung | Berechtigung |
|
||||
|--------|--------------|--------------|
|
||||
| `/nexuslobby parkour setstart` | Markiert Start-NPC | `nexuslobby.admin` |
|
||||
| `/nexuslobby parkour setcheckpoint <n>` | Setzt Checkpoint | `nexuslobby.admin` |
|
||||
| `/nexuslobby parkour setfinish` | Setzt Ziel | `nexuslobby.admin` |
|
||||
| `/nexuslobby parkour reset` | Löscht eigene Zeit | `nexuslobby.admin` |
|
||||
| `/nexuslobby parkour clear` | Löscht alle Zeiten | `nexuslobby.admin` |
|
||||
| `/setstart` | Alias für setstart | `nexuslobby.admin` |
|
||||
| `/setcheckpoint` | Alias für setcheckpoint | `nexuslobby.admin` |
|
||||
| `/setfinish` | Alias für setfinish | `nexuslobby.admin` |
|
||||
|
||||
### Soccer/Fußball
|
||||
|
||||
| Befehl | Beschreibung | Berechtigung |
|
||||
|--------|--------------|--------------|
|
||||
| `/nexuslobby ball setspawn` | Setzt Ball-Spawn | `nexuslobby.admin` |
|
||||
| `/nexuslobby ball respawn` | Spawnt Ball neu | `nexuslobby.admin` |
|
||||
| `/nexuslobby ball remove` | Entfernt Ball | `nexuslobby.admin` |
|
||||
|
||||
### Portal & Server
|
||||
|
||||
| Befehl | Beschreibung | Berechtigung |
|
||||
|--------|--------------|--------------|
|
||||
| `/portal create <name> <type>` | Erstellt Portal | `nexuslobby.portal` |
|
||||
| `/portal delete <name>` | Löscht Portal | `nexuslobby.portal` |
|
||||
| `/portal list` | Zeigt alle Portale | `nexuslobby.portal` |
|
||||
| `/giveportalwand` | Portal-Werkzeug | `nexuslobby.portal.give` |
|
||||
| `/serverswitcher` | Öffnet Server-GUI | `nexuslobby.serverswitcher` |
|
||||
|
||||
### Sonstiges
|
||||
|
||||
| Befehl | Beschreibung | Berechtigung |
|
||||
|--------|--------------|--------------|
|
||||
| `/build` | Build-Modus toggle | `nexuslobby.build` |
|
||||
| `/maintenance <on\|off>` | Wartungsmodus | `nexuslobby.maintenance` |
|
||||
| `/settings` | Lobby-Einstellungen (Gamerules) | `nexuslobby.admin` |
|
||||
| `/holo create <id> [text]` | Erstellt Hologramm | `nexuslobby.hologram` |
|
||||
| `/holo delete <id>` | Löscht Hologramm | `nexuslobby.hologram` |
|
||||
| `/mapart <URL> <BxH>` | Erstellt MapArt | `nexuslobby.mapart` |
|
||||
| `/intro <add\|clear\|start>` | Intro-Tour-Verwaltung | `nexuslobby.admin` |
|
||||
| `/border <circle\|square\|disable>` | Worldborder-Setup | `nexuslobby.admin` |
|
||||
|
||||
---
|
||||
|
||||
## ⚙️ Konfiguration
|
||||
|
||||
### config.yml (Auszug)
|
||||
|
||||
```yaml
|
||||
# Spawn-Einstellungen
|
||||
spawn:
|
||||
world: "world"
|
||||
x: 0.5
|
||||
y: 64.0
|
||||
z: 0.5
|
||||
yaw: 0.0
|
||||
pitch: 0.0
|
||||
|
||||
# Lobby-Einstellungen
|
||||
lobby:
|
||||
allow-fly: false
|
||||
pvp-enabled: false
|
||||
build-enabled: false
|
||||
default-gamemode: Adventure
|
||||
clear-inventory-on-join: true
|
||||
|
||||
# Server-Mapping (für Status-Check)
|
||||
servers:
|
||||
survival:
|
||||
ip: "127.0.0.1"
|
||||
port: 25566
|
||||
skyblock:
|
||||
ip: "127.0.0.1"
|
||||
port: 25567
|
||||
|
||||
# Ball/Soccer-Einstellungen
|
||||
ball:
|
||||
respawn_delay: 60 # Sekunden bis Auto-Respawn
|
||||
|
||||
# Worldborder
|
||||
worldborder:
|
||||
enabled: true
|
||||
type: "SQUARE" # SQUARE oder CIRCLE
|
||||
radius: 50.0
|
||||
```
|
||||
|
||||
### conversations.yml
|
||||
|
||||
```yaml
|
||||
conversations:
|
||||
willkommen:
|
||||
dialogue:
|
||||
- "&eWächter: &7Willkommen auf dem Server!"
|
||||
- "&aBürger: &7Schön, dass du da bist!"
|
||||
- "&eWächter: &7Viel Spaß beim Erkunden!"
|
||||
|
||||
quest_dialog:
|
||||
dialogue:
|
||||
- "&6Quest-Geber: &7Hast du meine Quest erledigt?"
|
||||
- "&aHeld: &7Ja, ich habe alle Monster besiegt!"
|
||||
|
||||
links:
|
||||
# UUID des ersten NPCs
|
||||
"550e8400-e29b-41d4-a716-446655440000":
|
||||
partner: "550e8400-e29b-41d4-a716-446655440001" # UUID des zweiten NPCs
|
||||
dialog: willkommen
|
||||
automated: true # Startet automatisch
|
||||
```
|
||||
|
||||
### visuals.yml (Auszug)
|
||||
|
||||
```yaml
|
||||
# ActionBar-Nachrichten
|
||||
actionbar:
|
||||
enabled: true
|
||||
speed: 3
|
||||
messages:
|
||||
- "&6&lWillkommen &8» &eauf unserem Server!"
|
||||
- "&b&lViel Spaß &8» &7in der Lobby!"
|
||||
|
||||
# BossBar
|
||||
bossbar:
|
||||
enabled: true
|
||||
interval: 40
|
||||
messages:
|
||||
- text: "&6&lNexusLobby &8» &eVersion 1.1.0"
|
||||
color: "YELLOW"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🔐 Berechtigungen
|
||||
|
||||
### Admin-Berechtigungen
|
||||
|
||||
| Berechtigung | Beschreibung |
|
||||
|--------------|--------------|
|
||||
| `nexuslobby.admin` | Voller Zugriff auf alle System-Einstellungen |
|
||||
| `nexuslobby.armorstand.cmd` | NPCs konfigurieren und Dialoge verknüpfen |
|
||||
| `nexuslobby.armorstand.use` | Zugriff auf die ArmorStand-Editor GUI |
|
||||
| `nexuslobby.build` | Berechtigung für den Baumodus |
|
||||
| `nexuslobby.portal` | Portale erstellen und löschen |
|
||||
| `nexuslobby.portal.give` | Portal-Werkzeug erhalten |
|
||||
| `nexuslobby.hologram` | Hologramme verwalten |
|
||||
| `nexuslobby.mapart` | MapArt erstellen |
|
||||
| `nexuslobby.maintenance` | Wartungsmodus togglen |
|
||||
|
||||
### Spieler-Berechtigungen
|
||||
|
||||
| Berechtigung | Beschreibung |
|
||||
|--------------|--------------|
|
||||
| `nexuslobby.spawn` | Spawn-Command nutzen |
|
||||
| `nexuslobby.serverswitcher` | Server-Switcher GUI öffnen |
|
||||
| `nexuslobby.scoreboard.admin` | Admin-Scoreboard sehen |
|
||||
|
||||
### Bypass-Berechtigungen
|
||||
|
||||
| Berechtigung | Beschreibung |
|
||||
|--------------|--------------|
|
||||
| `nexuslobby.bypass.maintenance` | Server trotz Wartungsmodus betreten |
|
||||
| `nexuslobby.bypass.vpn` | VPN-Check überspringen |
|
||||
| `nexuslobby.bypass.country` | Country-Check überspringen |
|
||||
|
||||
---
|
||||
|
||||
## 🔧 Technische Details
|
||||
|
||||
### Systemanforderungen
|
||||
- **Minecraft**: Paper/Spigot 1.21+ (Spigot-kompatibel, Paper empfohlen)
|
||||
- **Java**: Java 21 oder höher
|
||||
- **Dependencies**: LuckPerms, PlaceholderAPI (optional)
|
||||
|
||||
### Verwendete Technologien
|
||||
- **Build-Tool**: Maven 3.9+
|
||||
- **JSON-Library**: Gson 2.10.1 (gegenüber json-simple 1.1.1 aktualisiert)
|
||||
- **BungeeCord API**: Für Server-Wechsel und Messaging
|
||||
- **PlaceholderAPI**: Für dynamische Platzhalter
|
||||
|
||||
### Code-Qualität
|
||||
- ✅ Moderne Java 21 Features (Switch-Expressions, Pattern Matching)
|
||||
- ✅ Proper Error-Handling (Logger statt printStackTrace)
|
||||
- ✅ Memory-Management (Tasks & Listeners werden sauber disposed)
|
||||
- ✅ Config-Validierung mit Default-Werten
|
||||
- ✅ Optimiertes JSON-Parsing mit Gson
|
||||
- ✅ Spigot-kompatible BungeeCord Chat API
|
||||
|
||||
### Performance-Optimierungen
|
||||
- **Async-Processing** für API-Calls (Update-Check, VPN-Check)
|
||||
- **Caching** für Spieler-Daten und Config-Werte
|
||||
- **Optimierte Entity-Queries** (nur relevante Welten)
|
||||
- **Effiziente Scheduler-Nutzung** (Tasks werden gecancelt)
|
||||
|
||||
---
|
||||
|
||||
## 📦 Installation
|
||||
|
||||
1. **Download** der neuesten `NexusLobby-1.1.0.jar` aus den [Releases](../../releases)
|
||||
2. **Upload** der JAR-Datei in den `/plugins/` Ordner
|
||||
3. **Server-Neustart** durchführen
|
||||
4. **Konfiguration** anpassen (`config.yml`, `visuals.yml`, etc.)
|
||||
5. **Permissions** mit LuckPerms oder einem anderen Permissions-Plugin setzen
|
||||
6. **(Optional)** PlaceholderAPI installieren für erweiterte Platzhalter
|
||||
|
||||
---
|
||||
|
||||
## 🐛 Bekannte Issues & Lösungen
|
||||
|
||||
### Ball spawnt mehrfach
|
||||
- **Lösung**: Nutze `/nexuslobby ball remove` gefolgt von `/nexuslobby ball setspawn`
|
||||
- Das Anti-Duplikat-System sollte dies automatisch verhindern
|
||||
|
||||
### NPCs schauen nicht zu Spielern
|
||||
- **Lösung**: Stelle sicher, dass der NPC mit `/nexustools` das LookAt-Feature aktiviert hat
|
||||
- Prüfe, ob `ArmorStandLookAtModule` in den Logs geladen wird
|
||||
|
||||
### Server-Checker zeigt falsche Status
|
||||
- **Lösung**: Überprüfe die IP/Port-Einstellungen in `config.yml` unter `servers:`
|
||||
- Stelle sicher, dass die Server erreichbar sind (Firewall, Ports)
|
||||
|
||||
---
|
||||
|
||||
## 📚 Support & Dokumentation
|
||||
|
||||
- **Wiki**: Ausführliche Dokumentation im [Wiki](../../wiki)
|
||||
- **Bug-Reports**: Erstelle ein [Issue](../../issues) bei technischen Problemen
|
||||
- **Feature-Requests**: Vorschläge über [Issues](../../issues) mit Label "enhancement"
|
||||
|
||||
---
|
||||
|
||||
## 📝 Changelog
|
||||
|
||||
### Version 1.1.0 (Februar 2026)
|
||||
- ✨ Soccer/Fußball-System mit realistischer Physik
|
||||
- ✨ Parkour-System mit Bestenliste und Checkpoints
|
||||
- ✨ Player-Inspector Modul
|
||||
- ✨ Config-Validierung mit Auto-Defaults
|
||||
- 🔧 JSON-Library auf Gson 2.10.1 aktualisiert
|
||||
- 🔧 Alle printStackTrace() durch Logger ersetzt
|
||||
- 🔧 Memory-Management verbessert (Tasks & Listeners)
|
||||
- 🔧 UpdateChecker mit proper JSON-Parsing
|
||||
- 🐛 Diverse Bug-Fixes und Performance-Optimierungen
|
||||
|
||||
---
|
||||
|
||||
**Copyright © 2026 - M_Viper - Alle Rechte vorbehalten**
|
||||
|
||||
Die unbefugte Vervielfältigung, Verbreitung oder Weitergabe dieses Plugins ist strafbar und wird rechtlich verfolgt.
|
||||
@@ -69,6 +69,7 @@ public class NexusLobby extends JavaPlugin implements Listener {
|
||||
private BorderModule borderModule;
|
||||
private ParkourManager parkourManager;
|
||||
private SoccerModule soccerModule;
|
||||
private ArmorStandLookAtModule armorStandLookAtModule;
|
||||
|
||||
private ConversationManager conversationManager;
|
||||
|
||||
@@ -135,7 +136,7 @@ public class NexusLobby extends JavaPlugin implements Listener {
|
||||
|
||||
ServerChecker.startGlobalChecker();
|
||||
|
||||
new ArmorStandLookAtModule();
|
||||
armorStandLookAtModule = new ArmorStandLookAtModule();
|
||||
|
||||
startAutoConversationTimer();
|
||||
|
||||
@@ -192,7 +193,10 @@ public class NexusLobby extends JavaPlugin implements Listener {
|
||||
}
|
||||
|
||||
ServerChecker.startGlobalChecker();
|
||||
new ArmorStandLookAtModule();
|
||||
// FIX: ArmorStandLookAtModule als Feld tracken. Bukkit.getScheduler().cancelTasks()
|
||||
// am Anfang von reloadPlugin() cancelt den alten Task bereits – hier nur
|
||||
// neu starten und Referenz aktualisieren, damit kein doppelter Task läuft.
|
||||
armorStandLookAtModule = new ArmorStandLookAtModule();
|
||||
startAutoConversationTimer();
|
||||
|
||||
getLogger().info("Plugin Reload abgeschlossen. Änderungen wurden übernommen.");
|
||||
@@ -200,18 +204,55 @@ public class NexusLobby extends JavaPlugin implements Listener {
|
||||
|
||||
private void checkUpdates() {
|
||||
new UpdateChecker(this).getVersion(version -> {
|
||||
if (!this.getDescription().getVersion().equalsIgnoreCase(version)) {
|
||||
String currentVersion = this.getDescription().getVersion();
|
||||
if (isRemoteVersionNewer(currentVersion, version)) {
|
||||
this.updateAvailable = true;
|
||||
this.latestVersion = version;
|
||||
getLogger().warning("====================================================");
|
||||
getLogger().warning("Update gefunden! v" + getDescription().getVersion() + " -> v" + version);
|
||||
getLogger().warning("Update gefunden! v" + currentVersion + " -> v" + version);
|
||||
getLogger().warning("====================================================");
|
||||
} else {
|
||||
getLogger().info("NexusLobby ist aktuell (v" + version + ").");
|
||||
this.updateAvailable = false;
|
||||
this.latestVersion = "";
|
||||
getLogger().info("NexusLobby ist aktuell/neu genug (lokal v" + currentVersion + ", remote v" + version + ").");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private boolean isRemoteVersionNewer(String localVersion, String remoteVersion) {
|
||||
int[] local = extractVersionNumbers(localVersion);
|
||||
int[] remote = extractVersionNumbers(remoteVersion);
|
||||
|
||||
int max = Math.max(local.length, remote.length);
|
||||
for (int i = 0; i < max; i++) {
|
||||
int l = i < local.length ? local[i] : 0;
|
||||
int r = i < remote.length ? remote[i] : 0;
|
||||
if (r > l) return true;
|
||||
if (r < l) return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private int[] extractVersionNumbers(String version) {
|
||||
if (version == null || version.isBlank()) return new int[0];
|
||||
|
||||
java.util.regex.Matcher matcher = java.util.regex.Pattern.compile("\\\\d+").matcher(version);
|
||||
java.util.List<Integer> parts = new java.util.ArrayList<>();
|
||||
while (matcher.find()) {
|
||||
try {
|
||||
parts.add(Integer.parseInt(matcher.group()));
|
||||
} catch (NumberFormatException ignored) {
|
||||
parts.add(0);
|
||||
}
|
||||
}
|
||||
|
||||
int[] result = new int[parts.size()];
|
||||
for (int i = 0; i < parts.size(); i++) {
|
||||
result[i] = parts.get(i);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private void registerModules() {
|
||||
moduleManager.registerModule(new ProtectionModule());
|
||||
moduleManager.registerModule(new ScoreboardModule());
|
||||
@@ -319,7 +360,7 @@ public class NexusLobby extends JavaPlugin implements Listener {
|
||||
player.sendMessage(de.nexuslobby.utils.LangManager.get("update_available"));
|
||||
player.sendMessage(de.nexuslobby.utils.LangManager.get("update_version").replace("{old}", getDescription().getVersion()).replace("{new}", latestVersion));
|
||||
TextComponent link = new TextComponent(de.nexuslobby.utils.LangManager.get("update_download_link"));
|
||||
link.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://git.viper.ipv64.net/M_Viper/NexusLobby/releases"));
|
||||
link.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://www.spigotmc.org/resources/132388/"));
|
||||
link.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT,
|
||||
new ComponentBuilder(de.nexuslobby.utils.LangManager.get("update_download_hover")).create()));
|
||||
player.spigot().sendMessage(link);
|
||||
@@ -488,6 +529,12 @@ public class NexusLobby extends JavaPlugin implements Listener {
|
||||
if (params.equalsIgnoreCase("parkour_top")) {
|
||||
return parkourManager != null ? parkourManager.getTopTen() : "N/A";
|
||||
}
|
||||
if (params.equalsIgnoreCase("parkour_top_1")) {
|
||||
return parkourManager != null ? parkourManager.getTopTen(1) : "N/A";
|
||||
}
|
||||
if (params.equalsIgnoreCase("parkour_top_2")) {
|
||||
return parkourManager != null ? parkourManager.getTopTen(2) : "N/A";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ public class LobbyTabCompleter implements TabCompleter {
|
||||
private final HologramModule hologramModule;
|
||||
|
||||
public LobbyTabCompleter(PortalManager portalManager, HologramModule hologramModule) {
|
||||
this.portalManager = portalManager;
|
||||
this.portalManager = portalManager;
|
||||
this.hologramModule = hologramModule;
|
||||
}
|
||||
|
||||
@@ -28,65 +28,117 @@ public class LobbyTabCompleter implements TabCompleter {
|
||||
List<String> suggestions = new ArrayList<>();
|
||||
String cmdName = command.getName().toLowerCase();
|
||||
|
||||
// --- NexusLobby Hauptbefehl (/nexus) ---
|
||||
// ── NexusLobby Hauptbefehl (/nexus oder /nexuslobby) ──────────────────
|
||||
if (cmdName.equals("nexuslobby") || cmdName.equals("nexus")) {
|
||||
|
||||
// /nexuslobby <?>
|
||||
if (args.length == 1) {
|
||||
if (sender.hasPermission("nexuslobby.admin")) {
|
||||
suggestions.addAll(Arrays.asList("reload", "setspawn", "silentjoin", "parkour", "ball")); // NEU: ball
|
||||
suggestions.addAll(Arrays.asList(
|
||||
"reload", "setspawn", "silentjoin", "parkour", "ball", "cleanbubbles", "gadgetshield"
|
||||
));
|
||||
}
|
||||
suggestions.add("sb");
|
||||
|
||||
// /nexuslobby <sub> <?>
|
||||
} else if (args.length == 2) {
|
||||
if (args[0].equalsIgnoreCase("sb")) {
|
||||
suggestions.addAll(Arrays.asList("on", "off"));
|
||||
if (sender.hasPermission("nexuslobby.scoreboard.admin")) {
|
||||
suggestions.addAll(Arrays.asList("admin", "spieler"));
|
||||
switch (args[0].toLowerCase()) {
|
||||
case "sb" -> {
|
||||
suggestions.addAll(Arrays.asList("on", "off"));
|
||||
if (sender.hasPermission("nexuslobby.scoreboard.admin"))
|
||||
suggestions.addAll(Arrays.asList("admin", "spieler"));
|
||||
}
|
||||
} else if (args[0].equalsIgnoreCase("silentjoin")) {
|
||||
suggestions.addAll(Arrays.asList("on", "off"));
|
||||
} else if (args[0].equalsIgnoreCase("parkour")) {
|
||||
suggestions.addAll(Arrays.asList("setstart", "setfinish", "setcheckpoint", "reset", "clear", "removeall"));
|
||||
} else if (args[0].equalsIgnoreCase("ball")) {
|
||||
if (sender.hasPermission("nexuslobby.admin")) {
|
||||
suggestions.addAll(Arrays.asList("setspawn", "respawn", "remove"));
|
||||
case "silentjoin" -> suggestions.addAll(Arrays.asList("on", "off"));
|
||||
case "parkour" -> {
|
||||
if (sender.hasPermission("nexuslobby.admin")) {
|
||||
suggestions.addAll(Arrays.asList(
|
||||
"setstart", "setfinish", "setcheckpoint",
|
||||
"holo", "reset", "clear", "removeall", "info"
|
||||
));
|
||||
} else {
|
||||
// Normale Spieler können nur ihren Run abbrechen
|
||||
suggestions.add("reset");
|
||||
}
|
||||
}
|
||||
case "ball" -> {
|
||||
if (sender.hasPermission("nexuslobby.admin")) {
|
||||
suggestions.addAll(Arrays.asList(
|
||||
"setspawn", "respawn", "remove", "goal", "score"
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// /nexuslobby <sub> <sub2> <?>
|
||||
} else if (args.length == 3) {
|
||||
if (args[0].equalsIgnoreCase("parkour") && args[1].equalsIgnoreCase("setcheckpoint")) {
|
||||
suggestions.addAll(Arrays.asList("1", "2", "3", "4", "5", "6", "7", "8", "9"));
|
||||
switch (args[0].toLowerCase()) {
|
||||
// Für setstart / setfinish / setcheckpoint → Strecken-Nummer 1 oder 2
|
||||
case "parkour" -> {
|
||||
String parkSub = args[1].toLowerCase();
|
||||
if (parkSub.equals("setstart")
|
||||
|| parkSub.equals("setfinish")
|
||||
|| parkSub.equals("setcheckpoint")
|
||||
|| parkSub.equals("holo")) {
|
||||
suggestions.addAll(Arrays.asList("1", "2"));
|
||||
}
|
||||
}
|
||||
case "ball" -> {
|
||||
switch (args[1].toLowerCase()) {
|
||||
case "goal" -> suggestions.addAll(Arrays.asList(
|
||||
"pos1", "pos2", "save", "delete", "list", "show", "debug"
|
||||
));
|
||||
case "score" -> suggestions.add("reset");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// /nexuslobby <sub> <sub2> <sub3> <?>
|
||||
} else if (args.length == 4) {
|
||||
if (args[0].equalsIgnoreCase("ball") && args[1].equalsIgnoreCase("goal")) {
|
||||
switch (args[2].toLowerCase()) {
|
||||
case "save" -> suggestions.add("<TorName>");
|
||||
case "delete" -> {
|
||||
var section = NexusLobby.getInstance().getConfig()
|
||||
.getConfigurationSection("ball.goals");
|
||||
if (section != null) suggestions.addAll(section.getKeys(false));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// /nexuslobby ball goal save <Name> <?> → Team 1 oder 2
|
||||
} else if (args.length == 5) {
|
||||
if (args[0].equalsIgnoreCase("ball")
|
||||
&& args[1].equalsIgnoreCase("goal")
|
||||
&& args[2].equalsIgnoreCase("save")) {
|
||||
suggestions.addAll(Arrays.asList("1", "2"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --- Hologram Befehl ---
|
||||
}
|
||||
|
||||
// ── Hologram Befehl ───────────────────────────────────────────────────
|
||||
else if (cmdName.equals("holo")) {
|
||||
if (args.length == 1) {
|
||||
suggestions.addAll(Arrays.asList("create", "delete"));
|
||||
} else if (args.length == 2 && args[0].equalsIgnoreCase("delete")) {
|
||||
if (hologramModule != null) {
|
||||
suggestions.addAll(hologramModule.getHologramIds());
|
||||
}
|
||||
if (hologramModule != null) suggestions.addAll(hologramModule.getHologramIds());
|
||||
}
|
||||
}
|
||||
|
||||
// --- Wartungsmodus ---
|
||||
}
|
||||
|
||||
// ── Wartungsmodus ─────────────────────────────────────────────────────
|
||||
else if (cmdName.equals("maintenance")) {
|
||||
if (args.length == 1) {
|
||||
suggestions.addAll(Arrays.asList("on", "off"));
|
||||
}
|
||||
}
|
||||
|
||||
// --- Portalsystem ---
|
||||
if (args.length == 1) suggestions.addAll(Arrays.asList("on", "off"));
|
||||
}
|
||||
|
||||
// ── Portalsystem ──────────────────────────────────────────────────────
|
||||
else if (cmdName.equals("portal")) {
|
||||
if (args.length == 1) {
|
||||
suggestions.addAll(Arrays.asList("create", "delete", "list"));
|
||||
} else if (args.length == 2 && args[0].equalsIgnoreCase("delete")) {
|
||||
if (portalManager != null) {
|
||||
suggestions.addAll(portalManager.getPortalNames());
|
||||
}
|
||||
if (portalManager != null) suggestions.addAll(portalManager.getPortalNames());
|
||||
}
|
||||
}
|
||||
|
||||
// --- MapArt ---
|
||||
}
|
||||
|
||||
// ── MapArt ────────────────────────────────────────────────────────────
|
||||
else if (cmdName.equals("mapart")) {
|
||||
if (args.length == 1) {
|
||||
suggestions.add("https://");
|
||||
@@ -95,14 +147,12 @@ public class LobbyTabCompleter implements TabCompleter {
|
||||
}
|
||||
}
|
||||
|
||||
// --- Intro System ---
|
||||
// ── Intro System ──────────────────────────────────────────────────────
|
||||
else if (cmdName.equals("intro")) {
|
||||
if (args.length == 1) {
|
||||
suggestions.addAll(Arrays.asList("add", "clear", "start"));
|
||||
}
|
||||
if (args.length == 1) suggestions.addAll(Arrays.asList("add", "clear", "start"));
|
||||
}
|
||||
|
||||
// --- WorldBorder ---
|
||||
// ── WorldBorder ───────────────────────────────────────────────────────
|
||||
else if (cmdName.equals("border")) {
|
||||
if (args.length == 1) {
|
||||
suggestions.addAll(Arrays.asList("circle", "square", "disable"));
|
||||
@@ -110,63 +160,52 @@ public class LobbyTabCompleter implements TabCompleter {
|
||||
suggestions.addAll(Arrays.asList("10", "25", "50", "100", "250"));
|
||||
}
|
||||
}
|
||||
|
||||
// --- NexusCmd / ArmorStandTools ---
|
||||
else if (cmdName.equals("nexuscmd") || cmdName.equals("ncmd") || cmdName.equals("ascmd") || cmdName.equals("conv")) {
|
||||
|
||||
// ── NexusCmd / ArmorStandTools ────────────────────────────────────────
|
||||
else if (cmdName.equals("nexuscmd") || cmdName.equals("ncmd")
|
||||
|| cmdName.equals("ascmd") || cmdName.equals("conv")) {
|
||||
if (args.length == 1) {
|
||||
suggestions.addAll(Arrays.asList("add", "remove", "list", "name", "lookat", "conv", "say"));
|
||||
}
|
||||
else if (args.length == 2) {
|
||||
if (args[0].equalsIgnoreCase("add")) {
|
||||
suggestions.addAll(Arrays.asList("0", "1", "2", "3", "4", "5", "6", "7", "8", "9"));
|
||||
} else if (args[0].equalsIgnoreCase("name")) {
|
||||
suggestions.addAll(Arrays.asList("<Anzeigename>", "none"));
|
||||
} else if (args[0].equalsIgnoreCase("conv")) {
|
||||
suggestions.addAll(Arrays.asList("select1", "select2", "select3", "select4", "link", "unlink", "start"));
|
||||
} else if (args[0].equalsIgnoreCase("remove")) {
|
||||
suggestions.addAll(Arrays.asList("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "all"));
|
||||
} else if (args[0].equalsIgnoreCase("say")) {
|
||||
suggestions.add("<Nachricht>");
|
||||
suggestions.addAll(Arrays.asList("add", "remove", "list", "name", "lookat", "conv", "say", "clearbubbles"));
|
||||
} else if (args.length == 2) {
|
||||
switch (args[0].toLowerCase()) {
|
||||
case "add" -> suggestions.addAll(Arrays.asList("0","1","2","3","4","5","6","7","8","9"));
|
||||
case "name" -> suggestions.addAll(Arrays.asList("<Anzeigename>", "none"));
|
||||
case "conv" -> suggestions.addAll(Arrays.asList("select1","select2","select3","select4","link","unlink","start"));
|
||||
case "remove" -> suggestions.addAll(Arrays.asList("0","1","2","3","4","5","6","7","8","9","all"));
|
||||
case "say" -> suggestions.add("<Nachricht>");
|
||||
}
|
||||
}
|
||||
else if (args.length == 3) {
|
||||
} else if (args.length == 3) {
|
||||
if (args[0].equalsIgnoreCase("add")) {
|
||||
suggestions.addAll(Arrays.asList("0", "1", "2", "3", "4", "5", "6", "7", "8", "9"));
|
||||
} else if (args[0].equalsIgnoreCase("conv")) {
|
||||
if (args[1].equalsIgnoreCase("start") || args[1].equalsIgnoreCase("link")) {
|
||||
if (NexusLobby.getInstance().getConversationManager() != null) {
|
||||
suggestions.addAll(NexusLobby.getInstance().getConversationManager().getConversationIds());
|
||||
}
|
||||
}
|
||||
suggestions.addAll(Arrays.asList("0","1","2","3","4","5","6","7","8","9"));
|
||||
} else if (args[0].equalsIgnoreCase("conv")
|
||||
&& (args[1].equalsIgnoreCase("start") || args[1].equalsIgnoreCase("link"))) {
|
||||
if (NexusLobby.getInstance().getConversationManager() != null)
|
||||
suggestions.addAll(NexusLobby.getInstance().getConversationManager().getConversationIds());
|
||||
}
|
||||
}
|
||||
else if (args.length == 4 && args[0].equalsIgnoreCase("add")) {
|
||||
} else if (args.length == 4 && args[0].equalsIgnoreCase("add")) {
|
||||
suggestions.addAll(Arrays.asList("bungee", "console", "player"));
|
||||
}
|
||||
else if (args.length == 5 && args[0].equalsIgnoreCase("add") && args[3].equalsIgnoreCase("bungee")) {
|
||||
if (NexusLobby.getInstance().getConfig().getConfigurationSection("servers") != null) {
|
||||
suggestions.addAll(NexusLobby.getInstance().getConfig().getConfigurationSection("servers").getKeys(false));
|
||||
}
|
||||
} else if (args.length == 5 && args[0].equalsIgnoreCase("add")
|
||||
&& args[3].equalsIgnoreCase("bungee")) {
|
||||
var section = NexusLobby.getInstance().getConfig().getConfigurationSection("servers");
|
||||
if (section != null) suggestions.addAll(section.getKeys(false));
|
||||
}
|
||||
}
|
||||
|
||||
// --- ArmorStandTools Alternate ---
|
||||
// ── ArmorStandTools Alternate ─────────────────────────────────────────
|
||||
else if (cmdName.equals("astools") || cmdName.equals("nt") || cmdName.equals("ntools")) {
|
||||
if (args.length == 1) {
|
||||
suggestions.addAll(Arrays.asList("dynamic", "lookat", "addplayer", "addconsole", "remove", "reload", "say"));
|
||||
}
|
||||
else if (args.length == 2 && args[0].equalsIgnoreCase("say")) {
|
||||
suggestions.add("<Nachricht>");
|
||||
}
|
||||
else if (args.length == 2 && (args[0].equalsIgnoreCase("addplayer") || args[0].equalsIgnoreCase("addconsole"))) {
|
||||
suggestions.addAll(Arrays.asList("0", "1", "2", "3", "4", "5", "6", "7", "8", "9"));
|
||||
}
|
||||
else if (args.length == 3 && (args[0].equalsIgnoreCase("addplayer") || args[0].equalsIgnoreCase("addconsole"))) {
|
||||
suggestions.addAll(Arrays.asList("0", "1", "2", "3", "4", "5", "6", "7", "8", "9"));
|
||||
suggestions.addAll(Arrays.asList("dynamic","lookat","addplayer","addconsole","remove","reload","say"));
|
||||
} else if (args.length == 2) {
|
||||
if (args[0].equalsIgnoreCase("say"))
|
||||
suggestions.add("<Nachricht>");
|
||||
else if (args[0].equalsIgnoreCase("addplayer") || args[0].equalsIgnoreCase("addconsole"))
|
||||
suggestions.addAll(Arrays.asList("0","1","2","3","4","5","6","7","8","9"));
|
||||
} else if (args.length == 3) {
|
||||
if (args[0].equalsIgnoreCase("addplayer") || args[0].equalsIgnoreCase("addconsole"))
|
||||
suggestions.addAll(Arrays.asList("0","1","2","3","4","5","6","7","8","9"));
|
||||
}
|
||||
}
|
||||
|
||||
// Filtert die Liste basierend auf der bisherigen Eingabe
|
||||
return suggestions.stream()
|
||||
.filter(s -> s.toLowerCase().startsWith(args[args.length - 1].toLowerCase()))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
@@ -2,6 +2,7 @@ package de.nexuslobby.commands;
|
||||
|
||||
import de.nexuslobby.NexusLobby;
|
||||
import de.nexuslobby.modules.ScoreboardModule;
|
||||
import de.nexuslobby.modules.hologram.HologramModule;
|
||||
import de.nexuslobby.modules.parkour.ParkourManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
@@ -22,7 +23,7 @@ public class NexusLobbyCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
|
||||
|
||||
if (!(sender instanceof Player player)) {
|
||||
sender.sendMessage(de.nexuslobby.utils.LangManager.get("only_player"));
|
||||
return true;
|
||||
@@ -34,19 +35,18 @@ public class NexusLobbyCommand implements CommandExecutor {
|
||||
// --- DIREKTE KURZ-BEFEHLE ---
|
||||
if (cmdName.equalsIgnoreCase("setstart")) {
|
||||
if (!player.hasPermission("nexuslobby.admin")) return noPerm(player);
|
||||
handleSetStart(player, pm);
|
||||
// Standard: Strecke 1 setzen
|
||||
pm.setStartLocation(player, 1);
|
||||
return true;
|
||||
}
|
||||
if (cmdName.equalsIgnoreCase("setcheckpoint")) {
|
||||
if (!player.hasPermission("nexuslobby.admin")) return noPerm(player);
|
||||
pm.setCheckpoint(player, player.getLocation());
|
||||
player.sendMessage(de.nexuslobby.utils.LangManager.get("parkour_checkpoint_set"));
|
||||
pm.setCheckpoint(player, 1);
|
||||
return true;
|
||||
}
|
||||
if (cmdName.equalsIgnoreCase("setfinish")) {
|
||||
if (!player.hasPermission("nexuslobby.admin")) return noPerm(player);
|
||||
pm.setFinishLocation(player.getLocation());
|
||||
player.sendMessage(de.nexuslobby.utils.LangManager.get("parkour_finish_set"));
|
||||
pm.setFinishLocation(player, 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -75,6 +75,7 @@ public class NexusLobbyCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
switch (args[0].toLowerCase()) {
|
||||
|
||||
case "reload":
|
||||
if (!player.hasPermission("nexuslobby.admin")) return noPerm(player);
|
||||
NexusLobby.getInstance().reloadPlugin();
|
||||
@@ -82,6 +83,11 @@ public class NexusLobbyCommand implements CommandExecutor {
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1f, 1.5f);
|
||||
break;
|
||||
|
||||
case "cleanbubbles":
|
||||
if (!player.hasPermission("nexuslobby.admin")) return noPerm(player);
|
||||
handleCleanBubbles(player);
|
||||
break;
|
||||
|
||||
case "setspawn":
|
||||
if (!player.hasPermission("nexuslobby.admin")) return noPerm(player);
|
||||
Location loc = player.getLocation();
|
||||
@@ -90,7 +96,7 @@ public class NexusLobbyCommand implements CommandExecutor {
|
||||
config.set("spawn.x", loc.getX());
|
||||
config.set("spawn.y", loc.getY());
|
||||
config.set("spawn.z", loc.getZ());
|
||||
config.set("spawn.yaw", (double) loc.getYaw());
|
||||
config.set("spawn.yaw", (double) loc.getYaw());
|
||||
config.set("spawn.pitch", (double) loc.getPitch());
|
||||
NexusLobby.getInstance().saveConfig();
|
||||
player.sendMessage(de.nexuslobby.utils.LangManager.get("spawn_set"));
|
||||
@@ -111,7 +117,12 @@ public class NexusLobbyCommand implements CommandExecutor {
|
||||
handleScoreboard(player, args);
|
||||
break;
|
||||
|
||||
case "ball": // NEU: Weiterleitung an das SoccerModule
|
||||
case "gadgetshield":
|
||||
if (!player.hasPermission("nexuslobby.admin") && !player.isOp()) return noPerm(player);
|
||||
de.nexuslobby.modules.gadgets.GadgetShield.toggle(player);
|
||||
break;
|
||||
|
||||
case "ball":
|
||||
if (NexusLobby.getInstance().getSoccerModule() != null) {
|
||||
return NexusLobby.getInstance().getSoccerModule().onCommand(sender, command, label, args);
|
||||
}
|
||||
@@ -119,42 +130,7 @@ public class NexusLobbyCommand implements CommandExecutor {
|
||||
break;
|
||||
|
||||
case "parkour":
|
||||
if (args.length < 2) {
|
||||
player.sendMessage(de.nexuslobby.utils.LangManager.get("parkour_usage"));
|
||||
return true;
|
||||
}
|
||||
|
||||
String sub = args[1].toLowerCase();
|
||||
if (!player.hasPermission("nexuslobby.admin") && !sub.equals("reset")) return noPerm(player);
|
||||
|
||||
switch (sub) {
|
||||
case "setstart":
|
||||
handleSetStart(player, pm);
|
||||
break;
|
||||
case "setfinish":
|
||||
pm.setFinishLocation(player.getLocation());
|
||||
player.sendMessage(de.nexuslobby.utils.LangManager.get("parkour_finish_set"));
|
||||
break;
|
||||
case "setcheckpoint":
|
||||
pm.setCheckpoint(player, player.getLocation());
|
||||
break;
|
||||
case "reset":
|
||||
pm.stopParkour(player);
|
||||
player.sendMessage(de.nexuslobby.utils.LangManager.get("parkour_run_aborted"));
|
||||
break;
|
||||
case "clear":
|
||||
pm.clearStats();
|
||||
player.sendMessage(de.nexuslobby.utils.LangManager.get("parkour_besttimes_cleared"));
|
||||
break;
|
||||
case "removeall":
|
||||
pm.removeAllPoints();
|
||||
player.sendMessage(de.nexuslobby.utils.LangManager.get("parkour_track_removed"));
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_ITEM_BREAK, 1f, 1f);
|
||||
break;
|
||||
default:
|
||||
player.sendMessage(de.nexuslobby.utils.LangManager.get("unknown_subcommand"));
|
||||
break;
|
||||
}
|
||||
handleParkour(player, args, pm);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -165,13 +141,128 @@ public class NexusLobbyCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
private void handleSetStart(Player player, ParkourManager pm) {
|
||||
// NPC Erkennung (Blickrichtung auf ArmorStand)
|
||||
// ─────────────────────────────────────────────────────────────────────────
|
||||
// Parkour-Handler
|
||||
// ─────────────────────────────────────────────────────────────────────────
|
||||
|
||||
private void handleParkour(Player player, String[] args, ParkourManager pm) {
|
||||
if (args.length < 2) {
|
||||
player.sendMessage(de.nexuslobby.utils.LangManager.get("parkour_usage"));
|
||||
// Strecken-Info ausgeben
|
||||
player.sendMessage(pm.getTrackInfo());
|
||||
return;
|
||||
}
|
||||
|
||||
String sub = args[1].toLowerCase();
|
||||
|
||||
// Nur "reset" kann auch ohne Admin-Recht ausgeführt werden (eigenen Lauf abbrechen)
|
||||
if (!player.hasPermission("nexuslobby.admin") && !sub.equals("reset")) {
|
||||
noPerm(player);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (sub) {
|
||||
|
||||
// /nexus parkour setstart <1|2>
|
||||
case "setstart": {
|
||||
int track = parseTrack(args, 2, player);
|
||||
if (track == -1) return;
|
||||
handleSetStart(player, pm, track);
|
||||
break;
|
||||
}
|
||||
|
||||
// /nexus parkour setfinish <1|2>
|
||||
case "setfinish": {
|
||||
int track = parseTrack(args, 2, player);
|
||||
if (track == -1) return;
|
||||
pm.setFinishLocation(player, track);
|
||||
break;
|
||||
}
|
||||
|
||||
// /nexus parkour setcheckpoint <1|2>
|
||||
case "setcheckpoint": {
|
||||
int track = parseTrack(args, 2, player);
|
||||
if (track == -1) return;
|
||||
pm.setCheckpoint(player, track);
|
||||
break;
|
||||
}
|
||||
|
||||
case "reset":
|
||||
pm.stopParkour(player);
|
||||
player.sendMessage(de.nexuslobby.utils.LangManager.get("parkour_run_aborted"));
|
||||
break;
|
||||
|
||||
case "clear":
|
||||
pm.clearStats();
|
||||
player.sendMessage(de.nexuslobby.utils.LangManager.get("parkour_besttimes_cleared"));
|
||||
break;
|
||||
|
||||
case "removeall":
|
||||
pm.removeAllPoints();
|
||||
player.sendMessage(de.nexuslobby.utils.LangManager.get("parkour_track_removed"));
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_ITEM_BREAK, 1f, 1f);
|
||||
break;
|
||||
|
||||
case "info":
|
||||
player.sendMessage(pm.getTrackInfo());
|
||||
break;
|
||||
|
||||
// /nexus parkour holo <1|2> – Leaderboard-Hologramm an aktueller Position setzen
|
||||
case "holo": {
|
||||
int track = parseTrack(args, 2, player);
|
||||
if (track == -1) return;
|
||||
HologramModule hm = NexusLobby.getInstance().getHologramModule();
|
||||
if (hm == null) {
|
||||
player.sendMessage("§cHologram-Modul nicht verfügbar!");
|
||||
return;
|
||||
}
|
||||
String holoId = "parkour_top_" + track;
|
||||
List<String> pages = new java.util.ArrayList<>();
|
||||
pages.add("%nexuslobby_parkour_top_" + track + "%");
|
||||
hm.createHologram(holoId, player.getLocation(), pages);
|
||||
player.sendMessage("§8[§6Parkour§8] §aLeaderboard-Hologramm für §eStrecke " + track
|
||||
+ " §agesetzt! §8(ID: §7" + holoId + "§8)");
|
||||
player.sendMessage("§8[§6Parkour§8] §7Das Hologramm aktualisiert sich automatisch via PlaceholderAPI.");
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
player.sendMessage(de.nexuslobby.utils.LangManager.get("unknown_subcommand"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Liest die Track-Nummer aus args[index].
|
||||
* Gibt 1 oder 2 zurück; bei Fehler sendet er eine Nachricht und gibt -1 zurück.
|
||||
*/
|
||||
private int parseTrack(String[] args, int index, Player player) {
|
||||
if (args.length <= index) {
|
||||
player.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§cBitte gib eine Strecken-Nummer an: §e1 §7oder §e2");
|
||||
return -1;
|
||||
}
|
||||
int track;
|
||||
try {
|
||||
track = Integer.parseInt(args[index]);
|
||||
} catch (NumberFormatException e) {
|
||||
player.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§cUngültige Strecken-Nummer. Bitte §e1 §7oder §e2 §7verwenden.");
|
||||
return -1;
|
||||
}
|
||||
if (track < 1 || track > 2) {
|
||||
player.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§cNur Strecke §e1 §7oder §e2 §7sind erlaubt.");
|
||||
return -1;
|
||||
}
|
||||
return track;
|
||||
}
|
||||
|
||||
private void handleSetStart(Player player, ParkourManager pm, int track) {
|
||||
// NPC-Erkennung: schaut der Spieler auf einen ArmorStand?
|
||||
ArmorStand targetAs = null;
|
||||
List<Entity> nearby = player.getNearbyEntities(4, 4, 4);
|
||||
for (Entity e : nearby) {
|
||||
if (e instanceof ArmorStand as) {
|
||||
double dot = player.getLocation().getDirection().dot(as.getLocation().toVector().subtract(player.getLocation().toVector()).normalize());
|
||||
double dot = player.getLocation().getDirection()
|
||||
.dot(as.getLocation().toVector().subtract(player.getLocation().toVector()).normalize());
|
||||
if (dot > 0.9) {
|
||||
targetAs = as;
|
||||
break;
|
||||
@@ -183,8 +274,23 @@ public class NexusLobbyCommand implements CommandExecutor {
|
||||
targetAs.addScoreboardTag("parkour_npc");
|
||||
player.sendMessage(de.nexuslobby.utils.LangManager.get("parkour_npc_marked"));
|
||||
}
|
||||
pm.setStartLocation(player.getLocation());
|
||||
player.sendMessage(de.nexuslobby.utils.LangManager.get("parkour_start_set"));
|
||||
pm.setStartLocation(player, track);
|
||||
}
|
||||
|
||||
// ─────────────────────────────────────────────────────────────────────────
|
||||
// Sonstige Handler
|
||||
// ─────────────────────────────────────────────────────────────────────────
|
||||
|
||||
private void handleCleanBubbles(Player player) {
|
||||
de.nexuslobby.modules.armorstandtools.ConversationManager cm =
|
||||
NexusLobby.getInstance().getConversationManager();
|
||||
if (cm == null) {
|
||||
player.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§cConversationManager ist nicht aktiv.");
|
||||
return;
|
||||
}
|
||||
cm.clearHangingBubbles();
|
||||
player.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§aAlle hängengebliebenen Sprechblasen wurden entfernt.");
|
||||
player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_PLING, 1f, 2f);
|
||||
}
|
||||
|
||||
private boolean noPerm(Player player) {
|
||||
@@ -202,18 +308,17 @@ public class NexusLobbyCommand implements CommandExecutor {
|
||||
player.sendMessage(de.nexuslobby.utils.LangManager.get("scoreboard_module_disabled"));
|
||||
return;
|
||||
}
|
||||
String sub = args[1].toLowerCase();
|
||||
switch (sub) {
|
||||
case "on": sbModule.setVisibility(player, true); break;
|
||||
case "off": sbModule.setVisibility(player, false); break;
|
||||
case "admin":
|
||||
switch (args[1].toLowerCase()) {
|
||||
case "on" -> sbModule.setVisibility(player, true);
|
||||
case "off" -> sbModule.setVisibility(player, false);
|
||||
case "admin" -> {
|
||||
if (player.hasPermission("nexuslobby.scoreboard.admin")) sbModule.setAdminMode(player, true);
|
||||
else player.sendMessage(de.nexuslobby.utils.LangManager.get("no_permission"));
|
||||
break;
|
||||
case "spieler":
|
||||
}
|
||||
case "spieler" -> {
|
||||
if (player.hasPermission("nexuslobby.scoreboard.admin")) sbModule.setAdminMode(player, false);
|
||||
else player.sendMessage(de.nexuslobby.utils.LangManager.get("no_permission"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -230,12 +335,20 @@ public class NexusLobbyCommand implements CommandExecutor {
|
||||
player.sendMessage(de.nexuslobby.utils.LangManager.get("info_title"));
|
||||
player.sendMessage("");
|
||||
player.sendMessage(de.nexuslobby.utils.LangManager.get("info_spawn"));
|
||||
player.sendMessage(de.nexuslobby.utils.LangManager.get("info_parkour"));
|
||||
player.sendMessage("§e/nexus parkour setstart <1|2> §7- Start setzen");
|
||||
player.sendMessage("§e/nexus parkour setcheckpoint <1|2> §7- Checkpoint setzen");
|
||||
player.sendMessage("§e/nexus parkour setfinish <1|2> §7- Ziel setzen");
|
||||
player.sendMessage("§e/nexus parkour holo <1|2> §7- Top-10 Hologramm setzen");
|
||||
player.sendMessage("§e/nexus parkour reset §7- Eigenen Run abbrechen");
|
||||
player.sendMessage("§e/nexus parkour clear §7- §cTop-10 Liste löschen");
|
||||
player.sendMessage(de.nexuslobby.utils.LangManager.get("info_removeall"));
|
||||
player.sendMessage(de.nexuslobby.utils.LangManager.get("info_ball"));
|
||||
player.sendMessage(de.nexuslobby.utils.LangManager.get("info_setspawn"));
|
||||
player.sendMessage(de.nexuslobby.utils.LangManager.get("info_scoreboard"));
|
||||
player.sendMessage(de.nexuslobby.utils.LangManager.get("info_reload"));
|
||||
player.sendMessage("§e/nexuslobby cleanbubbles §7- Hängende Sprechblasen entfernen");
|
||||
if (player.hasPermission("nexuslobby.admin") || player.isOp())
|
||||
player.sendMessage("§e/nexuslobby gadgetshield §7- Gadget-Schutz für Admins ein/ausschalten");
|
||||
player.sendMessage(de.nexuslobby.utils.LangManager.get("info_footer"));
|
||||
}
|
||||
}
|
||||
@@ -1,47 +1,47 @@
|
||||
package de.nexuslobby.modules;
|
||||
|
||||
import de.nexuslobby.NexusLobby;
|
||||
import de.nexuslobby.api.Module;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Player;
|
||||
import java.util.ArrayList;
|
||||
import java.util.UUID;
|
||||
|
||||
public class BuildModule implements Module {
|
||||
|
||||
private final ArrayList<UUID> buildModePlayers = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Build";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
// Falls du hier den Command registrierst, achte darauf,
|
||||
// dass er nicht doppelt in der NexusLobby.java registriert wird.
|
||||
}
|
||||
|
||||
public void toggleBuildMode(Player player) {
|
||||
if (!player.hasPermission("nexuslobby.build")) return;
|
||||
|
||||
if (buildModePlayers.contains(player.getUniqueId())) {
|
||||
buildModePlayers.remove(player.getUniqueId());
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
player.getInventory().clear();
|
||||
|
||||
// KORREKTUR: Hier muss getItemsModule() mit "s" stehen!
|
||||
if (NexusLobby.getInstance().getItemsModule() != null) {
|
||||
NexusLobby.getInstance().getItemsModule().giveLobbyItems(player);
|
||||
}
|
||||
} else {
|
||||
buildModePlayers.add(player.getUniqueId());
|
||||
player.setGameMode(GameMode.CREATIVE);
|
||||
player.getInventory().clear();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {}
|
||||
package de.nexuslobby.modules;
|
||||
|
||||
import de.nexuslobby.NexusLobby;
|
||||
import de.nexuslobby.api.Module;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Player;
|
||||
import java.util.ArrayList;
|
||||
import java.util.UUID;
|
||||
|
||||
public class BuildModule implements Module {
|
||||
|
||||
private final ArrayList<UUID> buildModePlayers = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Build";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
// Falls du hier den Command registrierst, achte darauf,
|
||||
// dass er nicht doppelt in der NexusLobby.java registriert wird.
|
||||
}
|
||||
|
||||
public void toggleBuildMode(Player player) {
|
||||
if (!player.hasPermission("nexuslobby.build")) return;
|
||||
|
||||
if (buildModePlayers.contains(player.getUniqueId())) {
|
||||
buildModePlayers.remove(player.getUniqueId());
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
player.getInventory().clear();
|
||||
|
||||
// KORREKTUR: Hier muss getItemsModule() mit "s" stehen!
|
||||
if (NexusLobby.getInstance().getItemsModule() != null) {
|
||||
NexusLobby.getInstance().getItemsModule().giveLobbyItems(player);
|
||||
}
|
||||
} else {
|
||||
buildModePlayers.add(player.getUniqueId());
|
||||
player.setGameMode(GameMode.CREATIVE);
|
||||
player.getInventory().clear();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {}
|
||||
}
|
||||
@@ -6,11 +6,14 @@ import de.nexuslobby.commands.BuildCommand;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockExplodeEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.entity.EntityPickupItemEvent;
|
||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
@@ -30,7 +33,11 @@ public class ProtectionModule implements Module, Listener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {}
|
||||
public void onDisable() {
|
||||
// FIX: Listener nach dem Deaktivieren abmelden, damit nach /reload
|
||||
// keine doppelten Events ausgelöst werden.
|
||||
HandlerList.unregisterAll(this);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockBreak(BlockBreakEvent event) {
|
||||
@@ -91,4 +98,22 @@ public class ProtectionModule implements Module, Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// FIX: Fehlender Explosionsschutz - settings.yml hat allowExplosions: false,
|
||||
// aber bisher gab es keinen Handler dafür.
|
||||
@EventHandler
|
||||
public void onEntityExplode(EntityExplodeEvent event) {
|
||||
if (!getSettings().getBoolean("allowExplosions", false)) {
|
||||
event.blockList().clear();
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockExplode(BlockExplodeEvent event) {
|
||||
if (!getSettings().getBoolean("allowExplosions", false)) {
|
||||
event.blockList().clear();
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package de.nexuslobby.modules;
|
||||
|
||||
import de.nexuslobby.NexusLobby;
|
||||
import de.nexuslobby.api.Module;
|
||||
import io.papermc.paper.scoreboard.numbers.NumberFormat;
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
@@ -9,9 +10,12 @@ import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.scoreboard.*;
|
||||
import org.bukkit.scoreboard.Criteria;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
@@ -23,10 +27,12 @@ public class ScoreboardModule implements Module, Listener {
|
||||
|
||||
private final NexusLobby plugin = NexusLobby.getInstance();
|
||||
private boolean placeholderAPIEnabled;
|
||||
|
||||
// Speicher für die aktuellen Spieler-Einstellungen (bis zum Restart/Reload)
|
||||
|
||||
private final Set<UUID> hiddenPlayers = new HashSet<>();
|
||||
private final Set<UUID> adminModePlayers = new HashSet<>();
|
||||
|
||||
// WICHTIG: Hier speichern wir die Scoreboards pro Spieler, um sie wiederzuverwenden
|
||||
private final Map<UUID, Scoreboard> playerBoards = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
@@ -38,7 +44,6 @@ public class ScoreboardModule implements Module, Listener {
|
||||
FileConfiguration vConfig = plugin.getVisualsConfig();
|
||||
if (!vConfig.getBoolean("scoreboard.enabled", true)) return;
|
||||
|
||||
// Listener registrieren
|
||||
Bukkit.getPluginManager().registerEvents(this, plugin);
|
||||
|
||||
placeholderAPIEnabled = Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null;
|
||||
@@ -53,9 +58,6 @@ public class ScoreboardModule implements Module, Listener {
|
||||
}.runTaskTimer(plugin, 0L, vConfig.getLong("scoreboard.update_ticks", 20L));
|
||||
}
|
||||
|
||||
/**
|
||||
* Setzt Scoreboard-Status beim Join gemäß config.yml (scoreboard-default-visible)
|
||||
*/
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
@@ -63,13 +65,19 @@ public class ScoreboardModule implements Module, Listener {
|
||||
if (!defaultVisible) {
|
||||
hiddenPlayers.add(player.getUniqueId());
|
||||
player.setScoreboard(Bukkit.getScoreboardManager().getMainScoreboard());
|
||||
// Sicherstellen, dass kein altes Board gespeichert ist
|
||||
playerBoards.remove(player.getUniqueId());
|
||||
} else {
|
||||
hiddenPlayers.remove(player.getUniqueId());
|
||||
// Beim Einloggen initialisieren, damit es nicht beim ersten Tick flackert
|
||||
if (!playerBoards.containsKey(player.getUniqueId())) {
|
||||
playerBoards.put(player.getUniqueId(), Bukkit.getScoreboardManager().getNewScoreboard());
|
||||
player.setScoreboard(playerBoards.get(player.getUniqueId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateSidebar(Player player) {
|
||||
// 1. Prüfen, ob der Spieler das Scoreboard ausgeblendet hat
|
||||
if (hiddenPlayers.contains(player.getUniqueId())) {
|
||||
if (player.getScoreboard() != Bukkit.getScoreboardManager().getMainScoreboard()) {
|
||||
player.setScoreboard(Bukkit.getScoreboardManager().getMainScoreboard());
|
||||
@@ -78,49 +86,81 @@ public class ScoreboardModule implements Module, Listener {
|
||||
}
|
||||
|
||||
FileConfiguration vConfig = plugin.getVisualsConfig();
|
||||
Scoreboard board = player.getScoreboard();
|
||||
|
||||
String configPath = (adminModePlayers.contains(player.getUniqueId())
|
||||
&& player.hasPermission("nexuslobby.scoreboard.admin"))
|
||||
? "scoreboard.owner"
|
||||
: "scoreboard.default";
|
||||
|
||||
String title = vConfig.getString(configPath + ".title", "&6&lNexusLobby");
|
||||
List<String> lines = vConfig.getStringList(configPath + ".lines");
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// FIX: Statt getNewScoreboard() holen wir das gespeicherte Board
|
||||
// oder erstellen es genau einmal beim ersten Mal.
|
||||
// ---------------------------------------------------------
|
||||
Scoreboard board = playerBoards.get(player.getUniqueId());
|
||||
|
||||
if (board == Bukkit.getScoreboardManager().getMainScoreboard()) {
|
||||
if (board == null) {
|
||||
board = Bukkit.getScoreboardManager().getNewScoreboard();
|
||||
playerBoards.put(player.getUniqueId(), board);
|
||||
player.setScoreboard(board);
|
||||
}
|
||||
|
||||
Objective obj = board.getObjective("lobby");
|
||||
if (obj == null) {
|
||||
obj = board.registerNewObjective("lobby", "dummy", "title");
|
||||
obj.setDisplaySlot(DisplaySlot.SIDEBAR);
|
||||
// Altes Objective entfernen
|
||||
Objective oldObj = board.getObjective("lobby");
|
||||
if (oldObj != null) oldObj.unregister();
|
||||
|
||||
// Alle alten Zeilen-Teams sicher entfernen (großzügige Obergrenze)
|
||||
for (int i = 0; i < Math.max(lines.size() + 5, 32); i++) {
|
||||
Team old = board.getTeam("line_" + i);
|
||||
if (old != null) old.unregister();
|
||||
}
|
||||
|
||||
// 2. Pfad-Logik basierend auf dem Modus (/nexus sb admin/spieler)
|
||||
String configPath = "scoreboard.default";
|
||||
|
||||
// Wenn im Admin-Modus UND Rechte vorhanden -> owner Sektion
|
||||
if (adminModePlayers.contains(player.getUniqueId()) && player.hasPermission("nexuslobby.scoreboard.admin")) {
|
||||
configPath = "scoreboard.owner";
|
||||
} else {
|
||||
// Standardmäßig default nutzen
|
||||
configPath = "scoreboard.default";
|
||||
}
|
||||
|
||||
String title = vConfig.getString(configPath + ".title", "&6&lNexusLobby");
|
||||
obj.setDisplayName(translate(player, title));
|
||||
// Paper 1.21: Objective mit Component-Titel registrieren
|
||||
String translatedTitle = translate(player, title);
|
||||
Objective obj = board.registerNewObjective(
|
||||
"lobby",
|
||||
Criteria.DUMMY,
|
||||
net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer
|
||||
.legacySection()
|
||||
.deserialize(translatedTitle)
|
||||
);
|
||||
obj.setDisplaySlot(DisplaySlot.SIDEBAR);
|
||||
|
||||
List<String> lines = vConfig.getStringList(configPath + ".lines");
|
||||
|
||||
// Scores zurücksetzen um Duplikate zu vermeiden
|
||||
board.getEntries().forEach(board::resetScores);
|
||||
// Zahlen global für dieses Objective ausblenden (Paper 1.20.4+ API)
|
||||
obj.numberFormat(NumberFormat.blank());
|
||||
|
||||
for (int i = 0; i < lines.size(); i++) {
|
||||
String line = translate(player, lines.get(i));
|
||||
|
||||
// Verhindert das Verschwinden leerer Zeilen
|
||||
if (line.isEmpty() || line.trim().isEmpty()) {
|
||||
line = "" + ChatColor.values()[i] + ChatColor.RESET;
|
||||
String lineText = translate(player, lines.get(i));
|
||||
|
||||
// Eindeutiger unsichtbarer Entry pro Zeile via Farb-Code
|
||||
String entry = ChatColor.values()[i % ChatColor.values().length].toString()
|
||||
+ ChatColor.RESET;
|
||||
|
||||
// getTeam statt registerNewTeam — verhindert "already in use" Fehler
|
||||
Team team = board.getTeam("line_" + i);
|
||||
if (team == null) team = board.registerNewTeam("line_" + i);
|
||||
team.getEntries().forEach(team::removeEntry);
|
||||
team.addEntry(entry);
|
||||
|
||||
// Text aufteilen falls länger als 64 Zeichen
|
||||
if (lineText.length() > 64) {
|
||||
team.setPrefix(lineText.substring(0, 64));
|
||||
team.setSuffix(lineText.substring(64, Math.min(lineText.length(), 128)));
|
||||
} else {
|
||||
team.setPrefix(lineText);
|
||||
team.setSuffix("");
|
||||
}
|
||||
|
||||
Score score = obj.getScore(line);
|
||||
|
||||
// Score setzen + Zahl pro Eintrag zusätzlich ausblenden
|
||||
org.bukkit.scoreboard.Score score = obj.getScore(entry);
|
||||
score.setScore(lines.size() - i);
|
||||
score.numberFormat(NumberFormat.blank());
|
||||
}
|
||||
|
||||
// Kein player.setScoreboard(board) nötig, da wir das Objekt 'board'
|
||||
// direkt verändert haben, das der Spieler bereits hat.
|
||||
}
|
||||
|
||||
// --- Methoden für den /nexus sb Befehl ---
|
||||
@@ -128,23 +168,28 @@ public class ScoreboardModule implements Module, Listener {
|
||||
public void setVisibility(Player player, boolean visible) {
|
||||
if (visible) {
|
||||
hiddenPlayers.remove(player.getUniqueId());
|
||||
player.sendMessage("§7[§6Nexus§7] §aScoreboard eingeschaltet.");
|
||||
// Wenn wir es wieder einschalten, ggf. Board zurücksetzen oder neu holen
|
||||
if (!playerBoards.containsKey(player.getUniqueId())) {
|
||||
playerBoards.put(player.getUniqueId(), Bukkit.getScoreboardManager().getNewScoreboard());
|
||||
}
|
||||
player.setScoreboard(playerBoards.get(player.getUniqueId()));
|
||||
player.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§aScoreboard eingeschaltet.");
|
||||
updateSidebar(player); // Sofort aktualisieren
|
||||
} else {
|
||||
hiddenPlayers.add(player.getUniqueId());
|
||||
player.setScoreboard(Bukkit.getScoreboardManager().getMainScoreboard());
|
||||
player.sendMessage("§7[§6Nexus§7] §cScoreboard ausgeschaltet.");
|
||||
player.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§cScoreboard ausgeschaltet.");
|
||||
}
|
||||
}
|
||||
|
||||
public void setAdminMode(Player player, boolean admin) {
|
||||
if (admin) {
|
||||
adminModePlayers.add(player.getUniqueId());
|
||||
player.sendMessage("§7[§6Nexus§7] §eModus: §cAdmin-Scoreboard §7(Owner-Sektion)");
|
||||
player.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§eModus: §cAdmin-Scoreboard §7(Owner-Sektion)");
|
||||
} else {
|
||||
adminModePlayers.remove(player.getUniqueId());
|
||||
player.sendMessage("§7[§6Nexus§7] §eModus: §6Spieler-Scoreboard §7(Default-Sektion)");
|
||||
player.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§eModus: §6Spieler-Scoreboard §7(Default-Sektion)");
|
||||
}
|
||||
// Sofortiges Update erzwingen
|
||||
updateSidebar(player);
|
||||
}
|
||||
|
||||
@@ -153,19 +198,19 @@ public class ScoreboardModule implements Module, Listener {
|
||||
if (placeholderAPIEnabled) {
|
||||
try {
|
||||
translated = PlaceholderAPI.setPlaceholders(player, text);
|
||||
} catch (NoClassDefFoundError ignored) {
|
||||
// PlaceholderAPI fehlt zur Laufzeit
|
||||
}
|
||||
} catch (NoClassDefFoundError ignored) {}
|
||||
}
|
||||
return ChatColor.translateAlternateColorCodes('&', translated);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
org.bukkit.event.HandlerList.unregisterAll(this);
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
player.setScoreboard(Bukkit.getScoreboardManager().getMainScoreboard());
|
||||
}
|
||||
hiddenPlayers.clear();
|
||||
adminModePlayers.clear();
|
||||
playerBoards.clear(); // Speicher freigeben
|
||||
}
|
||||
}
|
||||
@@ -6,11 +6,15 @@ import de.nexuslobby.NexusLobby;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.player.PlayerArmorStandManipulateEvent;
|
||||
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@@ -20,6 +24,41 @@ import java.util.UUID;
|
||||
|
||||
public class ASTListener implements Listener {
|
||||
|
||||
private boolean hasArmorStandBypass(Player player) {
|
||||
return player.isOp() || player.hasPermission("nexuslobby.armorstand.editbypass");
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onArmorStandManipulate(PlayerArmorStandManipulateEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (hasArmorStandBypass(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Verhindert, dass Spieler Rüstung/Items aus ArmorStands nehmen oder austauschen.
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onArmorStandDamage(EntityDamageByEntityEvent event) {
|
||||
if (!(event.getEntity() instanceof ArmorStand)) return;
|
||||
|
||||
Player player = null;
|
||||
Entity damager = event.getDamager();
|
||||
if (damager instanceof Player p) {
|
||||
player = p;
|
||||
} else if (damager instanceof Projectile projectile && projectile.getShooter() instanceof Player p) {
|
||||
player = p;
|
||||
}
|
||||
|
||||
if (player != null && hasArmorStandBypass(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Verhindert Abbauen/Beschädigen ohne Bypass, damit keine Equipment-Drops entnommen werden können.
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onInteract(PlayerInteractAtEntityEvent event) {
|
||||
if (event.getHand() != EquipmentSlot.HAND) return;
|
||||
@@ -70,32 +109,34 @@ public class ASTListener implements Listener {
|
||||
|
||||
/**
|
||||
* Prüft, ob der ArmorStand Dialog-Tags hat und startet das Gespräch über den Manager.
|
||||
* Nutzt nun die Gruppen-Logik (z.B. owner_suche).
|
||||
* FIX: Liest jetzt alle Partner-Tags (conv_partner, conv_partner2, conv_partner3)
|
||||
* und verwendet playConversationGroup statt nur die 2-NPC-Methode.
|
||||
* Vorher wurden Gruppen-Gespräche mit 3-4 NPCs als 2-NPC-Gespräch ausgeführt.
|
||||
*/
|
||||
private void checkAndTriggerDialog(ArmorStand as, Player p) {
|
||||
String groupName = null;
|
||||
String partnerUUIDString = null;
|
||||
String partner1 = null, partner2 = null, partner3 = null;
|
||||
|
||||
for (String tag : as.getScoreboardTags()) {
|
||||
// conv_id enthält jetzt den Gruppennamen aus der conversations.yml
|
||||
if (tag.startsWith("conv_id:")) groupName = tag.split(":")[1];
|
||||
if (tag.startsWith("conv_partner:")) partnerUUIDString = tag.split(":")[1];
|
||||
if (tag.startsWith("conv_id:")) groupName = tag.split(":", 2)[1];
|
||||
if (tag.startsWith("conv_partner:")) partner1 = tag.split(":", 2)[1];
|
||||
if (tag.startsWith("conv_partner2:")) partner2 = tag.split(":", 2)[1];
|
||||
if (tag.startsWith("conv_partner3:")) partner3 = tag.split(":", 2)[1];
|
||||
}
|
||||
|
||||
if (groupName != null && partnerUUIDString != null) {
|
||||
try {
|
||||
UUID partnerUUID = UUID.fromString(partnerUUIDString);
|
||||
|
||||
// Wir rufen playConversation auf. Der Manager entscheidet selbst
|
||||
// anhand der Uhrzeit, ob er morgens, mittags oder nachts abspielt.
|
||||
NexusLobby.getInstance().getConversationManager().playConversation(
|
||||
as.getUniqueId(),
|
||||
partnerUUID,
|
||||
groupName
|
||||
);
|
||||
} catch (Exception ignored) {
|
||||
// Falls die UUID oder Gruppe ungültig ist
|
||||
}
|
||||
if (groupName == null || partner1 == null) return;
|
||||
|
||||
try {
|
||||
java.util.List<UUID> participants = new java.util.ArrayList<>();
|
||||
participants.add(as.getUniqueId());
|
||||
participants.add(UUID.fromString(partner1));
|
||||
if (partner2 != null) participants.add(UUID.fromString(partner2));
|
||||
if (partner3 != null) participants.add(UUID.fromString(partner3));
|
||||
|
||||
NexusLobby.getInstance().getConversationManager()
|
||||
.playConversationGroup(participants, groupName);
|
||||
} catch (Exception ignored) {
|
||||
// Ungültige UUID oder fehlende Gruppe – still ignorieren
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,7 +148,7 @@ public class ASTListener implements Listener {
|
||||
out.writeUTF("Connect");
|
||||
out.writeUTF(server);
|
||||
player.sendPluginMessage(NexusLobby.getInstance(), "BungeeCord", out.toByteArray());
|
||||
player.sendMessage("§8[§6Nexus§8] §7Du wirst mit §e" + server + " §7verbunden...");
|
||||
player.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§7Du wirst mit §e" + server + " §7verbunden...");
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
@@ -117,6 +158,9 @@ public class ASTListener implements Listener {
|
||||
if (!title.equals("Nexus ArmorStand Editor") &&
|
||||
!title.equals("Pose: Körperteil wählen") &&
|
||||
!title.startsWith("Achsen:")) return;
|
||||
|
||||
// Amboss-GUI wird von AnvilRenameGUI selbst verwaltet — hier nicht anfassen
|
||||
if (title.equals("§6Name ändern")) return;
|
||||
|
||||
event.setCancelled(true);
|
||||
if (!(event.getWhoClicked() instanceof Player p)) return;
|
||||
@@ -134,8 +178,11 @@ public class ASTListener implements Listener {
|
||||
ArmorStandTool tool = ArmorStandTool.get(item);
|
||||
if (tool != null) {
|
||||
tool.execute(as, p);
|
||||
// Menü aktualisieren, falls wir noch im selben Editor sind
|
||||
if (p.getOpenInventory().getTitle().equals(title)) {
|
||||
// Editor nur neu öffnen wenn kein Chat-Input-Modus aktiv ist
|
||||
// und wir wirklich noch im Editor-Inventar sind
|
||||
String newTitle = p.getOpenInventory().getTitle();
|
||||
if (newTitle.equals("Nexus ArmorStand Editor")
|
||||
&& !AST.chatInputMode.containsKey(p.getUniqueId())) {
|
||||
new ArmorStandGUI(as, p);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
package de.nexuslobby.modules.armorstandtools;
|
||||
|
||||
import de.nexuslobby.NexusLobby;
|
||||
import io.papermc.paper.event.player.AsyncChatEvent;
|
||||
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
/**
|
||||
* Chat-basierte Namenseingabe für ArmorStands.
|
||||
* Der Spieler tippt den neuen Namen in den Chat.
|
||||
* Unterstützt & Farb-Codes.
|
||||
*/
|
||||
public class AnvilRenameGUI implements Listener {
|
||||
|
||||
private final Player player;
|
||||
private final ArmorStand armorStand;
|
||||
|
||||
public AnvilRenameGUI(Player player, ArmorStand armorStand) {
|
||||
this.player = player;
|
||||
this.armorStand = armorStand;
|
||||
|
||||
// Listener registrieren
|
||||
Bukkit.getPluginManager().registerEvents(this, NexusLobby.getInstance());
|
||||
|
||||
// Inventar schließen + Anweisung anzeigen
|
||||
player.closeInventory();
|
||||
|
||||
// Title als UI-Feedback (wie AFK-Anzeige)
|
||||
player.sendTitle(
|
||||
"§6§lName eingeben",
|
||||
"§7Schreibe den neuen Namen in den §eChat§7. §8(&-Codes erlaubt)",
|
||||
10, 80, 20
|
||||
);
|
||||
player.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§7Gib den neuen §eNamen §7in den Chat ein. §8(&-Farb-Codes erlaubt)");
|
||||
player.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§c'abbrechen' §7eingeben zum Abbrechen.");
|
||||
}
|
||||
|
||||
// ─────────────────────────────────────────────────────────────────────────
|
||||
// Chat-Event — Paper 1.21 AsyncChatEvent
|
||||
// ─────────────────────────────────────────────────────────────────────────
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onChat(AsyncChatEvent event) {
|
||||
if (!event.getPlayer().equals(player)) return;
|
||||
|
||||
// Chat-Nachricht abfangen
|
||||
event.setCancelled(true);
|
||||
|
||||
// Plain-Text aus Adventure Component extrahieren
|
||||
String input = PlainTextComponentSerializer.plainText().serialize(event.message()).trim();
|
||||
|
||||
// Zurück auf Haupt-Thread wechseln für Bukkit-API Aufrufe
|
||||
Bukkit.getScheduler().runTask(NexusLobby.getInstance(), () -> {
|
||||
HandlerList.unregisterAll(this);
|
||||
AST.chatInputMode.remove(player.getUniqueId());
|
||||
|
||||
if (input.equalsIgnoreCase("abbrechen")) {
|
||||
player.sendTitle("§c§lAbgebrochen", "", 5, 30, 10);
|
||||
player.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§cNamensänderung abgebrochen.");
|
||||
} else {
|
||||
// & → § Farb-Codes
|
||||
String newName = ChatColor.translateAlternateColorCodes('&', input);
|
||||
armorStand.setCustomName(newName);
|
||||
armorStand.setCustomNameVisible(!ChatColor.stripColor(newName).isEmpty());
|
||||
|
||||
player.sendTitle("§a§lName gesetzt!", "§r" + newName, 5, 40, 10);
|
||||
player.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§aName gesetzt: " + newName);
|
||||
}
|
||||
|
||||
// Zurück zum ArmorStand-Editor
|
||||
if (armorStand.isValid()) {
|
||||
new ArmorStandGUI(armorStand, player);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// ─────────────────────────────────────────────────────────────────────────
|
||||
// Logout — Listener sauber abmelden
|
||||
// ─────────────────────────────────────────────────────────────────────────
|
||||
|
||||
@EventHandler
|
||||
public void onQuit(PlayerQuitEvent event) {
|
||||
if (!event.getPlayer().equals(player)) return;
|
||||
HandlerList.unregisterAll(this);
|
||||
AST.chatInputMode.remove(player.getUniqueId());
|
||||
}
|
||||
}
|
||||
@@ -27,14 +27,14 @@ import java.util.UUID;
|
||||
*/
|
||||
public class ArmorStandCmdExecutor implements CommandExecutor {
|
||||
|
||||
private final String prefix = "§8[§6Nexus§8] ";
|
||||
private String prefix() { return de.nexuslobby.utils.LangManager.getPrefix(); }
|
||||
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (!(sender instanceof Player p)) return true;
|
||||
|
||||
if (!p.hasPermission("nexuslobby.armorstand.cmd")) {
|
||||
p.sendMessage(prefix + de.nexuslobby.utils.LangManager.get("no_permission"));
|
||||
p.sendMessage(prefix() + de.nexuslobby.utils.LangManager.get("no_permission"));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ public class ArmorStandCmdExecutor implements CommandExecutor {
|
||||
case "select4":
|
||||
ArmorStand target = getTargetArmorStand(p);
|
||||
if (target == null) {
|
||||
p.sendMessage(prefix + de.nexuslobby.utils.LangManager.get("armorstand_lookat_required"));
|
||||
p.sendMessage(prefix() + de.nexuslobby.utils.LangManager.get("armorstand_lookat_required"));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -63,17 +63,17 @@ public class ArmorStandCmdExecutor implements CommandExecutor {
|
||||
UUID targetUUID = target.getUniqueId();
|
||||
|
||||
p.setMetadata(metaKey, new FixedMetadataValue(NexusLobby.getInstance(), targetUUID.toString()));
|
||||
p.sendMessage(prefix + "§aNPC §e" + slotStr + " §amarkiert (§7" + targetUUID.toString().substring(0, 8) + "...§a)");
|
||||
p.sendMessage(prefix() + "§aNPC §e" + slotStr + " §amarkiert (§7" + targetUUID.toString().substring(0, 8) + "...§a)");
|
||||
p.spawnParticle(Particle.WITCH, target.getLocation().add(0, 1.0, 0), 15, 0.2, 0.2, 0.2, 0.05);
|
||||
break;
|
||||
|
||||
case "link":
|
||||
if (args.length < 3) {
|
||||
p.sendMessage(prefix + de.nexuslobby.utils.LangManager.get("conv_link_usage"));
|
||||
p.sendMessage(prefix() + de.nexuslobby.utils.LangManager.get("conv_link_usage"));
|
||||
return true;
|
||||
}
|
||||
if (!p.hasMetadata("conv_npc1") || !p.hasMetadata("conv_npc2")) {
|
||||
p.sendMessage(prefix + de.nexuslobby.utils.LangManager.get("conv_mark_npcs"));
|
||||
p.sendMessage(prefix() + de.nexuslobby.utils.LangManager.get("conv_mark_npcs"));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -101,8 +101,8 @@ public class ArmorStandCmdExecutor implements CommandExecutor {
|
||||
// Im Manager speichern (Nutzt die erweiterte Methode für Gruppen)
|
||||
NexusLobby.getInstance().getConversationManager().saveLinkExtended(id1, id2, id3, id4, dialogId);
|
||||
|
||||
p.sendMessage(prefix + de.nexuslobby.utils.LangManager.get("conv_link_created"));
|
||||
p.sendMessage(prefix + de.nexuslobby.utils.LangManager.get("conv_link_npcs").replace("{count}", (id3 == null ? "2" : (id4 == null ? "3" : "4"))));
|
||||
p.sendMessage(prefix() + de.nexuslobby.utils.LangManager.get("conv_link_created"));
|
||||
p.sendMessage(prefix() + de.nexuslobby.utils.LangManager.get("conv_link_npcs").replace("{count}", (id3 == null ? "2" : (id4 == null ? "3" : "4"))));
|
||||
p.spawnParticle(Particle.HAPPY_VILLAGER, as1.getLocation().add(0, 1.5, 0), 20, 0.4, 0.4, 0.4, 0.1);
|
||||
|
||||
// Metadaten nach dem Linken aufräumen
|
||||
@@ -111,14 +111,14 @@ public class ArmorStandCmdExecutor implements CommandExecutor {
|
||||
p.removeMetadata("conv_npc3", NexusLobby.getInstance());
|
||||
p.removeMetadata("conv_npc4", NexusLobby.getInstance());
|
||||
} else {
|
||||
p.sendMessage(prefix + de.nexuslobby.utils.LangManager.get("conv_speaker_not_found"));
|
||||
p.sendMessage(prefix() + de.nexuslobby.utils.LangManager.get("conv_speaker_not_found"));
|
||||
}
|
||||
break;
|
||||
|
||||
case "unlink":
|
||||
ArmorStand targetUnlink = getTargetArmorStand(p);
|
||||
if (targetUnlink == null) {
|
||||
p.sendMessage(prefix + de.nexuslobby.utils.LangManager.get("conv_unlink_lookat"));
|
||||
p.sendMessage(prefix() + de.nexuslobby.utils.LangManager.get("conv_unlink_lookat"));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -128,17 +128,17 @@ public class ArmorStandCmdExecutor implements CommandExecutor {
|
||||
// Aus Konfiguration löschen
|
||||
NexusLobby.getInstance().getConversationManager().removeLink(targetUnlink.getUniqueId());
|
||||
|
||||
p.sendMessage(prefix + de.nexuslobby.utils.LangManager.get("conv_unlinked"));
|
||||
p.sendMessage(prefix() + de.nexuslobby.utils.LangManager.get("conv_unlinked"));
|
||||
p.spawnParticle(Particle.SMOKE, targetUnlink.getLocation().add(0, 1.0, 0), 20, 0.2, 0.2, 0.2, 0.02);
|
||||
break;
|
||||
|
||||
case "start":
|
||||
if (args.length < 3) {
|
||||
p.sendMessage(prefix + de.nexuslobby.utils.LangManager.get("conv_start_usage"));
|
||||
p.sendMessage(prefix() + de.nexuslobby.utils.LangManager.get("conv_start_usage"));
|
||||
return true;
|
||||
}
|
||||
if (!p.hasMetadata("conv_npc1") || !p.hasMetadata("conv_npc2")) {
|
||||
p.sendMessage(prefix + de.nexuslobby.utils.LangManager.get("conv_mark_two_npcs"));
|
||||
p.sendMessage(prefix() + de.nexuslobby.utils.LangManager.get("conv_mark_two_npcs"));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -163,7 +163,7 @@ public class ArmorStandCmdExecutor implements CommandExecutor {
|
||||
ArmorStand target = getTargetArmorStand(p);
|
||||
|
||||
if (args[0].equalsIgnoreCase("say") && args.length >= 2) {
|
||||
if (target == null) { p.sendMessage(prefix + de.nexuslobby.utils.LangManager.get("armorstand_lookat_required")); return true; }
|
||||
if (target == null) { p.sendMessage(prefix() + de.nexuslobby.utils.LangManager.get("armorstand_lookat_required")); return true; }
|
||||
|
||||
String text = buildString(args, 1);
|
||||
String colored = ChatColor.translateAlternateColorCodes('&', text);
|
||||
@@ -171,25 +171,25 @@ public class ArmorStandCmdExecutor implements CommandExecutor {
|
||||
// Nutzt die showBubble-Logik aus dem ConversationManager (Ohne Partner-Zwang)
|
||||
NexusLobby.getInstance().getConversationManager().showBubble(target, colored);
|
||||
|
||||
p.sendMessage(prefix + de.nexuslobby.utils.LangManager.get("npc_bubble_sent"));
|
||||
p.sendMessage(prefix() + de.nexuslobby.utils.LangManager.get("npc_bubble_sent"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("lookat")) {
|
||||
if (target == null) { p.sendMessage(prefix + de.nexuslobby.utils.LangManager.get("armorstand_lookat_required")); return true; }
|
||||
if (target == null) { p.sendMessage(prefix() + de.nexuslobby.utils.LangManager.get("armorstand_lookat_required")); return true; }
|
||||
if (target.getScoreboardTags().contains("as_lookat")) {
|
||||
target.removeScoreboardTag("as_lookat");
|
||||
target.setHeadPose(new EulerAngle(0, 0, 0));
|
||||
p.sendMessage(prefix + de.nexuslobby.utils.LangManager.get("lookat_off"));
|
||||
p.sendMessage(prefix() + de.nexuslobby.utils.LangManager.get("lookat_off"));
|
||||
} else {
|
||||
target.addScoreboardTag("as_lookat");
|
||||
p.sendMessage(prefix + de.nexuslobby.utils.LangManager.get("lookat_on"));
|
||||
p.sendMessage(prefix() + de.nexuslobby.utils.LangManager.get("lookat_on"));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("name") && args.length >= 2) {
|
||||
if (target == null) { p.sendMessage(prefix + de.nexuslobby.utils.LangManager.get("armorstand_lookat_required")); return true; }
|
||||
if (target == null) { p.sendMessage(prefix() + de.nexuslobby.utils.LangManager.get("armorstand_lookat_required")); return true; }
|
||||
String nameInput = buildString(args, 1);
|
||||
|
||||
// Wichtig: Alle alten Namens-Tags entfernen für Konsistenz
|
||||
@@ -198,7 +198,7 @@ public class ArmorStandCmdExecutor implements CommandExecutor {
|
||||
if (nameInput.equalsIgnoreCase("none")) {
|
||||
target.setCustomName("");
|
||||
target.setCustomNameVisible(false);
|
||||
p.sendMessage(prefix + de.nexuslobby.utils.LangManager.get("name_removed"));
|
||||
p.sendMessage(prefix() + de.nexuslobby.utils.LangManager.get("name_removed"));
|
||||
} else {
|
||||
String colored = ChatColor.translateAlternateColorCodes('&', nameInput);
|
||||
target.setCustomName(colored);
|
||||
@@ -208,19 +208,19 @@ public class ArmorStandCmdExecutor implements CommandExecutor {
|
||||
// ":" wird durch "§§" ersetzt, um Probleme in Scoreboard-Tags zu vermeiden
|
||||
target.addScoreboardTag("as_displayname:" + nameInput.replace(":", "§§"));
|
||||
|
||||
p.sendMessage(prefix + de.nexuslobby.utils.LangManager.get("name_set").replace("{name}", colored));
|
||||
p.sendMessage(prefix + de.nexuslobby.utils.LangManager.get("status_backup_saved"));
|
||||
p.sendMessage(prefix() + de.nexuslobby.utils.LangManager.get("name_set").replace("{name}", colored));
|
||||
p.sendMessage(prefix() + de.nexuslobby.utils.LangManager.get("status_backup_saved"));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("add") && args.length >= 5) {
|
||||
if (target == null) { p.sendMessage(prefix + de.nexuslobby.utils.LangManager.get("armorstand_lookat_required")); return true; }
|
||||
if (target == null) { p.sendMessage(prefix() + de.nexuslobby.utils.LangManager.get("armorstand_lookat_required")); return true; }
|
||||
String slot1 = args[1], slot2 = args[2], type = args[3].toLowerCase();
|
||||
String cmdStr = buildString(args, 4);
|
||||
|
||||
target.addScoreboardTag("ascmd:" + slot1 + ":" + slot2 + ":" + type + ":" + cmdStr);
|
||||
p.sendMessage(prefix + de.nexuslobby.utils.LangManager.get("command_bound"));
|
||||
p.sendMessage(prefix() + de.nexuslobby.utils.LangManager.get("command_bound"));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -234,7 +234,19 @@ public class ArmorStandCmdExecutor implements CommandExecutor {
|
||||
if (args[0].equalsIgnoreCase("remove")) {
|
||||
if (target == null) { p.sendMessage(de.nexuslobby.utils.LangManager.get("no_target")); return true; }
|
||||
target.getScoreboardTags().removeIf(tag -> tag.startsWith("ascmd:"));
|
||||
p.sendMessage(prefix + de.nexuslobby.utils.LangManager.get("commands_removed"));
|
||||
p.sendMessage(prefix() + de.nexuslobby.utils.LangManager.get("commands_removed"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("clearbubbles")) {
|
||||
ConversationManager cm = NexusLobby.getInstance().getConversationManager();
|
||||
if (cm == null) {
|
||||
p.sendMessage(prefix() + "§cConversationManager ist nicht aktiv.");
|
||||
return true;
|
||||
}
|
||||
cm.clearHangingBubbles();
|
||||
p.sendMessage(prefix() + "§aAlle hängenden Sprechblasen wurden entfernt.");
|
||||
p.playSound(p.getLocation(), org.bukkit.Sound.BLOCK_NOTE_BLOCK_PLING, 1f, 2f);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -284,6 +296,7 @@ public class ArmorStandCmdExecutor implements CommandExecutor {
|
||||
p.sendMessage("§e/nexuscmd conv §7- Gesprächs-Menü");
|
||||
p.sendMessage("§e/nexuscmd list §7- Zeigt alle Tags");
|
||||
p.sendMessage("§e/nexuscmd remove §7- Löscht Befehle");
|
||||
p.sendMessage("§e/nexuscmd clearbubbles §7- Entfernt hängende Sprechblasen");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -50,7 +50,7 @@ public class ArmorStandCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
// Fester Prefix für maximale Build-Sicherheit
|
||||
String prefix = "§8[§6Nexus§8] ";
|
||||
String prefix = de.nexuslobby.utils.LangManager.getPrefix();
|
||||
|
||||
if (!p.hasPermission("nexuslobby.armorstand.use")) {
|
||||
p.sendMessage(prefix + ChatColor.RED + "Dazu hast du keine Rechte!");
|
||||
|
||||
@@ -1,113 +1,113 @@
|
||||
package de.nexuslobby.modules.armorstandtools;
|
||||
|
||||
import de.nexuslobby.NexusLobby;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.util.EulerAngle;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class ArmorStandLookAtModule {
|
||||
|
||||
public ArmorStandLookAtModule() {
|
||||
startRotationTask();
|
||||
}
|
||||
|
||||
private void startRotationTask() {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// Wir gehen alle Welten durch, um markierte ArmorStands zu finden
|
||||
for (World world : Bukkit.getWorlds()) {
|
||||
for (ArmorStand as : world.getEntitiesByClass(ArmorStand.class)) {
|
||||
|
||||
// Nur ArmorStands mit dem Tag "as_lookat"
|
||||
if (as.getScoreboardTags().contains("as_lookat")) {
|
||||
|
||||
// Suche den nächsten Spieler im Umkreis von 7 Blöcken
|
||||
Player nearest = getNearestPlayer(as, 7.0);
|
||||
|
||||
if (nearest != null) {
|
||||
// Spieler gefunden -> Kopf zum Spieler drehen
|
||||
updateLookAt(as, nearest);
|
||||
} else {
|
||||
// Kein Spieler da -> Kopf sanft auf 0,0,0 zurücksetzen
|
||||
resetHeadPose(as);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}.runTaskTimer(NexusLobby.getInstance(), 0L, 1L);
|
||||
}
|
||||
|
||||
private void updateLookAt(ArmorStand as, Player player) {
|
||||
Location asLoc = as.getEyeLocation();
|
||||
Location target = player.getEyeLocation();
|
||||
|
||||
Vector direction = target.toVector().subtract(asLoc.toVector()).normalize();
|
||||
|
||||
// Ziel-Winkel aus Vektor berechnen
|
||||
double targetYaw = Math.toDegrees(Math.atan2(-direction.getX(), direction.getZ()));
|
||||
double targetPitch = Math.toDegrees(Math.asin(direction.getY()));
|
||||
|
||||
// Relativer Yaw zum Körper-Yaw
|
||||
double relativeYaw = targetYaw - as.getLocation().getYaw();
|
||||
relativeYaw = ((relativeYaw + 180) % 360 + 360) % 360 - 180;
|
||||
|
||||
double yawRad = Math.toRadians(relativeYaw);
|
||||
double pitchRad = Math.toRadians(-targetPitch);
|
||||
|
||||
// Begrenzung (Nacken-Schutz)
|
||||
if (yawRad > 1.2) yawRad = 1.2;
|
||||
if (yawRad < -1.2) yawRad = -1.2;
|
||||
if (pitchRad > 0.8) pitchRad = 0.8;
|
||||
if (pitchRad < -0.8) pitchRad = -0.8;
|
||||
|
||||
applySmoothPose(as, pitchRad, yawRad);
|
||||
}
|
||||
|
||||
private void resetHeadPose(ArmorStand as) {
|
||||
EulerAngle current = as.getHeadPose();
|
||||
// Wenn der Kopf schon (fast) gerade ist, nichts tun
|
||||
if (Math.abs(current.getX()) < 0.01 && Math.abs(current.getY()) < 0.01) {
|
||||
if (current.getX() != 0 || current.getY() != 0) {
|
||||
as.setHeadPose(new EulerAngle(0, 0, 0));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Ziel: 0, 0, 0 (Geradeaus schauen)
|
||||
applySmoothPose(as, 0, 0);
|
||||
}
|
||||
|
||||
private void applySmoothPose(ArmorStand as, double pitchRad, double yawRad) {
|
||||
EulerAngle current = as.getHeadPose();
|
||||
double lerp = 0.15; // Geschmeidigkeit
|
||||
|
||||
double finalPitch = current.getX() + (pitchRad - current.getX()) * lerp;
|
||||
double finalYaw = current.getY() + (yawRad - current.getY()) * lerp;
|
||||
|
||||
as.setHeadPose(new EulerAngle(finalPitch, finalYaw, 0));
|
||||
}
|
||||
|
||||
private Player getNearestPlayer(ArmorStand as, double range) {
|
||||
Player nearest = null;
|
||||
double dSquared = range * range;
|
||||
|
||||
for (Player p : as.getWorld().getPlayers()) {
|
||||
// Falls Spieler im Vanish/Spectator ist, ignorieren (optional)
|
||||
if (p.getGameMode().name().equals("SPECTATOR")) continue;
|
||||
|
||||
double dist = p.getLocation().distanceSquared(as.getLocation());
|
||||
if (dist < dSquared) {
|
||||
dSquared = dist;
|
||||
nearest = p;
|
||||
}
|
||||
}
|
||||
return nearest;
|
||||
}
|
||||
package de.nexuslobby.modules.armorstandtools;
|
||||
|
||||
import de.nexuslobby.NexusLobby;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.util.EulerAngle;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class ArmorStandLookAtModule {
|
||||
|
||||
public ArmorStandLookAtModule() {
|
||||
startRotationTask();
|
||||
}
|
||||
|
||||
private void startRotationTask() {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// Wir gehen alle Welten durch, um markierte ArmorStands zu finden
|
||||
for (World world : Bukkit.getWorlds()) {
|
||||
for (ArmorStand as : world.getEntitiesByClass(ArmorStand.class)) {
|
||||
|
||||
// Nur ArmorStands mit dem Tag "as_lookat"
|
||||
if (as.getScoreboardTags().contains("as_lookat")) {
|
||||
|
||||
// Suche den nächsten Spieler im Umkreis von 7 Blöcken
|
||||
Player nearest = getNearestPlayer(as, 7.0);
|
||||
|
||||
if (nearest != null) {
|
||||
// Spieler gefunden -> Kopf zum Spieler drehen
|
||||
updateLookAt(as, nearest);
|
||||
} else {
|
||||
// Kein Spieler da -> Kopf sanft auf 0,0,0 zurücksetzen
|
||||
resetHeadPose(as);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}.runTaskTimer(NexusLobby.getInstance(), 0L, 1L);
|
||||
}
|
||||
|
||||
private void updateLookAt(ArmorStand as, Player player) {
|
||||
Location asLoc = as.getEyeLocation();
|
||||
Location target = player.getEyeLocation();
|
||||
|
||||
Vector direction = target.toVector().subtract(asLoc.toVector()).normalize();
|
||||
|
||||
// Ziel-Winkel aus Vektor berechnen
|
||||
double targetYaw = Math.toDegrees(Math.atan2(-direction.getX(), direction.getZ()));
|
||||
double targetPitch = Math.toDegrees(Math.asin(direction.getY()));
|
||||
|
||||
// Relativer Yaw zum Körper-Yaw
|
||||
double relativeYaw = targetYaw - as.getLocation().getYaw();
|
||||
relativeYaw = ((relativeYaw + 180) % 360 + 360) % 360 - 180;
|
||||
|
||||
double yawRad = Math.toRadians(relativeYaw);
|
||||
double pitchRad = Math.toRadians(-targetPitch);
|
||||
|
||||
// Begrenzung (Nacken-Schutz)
|
||||
if (yawRad > 1.2) yawRad = 1.2;
|
||||
if (yawRad < -1.2) yawRad = -1.2;
|
||||
if (pitchRad > 0.8) pitchRad = 0.8;
|
||||
if (pitchRad < -0.8) pitchRad = -0.8;
|
||||
|
||||
applySmoothPose(as, pitchRad, yawRad);
|
||||
}
|
||||
|
||||
private void resetHeadPose(ArmorStand as) {
|
||||
EulerAngle current = as.getHeadPose();
|
||||
// Wenn der Kopf schon (fast) gerade ist, nichts tun
|
||||
if (Math.abs(current.getX()) < 0.01 && Math.abs(current.getY()) < 0.01) {
|
||||
if (current.getX() != 0 || current.getY() != 0) {
|
||||
as.setHeadPose(new EulerAngle(0, 0, 0));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Ziel: 0, 0, 0 (Geradeaus schauen)
|
||||
applySmoothPose(as, 0, 0);
|
||||
}
|
||||
|
||||
private void applySmoothPose(ArmorStand as, double pitchRad, double yawRad) {
|
||||
EulerAngle current = as.getHeadPose();
|
||||
double lerp = 0.15; // Geschmeidigkeit
|
||||
|
||||
double finalPitch = current.getX() + (pitchRad - current.getX()) * lerp;
|
||||
double finalYaw = current.getY() + (yawRad - current.getY()) * lerp;
|
||||
|
||||
as.setHeadPose(new EulerAngle(finalPitch, finalYaw, 0));
|
||||
}
|
||||
|
||||
private Player getNearestPlayer(ArmorStand as, double range) {
|
||||
Player nearest = null;
|
||||
double dSquared = range * range;
|
||||
|
||||
for (Player p : as.getWorld().getPlayers()) {
|
||||
// Falls Spieler im Vanish/Spectator ist, ignorieren (optional)
|
||||
if (p.getGameMode().name().equals("SPECTATOR")) continue;
|
||||
|
||||
double dist = p.getLocation().distanceSquared(as.getLocation());
|
||||
if (dist < dSquared) {
|
||||
dSquared = dist;
|
||||
nearest = p;
|
||||
}
|
||||
}
|
||||
return nearest;
|
||||
}
|
||||
}
|
||||
@@ -1,111 +1,111 @@
|
||||
package de.nexuslobby.modules.armorstandtools;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.util.EulerAngle;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class ArmorStandPoseGUI {
|
||||
|
||||
// Schritt 1: Auswahl welches Körperteil (Die "letzte Reihe" ist jetzt hier)
|
||||
public static void openPartSelectionMenu(Player p, ArmorStand as) {
|
||||
Inventory inv = Bukkit.createInventory(null, 45, "Pose: Körperteil wählen");
|
||||
ItemStack filler = new ItemStack(Material.BLACK_STAINED_GLASS_PANE);
|
||||
for (int i = 0; i < 45; i++) inv.setItem(i, filler);
|
||||
|
||||
inv.setItem(10, createPartIcon(Material.PLAYER_HEAD, "§eKopf", as.getHeadPose()));
|
||||
inv.setItem(12, createPartIcon(Material.IRON_CHESTPLATE, "§eTorso", as.getBodyPose()));
|
||||
inv.setItem(14, createPartIcon(Material.STICK, "§eLinker Arm", as.getLeftArmPose()));
|
||||
inv.setItem(16, createPartIcon(Material.STICK, "§eRechter Arm", as.getRightArmPose()));
|
||||
inv.setItem(28, createPartIcon(Material.LEATHER_BOOTS, "§eLinkes Bein", as.getLeftLegPose()));
|
||||
inv.setItem(30, createPartIcon(Material.LEATHER_BOOTS, "§eRechtes Bein", as.getRightLegPose()));
|
||||
|
||||
inv.setItem(40, createNamedItem(Material.BARRIER, "§cZurück zum Hauptmenü"));
|
||||
p.openInventory(inv);
|
||||
}
|
||||
|
||||
// Schritt 2: Detail-Einstellung der Achsen (X, Y, Z)
|
||||
public static void openAxisDetailMenu(Player p, ArmorStand as, String partName) {
|
||||
Inventory inv = Bukkit.createInventory(null, 27, "Achsen: " + partName);
|
||||
ItemStack filler = new ItemStack(Material.GRAY_STAINED_GLASS_PANE);
|
||||
for (int i = 0; i < 27; i++) inv.setItem(i, filler);
|
||||
|
||||
ArmorStandTool tool = ArmorStandTool.valueOf(partName);
|
||||
EulerAngle angle = getAngleForPart(as, tool);
|
||||
|
||||
inv.setItem(11, createAxisItem(Material.RED_DYE, "§c§lX-Achse (Pitch)", angle.getX()));
|
||||
inv.setItem(13, createAxisItem(Material.GREEN_DYE, "§a§lY-Achse (Yaw)", angle.getY()));
|
||||
inv.setItem(15, createAxisItem(Material.BLUE_DYE, "§b§lZ-Achse (Roll)", angle.getZ()));
|
||||
|
||||
inv.setItem(22, createNamedItem(Material.ARROW, "§7Zurück zur Auswahl"));
|
||||
p.openInventory(inv);
|
||||
}
|
||||
|
||||
private static ItemStack createPartIcon(Material mat, String name, EulerAngle angle) {
|
||||
ItemStack item = new ItemStack(mat);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
if (meta == null) return item;
|
||||
meta.setDisplayName(name);
|
||||
meta.setLore(Arrays.asList(
|
||||
"§8Rotation:",
|
||||
"§7X: §f" + Math.round(Math.toDegrees(angle.getX())) + "°",
|
||||
"§7Y: §f" + Math.round(Math.toDegrees(angle.getY())) + "°",
|
||||
"§7Z: §f" + Math.round(Math.toDegrees(angle.getZ())) + "°",
|
||||
"", "§6Klicken zum Justieren"
|
||||
));
|
||||
item.setItemMeta(meta);
|
||||
return item;
|
||||
}
|
||||
|
||||
private static ItemStack createAxisItem(Material mat, String name, double angleRad) {
|
||||
ItemStack item = new ItemStack(mat);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
if (meta == null) return item;
|
||||
meta.setDisplayName(name);
|
||||
meta.setLore(Arrays.asList(
|
||||
"§7Aktueller Winkel: §f" + Math.round(Math.toDegrees(angleRad)) + "°",
|
||||
"",
|
||||
"§eLinksklick: §f+15° §8| §eRechtsklick: §f-15°",
|
||||
"§6Shift-Klick: §f+1° §8| §6Shift-Rechts: §f-1°"
|
||||
));
|
||||
item.setItemMeta(meta);
|
||||
return item;
|
||||
}
|
||||
|
||||
private static ItemStack createNamedItem(Material mat, String name) {
|
||||
ItemStack item = new ItemStack(mat);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
if (meta == null) return item;
|
||||
meta.setDisplayName(name);
|
||||
item.setItemMeta(meta);
|
||||
return item;
|
||||
}
|
||||
|
||||
public static EulerAngle getAngleForPart(ArmorStand as, ArmorStandTool part) {
|
||||
return switch (part) {
|
||||
case HEAD_ROT -> as.getHeadPose();
|
||||
case BODY_ROT -> as.getBodyPose();
|
||||
case L_ARM_ROT -> as.getLeftArmPose();
|
||||
case R_ARM_ROT -> as.getRightArmPose();
|
||||
case L_LEG_ROT -> as.getLeftLegPose();
|
||||
case R_LEG_ROT -> as.getRightLegPose();
|
||||
default -> EulerAngle.ZERO;
|
||||
};
|
||||
}
|
||||
|
||||
public static void setAngleForPart(ArmorStand as, ArmorStandTool part, EulerAngle angle) {
|
||||
switch (part) {
|
||||
case HEAD_ROT -> as.setHeadPose(angle);
|
||||
case BODY_ROT -> as.setBodyPose(angle);
|
||||
case L_ARM_ROT -> as.setLeftArmPose(angle);
|
||||
case R_ARM_ROT -> as.setRightArmPose(angle);
|
||||
case L_LEG_ROT -> as.setLeftLegPose(angle);
|
||||
case R_LEG_ROT -> as.setRightLegPose(angle);
|
||||
}
|
||||
}
|
||||
package de.nexuslobby.modules.armorstandtools;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.util.EulerAngle;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class ArmorStandPoseGUI {
|
||||
|
||||
// Schritt 1: Auswahl welches Körperteil (Die "letzte Reihe" ist jetzt hier)
|
||||
public static void openPartSelectionMenu(Player p, ArmorStand as) {
|
||||
Inventory inv = Bukkit.createInventory(null, 45, "Pose: Körperteil wählen");
|
||||
ItemStack filler = new ItemStack(Material.BLACK_STAINED_GLASS_PANE);
|
||||
for (int i = 0; i < 45; i++) inv.setItem(i, filler);
|
||||
|
||||
inv.setItem(10, createPartIcon(Material.PLAYER_HEAD, "§eKopf", as.getHeadPose()));
|
||||
inv.setItem(12, createPartIcon(Material.IRON_CHESTPLATE, "§eTorso", as.getBodyPose()));
|
||||
inv.setItem(14, createPartIcon(Material.STICK, "§eLinker Arm", as.getLeftArmPose()));
|
||||
inv.setItem(16, createPartIcon(Material.STICK, "§eRechter Arm", as.getRightArmPose()));
|
||||
inv.setItem(28, createPartIcon(Material.LEATHER_BOOTS, "§eLinkes Bein", as.getLeftLegPose()));
|
||||
inv.setItem(30, createPartIcon(Material.LEATHER_BOOTS, "§eRechtes Bein", as.getRightLegPose()));
|
||||
|
||||
inv.setItem(40, createNamedItem(Material.BARRIER, "§cZurück zum Hauptmenü"));
|
||||
p.openInventory(inv);
|
||||
}
|
||||
|
||||
// Schritt 2: Detail-Einstellung der Achsen (X, Y, Z)
|
||||
public static void openAxisDetailMenu(Player p, ArmorStand as, String partName) {
|
||||
Inventory inv = Bukkit.createInventory(null, 27, "Achsen: " + partName);
|
||||
ItemStack filler = new ItemStack(Material.GRAY_STAINED_GLASS_PANE);
|
||||
for (int i = 0; i < 27; i++) inv.setItem(i, filler);
|
||||
|
||||
ArmorStandTool tool = ArmorStandTool.valueOf(partName);
|
||||
EulerAngle angle = getAngleForPart(as, tool);
|
||||
|
||||
inv.setItem(11, createAxisItem(Material.RED_DYE, "§c§lX-Achse (Pitch)", angle.getX()));
|
||||
inv.setItem(13, createAxisItem(Material.GREEN_DYE, "§a§lY-Achse (Yaw)", angle.getY()));
|
||||
inv.setItem(15, createAxisItem(Material.BLUE_DYE, "§b§lZ-Achse (Roll)", angle.getZ()));
|
||||
|
||||
inv.setItem(22, createNamedItem(Material.ARROW, "§7Zurück zur Auswahl"));
|
||||
p.openInventory(inv);
|
||||
}
|
||||
|
||||
private static ItemStack createPartIcon(Material mat, String name, EulerAngle angle) {
|
||||
ItemStack item = new ItemStack(mat);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
if (meta == null) return item;
|
||||
meta.setDisplayName(name);
|
||||
meta.setLore(Arrays.asList(
|
||||
"§8Rotation:",
|
||||
"§7X: §f" + Math.round(Math.toDegrees(angle.getX())) + "°",
|
||||
"§7Y: §f" + Math.round(Math.toDegrees(angle.getY())) + "°",
|
||||
"§7Z: §f" + Math.round(Math.toDegrees(angle.getZ())) + "°",
|
||||
"", "§6Klicken zum Justieren"
|
||||
));
|
||||
item.setItemMeta(meta);
|
||||
return item;
|
||||
}
|
||||
|
||||
private static ItemStack createAxisItem(Material mat, String name, double angleRad) {
|
||||
ItemStack item = new ItemStack(mat);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
if (meta == null) return item;
|
||||
meta.setDisplayName(name);
|
||||
meta.setLore(Arrays.asList(
|
||||
"§7Aktueller Winkel: §f" + Math.round(Math.toDegrees(angleRad)) + "°",
|
||||
"",
|
||||
"§eLinksklick: §f+15° §8| §eRechtsklick: §f-15°",
|
||||
"§6Shift-Klick: §f+1° §8| §6Shift-Rechts: §f-1°"
|
||||
));
|
||||
item.setItemMeta(meta);
|
||||
return item;
|
||||
}
|
||||
|
||||
private static ItemStack createNamedItem(Material mat, String name) {
|
||||
ItemStack item = new ItemStack(mat);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
if (meta == null) return item;
|
||||
meta.setDisplayName(name);
|
||||
item.setItemMeta(meta);
|
||||
return item;
|
||||
}
|
||||
|
||||
public static EulerAngle getAngleForPart(ArmorStand as, ArmorStandTool part) {
|
||||
return switch (part) {
|
||||
case HEAD_ROT -> as.getHeadPose();
|
||||
case BODY_ROT -> as.getBodyPose();
|
||||
case L_ARM_ROT -> as.getLeftArmPose();
|
||||
case R_ARM_ROT -> as.getRightArmPose();
|
||||
case L_LEG_ROT -> as.getLeftLegPose();
|
||||
case R_LEG_ROT -> as.getRightLegPose();
|
||||
default -> EulerAngle.ZERO;
|
||||
};
|
||||
}
|
||||
|
||||
public static void setAngleForPart(ArmorStand as, ArmorStandTool part, EulerAngle angle) {
|
||||
switch (part) {
|
||||
case HEAD_ROT -> as.setHeadPose(angle);
|
||||
case BODY_ROT -> as.setBodyPose(angle);
|
||||
case L_ARM_ROT -> as.setLeftArmPose(angle);
|
||||
case R_ARM_ROT -> as.setRightArmPose(angle);
|
||||
case L_LEG_ROT -> as.setLeftLegPose(angle);
|
||||
case R_LEG_ROT -> as.setRightLegPose(angle);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,135 +1,135 @@
|
||||
package de.nexuslobby.modules.armorstandtools;
|
||||
|
||||
import de.nexuslobby.NexusLobby;
|
||||
import de.nexuslobby.api.Module;
|
||||
import de.nexuslobby.modules.servers.ServerChecker;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.World;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* ArmorStandStatusModule - Optimierte Statusanzeige für Java & Bedrock.
|
||||
* - Schaltet zwischen Servername und "Offline" um.
|
||||
* - Anti-Blink-Logik für Java-Spieler.
|
||||
* - Force-Refresh-Logik für Bedrock-Spieler (Geyser).
|
||||
*/
|
||||
public class ArmorStandStatusModule implements Module {
|
||||
|
||||
private final Map<UUID, Boolean> lastStatus = new HashMap<>();
|
||||
private final Map<String, Integer> failCount = new HashMap<>();
|
||||
|
||||
// Zähler für den Force-Refresh (Bedrock-Sicherheit)
|
||||
private int refreshTicks = 0;
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "ArmorStandStatus";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
// Alle 10 Sekunden (200 Ticks)
|
||||
Bukkit.getScheduler().runTaskTimer(NexusLobby.getInstance(), () -> {
|
||||
refreshTicks++;
|
||||
updateAllServerArmorStands();
|
||||
}, 100L, 200L);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
lastStatus.clear();
|
||||
failCount.clear();
|
||||
}
|
||||
|
||||
private void updateAllServerArmorStands() {
|
||||
// Alle 6 Durchgänge (ca. jede Minute) erzwingen wir ein Update für Bedrock
|
||||
boolean forceRefresh = (refreshTicks >= 6);
|
||||
if (forceRefresh) refreshTicks = 0;
|
||||
|
||||
for (World world : Bukkit.getWorlds()) {
|
||||
for (Entity entity : world.getEntitiesByClass(ArmorStand.class)) {
|
||||
if (entity instanceof ArmorStand as) {
|
||||
checkAndRefreshStatus(as, forceRefresh);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void checkAndRefreshStatus(ArmorStand as, boolean forceRefresh) {
|
||||
String serverName = null;
|
||||
|
||||
for (String tag : as.getScoreboardTags()) {
|
||||
if (tag.startsWith("ascmd:")) {
|
||||
if (tag.contains(":bungee:")) {
|
||||
String[] parts = tag.split(":");
|
||||
if (parts.length >= 5) {
|
||||
serverName = parts[4].toLowerCase();
|
||||
} else if (tag.startsWith("ascmd:bungee:")) {
|
||||
serverName = tag.replace("ascmd:bungee:", "").toLowerCase();
|
||||
}
|
||||
}
|
||||
if (serverName != null) break;
|
||||
}
|
||||
}
|
||||
|
||||
if (serverName == null) return;
|
||||
|
||||
final String finalServerName = serverName;
|
||||
String ip = NexusLobby.getInstance().getConfig().getString("servers." + serverName + ".ip", "127.0.0.1");
|
||||
int port = NexusLobby.getInstance().getConfig().getInt("servers." + serverName + ".port", 25565);
|
||||
|
||||
ServerChecker.isOnline(ip, port).thenAccept(isOnline -> {
|
||||
Bukkit.getScheduler().runTask(NexusLobby.getInstance(), () -> {
|
||||
|
||||
// Toleranz-Logik gegen kurzes Flackern
|
||||
if (isOnline) {
|
||||
failCount.put(finalServerName, 0);
|
||||
} else {
|
||||
int fails = failCount.getOrDefault(finalServerName, 0) + 1;
|
||||
failCount.put(finalServerName, fails);
|
||||
if (fails < 2) return;
|
||||
}
|
||||
|
||||
String originalDisplayName = getOriginalName(as);
|
||||
if (originalDisplayName == null) return;
|
||||
|
||||
// Status-Check: Hat sich etwas geändert?
|
||||
Boolean lastKnown = lastStatus.get(as.getUniqueId());
|
||||
|
||||
// Nur wenn Status neu ODER Force-Refresh (für Bedrock) aktiv ist
|
||||
if (!forceRefresh && lastKnown != null && lastKnown == isOnline) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Namen setzen
|
||||
if (isOnline) {
|
||||
String translatedName = ChatColor.translateAlternateColorCodes('&', originalDisplayName);
|
||||
as.setCustomName(translatedName);
|
||||
} else {
|
||||
as.setCustomName("§cOffline");
|
||||
}
|
||||
|
||||
// Bedrock-Fix: Sichtbarkeit explizit triggern
|
||||
as.setCustomNameVisible(true);
|
||||
|
||||
// Status speichern
|
||||
lastStatus.put(as.getUniqueId(), isOnline);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private String getOriginalName(ArmorStand as) {
|
||||
for (String tag : as.getScoreboardTags()) {
|
||||
if (tag.startsWith("as_displayname:")) {
|
||||
return tag.replace("as_displayname:", "").replace("§§", ":");
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
package de.nexuslobby.modules.armorstandtools;
|
||||
|
||||
import de.nexuslobby.NexusLobby;
|
||||
import de.nexuslobby.api.Module;
|
||||
import de.nexuslobby.modules.servers.ServerChecker;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.World;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* ArmorStandStatusModule - Optimierte Statusanzeige für Java & Bedrock.
|
||||
* - Schaltet zwischen Servername und "Offline" um.
|
||||
* - Anti-Blink-Logik für Java-Spieler.
|
||||
* - Force-Refresh-Logik für Bedrock-Spieler (Geyser).
|
||||
*/
|
||||
public class ArmorStandStatusModule implements Module {
|
||||
|
||||
private final Map<UUID, Boolean> lastStatus = new HashMap<>();
|
||||
private final Map<String, Integer> failCount = new HashMap<>();
|
||||
|
||||
// Zähler für den Force-Refresh (Bedrock-Sicherheit)
|
||||
private int refreshTicks = 0;
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "ArmorStandStatus";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
// Alle 10 Sekunden (200 Ticks)
|
||||
Bukkit.getScheduler().runTaskTimer(NexusLobby.getInstance(), () -> {
|
||||
refreshTicks++;
|
||||
updateAllServerArmorStands();
|
||||
}, 100L, 200L);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
lastStatus.clear();
|
||||
failCount.clear();
|
||||
}
|
||||
|
||||
private void updateAllServerArmorStands() {
|
||||
// Alle 6 Durchgänge (ca. jede Minute) erzwingen wir ein Update für Bedrock
|
||||
boolean forceRefresh = (refreshTicks >= 6);
|
||||
if (forceRefresh) refreshTicks = 0;
|
||||
|
||||
for (World world : Bukkit.getWorlds()) {
|
||||
for (Entity entity : world.getEntitiesByClass(ArmorStand.class)) {
|
||||
if (entity instanceof ArmorStand as) {
|
||||
checkAndRefreshStatus(as, forceRefresh);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void checkAndRefreshStatus(ArmorStand as, boolean forceRefresh) {
|
||||
String serverName = null;
|
||||
|
||||
for (String tag : as.getScoreboardTags()) {
|
||||
if (tag.startsWith("ascmd:")) {
|
||||
if (tag.contains(":bungee:")) {
|
||||
String[] parts = tag.split(":");
|
||||
if (parts.length >= 5) {
|
||||
serverName = parts[4].toLowerCase();
|
||||
} else if (tag.startsWith("ascmd:bungee:")) {
|
||||
serverName = tag.replace("ascmd:bungee:", "").toLowerCase();
|
||||
}
|
||||
}
|
||||
if (serverName != null) break;
|
||||
}
|
||||
}
|
||||
|
||||
if (serverName == null) return;
|
||||
|
||||
final String finalServerName = serverName;
|
||||
String ip = NexusLobby.getInstance().getConfig().getString("servers." + serverName + ".ip", "127.0.0.1");
|
||||
int port = NexusLobby.getInstance().getConfig().getInt("servers." + serverName + ".port", 25565);
|
||||
|
||||
ServerChecker.isOnline(ip, port).thenAccept(isOnline -> {
|
||||
Bukkit.getScheduler().runTask(NexusLobby.getInstance(), () -> {
|
||||
|
||||
// Toleranz-Logik gegen kurzes Flackern
|
||||
if (isOnline) {
|
||||
failCount.put(finalServerName, 0);
|
||||
} else {
|
||||
int fails = failCount.getOrDefault(finalServerName, 0) + 1;
|
||||
failCount.put(finalServerName, fails);
|
||||
if (fails < 2) return;
|
||||
}
|
||||
|
||||
String originalDisplayName = getOriginalName(as);
|
||||
if (originalDisplayName == null) return;
|
||||
|
||||
// Status-Check: Hat sich etwas geändert?
|
||||
Boolean lastKnown = lastStatus.get(as.getUniqueId());
|
||||
|
||||
// Nur wenn Status neu ODER Force-Refresh (für Bedrock) aktiv ist
|
||||
if (!forceRefresh && lastKnown != null && lastKnown == isOnline) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Namen setzen
|
||||
if (isOnline) {
|
||||
String translatedName = ChatColor.translateAlternateColorCodes('&', originalDisplayName);
|
||||
as.setCustomName(translatedName);
|
||||
} else {
|
||||
as.setCustomName("§cOffline");
|
||||
}
|
||||
|
||||
// Bedrock-Fix: Sichtbarkeit explizit triggern
|
||||
as.setCustomNameVisible(true);
|
||||
|
||||
// Status speichern
|
||||
lastStatus.put(as.getUniqueId(), isOnline);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private String getOriginalName(ArmorStand as) {
|
||||
for (String tag : as.getScoreboardTags()) {
|
||||
if (tag.startsWith("as_displayname:")) {
|
||||
return tag.replace("as_displayname:", "").replace("§§", ":");
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -51,19 +51,19 @@ public enum ArmorStandTool {
|
||||
case GRAV -> as.setGravity(!as.hasGravity());
|
||||
case INVUL -> as.setInvulnerable(!as.isInvulnerable());
|
||||
case SET_NAME -> {
|
||||
p.closeInventory();
|
||||
p.sendMessage("§8[§6Nexus§8] §7Nutze §e/nexuscmd name <Text>");
|
||||
AST.selectedArmorStand.put(p.getUniqueId(), as);
|
||||
AST.chatInputMode.put(p.getUniqueId(), as);
|
||||
new AnvilRenameGUI(p, as); // schließt Inventar intern
|
||||
}
|
||||
case CONV_SETUP -> {
|
||||
// Automatisches Markieren via GUI
|
||||
if (!p.hasMetadata("conv_npc1")) {
|
||||
p.setMetadata("conv_npc1", new FixedMetadataValue(NexusLobby.getInstance(), as.getUniqueId().toString()));
|
||||
p.sendMessage("§8[§6Nexus§8] §aNPC als Sprecher 1 markiert.");
|
||||
p.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§aNPC als Sprecher 1 markiert.");
|
||||
} else {
|
||||
p.setMetadata("conv_npc2", new FixedMetadataValue(NexusLobby.getInstance(), as.getUniqueId().toString()));
|
||||
p.sendMessage("§8[§6Nexus§8] §aNPC als Sprecher 2 markiert.");
|
||||
p.sendMessage("§8[§6Nexus§8] §7Nutze nun §e/nexuscmd conv start <ID>");
|
||||
p.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§aNPC als Sprecher 2 markiert.");
|
||||
p.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§7Nutze nun §e/nexuscmd conv start <ID>");
|
||||
}
|
||||
p.closeInventory();
|
||||
}
|
||||
@@ -99,8 +99,11 @@ public enum ArmorStandTool {
|
||||
}
|
||||
|
||||
public static ArmorStandTool get(ItemStack item) {
|
||||
if (item == null || !item.hasItemMeta() || !item.getItemMeta().hasDisplayName()) return null;
|
||||
String name = ChatColor.stripColor(item.getItemMeta().getDisplayName()).replace(" ", "_");
|
||||
if (item == null || !item.hasItemMeta()) return null;
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
// FIX: getItemMeta() kann null zurückgeben; hasDisplayName() vor getDisplayName() prüfen
|
||||
if (meta == null || !meta.hasDisplayName()) return null;
|
||||
String name = ChatColor.stripColor(meta.getDisplayName()).replace(" ", "_");
|
||||
if (name.equals("Pose_Editor_öffnen")) return OPEN_POSE_EDITOR;
|
||||
if (name.equals("Gesprächs-Setup")) return CONV_SETUP;
|
||||
try { return valueOf(name); } catch (Exception e) { return null; }
|
||||
|
||||
@@ -1,280 +1,297 @@
|
||||
package de.nexuslobby.modules.armorstandtools;
|
||||
|
||||
import de.nexuslobby.NexusLobby;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ConversationManager {
|
||||
|
||||
private final NexusLobby plugin;
|
||||
private File file;
|
||||
private FileConfiguration config;
|
||||
|
||||
// Verhindert Mehrfach-Gespräche und regelt die 60s Pause
|
||||
private final Set<UUID> activeSpeakers = new HashSet<>();
|
||||
|
||||
public ConversationManager(NexusLobby plugin) {
|
||||
this.plugin = plugin;
|
||||
setupFile();
|
||||
clearHangingBubbles();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gibt alle verfügbaren IDs zurück.
|
||||
*/
|
||||
public List<String> getConversationIds() {
|
||||
if (config == null || !config.contains("conversations")) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
ConfigurationSection section = config.getConfigurationSection("conversations");
|
||||
if (section == null) return new ArrayList<>();
|
||||
|
||||
return new ArrayList<>(section.getKeys(false));
|
||||
}
|
||||
|
||||
/**
|
||||
* Entfernt alle verwaisten Sprechblasen in allen Welten.
|
||||
*/
|
||||
public void clearHangingBubbles() {
|
||||
int count = 0;
|
||||
for (World world : Bukkit.getWorlds()) {
|
||||
for (ArmorStand as : world.getEntitiesByClass(ArmorStand.class)) {
|
||||
if (as.getScoreboardTags().contains("nexus_bubble") ||
|
||||
(!as.isVisible() && as.isMarker() && as.getCustomName() != null)) {
|
||||
as.remove();
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (count > 0) {
|
||||
Bukkit.getLogger().info("[NexusLobby] Cleanup: " + count + " verwaiste Sprechblasen entfernt.");
|
||||
}
|
||||
}
|
||||
|
||||
public void setupFile() {
|
||||
this.file = new File(plugin.getDataFolder(), "conversations.yml");
|
||||
if (!file.exists()) {
|
||||
plugin.saveResource("conversations.yml", false);
|
||||
}
|
||||
this.config = YamlConfiguration.loadConfiguration(file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ermittelt die Tageszeit für die YAML-Pfade.
|
||||
*/
|
||||
private String getDaytimeSuffix() {
|
||||
if (Bukkit.getWorlds().isEmpty()) return "mittags";
|
||||
World world = Bukkit.getWorlds().get(0);
|
||||
long time = world.getTime();
|
||||
|
||||
if (time >= 0 && time < 12000) return "morgens";
|
||||
if (time >= 12000 && time < 13000) return "abends";
|
||||
if (time >= 13000 && time < 23000) return "nacht";
|
||||
return "mittags";
|
||||
}
|
||||
|
||||
/**
|
||||
* Pool-Logik für zufällige Dialog-Varianten oder zeitbasierte IDs.
|
||||
*/
|
||||
private String resolveDialogKey(String key) {
|
||||
ConfigurationSection section = config.getConfigurationSection("conversations");
|
||||
if (section == null) return key;
|
||||
|
||||
String daytimeKey = key + "_" + getDaytimeSuffix();
|
||||
if (section.contains(daytimeKey)) return daytimeKey;
|
||||
|
||||
List<String> pool = section.getKeys(false).stream()
|
||||
.filter(s -> s.startsWith(key))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (pool.isEmpty()) return key;
|
||||
|
||||
return pool.get(new Random().nextInt(pool.size()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Automatische Prüfung für NPCs in Spieler-Nähe (Unterstützt bis zu 4 Partner).
|
||||
*/
|
||||
public void startAllAutomatedConversations() {
|
||||
ConfigurationSection links = config.getConfigurationSection("links");
|
||||
if (links == null) return;
|
||||
|
||||
for (String npc1String : links.getKeys(false)) {
|
||||
try {
|
||||
UUID id1 = UUID.fromString(npc1String);
|
||||
if (activeSpeakers.contains(id1)) continue;
|
||||
|
||||
ConfigurationSection npcLink = links.getConfigurationSection(npc1String);
|
||||
if (npcLink == null) continue;
|
||||
|
||||
String dialogId = npcLink.getString("dialog");
|
||||
List<UUID> partners = new ArrayList<>();
|
||||
partners.add(id1); // Der Starter ist immer Teilnehmer 0
|
||||
|
||||
// Partner 1 bis 3 einsammeln (Max 4 Teilnehmer insgesamt)
|
||||
if (npcLink.contains("partner")) partners.add(UUID.fromString(npcLink.getString("partner")));
|
||||
if (npcLink.contains("partner2")) partners.add(UUID.fromString(npcLink.getString("partner2")));
|
||||
if (npcLink.contains("partner3")) partners.add(UUID.fromString(npcLink.getString("partner3")));
|
||||
|
||||
Entity starter = Bukkit.getEntity(id1);
|
||||
if (starter instanceof ArmorStand as1) {
|
||||
if (as1.getNearbyEntities(15, 15, 15).stream().anyMatch(e -> e instanceof Player)) {
|
||||
String finalDialogId = resolveDialogKey(dialogId);
|
||||
playConversationGroup(partners, finalDialogId);
|
||||
}
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Neue Gruppen-Logik: Spielt Dialoge für 2, 3 oder 4 Teilnehmer ab.
|
||||
*/
|
||||
public void playConversationGroup(List<UUID> participants, String key) {
|
||||
String daytime = getDaytimeSuffix();
|
||||
|
||||
// Pfad-Ermittlung
|
||||
String path = "conversations." + key + "." + daytime;
|
||||
if (!config.contains(path + ".dialogue")) {
|
||||
path = "conversations." + key + ".mittags";
|
||||
}
|
||||
if (!config.contains(path + ".dialogue")) {
|
||||
path = "conversations." + key;
|
||||
}
|
||||
|
||||
if (!config.contains(path + ".dialogue")) return;
|
||||
|
||||
List<String> lines = config.getStringList(path + ".dialogue");
|
||||
if (lines.isEmpty()) return;
|
||||
|
||||
// Alle Teilnehmer blockieren
|
||||
for (UUID id : participants) activeSpeakers.add(id);
|
||||
|
||||
new BukkitRunnable() {
|
||||
int step = 0;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (step >= lines.size()) {
|
||||
// 60 SEKUNDEN COOLDOWN
|
||||
Bukkit.getScheduler().runTaskLater(plugin, () -> {
|
||||
for (UUID id : participants) activeSpeakers.remove(id);
|
||||
}, 1200L);
|
||||
|
||||
this.cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
// Rotations-Logik: Teilnehmer 0 -> 1 -> 2 -> 3 -> 0 ...
|
||||
UUID speakerUUID = participants.get(step % participants.size());
|
||||
Entity entity = Bukkit.getEntity(speakerUUID);
|
||||
|
||||
if (entity instanceof ArmorStand as) {
|
||||
playDynamicSound(as);
|
||||
showBubble(as, lines.get(step));
|
||||
} else {
|
||||
for (UUID id : participants) activeSpeakers.remove(id);
|
||||
this.cancel();
|
||||
return;
|
||||
}
|
||||
step++;
|
||||
}
|
||||
}.runTaskTimer(plugin, 0L, 90L); // 4.5s Intervall
|
||||
}
|
||||
|
||||
/**
|
||||
* Spielt einen Sound ab, dessen Pitch (Tonhöhe) zum Namen des ArmorStands passt.
|
||||
*/
|
||||
private void playDynamicSound(ArmorStand as) {
|
||||
float pitch = 1.0f;
|
||||
String name = as.getCustomName() != null ? as.getCustomName() : "";
|
||||
|
||||
if (name.contains("Timmy") || name.contains("Mia") || name.contains("Lotte")) {
|
||||
pitch = 1.5f + (new Random().nextFloat() * 0.3f); // Hoch (Kind/Frau)
|
||||
} else if (name.contains("Schmidt") || name.contains("Vater") || name.contains("Trainer")) {
|
||||
pitch = 0.6f + (new Random().nextFloat() * 0.2f); // Tief (Mann)
|
||||
} else {
|
||||
pitch = 0.9f + (new Random().nextFloat() * 0.4f); // Neutral
|
||||
}
|
||||
as.getWorld().playSound(as.getLocation(), Sound.ENTITY_VILLAGER_AMBIENT, 0.5f, pitch);
|
||||
}
|
||||
|
||||
/**
|
||||
* Erzeugt die Sprechblase und einen visuellen Effekt (Partikel).
|
||||
*/
|
||||
public void showBubble(ArmorStand as, String text) {
|
||||
Location loc = as.getEyeLocation().add(0, 0.8, 0);
|
||||
|
||||
// Kleiner Partikel-Effekt ("Sprechwolke")
|
||||
as.getWorld().spawnParticle(Particle.CLOUD, loc, 3, 0.1, 0.1, 0.1, 0.02);
|
||||
|
||||
ArmorStand bubble = as.getWorld().spawn(loc, ArmorStand.class, s -> {
|
||||
s.setMarker(true);
|
||||
s.setVisible(false);
|
||||
s.setGravity(false);
|
||||
s.setCustomName(ChatColorTranslate(text));
|
||||
s.setCustomNameVisible(true);
|
||||
s.setInvulnerable(true);
|
||||
s.addScoreboardTag("nexus_bubble");
|
||||
});
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(plugin, bubble::remove, 80L); // 4s Sichtbarkeit
|
||||
}
|
||||
|
||||
// --- Legacy Support & Config Methoden ---
|
||||
|
||||
public void playConversation(UUID id1, UUID id2, String key) {
|
||||
playConversationGroup(Arrays.asList(id1, id2), key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Neue erweiterte Speicher-Methode für bis zu 4 Partner.
|
||||
*/
|
||||
public void saveLinkExtended(UUID id1, UUID id2, UUID id3, UUID id4, String dialogId) {
|
||||
String path = "links." + id1.toString();
|
||||
config.set(path + ".dialog", dialogId);
|
||||
config.set(path + ".partner", id2.toString());
|
||||
if (id3 != null) config.set(path + ".partner2", id3.toString());
|
||||
if (id4 != null) config.set(path + ".partner3", id4.toString());
|
||||
saveConfig();
|
||||
}
|
||||
|
||||
public void saveLink(UUID id1, UUID id2, String dialogId) {
|
||||
saveLinkExtended(id1, id2, null, null, dialogId);
|
||||
}
|
||||
|
||||
public void removeLink(UUID id) {
|
||||
config.set("links." + id.toString(), null);
|
||||
saveConfig();
|
||||
}
|
||||
|
||||
private String ChatColorTranslate(String text) {
|
||||
if (text == null) return "";
|
||||
return text.replace("&", "§");
|
||||
}
|
||||
|
||||
private void saveConfig() {
|
||||
try {
|
||||
config.save(file);
|
||||
} catch (IOException e) {
|
||||
Bukkit.getLogger().severe("Fehler beim Speichern der Conversations: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void reload() {
|
||||
setupFile();
|
||||
activeSpeakers.clear();
|
||||
clearHangingBubbles();
|
||||
}
|
||||
package de.nexuslobby.modules.armorstandtools;
|
||||
|
||||
import de.nexuslobby.NexusLobby;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ConversationManager {
|
||||
|
||||
private final NexusLobby plugin;
|
||||
private File file;
|
||||
private FileConfiguration config;
|
||||
|
||||
// Verhindert Mehrfach-Gespräche und regelt die 60s Pause
|
||||
private final Set<UUID> activeSpeakers = new HashSet<>();
|
||||
// Alle aktiven Bubble-Entities tracken – für zuverlässiges Cleanup bei Reload/Crash
|
||||
private final Set<UUID> activeBubbles = new HashSet<>();
|
||||
|
||||
public ConversationManager(NexusLobby plugin) {
|
||||
this.plugin = plugin;
|
||||
setupFile();
|
||||
clearHangingBubbles();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gibt alle verfügbaren IDs zurück.
|
||||
*/
|
||||
public List<String> getConversationIds() {
|
||||
if (config == null || !config.contains("conversations")) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
ConfigurationSection section = config.getConfigurationSection("conversations");
|
||||
if (section == null) return new ArrayList<>();
|
||||
|
||||
return new ArrayList<>(section.getKeys(false));
|
||||
}
|
||||
|
||||
/**
|
||||
* Entfernt alle verwaisten Sprechblasen in allen Welten.
|
||||
* FIX: Nur ArmorStands mit dem Tag "nexus_bubble" werden entfernt.
|
||||
* Die alte Bedingung (!isVisible && isMarker && customName != null) war
|
||||
* zu breit und hätte auch legitime Marker-ArmorStands anderer Systeme gelöscht.
|
||||
*/
|
||||
public void clearHangingBubbles() {
|
||||
// Zuerst: Alle getrackte Bubble-Entities direkt entfernen (schnell, kein World-Scan nötig)
|
||||
for (UUID uuid : new HashSet<>(activeBubbles)) {
|
||||
Entity e = Bukkit.getEntity(uuid);
|
||||
if (e != null) e.remove();
|
||||
}
|
||||
activeBubbles.clear();
|
||||
|
||||
// Danach: Vollständiger World-Scan als Fallback (fängt Bubbles nach Crash/Reload ab)
|
||||
int count = 0;
|
||||
for (World world : Bukkit.getWorlds()) {
|
||||
for (ArmorStand as : world.getEntitiesByClass(ArmorStand.class)) {
|
||||
if (as.getScoreboardTags().contains("nexus_bubble")) {
|
||||
as.remove();
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (count > 0) {
|
||||
Bukkit.getLogger().info("[NexusLobby] Cleanup: " + count + " verwaiste Sprechblasen entfernt.");
|
||||
}
|
||||
}
|
||||
|
||||
public void setupFile() {
|
||||
this.file = new File(plugin.getDataFolder(), "conversations.yml");
|
||||
if (!file.exists()) {
|
||||
plugin.saveResource("conversations.yml", false);
|
||||
}
|
||||
this.config = YamlConfiguration.loadConfiguration(file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ermittelt die Tageszeit für die YAML-Pfade.
|
||||
*/
|
||||
private String getDaytimeSuffix() {
|
||||
if (Bukkit.getWorlds().isEmpty()) return "mittags";
|
||||
World world = Bukkit.getWorlds().get(0);
|
||||
long time = world.getTime();
|
||||
|
||||
if (time >= 0 && time < 12000) return "morgens";
|
||||
if (time >= 12000 && time < 13000) return "abends";
|
||||
if (time >= 13000 && time < 23000) return "nacht";
|
||||
return "mittags";
|
||||
}
|
||||
|
||||
/**
|
||||
* Pool-Logik für zufällige Dialog-Varianten oder zeitbasierte IDs.
|
||||
*/
|
||||
private String resolveDialogKey(String key) {
|
||||
ConfigurationSection section = config.getConfigurationSection("conversations");
|
||||
if (section == null) return key;
|
||||
|
||||
String daytimeKey = key + "_" + getDaytimeSuffix();
|
||||
if (section.contains(daytimeKey)) return daytimeKey;
|
||||
|
||||
List<String> pool = section.getKeys(false).stream()
|
||||
.filter(s -> s.startsWith(key))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (pool.isEmpty()) return key;
|
||||
|
||||
return pool.get(new Random().nextInt(pool.size()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Automatische Prüfung für NPCs in Spieler-Nähe (Unterstützt bis zu 4 Partner).
|
||||
*/
|
||||
public void startAllAutomatedConversations() {
|
||||
ConfigurationSection links = config.getConfigurationSection("links");
|
||||
if (links == null) return;
|
||||
|
||||
for (String npc1String : links.getKeys(false)) {
|
||||
try {
|
||||
UUID id1 = UUID.fromString(npc1String);
|
||||
if (activeSpeakers.contains(id1)) continue;
|
||||
|
||||
ConfigurationSection npcLink = links.getConfigurationSection(npc1String);
|
||||
if (npcLink == null) continue;
|
||||
|
||||
String dialogId = npcLink.getString("dialog");
|
||||
List<UUID> partners = new ArrayList<>();
|
||||
partners.add(id1); // Der Starter ist immer Teilnehmer 0
|
||||
|
||||
// Partner 1 bis 3 einsammeln (Max 4 Teilnehmer insgesamt)
|
||||
if (npcLink.contains("partner")) partners.add(UUID.fromString(npcLink.getString("partner")));
|
||||
if (npcLink.contains("partner2")) partners.add(UUID.fromString(npcLink.getString("partner2")));
|
||||
if (npcLink.contains("partner3")) partners.add(UUID.fromString(npcLink.getString("partner3")));
|
||||
|
||||
Entity starter = Bukkit.getEntity(id1);
|
||||
if (starter instanceof ArmorStand as1) {
|
||||
if (as1.getNearbyEntities(15, 15, 15).stream().anyMatch(e -> e instanceof Player)) {
|
||||
String finalDialogId = resolveDialogKey(dialogId);
|
||||
playConversationGroup(partners, finalDialogId);
|
||||
}
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Neue Gruppen-Logik: Spielt Dialoge für 2, 3 oder 4 Teilnehmer ab.
|
||||
*/
|
||||
public void playConversationGroup(List<UUID> participants, String key) {
|
||||
String daytime = getDaytimeSuffix();
|
||||
|
||||
// Pfad-Ermittlung
|
||||
String path = "conversations." + key + "." + daytime;
|
||||
if (!config.contains(path + ".dialogue")) {
|
||||
path = "conversations." + key + ".mittags";
|
||||
}
|
||||
if (!config.contains(path + ".dialogue")) {
|
||||
path = "conversations." + key;
|
||||
}
|
||||
|
||||
if (!config.contains(path + ".dialogue")) return;
|
||||
|
||||
List<String> lines = config.getStringList(path + ".dialogue");
|
||||
if (lines.isEmpty()) return;
|
||||
|
||||
// Alle Teilnehmer blockieren
|
||||
for (UUID id : participants) activeSpeakers.add(id);
|
||||
|
||||
new BukkitRunnable() {
|
||||
int step = 0;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (step >= lines.size()) {
|
||||
// 60 SEKUNDEN COOLDOWN
|
||||
Bukkit.getScheduler().runTaskLater(plugin, () -> {
|
||||
for (UUID id : participants) activeSpeakers.remove(id);
|
||||
}, 1200L);
|
||||
|
||||
this.cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
// Rotations-Logik: Teilnehmer 0 -> 1 -> 2 -> 3 -> 0 ...
|
||||
UUID speakerUUID = participants.get(step % participants.size());
|
||||
Entity entity = Bukkit.getEntity(speakerUUID);
|
||||
|
||||
if (entity instanceof ArmorStand as) {
|
||||
playDynamicSound(as);
|
||||
showBubble(as, lines.get(step));
|
||||
} else {
|
||||
for (UUID id : participants) activeSpeakers.remove(id);
|
||||
this.cancel();
|
||||
return;
|
||||
}
|
||||
step++;
|
||||
}
|
||||
}.runTaskTimer(plugin, 0L, 90L); // 4.5s Intervall
|
||||
}
|
||||
|
||||
/**
|
||||
* Spielt einen Sound ab, dessen Pitch (Tonhöhe) zum Namen des ArmorStands passt.
|
||||
*/
|
||||
private void playDynamicSound(ArmorStand as) {
|
||||
float pitch = 1.0f;
|
||||
String name = as.getCustomName() != null ? as.getCustomName() : "";
|
||||
|
||||
if (name.contains("Timmy") || name.contains("Mia") || name.contains("Lotte")) {
|
||||
pitch = 1.5f + (new Random().nextFloat() * 0.3f); // Hoch (Kind/Frau)
|
||||
} else if (name.contains("Schmidt") || name.contains("Vater") || name.contains("Trainer")) {
|
||||
pitch = 0.6f + (new Random().nextFloat() * 0.2f); // Tief (Mann)
|
||||
} else {
|
||||
pitch = 0.9f + (new Random().nextFloat() * 0.4f); // Neutral
|
||||
}
|
||||
as.getWorld().playSound(as.getLocation(), Sound.ENTITY_VILLAGER_AMBIENT, 0.5f, pitch);
|
||||
}
|
||||
|
||||
/**
|
||||
* Erzeugt die Sprechblase und einen visuellen Effekt (Partikel).
|
||||
*/
|
||||
public void showBubble(ArmorStand as, String text) {
|
||||
Location loc = as.getEyeLocation().add(0, 0.8, 0);
|
||||
|
||||
// Kleiner Partikel-Effekt ("Sprechwolke")
|
||||
as.getWorld().spawnParticle(Particle.CLOUD, loc, 3, 0.1, 0.1, 0.1, 0.02);
|
||||
|
||||
ArmorStand bubble = as.getWorld().spawn(loc, ArmorStand.class, s -> {
|
||||
s.setMarker(true);
|
||||
s.setVisible(false);
|
||||
s.setGravity(false);
|
||||
s.setCustomName(ChatColorTranslate(text));
|
||||
s.setCustomNameVisible(true);
|
||||
s.setInvulnerable(true);
|
||||
s.setPersistent(false); // Überlebt keinen Server-Neustart/-Absturz
|
||||
s.addScoreboardTag("nexus_bubble");
|
||||
});
|
||||
|
||||
activeBubbles.add(bubble.getUniqueId());
|
||||
Bukkit.getScheduler().runTaskLater(plugin, () -> {
|
||||
bubble.remove();
|
||||
activeBubbles.remove(bubble.getUniqueId());
|
||||
}, 80L); // 4s Sichtbarkeit
|
||||
}
|
||||
|
||||
// --- Legacy Support & Config Methoden ---
|
||||
|
||||
public void playConversation(UUID id1, UUID id2, String key) {
|
||||
playConversationGroup(Arrays.asList(id1, id2), key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Neue erweiterte Speicher-Methode für bis zu 4 Partner.
|
||||
*/
|
||||
public void saveLinkExtended(UUID id1, UUID id2, UUID id3, UUID id4, String dialogId) {
|
||||
String path = "links." + id1.toString();
|
||||
config.set(path + ".dialog", dialogId);
|
||||
config.set(path + ".partner", id2.toString());
|
||||
if (id3 != null) config.set(path + ".partner2", id3.toString());
|
||||
if (id4 != null) config.set(path + ".partner3", id4.toString());
|
||||
saveConfig();
|
||||
}
|
||||
|
||||
public void saveLink(UUID id1, UUID id2, String dialogId) {
|
||||
saveLinkExtended(id1, id2, null, null, dialogId);
|
||||
}
|
||||
|
||||
public void removeLink(UUID id) {
|
||||
config.set("links." + id.toString(), null);
|
||||
saveConfig();
|
||||
}
|
||||
|
||||
private String ChatColorTranslate(String text) {
|
||||
if (text == null) return "";
|
||||
return text.replace("&", "§");
|
||||
}
|
||||
|
||||
private void saveConfig() {
|
||||
try {
|
||||
config.save(file);
|
||||
} catch (IOException e) {
|
||||
Bukkit.getLogger().severe("Fehler beim Speichern der Conversations: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void reload() {
|
||||
clearHangingBubbles(); // Erst aufräumen, dann neu laden
|
||||
activeSpeakers.clear();
|
||||
setupFile();
|
||||
}
|
||||
}
|
||||
+130
-130
@@ -1,131 +1,131 @@
|
||||
package de.nexuslobby.modules.armorstandtools;
|
||||
|
||||
import de.nexuslobby.NexusLobby;
|
||||
import de.nexuslobby.api.Module;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
import org.bukkit.util.EulerAngle;
|
||||
|
||||
public class DynamicArmorStandModule implements Module {
|
||||
|
||||
private final NamespacedKey npcKey = new NamespacedKey(NexusLobby.getInstance(), "dynamic_npc");
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "DynamicArmorStands";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
startUpdateTask();
|
||||
}
|
||||
|
||||
private void startUpdateTask() {
|
||||
// Alle 5 Ticks (0.25s) für flüssige Partikel
|
||||
Bukkit.getScheduler().runTaskTimer(NexusLobby.getInstance(), this::updateAllArmorStands, 20L, 5L);
|
||||
}
|
||||
|
||||
public void updateAllArmorStands() {
|
||||
for (World world : Bukkit.getWorlds()) {
|
||||
long time = world.getTime();
|
||||
boolean isIngameNight = (time >= 13000 && time <= 23000);
|
||||
|
||||
for (Entity entity : world.getEntities()) {
|
||||
if (entity instanceof ArmorStand as) {
|
||||
if (as.getPersistentDataContainer().has(npcKey, PersistentDataType.BYTE) ||
|
||||
as.getScoreboardTags().contains("as_dynamic")) {
|
||||
|
||||
applyDynamicChanges(as, isIngameNight);
|
||||
|
||||
if (isIngameNight && as.getEquipment().getItemInOffHand().getType() == Material.TORCH) {
|
||||
spawnStarParticles(as);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void applyDynamicChanges(ArmorStand as, boolean isNight) {
|
||||
if (!as.hasArms()) as.setArms(true);
|
||||
|
||||
// --- SPIELER-NÄHE ---
|
||||
boolean playerNearby = false;
|
||||
for (Entity nearby : as.getNearbyEntities(2.0, 2.0, 2.0)) {
|
||||
if (nearby instanceof Player) { playerNearby = true; break; }
|
||||
}
|
||||
|
||||
if (playerNearby) {
|
||||
if (as.getEquipment().getItemInMainHand().getType() != Material.STONE_SWORD) {
|
||||
as.getEquipment().setItemInMainHand(new ItemStack(Material.STONE_SWORD));
|
||||
as.setRightArmPose(new EulerAngle(Math.toRadians(-80), Math.toRadians(-10), 0));
|
||||
}
|
||||
} else {
|
||||
if (as.getEquipment().getItemInMainHand().getType() == Material.STONE_SWORD) {
|
||||
as.getEquipment().setItemInMainHand(null);
|
||||
as.setRightArmPose(EulerAngle.ZERO);
|
||||
}
|
||||
}
|
||||
|
||||
// --- INGAME-ZEIT ---
|
||||
if (isNight) {
|
||||
if (as.getEquipment().getItemInOffHand().getType() != Material.TORCH) {
|
||||
as.getEquipment().setItemInOffHand(new ItemStack(Material.TORCH));
|
||||
as.setLeftArmPose(new EulerAngle(Math.toRadians(-50), Math.toRadians(15), 0));
|
||||
}
|
||||
} else {
|
||||
if (as.getEquipment().getItemInOffHand().getType() == Material.TORCH) {
|
||||
as.getEquipment().setItemInOffHand(null);
|
||||
as.setLeftArmPose(EulerAngle.ZERO);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void spawnStarParticles(ArmorStand as) {
|
||||
Location loc = as.getLocation();
|
||||
double yawRad = Math.toRadians(loc.getYaw());
|
||||
|
||||
// Vektoren für Blickrichtung und Seite
|
||||
double dirX = -Math.sin(yawRad);
|
||||
double dirZ = Math.cos(yawRad);
|
||||
double sideX = Math.cos(yawRad);
|
||||
double sideZ = Math.sin(yawRad);
|
||||
|
||||
// Position: Vorne (0.4), Links (0.5), Oben (1.45)
|
||||
double finalX = loc.getX() + (dirX * 0.8) + (sideX * 0.2);
|
||||
double finalY = loc.getY() + 1.45;
|
||||
double finalZ = loc.getZ() + (dirZ * 0.8) + (sideZ * 0.2);
|
||||
|
||||
Location particleLoc = new Location(as.getWorld(), finalX, finalY, finalZ);
|
||||
as.getWorld().spawnParticle(Particle.WAX_OFF, particleLoc, 2, 0.05, 0.05, 0.05, 0.01);
|
||||
}
|
||||
|
||||
public void toggleDynamicStatus(ArmorStand as) {
|
||||
if (as.getPersistentDataContainer().has(npcKey, PersistentDataType.BYTE)) {
|
||||
as.getPersistentDataContainer().remove(npcKey);
|
||||
as.removeScoreboardTag("as_dynamic");
|
||||
as.getEquipment().setItemInMainHand(null);
|
||||
as.getEquipment().setItemInOffHand(null);
|
||||
as.setRightArmPose(EulerAngle.ZERO);
|
||||
as.setLeftArmPose(EulerAngle.ZERO);
|
||||
} else {
|
||||
as.getPersistentDataContainer().set(npcKey, PersistentDataType.BYTE, (byte) 1);
|
||||
as.addScoreboardTag("as_dynamic");
|
||||
applyDynamicChanges(as, (as.getWorld().getTime() >= 13000 && as.getWorld().getTime() <= 23000));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
// Bereinigung falls nötig
|
||||
}
|
||||
package de.nexuslobby.modules.armorstandtools;
|
||||
|
||||
import de.nexuslobby.NexusLobby;
|
||||
import de.nexuslobby.api.Module;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
import org.bukkit.util.EulerAngle;
|
||||
|
||||
public class DynamicArmorStandModule implements Module {
|
||||
|
||||
private final NamespacedKey npcKey = new NamespacedKey(NexusLobby.getInstance(), "dynamic_npc");
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "DynamicArmorStands";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
startUpdateTask();
|
||||
}
|
||||
|
||||
private void startUpdateTask() {
|
||||
// Alle 5 Ticks (0.25s) für flüssige Partikel
|
||||
Bukkit.getScheduler().runTaskTimer(NexusLobby.getInstance(), this::updateAllArmorStands, 20L, 5L);
|
||||
}
|
||||
|
||||
public void updateAllArmorStands() {
|
||||
for (World world : Bukkit.getWorlds()) {
|
||||
long time = world.getTime();
|
||||
boolean isIngameNight = (time >= 13000 && time <= 23000);
|
||||
|
||||
for (Entity entity : world.getEntities()) {
|
||||
if (entity instanceof ArmorStand as) {
|
||||
if (as.getPersistentDataContainer().has(npcKey, PersistentDataType.BYTE) ||
|
||||
as.getScoreboardTags().contains("as_dynamic")) {
|
||||
|
||||
applyDynamicChanges(as, isIngameNight);
|
||||
|
||||
if (isIngameNight && as.getEquipment().getItemInOffHand().getType() == Material.TORCH) {
|
||||
spawnStarParticles(as);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void applyDynamicChanges(ArmorStand as, boolean isNight) {
|
||||
if (!as.hasArms()) as.setArms(true);
|
||||
|
||||
// --- SPIELER-NÄHE ---
|
||||
boolean playerNearby = false;
|
||||
for (Entity nearby : as.getNearbyEntities(2.0, 2.0, 2.0)) {
|
||||
if (nearby instanceof Player) { playerNearby = true; break; }
|
||||
}
|
||||
|
||||
if (playerNearby) {
|
||||
if (as.getEquipment().getItemInMainHand().getType() != Material.STONE_SWORD) {
|
||||
as.getEquipment().setItemInMainHand(new ItemStack(Material.STONE_SWORD));
|
||||
as.setRightArmPose(new EulerAngle(Math.toRadians(-80), Math.toRadians(-10), 0));
|
||||
}
|
||||
} else {
|
||||
if (as.getEquipment().getItemInMainHand().getType() == Material.STONE_SWORD) {
|
||||
as.getEquipment().setItemInMainHand(null);
|
||||
as.setRightArmPose(EulerAngle.ZERO);
|
||||
}
|
||||
}
|
||||
|
||||
// --- INGAME-ZEIT ---
|
||||
if (isNight) {
|
||||
if (as.getEquipment().getItemInOffHand().getType() != Material.TORCH) {
|
||||
as.getEquipment().setItemInOffHand(new ItemStack(Material.TORCH));
|
||||
as.setLeftArmPose(new EulerAngle(Math.toRadians(-50), Math.toRadians(15), 0));
|
||||
}
|
||||
} else {
|
||||
if (as.getEquipment().getItemInOffHand().getType() == Material.TORCH) {
|
||||
as.getEquipment().setItemInOffHand(null);
|
||||
as.setLeftArmPose(EulerAngle.ZERO);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void spawnStarParticles(ArmorStand as) {
|
||||
Location loc = as.getLocation();
|
||||
double yawRad = Math.toRadians(loc.getYaw());
|
||||
|
||||
// Vektoren für Blickrichtung und Seite
|
||||
double dirX = -Math.sin(yawRad);
|
||||
double dirZ = Math.cos(yawRad);
|
||||
double sideX = Math.cos(yawRad);
|
||||
double sideZ = Math.sin(yawRad);
|
||||
|
||||
// Position: Vorne (0.4), Links (0.5), Oben (1.45)
|
||||
double finalX = loc.getX() + (dirX * 0.8) + (sideX * 0.2);
|
||||
double finalY = loc.getY() + 1.45;
|
||||
double finalZ = loc.getZ() + (dirZ * 0.8) + (sideZ * 0.2);
|
||||
|
||||
Location particleLoc = new Location(as.getWorld(), finalX, finalY, finalZ);
|
||||
as.getWorld().spawnParticle(Particle.WAX_OFF, particleLoc, 2, 0.05, 0.05, 0.05, 0.01);
|
||||
}
|
||||
|
||||
public void toggleDynamicStatus(ArmorStand as) {
|
||||
if (as.getPersistentDataContainer().has(npcKey, PersistentDataType.BYTE)) {
|
||||
as.getPersistentDataContainer().remove(npcKey);
|
||||
as.removeScoreboardTag("as_dynamic");
|
||||
as.getEquipment().setItemInMainHand(null);
|
||||
as.getEquipment().setItemInOffHand(null);
|
||||
as.setRightArmPose(EulerAngle.ZERO);
|
||||
as.setLeftArmPose(EulerAngle.ZERO);
|
||||
} else {
|
||||
as.getPersistentDataContainer().set(npcKey, PersistentDataType.BYTE, (byte) 1);
|
||||
as.addScoreboardTag("as_dynamic");
|
||||
applyDynamicChanges(as, (as.getWorld().getTime() >= 13000 && as.getWorld().getTime() <= 23000));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
// Bereinigung falls nötig
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,86 +1,108 @@
|
||||
package de.nexuslobby.commands;
|
||||
|
||||
import de.nexuslobby.NexusLobby;
|
||||
import de.nexuslobby.modules.portal.PortalCommand;
|
||||
import de.nexuslobby.modules.border.BorderModule;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class BorderCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (!(sender instanceof Player p)) return true;
|
||||
if (!p.hasPermission("nexuslobby.admin")) {
|
||||
p.sendMessage("§8[§6Nexus§8] §cKeine Rechte.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length == 0) {
|
||||
p.sendMessage("§8§m------------------------------------");
|
||||
p.sendMessage("§6§lNexus WorldBorder Setup");
|
||||
p.sendMessage("§e/border circle <Radius> §7- Kreis um dich herum");
|
||||
p.sendMessage("§e/border square §7- Nutzt Axt-Markierung (Viereck)");
|
||||
p.sendMessage("§e/border disable §7- Grenze deaktivieren");
|
||||
p.sendMessage("§8§m------------------------------------");
|
||||
return true;
|
||||
}
|
||||
|
||||
var config = NexusLobby.getInstance().getConfig();
|
||||
|
||||
switch (args[0].toLowerCase()) {
|
||||
case "circle" -> {
|
||||
if (args.length < 2) {
|
||||
p.sendMessage("§cBitte gib einen Radius an.");
|
||||
return true;
|
||||
}
|
||||
try {
|
||||
double radius = Double.parseDouble(args[1]);
|
||||
config.set("worldborder.type", "CIRCLE");
|
||||
config.set("worldborder.center", p.getLocation());
|
||||
config.set("worldborder.radius", radius);
|
||||
config.set("worldborder.enabled", true);
|
||||
p.sendMessage("§8[§6Nexus§8] §aKreis-Grenze (Radius: " + radius + ") gesetzt.");
|
||||
} catch (NumberFormatException e) {
|
||||
p.sendMessage("§cUngültige Zahl.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
case "square" -> {
|
||||
Location l1 = PortalCommand.getSelection1(p);
|
||||
Location l2 = PortalCommand.getSelection2(p);
|
||||
if (l1 == null || l2 == null) {
|
||||
p.sendMessage("§8[§6Nexus§8] §cBitte markiere erst 2 Punkte mit der Portalwand!");
|
||||
return true;
|
||||
}
|
||||
config.set("worldborder.type", "SQUARE");
|
||||
config.set("worldborder.pos1", l1);
|
||||
config.set("worldborder.pos2", l2);
|
||||
config.set("worldborder.enabled", true);
|
||||
p.sendMessage("§8[§6Nexus§8] §aViereckige Grenze erfolgreich gesetzt.");
|
||||
}
|
||||
case "disable" -> {
|
||||
config.set("worldborder.enabled", false);
|
||||
p.sendMessage("§8[§6Nexus§8] §cGrenze wurde deaktiviert.");
|
||||
}
|
||||
default -> {
|
||||
p.sendMessage("§cUnbekannter Unterbefehl.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
NexusLobby.getInstance().saveConfig();
|
||||
|
||||
// Update das Modul direkt im RAM
|
||||
BorderModule module = NexusLobby.getInstance().getModuleManager().getModule(BorderModule.class);
|
||||
if (module != null) {
|
||||
module.reloadConfig();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
package de.nexuslobby.commands;
|
||||
|
||||
import de.nexuslobby.NexusLobby;
|
||||
import de.nexuslobby.modules.portal.PortalCommand;
|
||||
import de.nexuslobby.modules.border.BorderModule;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class BorderCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (!(sender instanceof Player p)) return true;
|
||||
if (!p.hasPermission("nexuslobby.admin")) {
|
||||
p.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§cKeine Rechte.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length == 0) {
|
||||
p.sendMessage("§8§m------------------------------------");
|
||||
p.sendMessage("§6§lNexus WorldBorder Setup");
|
||||
p.sendMessage("§e/border circle <Radius> §7- Kreis um dich herum");
|
||||
p.sendMessage("§e/border square §7- Nutzt Axt-Markierung (Viereck)");
|
||||
p.sendMessage("§e/border disable §7- Grenze deaktivieren");
|
||||
p.sendMessage("§8§m------------------------------------");
|
||||
return true;
|
||||
}
|
||||
|
||||
var config = NexusLobby.getInstance().getConfig();
|
||||
|
||||
switch (args[0].toLowerCase()) {
|
||||
case "circle" -> {
|
||||
if (args.length < 2) {
|
||||
p.sendMessage("§cBitte gib einen Radius an.");
|
||||
return true;
|
||||
}
|
||||
try {
|
||||
double radius = Double.parseDouble(args[1]);
|
||||
Location loc = p.getLocation();
|
||||
|
||||
config.set("worldborder.type", "CIRCLE");
|
||||
config.set("worldborder.enabled", true);
|
||||
config.set("worldborder.radius", radius);
|
||||
|
||||
// FIX: Location als einzelne Werte speichern statt als Objekt.
|
||||
// config.set(key, Location) ist nach Neustarts unzuverlässig,
|
||||
// weil config.getLocation() die Welt zum Deserialisierungs-
|
||||
// zeitpunkt auflösen muss und das fehlschlagen kann.
|
||||
config.set("worldborder.center.world", loc.getWorld().getName());
|
||||
config.set("worldborder.center.x", loc.getX());
|
||||
config.set("worldborder.center.y", loc.getY());
|
||||
config.set("worldborder.center.z", loc.getZ());
|
||||
|
||||
p.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§aKreis-Grenze (Radius: " + radius + ") gesetzt.");
|
||||
} catch (NumberFormatException e) {
|
||||
p.sendMessage("§cUngültige Zahl.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
case "square" -> {
|
||||
Location l1 = PortalCommand.getSelection1(p);
|
||||
Location l2 = PortalCommand.getSelection2(p);
|
||||
if (l1 == null || l2 == null) {
|
||||
p.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§cBitte markiere erst 2 Punkte mit der Portalwand!");
|
||||
return true;
|
||||
}
|
||||
|
||||
config.set("worldborder.type", "SQUARE");
|
||||
config.set("worldborder.enabled", true);
|
||||
|
||||
// FIX: Beide Positionen als einzelne Werte speichern
|
||||
config.set("worldborder.pos1.world", l1.getWorld().getName());
|
||||
config.set("worldborder.pos1.x", l1.getX());
|
||||
config.set("worldborder.pos1.y", l1.getY());
|
||||
config.set("worldborder.pos1.z", l1.getZ());
|
||||
|
||||
config.set("worldborder.pos2.world", l2.getWorld().getName());
|
||||
config.set("worldborder.pos2.x", l2.getX());
|
||||
config.set("worldborder.pos2.y", l2.getY());
|
||||
config.set("worldborder.pos2.z", l2.getZ());
|
||||
|
||||
p.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§aViereckige Grenze erfolgreich gesetzt.");
|
||||
}
|
||||
case "disable" -> {
|
||||
config.set("worldborder.enabled", false);
|
||||
p.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§cGrenze wurde deaktiviert.");
|
||||
}
|
||||
default -> {
|
||||
p.sendMessage("§cUnbekannter Unterbefehl.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
NexusLobby.getInstance().saveConfig();
|
||||
|
||||
// Update das Modul direkt im RAM
|
||||
BorderModule module = NexusLobby.getInstance().getModuleManager().getModule(BorderModule.class);
|
||||
if (module != null) {
|
||||
module.reloadConfig();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,132 +1,162 @@
|
||||
package de.nexuslobby.modules.border;
|
||||
|
||||
import de.nexuslobby.NexusLobby;
|
||||
import de.nexuslobby.api.Module;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
/**
|
||||
* Verwaltet die Lobby-Begrenzung (Kreis oder Rechteck).
|
||||
* Speichert Daten in der Haupt-config.yml unter 'worldborder'.
|
||||
*/
|
||||
public class BorderModule implements Module, Listener {
|
||||
|
||||
private String type;
|
||||
private Location pos1, pos2, center;
|
||||
private double radius;
|
||||
private boolean enabled;
|
||||
|
||||
@Override
|
||||
public String getName() { return "WorldBorder"; }
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
reloadConfig();
|
||||
Bukkit.getPluginManager().registerEvents(this, NexusLobby.getInstance());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
// Aufräumarbeiten falls nötig
|
||||
}
|
||||
|
||||
/**
|
||||
* Lädt die Border-Einstellungen aus der config.yml.
|
||||
* Wird auch von NexusLobby.reloadPlugin() aufgerufen.
|
||||
*/
|
||||
public void reloadConfig() {
|
||||
FileConfiguration config = NexusLobby.getInstance().getConfig();
|
||||
|
||||
// Pfad in der config.yml: worldborder.enabled etc.
|
||||
this.enabled = config.getBoolean("worldborder.enabled", false);
|
||||
this.type = config.getString("worldborder.type", "CIRCLE");
|
||||
this.radius = config.getDouble("worldborder.radius", 50.0);
|
||||
|
||||
// Locations laden
|
||||
this.center = config.getLocation("worldborder.center");
|
||||
this.pos1 = config.getLocation("worldborder.pos1");
|
||||
this.pos2 = config.getLocation("worldborder.pos2");
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onMove(PlayerMoveEvent event) {
|
||||
if (!enabled || event.getTo() == null) return;
|
||||
|
||||
// Performance: Nur prüfen, wenn sich die Block-Koordinaten ändern
|
||||
if (event.getFrom().getBlockX() == event.getTo().getBlockX() &&
|
||||
event.getFrom().getBlockZ() == event.getTo().getBlockZ() &&
|
||||
event.getFrom().getBlockY() == event.getTo().getBlockY()) return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
// Admins und Spectators ignorieren
|
||||
if (player.hasPermission("nexuslobby.admin") || player.getGameMode().name().equals("SPECTATOR")) return;
|
||||
|
||||
Location to = event.getTo();
|
||||
boolean outside = false;
|
||||
|
||||
// --- Prüfung: Kreis-Border ---
|
||||
if (type.equalsIgnoreCase("CIRCLE") && center != null) {
|
||||
if (to.getWorld().equals(center.getWorld())) {
|
||||
double distSq = Math.pow(to.getX() - center.getX(), 2) + Math.pow(to.getZ() - center.getZ(), 2);
|
||||
if (distSq > Math.pow(radius, 2)) outside = true;
|
||||
}
|
||||
}
|
||||
// --- Prüfung: Rechteck-Border (Square) ---
|
||||
else if (type.equalsIgnoreCase("SQUARE") && pos1 != null && pos2 != null) {
|
||||
if (to.getWorld().equals(pos1.getWorld())) {
|
||||
double minX = Math.min(pos1.getX(), pos2.getX());
|
||||
double maxX = Math.max(pos1.getX(), pos2.getX());
|
||||
double minZ = Math.min(pos1.getZ(), pos2.getZ());
|
||||
double maxZ = Math.max(pos1.getZ(), pos2.getZ());
|
||||
|
||||
if (to.getX() < minX || to.getX() > maxX || to.getZ() < minZ || to.getZ() > maxZ) {
|
||||
outside = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --- Aktion wenn außerhalb ---
|
||||
if (outside) {
|
||||
Location spawnLocation = getMainSpawnLocation();
|
||||
|
||||
if (spawnLocation != null) {
|
||||
// Sofortiger Teleport zum definierten Spawn
|
||||
player.teleport(spawnLocation);
|
||||
|
||||
// Feedback an den Spieler
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_ENDERMAN_TELEPORT, 1.0f, 0.5f);
|
||||
player.sendMessage("§8[§6Nexus§8] §cDu hast den Lobby-Bereich verlassen!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Holt den zentralen Spawnpunkt aus der Config (Pfad: spawn.world, spawn.x, etc.)
|
||||
*/
|
||||
private Location getMainSpawnLocation() {
|
||||
FileConfiguration config = NexusLobby.getInstance().getConfig();
|
||||
String worldName = config.getString("spawn.world");
|
||||
|
||||
if (worldName != null) {
|
||||
World w = Bukkit.getWorld(worldName);
|
||||
if (w != null) {
|
||||
return new Location(w,
|
||||
config.getDouble("spawn.x"),
|
||||
config.getDouble("spawn.y"),
|
||||
config.getDouble("spawn.z"),
|
||||
(float) config.getDouble("spawn.yaw"),
|
||||
(float) config.getDouble("spawn.pitch"));
|
||||
}
|
||||
}
|
||||
// Fallback falls kein Spawn gesetzt ist
|
||||
return Bukkit.getWorlds().isEmpty() ? null : Bukkit.getWorlds().get(0).getSpawnLocation();
|
||||
}
|
||||
package de.nexuslobby.modules.border;
|
||||
|
||||
import de.nexuslobby.NexusLobby;
|
||||
import de.nexuslobby.api.Module;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
/**
|
||||
* Verwaltet die Lobby-Begrenzung (Kreis oder Rechteck).
|
||||
* Speichert Daten in der Haupt-config.yml unter 'worldborder'.
|
||||
*
|
||||
* FIX: Locations werden als einzelne Werte (worldName, x, y, z) gespeichert
|
||||
* statt als serialisiertes Location-Objekt, da config.getLocation()
|
||||
* nach einem Neustart unzuverlässig ist.
|
||||
*/
|
||||
public class BorderModule implements Module, Listener {
|
||||
|
||||
private String type;
|
||||
// FIX: Statt Location-Objekte die rohen Werte cachen
|
||||
private String pos1World, pos2World, centerWorld;
|
||||
private double pos1X, pos1Y, pos1Z;
|
||||
private double pos2X, pos2Y, pos2Z;
|
||||
private double centerX, centerZ;
|
||||
private double radius;
|
||||
private boolean enabled;
|
||||
private boolean hasPos1, hasPos2, hasCenter;
|
||||
|
||||
@Override
|
||||
public String getName() { return "WorldBorder"; }
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
reloadConfig();
|
||||
Bukkit.getPluginManager().registerEvents(this, NexusLobby.getInstance());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
// FIX: Listener beim Deaktivieren abmelden, damit nach /reload
|
||||
// keine doppelten Events gefeuert werden.
|
||||
HandlerList.unregisterAll(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Lädt die Border-Einstellungen aus der config.yml.
|
||||
* Wird auch von BorderCommand und NexusLobby.reloadPlugin() aufgerufen.
|
||||
*
|
||||
* FIX: Robuste Methode - liest world-Name und einzelne Koordinaten,
|
||||
* kein config.getLocation() mehr (das nach Neustarts versagen kann).
|
||||
*/
|
||||
public void reloadConfig() {
|
||||
FileConfiguration config = NexusLobby.getInstance().getConfig();
|
||||
|
||||
this.enabled = config.getBoolean("worldborder.enabled", false);
|
||||
this.type = config.getString("worldborder.type", "CIRCLE").toUpperCase();
|
||||
this.radius = config.getDouble("worldborder.radius", 50.0);
|
||||
|
||||
// --- CIRCLE-Daten laden ---
|
||||
this.hasCenter = config.contains("worldborder.center.world");
|
||||
if (hasCenter) {
|
||||
this.centerWorld = config.getString("worldborder.center.world");
|
||||
this.centerX = config.getDouble("worldborder.center.x");
|
||||
this.centerZ = config.getDouble("worldborder.center.z");
|
||||
}
|
||||
|
||||
// --- SQUARE-Daten laden ---
|
||||
this.hasPos1 = config.contains("worldborder.pos1.world");
|
||||
this.hasPos2 = config.contains("worldborder.pos2.world");
|
||||
if (hasPos1) {
|
||||
this.pos1World = config.getString("worldborder.pos1.world");
|
||||
this.pos1X = config.getDouble("worldborder.pos1.x");
|
||||
this.pos1Y = config.getDouble("worldborder.pos1.y");
|
||||
this.pos1Z = config.getDouble("worldborder.pos1.z");
|
||||
}
|
||||
if (hasPos2) {
|
||||
this.pos2World = config.getString("worldborder.pos2.world");
|
||||
this.pos2X = config.getDouble("worldborder.pos2.x");
|
||||
this.pos2Y = config.getDouble("worldborder.pos2.y");
|
||||
this.pos2Z = config.getDouble("worldborder.pos2.z");
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onMove(PlayerMoveEvent event) {
|
||||
if (!enabled || event.getTo() == null) return;
|
||||
|
||||
// Performance: Nur prüfen wenn sich Block-Koordinaten ändern
|
||||
if (event.getFrom().getBlockX() == event.getTo().getBlockX() &&
|
||||
event.getFrom().getBlockZ() == event.getTo().getBlockZ() &&
|
||||
event.getFrom().getBlockY() == event.getTo().getBlockY()) return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
// FIX: nexuslobby.border.bypass statt nur nexuslobby.admin prüfen
|
||||
if (player.hasPermission("nexuslobby.border.bypass") ||
|
||||
player.hasPermission("nexuslobby.admin") ||
|
||||
player.getGameMode().name().equals("SPECTATOR")) return;
|
||||
|
||||
Location to = event.getTo();
|
||||
boolean outside = false;
|
||||
|
||||
// --- Prüfung: Kreis-Border ---
|
||||
if (type.equals("CIRCLE") && hasCenter) {
|
||||
World cWorld = Bukkit.getWorld(centerWorld);
|
||||
if (cWorld != null && to.getWorld().equals(cWorld)) {
|
||||
double distSq = Math.pow(to.getX() - centerX, 2) + Math.pow(to.getZ() - centerZ, 2);
|
||||
if (distSq > radius * radius) outside = true;
|
||||
}
|
||||
}
|
||||
// --- Prüfung: Rechteck-Border (Square) ---
|
||||
else if (type.equals("SQUARE") && hasPos1 && hasPos2) {
|
||||
World bWorld = Bukkit.getWorld(pos1World);
|
||||
if (bWorld != null && to.getWorld().equals(bWorld)) {
|
||||
double minX = Math.min(pos1X, pos2X);
|
||||
double maxX = Math.max(pos1X, pos2X);
|
||||
double minZ = Math.min(pos1Z, pos2Z);
|
||||
double maxZ = Math.max(pos1Z, pos2Z);
|
||||
if (to.getX() < minX || to.getX() > maxX ||
|
||||
to.getZ() < minZ || to.getZ() > maxZ) {
|
||||
outside = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (outside) {
|
||||
Location spawnLocation = getMainSpawnLocation();
|
||||
if (spawnLocation != null) {
|
||||
player.teleport(spawnLocation);
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_ENDERMAN_TELEPORT, 1.0f, 0.5f);
|
||||
player.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§cDu hast den Lobby-Bereich verlassen!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Holt den Spawnpunkt aus der Config (Pfad: spawn.world, spawn.x, etc.)
|
||||
*/
|
||||
private Location getMainSpawnLocation() {
|
||||
FileConfiguration config = NexusLobby.getInstance().getConfig();
|
||||
String worldName = config.getString("spawn.world");
|
||||
if (worldName != null) {
|
||||
World w = Bukkit.getWorld(worldName);
|
||||
if (w != null) {
|
||||
return new Location(w,
|
||||
config.getDouble("spawn.x"),
|
||||
config.getDouble("spawn.y"),
|
||||
config.getDouble("spawn.z"),
|
||||
(float) config.getDouble("spawn.yaw"),
|
||||
(float) config.getDouble("spawn.pitch"));
|
||||
}
|
||||
}
|
||||
return Bukkit.getWorlds().isEmpty() ? null : Bukkit.getWorlds().get(0).getSpawnLocation();
|
||||
}
|
||||
}
|
||||
@@ -1,77 +1,70 @@
|
||||
package de.nexuslobby.modules.gadgets;
|
||||
|
||||
import java.util.UUID;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class Balloon {
|
||||
private final UUID playerUUID;
|
||||
private final LivingEntity balloonEntity;
|
||||
private final ArmorStand headStand;
|
||||
|
||||
private final UUID playerUUID;
|
||||
private final LivingEntity balloonEntity;
|
||||
private final ArmorStand headStand;
|
||||
public Balloon(Player player, Material balloonMaterial) {
|
||||
this.playerUUID = player.getUniqueId();
|
||||
Location loc = player.getLocation().add((double)0.0F, (double)2.0F, (double)0.0F);
|
||||
this.balloonEntity = (LivingEntity)loc.getWorld().spawnEntity(loc, EntityType.PIG);
|
||||
this.balloonEntity.setInvisible(true);
|
||||
this.balloonEntity.setSilent(true);
|
||||
this.balloonEntity.setInvulnerable(true);
|
||||
this.balloonEntity.setGravity(false);
|
||||
this.balloonEntity.setLeashHolder(player);
|
||||
this.balloonEntity.addScoreboardTag("nexus_balloon");
|
||||
this.headStand = (ArmorStand)loc.getWorld().spawnEntity(loc, EntityType.ARMOR_STAND);
|
||||
this.headStand.setVisible(false);
|
||||
this.headStand.setGravity(false);
|
||||
this.headStand.setMarker(true);
|
||||
this.headStand.setHelmet(new ItemStack(balloonMaterial));
|
||||
}
|
||||
|
||||
public Balloon(Player player, Material balloonMaterial) {
|
||||
this.playerUUID = player.getUniqueId();
|
||||
Location loc = player.getLocation().add(0, 2, 0);
|
||||
public void update() {
|
||||
Player player = Bukkit.getPlayer(this.playerUUID);
|
||||
if (player != null && player.isOnline() && this.balloonEntity != null && this.balloonEntity.isValid()) {
|
||||
if (!this.balloonEntity.isLeashed()) {
|
||||
this.remove();
|
||||
} else {
|
||||
Location targetLoc = player.getLocation().clone().add((double)0.0F, (double)2.5F, (double)0.0F);
|
||||
Vector direction = targetLoc.toVector().subtract(this.balloonEntity.getLocation().toVector());
|
||||
double distance = direction.length();
|
||||
if (distance > (double)5.0F) {
|
||||
this.balloonEntity.teleport(targetLoc);
|
||||
} else if (distance > 0.1) {
|
||||
this.balloonEntity.setVelocity(direction.multiply(0.4));
|
||||
}
|
||||
|
||||
// Das unsichtbare Träger-Entity
|
||||
this.balloonEntity = (LivingEntity) loc.getWorld().spawnEntity(loc, EntityType.PIG);
|
||||
this.balloonEntity.setInvisible(true);
|
||||
this.balloonEntity.setSilent(true);
|
||||
this.balloonEntity.setInvulnerable(true);
|
||||
this.balloonEntity.setGravity(false);
|
||||
this.balloonEntity.setLeashHolder(player);
|
||||
this.headStand.teleport(this.balloonEntity.getLocation().clone().subtract((double)0.0F, (double)1.5F, (double)0.0F));
|
||||
}
|
||||
} else {
|
||||
this.remove();
|
||||
}
|
||||
}
|
||||
|
||||
// Der ArmorStand, der den farbigen Block trägt
|
||||
this.headStand = (ArmorStand) loc.getWorld().spawnEntity(loc, EntityType.ARMOR_STAND);
|
||||
this.headStand.setVisible(false);
|
||||
this.headStand.setGravity(false);
|
||||
this.headStand.setMarker(true);
|
||||
|
||||
// Hier wird das übergebene Material gesetzt (z.B. RED_WOOL, BLUE_WOOL etc.)
|
||||
this.headStand.setHelmet(new ItemStack(balloonMaterial));
|
||||
}
|
||||
public void remove() {
|
||||
if (this.balloonEntity != null) {
|
||||
this.balloonEntity.setLeashHolder((Entity)null);
|
||||
this.balloonEntity.remove();
|
||||
}
|
||||
|
||||
public void update() {
|
||||
Player player = org.bukkit.Bukkit.getPlayer(playerUUID);
|
||||
if (this.headStand != null) {
|
||||
this.headStand.remove();
|
||||
}
|
||||
|
||||
if (player == null || !player.isOnline() || balloonEntity == null || !balloonEntity.isValid()) {
|
||||
remove();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!balloonEntity.isLeashed()) {
|
||||
remove();
|
||||
return;
|
||||
}
|
||||
|
||||
Location targetLoc = player.getLocation().clone().add(0, 2.5, 0);
|
||||
Vector direction = targetLoc.toVector().subtract(balloonEntity.getLocation().toVector());
|
||||
double distance = direction.length();
|
||||
|
||||
if (distance > 5) {
|
||||
balloonEntity.teleport(targetLoc);
|
||||
} else if (distance > 0.1) {
|
||||
balloonEntity.setVelocity(direction.multiply(0.4));
|
||||
}
|
||||
|
||||
headStand.teleport(balloonEntity.getLocation().clone().subtract(0, 1.5, 0));
|
||||
}
|
||||
|
||||
public void remove() {
|
||||
if (balloonEntity != null) {
|
||||
balloonEntity.setLeashHolder(null);
|
||||
balloonEntity.remove();
|
||||
}
|
||||
if (headStand != null) {
|
||||
headStand.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
package de.nexuslobby.modules.gadgets;
|
||||
|
||||
import de.nexuslobby.NexusLobby;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Particle;
|
||||
@@ -10,45 +15,40 @@ import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class ChickenRain {
|
||||
private static final Set<UUID> activeRains = Collections.synchronizedSet(new HashSet());
|
||||
|
||||
public static void start(Player player) {
|
||||
new BukkitRunnable() {
|
||||
public static void start(final Player player) {
|
||||
if (!activeRains.contains(player.getUniqueId())) {
|
||||
activeRains.add(player.getUniqueId());
|
||||
(new BukkitRunnable() {
|
||||
int ticks = 0;
|
||||
final Random random = new Random();
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (!player.isOnline() || ticks > 100) { // 100 Ticks = 5 Sekunden
|
||||
this.cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
// Alle 2 Ticks ein Huhn spawnen
|
||||
if (ticks % 2 == 0) {
|
||||
Location spawnLoc = player.getLocation().add(
|
||||
(random.nextDouble() - 0.5) * 4,
|
||||
4.0,
|
||||
(random.nextDouble() - 0.5) * 4
|
||||
);
|
||||
|
||||
Chicken chicken = (Chicken) spawnLoc.getWorld().spawnEntity(spawnLoc, EntityType.CHICKEN);
|
||||
chicken.setBaby();
|
||||
chicken.setInvulnerable(true);
|
||||
|
||||
// Nach 1.5 Sekunden "ploppt" das Huhn
|
||||
Bukkit.getScheduler().runTaskLater(NexusLobby.getInstance(), () -> {
|
||||
if (player.isOnline() && this.ticks <= 100) {
|
||||
if (this.ticks % 2 == 0) {
|
||||
Location spawnLoc = player.getLocation().add((this.random.nextDouble() - (double)0.5F) * (double)4.0F, (double)4.0F, (this.random.nextDouble() - (double)0.5F) * (double)4.0F);
|
||||
Chicken chicken = (Chicken)spawnLoc.getWorld().spawnEntity(spawnLoc, EntityType.CHICKEN);
|
||||
chicken.setBaby();
|
||||
chicken.setInvulnerable(true);
|
||||
Bukkit.getScheduler().runTaskLater(NexusLobby.getInstance(), () -> {
|
||||
if (chicken.isValid()) {
|
||||
chicken.getWorld().spawnParticle(Particle.CLOUD, chicken.getLocation(), 5, 0.2, 0.2, 0.2, 0.1);
|
||||
chicken.getWorld().playSound(chicken.getLocation(), Sound.ENTITY_CHICKEN_EGG, 1.0f, 1.5f);
|
||||
chicken.remove();
|
||||
chicken.getWorld().spawnParticle(Particle.CLOUD, chicken.getLocation(), 5, 0.2, 0.2, 0.2, 0.1);
|
||||
chicken.getWorld().playSound(chicken.getLocation(), Sound.ENTITY_CHICKEN_EGG, 1.0F, 1.5F);
|
||||
chicken.remove();
|
||||
}
|
||||
}, 30L);
|
||||
}
|
||||
ticks++;
|
||||
|
||||
}, 30L);
|
||||
}
|
||||
|
||||
++this.ticks;
|
||||
} else {
|
||||
ChickenRain.activeRains.remove(player.getUniqueId());
|
||||
this.cancel();
|
||||
}
|
||||
}
|
||||
}.runTaskTimer(NexusLobby.getInstance(), 0L, 1L);
|
||||
}
|
||||
}
|
||||
}).runTaskTimer(NexusLobby.getInstance(), 0L, 1L);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,97 +1,100 @@
|
||||
package de.nexuslobby.modules.gadgets;
|
||||
|
||||
import de.nexuslobby.NexusLobby;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public class FreezeRay {
|
||||
// Auf public gesetzt, damit das GadgetModule im PlayerMoveEvent darauf prüfen kann
|
||||
public static final Set<UUID> frozenPlayers = new HashSet<>();
|
||||
private static final Set<UUID> frozenPlayers = new HashSet();
|
||||
|
||||
public static void shoot(Player shooter) {
|
||||
Location start = shooter.getEyeLocation();
|
||||
Vector direction = start.getDirection();
|
||||
public static boolean isFrozen(UUID uuid) {
|
||||
return frozenPlayers.contains(uuid);
|
||||
}
|
||||
|
||||
// Sound beim Schießen
|
||||
shooter.getWorld().playSound(start, Sound.ENTITY_SNOW_GOLEM_SHOOT, 1.0f, 1.5f);
|
||||
public static void unfreeze(UUID uuid) {
|
||||
frozenPlayers.remove(uuid);
|
||||
}
|
||||
|
||||
// Wir prüfen in 0.3er Schritten bis zu 15 Blöcke weit
|
||||
for (double d = 0; d < 15; d += 0.3) {
|
||||
Location point = start.clone().add(direction.clone().multiply(d));
|
||||
|
||||
// Partikel-Strahl sichtbar machen
|
||||
point.getWorld().spawnParticle(Particle.SNOWFLAKE, point, 1, 0, 0, 0, 0);
|
||||
public static void shoot(Player shooter) {
|
||||
Location start = shooter.getEyeLocation();
|
||||
Vector direction = start.getDirection();
|
||||
shooter.getWorld().playSound(start, Sound.ENTITY_SNOW_GOLEM_SHOOT, 1.0F, 1.5F);
|
||||
|
||||
// Prüfung auf Spieler im Umkreis von 0.8 Blöcken (etwas großzügiger)
|
||||
for (Entity entity : point.getWorld().getNearbyEntities(point, 0.8, 0.8, 0.8)) {
|
||||
if (entity instanceof Player target && target != shooter) {
|
||||
applyFreeze(target);
|
||||
return; // Stoppt den Strahl beim ersten Treffer
|
||||
}
|
||||
for(double d = (double)0.0F; d < (double)15.0F; d += 0.3) {
|
||||
Location point = start.clone().add(direction.clone().multiply(d));
|
||||
point.getWorld().spawnParticle(Particle.SNOWFLAKE, point, 1, (double)0.0F, (double)0.0F, (double)0.0F, (double)0.0F);
|
||||
|
||||
for(Entity entity : point.getWorld().getNearbyEntities(point, 0.8, 0.8, 0.8)) {
|
||||
if (entity instanceof Player target) {
|
||||
if (target != shooter) {
|
||||
if (GadgetShield.isProtected(target)) {
|
||||
String reason = GadgetShield.isAdminShielded(target) ? "Dieser Spieler hat Gadget-Schutz aktiviert." : "Dieser Spieler ist gerade im Parkour.";
|
||||
shooter.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§7" + reason);
|
||||
return;
|
||||
}
|
||||
|
||||
applyFreeze(target);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Stoppe den Strahl, falls er eine Wand trifft
|
||||
if (point.getBlock().getType().isSolid()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void applyFreeze(Player target) {
|
||||
if (frozenPlayers.contains(target.getUniqueId())) return;
|
||||
if (point.getBlock().getType().isSolid()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
frozenPlayers.add(target.getUniqueId());
|
||||
|
||||
// Fixiere die Position für den Stasis-Effekt
|
||||
final Location freezeLocation = target.getLocation();
|
||||
|
||||
// Feedback für getroffenen Spieler
|
||||
target.sendMessage("§8[§6Nexus§8] §bDu wurdest eingefroren!");
|
||||
target.getWorld().playSound(target.getLocation(), Sound.BLOCK_GLASS_BREAK, 1.0f, 0.5f);
|
||||
}
|
||||
|
||||
new org.bukkit.scheduler.BukkitRunnable() {
|
||||
private static void applyFreeze(final Player target) {
|
||||
if (!frozenPlayers.contains(target.getUniqueId())) {
|
||||
frozenPlayers.add(target.getUniqueId());
|
||||
final Location freezeLocation = target.getLocation();
|
||||
target.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§bDu wurdest eingefroren!");
|
||||
target.getWorld().playSound(target.getLocation(), Sound.BLOCK_GLASS_BREAK, 1.0F, 0.5F);
|
||||
(new BukkitRunnable() {
|
||||
int ticks = 0;
|
||||
@Override
|
||||
|
||||
public void run() {
|
||||
// Sicherheitscheck: Ist der Spieler noch online?
|
||||
if (!target.isOnline() || ticks >= 60) {
|
||||
frozenPlayers.remove(target.getUniqueId());
|
||||
this.cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
// Stasis-Effekt: Bewegung auf 0 setzen und Position fixieren
|
||||
target.setVelocity(new Vector(0, 0, 0));
|
||||
|
||||
// Alle 2 Ticks zurückteleportieren, falls er versucht zu laufen
|
||||
// (Behält die Blickrichtung des Spielers bei)
|
||||
Location current = target.getLocation();
|
||||
if (current.getX() != freezeLocation.getX() || current.getZ() != freezeLocation.getZ()) {
|
||||
freezeLocation.setYaw(current.getYaw());
|
||||
freezeLocation.setPitch(current.getPitch());
|
||||
target.teleport(freezeLocation);
|
||||
}
|
||||
|
||||
// Optischer Käfig (Ring-Effekt)
|
||||
Location loc = target.getLocation();
|
||||
for (int i = 0; i < 8; i++) {
|
||||
double angle = i * Math.PI / 4;
|
||||
double x = Math.cos(angle) * 0.7;
|
||||
double z = Math.sin(angle) * 0.7;
|
||||
loc.getWorld().spawnParticle(Particle.SNOWFLAKE, loc.clone().add(x, 1, z), 1, 0, 0, 0, 0);
|
||||
loc.getWorld().spawnParticle(Particle.SNOWFLAKE, loc.clone().add(x, 0.2, z), 1, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
ticks += 2;
|
||||
if (target.isOnline() && this.ticks < 60) {
|
||||
if (GadgetShield.isProtected(target)) {
|
||||
FreezeRay.frozenPlayers.remove(target.getUniqueId());
|
||||
this.cancel();
|
||||
} else {
|
||||
target.setVelocity(new Vector(0, 0, 0));
|
||||
Location current = target.getLocation();
|
||||
if (current.getX() != freezeLocation.getX() || current.getZ() != freezeLocation.getZ()) {
|
||||
freezeLocation.setYaw(current.getYaw());
|
||||
freezeLocation.setPitch(current.getPitch());
|
||||
target.teleport(freezeLocation);
|
||||
}
|
||||
|
||||
Location loc = target.getLocation();
|
||||
|
||||
for(int i = 0; i < 8; ++i) {
|
||||
double angle = (double)i * Math.PI / (double)4.0F;
|
||||
double x = Math.cos(angle) * 0.7;
|
||||
double z = Math.sin(angle) * 0.7;
|
||||
loc.getWorld().spawnParticle(Particle.SNOWFLAKE, loc.clone().add(x, (double)1.0F, z), 1, (double)0.0F, (double)0.0F, (double)0.0F, (double)0.0F);
|
||||
loc.getWorld().spawnParticle(Particle.SNOWFLAKE, loc.clone().add(x, 0.2, z), 1, (double)0.0F, (double)0.0F, (double)0.0F, (double)0.0F);
|
||||
}
|
||||
|
||||
this.ticks += 2;
|
||||
}
|
||||
} else {
|
||||
FreezeRay.frozenPlayers.remove(target.getUniqueId());
|
||||
this.cancel();
|
||||
}
|
||||
}
|
||||
}.runTaskTimer(NexusLobby.getInstance(), 0L, 2L);
|
||||
}
|
||||
}
|
||||
}).runTaskTimer(NexusLobby.getInstance(), 0L, 2L);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,45 @@
|
||||
package de.nexuslobby.modules.gadgets;
|
||||
|
||||
import de.nexuslobby.NexusLobby;
|
||||
import de.nexuslobby.modules.parkour.ParkourManager;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class GadgetShield {
|
||||
private static final Set<UUID> shielded = new HashSet();
|
||||
|
||||
public static boolean toggle(Player player) {
|
||||
UUID uuid = player.getUniqueId();
|
||||
if (shielded.contains(uuid)) {
|
||||
shielded.remove(uuid);
|
||||
player.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§cGadget-Schutz §7deaktiviert.");
|
||||
player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_BASS, 1.0F, 1.0F);
|
||||
return false;
|
||||
} else {
|
||||
shielded.add(uuid);
|
||||
player.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§aGadget-Schutz §7aktiviert. §8Du bist nun immun gegen Gadgets.");
|
||||
player.playSound(player.getLocation(), Sound.BLOCK_AMETHYST_BLOCK_CHIME, 1.0F, 1.5F);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isAdminShielded(Player player) {
|
||||
return shielded.contains(player.getUniqueId());
|
||||
}
|
||||
|
||||
public static boolean isProtected(Player player) {
|
||||
if (shielded.contains(player.getUniqueId())) {
|
||||
return true;
|
||||
} else {
|
||||
ParkourManager pm = NexusLobby.getInstance().getParkourManager();
|
||||
return pm != null && pm.isIngame(player);
|
||||
}
|
||||
}
|
||||
|
||||
public static void clear() {
|
||||
shielded.clear();
|
||||
}
|
||||
}
|
||||
@@ -6,32 +6,20 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class GrapplingHook {
|
||||
public static void pullPlayer(Player player, Location target) {
|
||||
Location playerLoc = player.getLocation();
|
||||
double distance = target.distance(playerLoc);
|
||||
if (!(distance < (double)2.0F) && !(distance > (double)50.0F)) {
|
||||
Vector v = target.toVector().subtract(playerLoc.toVector());
|
||||
v.multiply(0.3);
|
||||
v.setY(v.getY() * 0.6 + (double)0.5F);
|
||||
if (v.length() > (double)2.5F) {
|
||||
v.normalize().multiply((double)2.5F);
|
||||
}
|
||||
|
||||
public static void pullPlayer(Player player, Location target) {
|
||||
Location playerLoc = player.getLocation();
|
||||
|
||||
// Vektor vom Spieler zum Ziel berechnen
|
||||
double distance = target.distance(playerLoc);
|
||||
|
||||
// Wenn das Ziel zu nah oder zu weit weg ist, nichts tun
|
||||
if (distance < 2 || distance > 50) return;
|
||||
|
||||
// Berechnung des Wurfs (Vektor)
|
||||
Vector v = target.toVector().subtract(playerLoc.toVector());
|
||||
|
||||
// Den Vektor normalisieren und skalieren (Stärke des Zugs)
|
||||
v.multiply(0.3); // Basis-Geschwindigkeit
|
||||
v.setY(v.getY() * 0.6 + 0.5); // Etwas mehr Höhe für den Bogen-Effekt
|
||||
|
||||
// Geschwindigkeit begrenzen, damit man nicht aus der Map schießt
|
||||
if (v.length() > 2.5) {
|
||||
v.normalize().multiply(2.5);
|
||||
}
|
||||
|
||||
player.setVelocity(v);
|
||||
|
||||
// Sound-Effekt für das "Ziehen"
|
||||
player.playSound(playerLoc, Sound.ENTITY_WIND_CHARGE_WIND_BURST, 1.0f, 1.2f);
|
||||
player.playSound(playerLoc, Sound.ITEM_TRIDENT_RIPTIDE_1, 0.5f, 1.5f);
|
||||
}
|
||||
}
|
||||
player.setVelocity(v);
|
||||
player.playSound(playerLoc, Sound.ENTITY_WIND_CHARGE_WIND_BURST, 1.0F, 1.2F);
|
||||
player.playSound(playerLoc, Sound.ITEM_TRIDENT_RIPTIDE_1, 0.5F, 1.5F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,21 +6,19 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
public class HatManager {
|
||||
public static void setHat(Player player, Material material, String name) {
|
||||
ItemStack hat = new ItemStack(material);
|
||||
ItemMeta meta = hat.getItemMeta();
|
||||
if (meta != null) {
|
||||
meta.setDisplayName("§6Hut: " + name);
|
||||
hat.setItemMeta(meta);
|
||||
}
|
||||
|
||||
public static void setHat(Player player, Material material, String name) {
|
||||
ItemStack hat = new ItemStack(material);
|
||||
ItemMeta meta = hat.getItemMeta();
|
||||
if (meta != null) {
|
||||
meta.setDisplayName("§6Hut: " + name);
|
||||
hat.setItemMeta(meta);
|
||||
}
|
||||
|
||||
// Den Gegenstand auf den Kopf setzen
|
||||
player.getInventory().setHelmet(hat);
|
||||
player.sendMessage("§8[§6Nexus§8] §aDu trägst nun: " + name);
|
||||
}
|
||||
player.getInventory().setHelmet(hat);
|
||||
player.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§aDu trägst nun: " + name);
|
||||
}
|
||||
|
||||
public static void removeHat(Player player) {
|
||||
player.getInventory().setHelmet(null);
|
||||
}
|
||||
}
|
||||
public static void removeHat(Player player) {
|
||||
player.getInventory().setHelmet((ItemStack)null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package de.nexuslobby.modules.gadgets;
|
||||
|
||||
import de.nexuslobby.NexusLobby;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.Sound;
|
||||
@@ -9,39 +10,45 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class MeteorStrike {
|
||||
public static void launch(Player shooter) {
|
||||
Location target = null;
|
||||
Location start = shooter.getEyeLocation();
|
||||
Vector direction = start.getDirection();
|
||||
|
||||
public static void launch(Player shooter) {
|
||||
Location target = null;
|
||||
Location start = shooter.getEyeLocation();
|
||||
Vector direction = start.getDirection();
|
||||
for(double d = (double)0.0F; d < (double)30.0F; d += (double)0.5F) {
|
||||
Location point = start.clone().add(direction.clone().multiply(d));
|
||||
if (point.getBlock().getType().isSolid()) {
|
||||
target = point;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (double d = 0; d < 30; d += 0.5) {
|
||||
Location point = start.clone().add(direction.clone().multiply(d));
|
||||
if (point.getBlock().getType().isSolid()) {
|
||||
target = point;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (target == null) return;
|
||||
final Location finalTarget = target.clone().add(0, 0.5, 0);
|
||||
|
||||
finalTarget.getWorld().spawnParticle(Particle.FLAME, finalTarget, 20, 0.5, 0.1, 0.5, 0.05);
|
||||
shooter.sendMessage("§8[§6Nexus§8] §cMeteorit im Anflug...");
|
||||
|
||||
org.bukkit.Bukkit.getScheduler().runTaskLater(NexusLobby.getInstance(), () -> {
|
||||
// EXPLOSION_EMITTER ist der moderne Name für HUGE_EXPLOSION
|
||||
if (target != null) {
|
||||
Location finalTarget = target.clone().add((double)0.0F, (double)0.5F, (double)0.0F);
|
||||
finalTarget.getWorld().spawnParticle(Particle.FLAME, finalTarget, 20, (double)0.5F, 0.1, (double)0.5F, 0.05);
|
||||
shooter.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§cMeteorit im Anflug...");
|
||||
Bukkit.getScheduler().runTaskLater(NexusLobby.getInstance(), () -> {
|
||||
finalTarget.getWorld().spawnParticle(Particle.EXPLOSION_EMITTER, finalTarget, 1);
|
||||
finalTarget.getWorld().spawnParticle(Particle.LAVA, finalTarget, 30, 0.5, 0.5, 0.5, 0.1);
|
||||
finalTarget.getWorld().playSound(finalTarget, Sound.ENTITY_GENERIC_EXPLODE, 1.0f, 0.8f);
|
||||
finalTarget.getWorld().spawnParticle(Particle.LAVA, finalTarget, 30, (double)0.5F, (double)0.5F, (double)0.5F, 0.1);
|
||||
finalTarget.getWorld().playSound(finalTarget, Sound.ENTITY_GENERIC_EXPLODE, 1.0F, 0.8F);
|
||||
|
||||
for (Entity entity : finalTarget.getWorld().getNearbyEntities(finalTarget, 4, 4, 4)) {
|
||||
if (entity instanceof Player p) {
|
||||
Vector v = p.getLocation().toVector().subtract(finalTarget.toVector()).normalize().multiply(1.5).setY(0.5);
|
||||
p.setVelocity(v);
|
||||
p.sendMessage("§cBUMM!");
|
||||
}
|
||||
for(Entity entity : finalTarget.getWorld().getNearbyEntities(finalTarget, (double)4.0F, (double)4.0F, (double)4.0F)) {
|
||||
if (entity instanceof Player p) {
|
||||
if (GadgetShield.isProtected(p)) {
|
||||
if (GadgetShield.isAdminShielded(p)) {
|
||||
p.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§7Dein Gadget-Schutzschild hat den Meteoriten abgelenkt!");
|
||||
} else {
|
||||
p.sendMessage("§8[§6Parkour§8] §7Dein Parkour-Schutzschild hat den Meteoriten abgelenkt!");
|
||||
}
|
||||
} else {
|
||||
Vector v = p.getLocation().toVector().subtract(finalTarget.toVector()).normalize().multiply((double)1.5F).setY((double)0.5F);
|
||||
p.setVelocity(v);
|
||||
p.sendMessage("§cBUMM!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 30L);
|
||||
}
|
||||
}
|
||||
|
||||
}, 30L);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package de.nexuslobby.modules.gadgets;
|
||||
|
||||
import de.nexuslobby.NexusLobby;
|
||||
import java.util.Random;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@@ -10,80 +11,65 @@ import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class PaintballGun {
|
||||
private static final Random random = new Random();
|
||||
|
||||
// Wir nutzen jetzt Wolle für kräftigere Farben
|
||||
private static final Material[] COLORS = {
|
||||
Material.RED_WOOL, Material.BLUE_WOOL, Material.LIME_WOOL,
|
||||
Material.ORANGE_WOOL, Material.MAGENTA_WOOL, Material.LIGHT_BLUE_WOOL,
|
||||
Material.YELLOW_WOOL, Material.PURPLE_WOOL, Material.PINK_WOOL
|
||||
};
|
||||
private static final Random random = new Random();
|
||||
private static final Material[] COLORS;
|
||||
|
||||
public static void shoot(Player shooter) {
|
||||
Location start = shooter.getEyeLocation();
|
||||
Vector direction = start.getDirection();
|
||||
Material randomColor = COLORS[random.nextInt(COLORS.length)];
|
||||
public static void shoot(Player shooter) {
|
||||
Location start = shooter.getEyeLocation();
|
||||
Vector direction = start.getDirection();
|
||||
Material randomColor = COLORS[random.nextInt(COLORS.length)];
|
||||
shooter.getWorld().playSound(start, Sound.ENTITY_CHICKEN_EGG, 1.0F, 2.0F);
|
||||
|
||||
shooter.getWorld().playSound(start, Sound.ENTITY_CHICKEN_EGG, 1.0f, 2.0f);
|
||||
for(double d = (double)0.0F; d < (double)25.0F; d += (double)0.5F) {
|
||||
Location point = start.clone().add(direction.clone().multiply(d));
|
||||
point.getWorld().spawnParticle(Particle.ITEM_SNOWBALL, point, 1, (double)0.0F, (double)0.0F, (double)0.0F, (double)0.0F);
|
||||
Block block = point.getBlock();
|
||||
if (block.getType().isSolid()) {
|
||||
impact(block, randomColor);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (double d = 0; d < 25; d += 0.5) {
|
||||
Location point = start.clone().add(direction.clone().multiply(d));
|
||||
|
||||
// Flug-Partikel (kleiner Rauch oder Schneeball)
|
||||
point.getWorld().spawnParticle(Particle.ITEM_SNOWBALL, point, 1, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
Block block = point.getBlock();
|
||||
if (block.getType().isSolid()) {
|
||||
impact(block, randomColor);
|
||||
break;
|
||||
private static void impact(Block centerBlock, Material color) {
|
||||
Location centerLoc = centerBlock.getLocation();
|
||||
centerLoc.getWorld().playSound(centerLoc, Sound.ENTITY_SLIME_SQUISH, 1.0F, 1.2F);
|
||||
int radius = 2;
|
||||
|
||||
for(int x = -radius; x <= radius; ++x) {
|
||||
for(int y = -radius; y <= radius; ++y) {
|
||||
for(int z = -radius; z <= radius; ++z) {
|
||||
if ((double)(x * x + y * y + z * z) <= (double)(radius * radius) + (double)0.5F) {
|
||||
Block target = centerLoc.clone().add((double)x, (double)y, (double)z).getBlock();
|
||||
if (target.getType().isSolid()) {
|
||||
applyColor(target, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void impact(Block centerBlock, Material color) {
|
||||
Location centerLoc = centerBlock.getLocation();
|
||||
centerLoc.getWorld().playSound(centerLoc, Sound.ENTITY_SLIME_SQUISH, 1.0f, 1.2f);
|
||||
|
||||
int radius = 2; // Radius der Farbkugel
|
||||
}
|
||||
|
||||
// Wir gehen alle Blöcke im Würfel um den Einschlag durch
|
||||
for (int x = -radius; x <= radius; x++) {
|
||||
for (int y = -radius; y <= radius; y++) {
|
||||
for (int z = -radius; z <= radius; z++) {
|
||||
|
||||
// Berechne Distanz für eine Kugelform (statt Würfel)
|
||||
if (x * x + y * y + z * z <= radius * radius + 0.5) {
|
||||
Block target = centerLoc.clone().add(x, y, z).getBlock();
|
||||
|
||||
// Nur solide Blöcke färben (keine Luft/Gras)
|
||||
if (target.getType().isSolid()) {
|
||||
applyColor(target, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private static void applyColor(Block block, Material color) {
|
||||
Location loc = block.getLocation();
|
||||
loc.getWorld().spawnParticle(Particle.BLOCK, loc.clone().add((double)0.5F, (double)0.5F, (double)0.5F), 3, 0.1, 0.1, 0.1, color.createBlockData());
|
||||
|
||||
private static void applyColor(Block block, Material color) {
|
||||
Location loc = block.getLocation();
|
||||
|
||||
// Effekt-Partikel am Block
|
||||
loc.getWorld().spawnParticle(Particle.BLOCK, loc.clone().add(0.5, 0.5, 0.5), 3, 0.1, 0.1, 0.1, color.createBlockData());
|
||||
for(Player online : Bukkit.getOnlinePlayers()) {
|
||||
online.sendBlockChange(loc, color.createBlockData());
|
||||
}
|
||||
|
||||
// Block-Änderung an alle senden
|
||||
for (Player online : Bukkit.getOnlinePlayers()) {
|
||||
online.sendBlockChange(loc, color.createBlockData());
|
||||
}
|
||||
Bukkit.getScheduler().runTaskLater(NexusLobby.getInstance(), () -> {
|
||||
for(Player online : Bukkit.getOnlinePlayers()) {
|
||||
online.sendBlockChange(loc, block.getBlockData());
|
||||
}
|
||||
|
||||
// Nach 10 Sekunden zurücksetzen
|
||||
Bukkit.getScheduler().runTaskLater(NexusLobby.getInstance(), () -> {
|
||||
for (Player online : Bukkit.getOnlinePlayers()) {
|
||||
online.sendBlockChange(loc, block.getBlockData());
|
||||
}
|
||||
}, 400L);
|
||||
}
|
||||
}
|
||||
}, 400L);
|
||||
}
|
||||
|
||||
static {
|
||||
COLORS = new Material[]{Material.RED_WOOL, Material.BLUE_WOOL, Material.LIME_WOOL, Material.ORANGE_WOOL, Material.MAGENTA_WOOL, Material.LIGHT_BLUE_WOOL, Material.YELLOW_WOOL, Material.PURPLE_WOOL, Material.PINK_WOOL};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,27 +5,29 @@ import org.bukkit.Particle;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ParticleEffect {
|
||||
private final String type;
|
||||
private double angle = 0;
|
||||
private final String type;
|
||||
private double angle = (double)0.0F;
|
||||
|
||||
public ParticleEffect(String type) { this.type = type; }
|
||||
public ParticleEffect(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public void update(Player player) {
|
||||
Location loc = player.getLocation();
|
||||
switch (type.toLowerCase()) {
|
||||
case "hearts":
|
||||
player.getWorld().spawnParticle(Particle.HEART, loc.clone().add(0, 2.2, 0), 1, 0.3, 0.3, 0.3, 0);
|
||||
break;
|
||||
case "flames":
|
||||
double x = 0.6 * Math.cos(angle);
|
||||
double z = 0.6 * Math.sin(angle);
|
||||
player.getWorld().spawnParticle(Particle.FLAME, loc.clone().add(x, 0.1, z), 1, 0, 0, 0, 0);
|
||||
angle += 0.2;
|
||||
break;
|
||||
case "cloud":
|
||||
player.getWorld().spawnParticle(Particle.CLOUD, loc.clone().add(0, 2.5, 0), 2, 0.2, 0.05, 0.2, 0);
|
||||
player.getWorld().spawnParticle(Particle.FALLING_WATER, loc.clone().add(0, 2.4, 0), 1, 0.1, 0, 0.1, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
public void update(Player player) {
|
||||
Location loc = player.getLocation();
|
||||
switch (this.type.toLowerCase()) {
|
||||
case "hearts":
|
||||
player.getWorld().spawnParticle(Particle.HEART, loc.clone().add((double)0.0F, 2.2, (double)0.0F), 1, 0.3, 0.3, 0.3, (double)0.0F);
|
||||
break;
|
||||
case "flames":
|
||||
double x = 0.6 * Math.cos(this.angle);
|
||||
double z = 0.6 * Math.sin(this.angle);
|
||||
player.getWorld().spawnParticle(Particle.FLAME, loc.clone().add(x, 0.1, z), 1, (double)0.0F, (double)0.0F, (double)0.0F, (double)0.0F);
|
||||
this.angle += 0.2;
|
||||
break;
|
||||
case "cloud":
|
||||
player.getWorld().spawnParticle(Particle.CLOUD, loc.clone().add((double)0.0F, (double)2.5F, (double)0.0F), 2, 0.2, 0.05, 0.2, (double)0.0F);
|
||||
player.getWorld().spawnParticle(Particle.FALLING_WATER, loc.clone().add((double)0.0F, 2.4, (double)0.0F), 1, 0.1, (double)0.0F, 0.1, (double)0.0F);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,138 +1,234 @@
|
||||
package de.nexuslobby.modules.gadgets;
|
||||
|
||||
import de.nexuslobby.NexusLobby;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.Registry;
|
||||
import org.bukkit.entity.Ageable;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Fox;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Tameable;
|
||||
import org.bukkit.entity.Wolf;
|
||||
import org.bukkit.entity.Fox.Type;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityTargetEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import org.bukkit.scoreboard.Scoreboard;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
|
||||
public class PetManager implements Listener {
|
||||
private static final Map<UUID, Entity> activePets = new HashMap();
|
||||
private static PetManager instance;
|
||||
|
||||
private static final Map<UUID, Entity> activePets = new HashMap<>();
|
||||
public PetManager() {
|
||||
Bukkit.getPluginManager().registerEvents(this, NexusLobby.getInstance());
|
||||
}
|
||||
|
||||
public PetManager() {
|
||||
Bukkit.getPluginManager().registerEvents(this, NexusLobby.getInstance());
|
||||
}
|
||||
public static void register() {
|
||||
if (instance == null) {
|
||||
instance = new PetManager();
|
||||
}
|
||||
|
||||
/**
|
||||
* Spawnt ein echtes Tier-Entity für den Spieler.
|
||||
*/
|
||||
public static void spawnEntityPet(Player player, String type) {
|
||||
removePet(player);
|
||||
}
|
||||
|
||||
EntityType entityType;
|
||||
try {
|
||||
entityType = EntityType.valueOf(type);
|
||||
} catch (IllegalArgumentException e) {
|
||||
player.sendMessage("§cFehler: Tier-Typ nicht gefunden.");
|
||||
return;
|
||||
}
|
||||
public static void unregister() {
|
||||
if (instance != null) {
|
||||
HandlerList.unregisterAll(instance);
|
||||
instance = null;
|
||||
}
|
||||
|
||||
Location loc = player.getLocation();
|
||||
Entity pet = player.getWorld().spawnEntity(loc, entityType);
|
||||
}
|
||||
|
||||
pet.setCustomName("§d" + player.getName() + "'s " + capitalize(type.toLowerCase()));
|
||||
pet.setCustomNameVisible(true);
|
||||
pet.setInvulnerable(true);
|
||||
pet.setPersistent(false);
|
||||
public static void spawnEntityPet(Player player, String type) {
|
||||
spawnEntityPet(player, type, false);
|
||||
}
|
||||
|
||||
if (pet instanceof LivingEntity) {
|
||||
LivingEntity le = (LivingEntity) pet;
|
||||
le.setRemoveWhenFarAway(false);
|
||||
|
||||
// Verhindert, dass das Pet andere angreift
|
||||
if (le instanceof Tameable) {
|
||||
((Tameable) le).setTamed(true);
|
||||
((Tameable) le).setOwner(player);
|
||||
public static void spawnEntityPet(Player player, String type, boolean baby) {
|
||||
spawnEntityPet(player, type, baby, (String)null);
|
||||
}
|
||||
|
||||
public static void spawnEntityPet(Player player, String type, boolean baby, String variantName) {
|
||||
removePet(player);
|
||||
|
||||
EntityType entityType;
|
||||
try {
|
||||
entityType = EntityType.valueOf(type);
|
||||
} catch (IllegalArgumentException var12) {
|
||||
player.sendMessage("§cFehler: Tier-Typ nicht gefunden.");
|
||||
return;
|
||||
}
|
||||
|
||||
Location loc = player.getLocation();
|
||||
Entity pet = player.getWorld().spawnEntity(loc, entityType);
|
||||
String agePrefix = baby ? "§bBaby " : "";
|
||||
String petName = buildPetDisplayName(type, variantName);
|
||||
pet.setCustomName(agePrefix + petName);
|
||||
pet.setCustomNameVisible(true);
|
||||
pet.setInvulnerable(true);
|
||||
pet.setPersistent(false);
|
||||
applyNeutralPetTeam(pet);
|
||||
if (pet instanceof LivingEntity le) {
|
||||
le.setRemoveWhenFarAway(false);
|
||||
if (le instanceof Ageable ageable) {
|
||||
if (baby) {
|
||||
ageable.setBaby();
|
||||
} else {
|
||||
ageable.setAdult();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
activePets.put(player.getUniqueId(), pet);
|
||||
}
|
||||
if (le instanceof Wolf && variantName != null && !variantName.isEmpty()) {
|
||||
Wolf.Variant variant = resolveWolfVariant(variantName);
|
||||
if (variant != null) {
|
||||
((Wolf)le).setVariant(variant);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Steuert das Folgen der Tiere. Wird vom GadgetModule-Timer aufgerufen.
|
||||
*/
|
||||
public static void updatePets() {
|
||||
for (Map.Entry<UUID, Entity> entry : activePets.entrySet()) {
|
||||
Player owner = Bukkit.getPlayer(entry.getKey());
|
||||
Entity pet = entry.getValue();
|
||||
if (le instanceof Fox && variantName != null && !variantName.isEmpty()) {
|
||||
try {
|
||||
((Fox)le).setFoxType(Type.valueOf(variantName));
|
||||
} catch (IllegalArgumentException var11) {
|
||||
}
|
||||
}
|
||||
|
||||
if (owner == null || !owner.isOnline() || pet.isDead()) {
|
||||
continue;
|
||||
if (le instanceof Tameable) {
|
||||
((Tameable)le).setTamed(true);
|
||||
((Tameable)le).setOwner(player);
|
||||
}
|
||||
}
|
||||
|
||||
activePets.put(player.getUniqueId(), pet);
|
||||
}
|
||||
|
||||
public static void updatePets() {
|
||||
for(Map.Entry<UUID, Entity> entry : activePets.entrySet()) {
|
||||
Player owner = Bukkit.getPlayer((UUID)entry.getKey());
|
||||
Entity pet = (Entity)entry.getValue();
|
||||
if (owner != null && owner.isOnline() && !pet.isDead()) {
|
||||
if (pet.getWorld().equals(owner.getWorld()) && !(pet.getLocation().distance(owner.getLocation()) > (double)10.0F)) {
|
||||
if (pet.getLocation().distance(owner.getLocation()) > (double)3.0F) {
|
||||
Location target = owner.getLocation().clone().add(owner.getLocation().getDirection().multiply((double)-1.5F));
|
||||
target.setY(owner.getLocation().getY());
|
||||
pet.teleport(pet.getLocation().add(target.toVector().subtract(pet.getLocation().toVector()).normalize().multiply(0.2)));
|
||||
Location lookAt = pet.getLocation();
|
||||
lookAt.setDirection(owner.getLocation().toVector().subtract(pet.getLocation().toVector()));
|
||||
pet.teleport(lookAt);
|
||||
}
|
||||
} else {
|
||||
pet.teleport(owner.getLocation());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void removePet(Player player) {
|
||||
if (activePets.containsKey(player.getUniqueId())) {
|
||||
Entity pet = (Entity)activePets.get(player.getUniqueId());
|
||||
removeFromPetTeam(pet);
|
||||
pet.remove();
|
||||
activePets.remove(player.getUniqueId());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void clearAll() {
|
||||
for(Entity pet : activePets.values()) {
|
||||
removeFromPetTeam(pet);
|
||||
pet.remove();
|
||||
}
|
||||
|
||||
activePets.clear();
|
||||
}
|
||||
|
||||
private static String capitalize(String str) {
|
||||
if (str != null && !str.isEmpty()) {
|
||||
String var10000 = str.substring(0, 1).toUpperCase();
|
||||
return var10000 + str.substring(1);
|
||||
} else {
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
||||
private static String buildPetDisplayName(String type, String variantName) {
|
||||
String baseType = capitalize(type.toLowerCase());
|
||||
if (variantName != null && !variantName.isEmpty()) {
|
||||
String variant = capitalize(variantName.toLowerCase());
|
||||
return variant + " " + baseType;
|
||||
} else {
|
||||
return baseType;
|
||||
}
|
||||
}
|
||||
|
||||
private static Wolf.Variant resolveWolfVariant(String variantName) {
|
||||
String keyName = variantName.toLowerCase();
|
||||
NamespacedKey key = NamespacedKey.minecraft(keyName);
|
||||
return (Wolf.Variant)Registry.WOLF_VARIANT.get(key);
|
||||
}
|
||||
|
||||
private static Team getOrCreatePetTeam() {
|
||||
Scoreboard scoreboard = Bukkit.getScoreboardManager().getMainScoreboard();
|
||||
Team team = scoreboard.getTeam("nexus_pets");
|
||||
if (team == null) {
|
||||
team = scoreboard.registerNewTeam("nexus_pets");
|
||||
team.setPrefix("");
|
||||
team.setSuffix("");
|
||||
}
|
||||
|
||||
return team;
|
||||
}
|
||||
|
||||
private static void applyNeutralPetTeam(Entity pet) {
|
||||
Team team = getOrCreatePetTeam();
|
||||
String entry = pet.getUniqueId().toString();
|
||||
if (!team.hasEntry(entry)) {
|
||||
team.addEntry(entry);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static void removeFromPetTeam(Entity pet) {
|
||||
if (pet != null) {
|
||||
Scoreboard scoreboard = Bukkit.getScoreboardManager().getMainScoreboard();
|
||||
Team team = scoreboard.getTeam("nexus_pets");
|
||||
if (team != null) {
|
||||
String entry = pet.getUniqueId().toString();
|
||||
if (team.hasEntry(entry)) {
|
||||
team.removeEntry(entry);
|
||||
}
|
||||
|
||||
// Wenn das Pet in einer anderen Welt ist oder zu weit weg, teleportiere es
|
||||
if (!pet.getWorld().equals(owner.getWorld()) || pet.getLocation().distance(owner.getLocation()) > 10) {
|
||||
pet.teleport(owner.getLocation());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Sanftes Folgen: Wenn das Pet weiter als 3 Blöcke weg ist
|
||||
if (pet.getLocation().distance(owner.getLocation()) > 3) {
|
||||
Location target = owner.getLocation().clone().add(owner.getLocation().getDirection().multiply(-1.5));
|
||||
target.setY(owner.getLocation().getY());
|
||||
|
||||
// Teleportiert das Pet leicht zum Ziel (simuliert Laufen)
|
||||
pet.teleport(pet.getLocation().add(target.toVector().subtract(pet.getLocation().toVector()).normalize().multiply(0.2)));
|
||||
|
||||
// Blickrichtung anpassen
|
||||
Location lookAt = pet.getLocation();
|
||||
lookAt.setDirection(owner.getLocation().toVector().subtract(pet.getLocation().toVector()));
|
||||
pet.teleport(lookAt);
|
||||
}
|
||||
}
|
||||
}
|
||||
@EventHandler
|
||||
public void onPetDamage(EntityDamageEvent event) {
|
||||
if (activePets.containsValue(event.getEntity())) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
public static void removePet(Player player) {
|
||||
if (activePets.containsKey(player.getUniqueId())) {
|
||||
activePets.get(player.getUniqueId()).remove();
|
||||
activePets.remove(player.getUniqueId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void clearAll() {
|
||||
for (Entity pet : activePets.values()) {
|
||||
pet.remove();
|
||||
}
|
||||
activePets.clear();
|
||||
}
|
||||
@EventHandler
|
||||
public void onPetTarget(EntityTargetEvent event) {
|
||||
if (activePets.containsValue(event.getEntity())) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
private static String capitalize(String str) {
|
||||
if (str == null || str.isEmpty()) return str;
|
||||
return str.substring(0, 1).toUpperCase() + str.substring(1);
|
||||
}
|
||||
}
|
||||
|
||||
// --- Events um die Pets zu schützen ---
|
||||
|
||||
@EventHandler
|
||||
public void onPetDamage(EntityDamageEvent event) {
|
||||
if (activePets.containsValue(event.getEntity())) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPetTarget(EntityTargetEvent event) {
|
||||
if (activePets.containsValue(event.getEntity())) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onQuit(PlayerQuitEvent event) {
|
||||
removePet(event.getPlayer());
|
||||
}
|
||||
}
|
||||
@EventHandler
|
||||
public void onQuit(PlayerQuitEvent event) {
|
||||
removePet(event.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package de.nexuslobby.modules.gadgets;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Entity;
|
||||
@@ -7,26 +10,32 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class ShieldTask {
|
||||
private static final Map<UUID, Long> pushCooldowns = new HashMap();
|
||||
private static final long PUSH_COOLDOWN_MS = 3000L;
|
||||
|
||||
public static void handleShield(Player owner) {
|
||||
// Erzeuge einen Partikel-Ring um den Spieler
|
||||
for (double i = 0; i < Math.PI * 2; i += Math.PI / 8) {
|
||||
double x = Math.cos(i) * 2.2;
|
||||
double z = Math.sin(i) * 2.2;
|
||||
owner.getWorld().spawnParticle(Particle.WITCH, owner.getLocation().add(x, 0.5, z), 1, 0, 0, 0, 0);
|
||||
}
|
||||
public static void handleShield(Player owner) {
|
||||
for(double i = (double)0.0F; i < (Math.PI * 2D); i += (Math.PI / 8D)) {
|
||||
double x = Math.cos(i) * 2.2;
|
||||
double z = Math.sin(i) * 2.2;
|
||||
owner.getWorld().spawnParticle(Particle.WITCH, owner.getLocation().add(x, (double)0.5F, z), 1, (double)0.0F, (double)0.0F, (double)0.0F, (double)0.0F);
|
||||
}
|
||||
|
||||
// Stoße andere Spieler weg
|
||||
for (Entity entity : owner.getNearbyEntities(2.2, 2.0, 2.2)) {
|
||||
if (entity instanceof Player && entity != owner) {
|
||||
Player target = (Player) entity;
|
||||
|
||||
Vector direction = target.getLocation().toVector().subtract(owner.getLocation().toVector()).normalize();
|
||||
direction.multiply(0.4).setY(0.2);
|
||||
|
||||
target.setVelocity(direction);
|
||||
target.playSound(target.getLocation(), Sound.ENTITY_CHICKEN_EGG, 0.5f, 0.5f);
|
||||
long now = System.currentTimeMillis();
|
||||
|
||||
for(Entity entity : owner.getNearbyEntities(2.2, (double)2.0F, 2.2)) {
|
||||
if (entity instanceof Player target) {
|
||||
if (entity != owner && !GadgetShield.isProtected(target)) {
|
||||
long lastPush = (Long)pushCooldowns.getOrDefault(target.getUniqueId(), 0L);
|
||||
if (now - lastPush >= 3000L) {
|
||||
pushCooldowns.put(target.getUniqueId(), now);
|
||||
Vector direction = target.getLocation().toVector().subtract(owner.getLocation().toVector()).normalize();
|
||||
direction.multiply(0.4).setY(0.2);
|
||||
target.setVelocity(direction);
|
||||
target.playSound(target.getLocation(), Sound.ENTITY_CHICKEN_EGG, 0.5F, 0.5F);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,85 +1,90 @@
|
||||
package de.nexuslobby.commands;
|
||||
|
||||
import de.nexuslobby.modules.hologram.HologramModule;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class HoloCommand implements CommandExecutor {
|
||||
|
||||
private final HologramModule module;
|
||||
|
||||
public HoloCommand(HologramModule module) {
|
||||
this.module = module;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!(sender instanceof Player player)) return true;
|
||||
|
||||
if (!player.hasPermission("nexuslobby.hologram")) {
|
||||
player.sendMessage("§8[§6Nexus§8] §cKeine Rechte.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length < 1) {
|
||||
sendHelp(player);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("create")) {
|
||||
// Wir brauchen id, typ und mindestens ein Wort Text
|
||||
if (args.length < 4) {
|
||||
player.sendMessage("§cNutze: /holo create <id> <NONE|FAST|SLOW> <text>");
|
||||
return true;
|
||||
}
|
||||
|
||||
String id = args[1];
|
||||
// Der Typ (args[2]) wird im neuen System ignoriert, da wir Seiten nutzen
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 3; i < args.length; i++) {
|
||||
sb.append(args[i]).append(i == args.length - 1 ? "" : " ");
|
||||
}
|
||||
|
||||
String fullText = sb.toString().trim();
|
||||
List<String> pages = new ArrayList<>();
|
||||
|
||||
// Support für mehrere Seiten via ";"
|
||||
if (fullText.contains(";")) {
|
||||
pages.addAll(Arrays.asList(fullText.split(";")));
|
||||
} else {
|
||||
pages.add(fullText);
|
||||
}
|
||||
|
||||
// Aufruf der neuen Methode mit List<String>
|
||||
module.createHologram(id, player.getLocation(), pages);
|
||||
player.sendMessage("§8[§6Nexus§8] §aHologramm §e" + id + " §aerstellt (" + pages.size() + " Seiten).");
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("delete")) {
|
||||
if (args.length < 2) {
|
||||
player.sendMessage("§cBitte gib eine ID an: /holo delete <id>");
|
||||
return true;
|
||||
}
|
||||
module.removeHologram(args[1]);
|
||||
player.sendMessage("§8[§6Nexus§8] §cHologramm §e" + args[1] + " §agelöscht.");
|
||||
} else {
|
||||
sendHelp(player);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void sendHelp(Player player) {
|
||||
player.sendMessage("§8§m-----------§r §6Hologramme §8§m-----------");
|
||||
player.sendMessage("§e/holo create <id> <NONE|FAST|SLOW> <text>");
|
||||
player.sendMessage("§e/holo delete <id>");
|
||||
player.sendMessage("§7Nutze §b; §7für neue Seiten.");
|
||||
player.sendMessage("§7Nutze §b\\n §7für Zeilenumbruch.");
|
||||
}
|
||||
package de.nexuslobby.commands;
|
||||
|
||||
import de.nexuslobby.modules.hologram.HologramModule;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class HoloCommand implements CommandExecutor {
|
||||
|
||||
private final HologramModule module;
|
||||
|
||||
public HoloCommand(HologramModule module) {
|
||||
this.module = module;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!(sender instanceof Player player)) return true;
|
||||
|
||||
if (!player.hasPermission("nexuslobby.hologram")) {
|
||||
player.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§cKeine Rechte.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length < 1) {
|
||||
sendHelp(player);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("create")) {
|
||||
// Wir brauchen id, typ und mindestens ein Wort Text
|
||||
if (args.length < 4) {
|
||||
player.sendMessage("§cNutze: /holo create <id> <NONE|FAST|SLOW> <text>");
|
||||
return true;
|
||||
}
|
||||
|
||||
String id = args[1];
|
||||
// Der Typ (args[2]) wird im neuen System ignoriert, da wir Seiten nutzen
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 3; i < args.length; i++) {
|
||||
sb.append(args[i]).append(i == args.length - 1 ? "" : " ");
|
||||
}
|
||||
|
||||
String fullText = sb.toString().trim();
|
||||
List<String> pages = new ArrayList<>();
|
||||
|
||||
// Support für mehrere Seiten via ";"
|
||||
if (fullText.contains(";")) {
|
||||
pages.addAll(Arrays.asList(fullText.split(";")));
|
||||
} else {
|
||||
pages.add(fullText);
|
||||
}
|
||||
|
||||
// Aufruf der neuen Methode mit List<String>
|
||||
module.createHologram(id, player.getLocation(), pages);
|
||||
player.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§aHologramm §e" + id + " §aerstellt (" + pages.size() + " Seiten).");
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("delete")) {
|
||||
if (args.length < 2) {
|
||||
player.sendMessage("§cBitte gib eine ID an: /holo delete <id>");
|
||||
return true;
|
||||
}
|
||||
module.removeHologram(args[1]);
|
||||
player.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§cHologramm §e" + args[1] + " §agelöscht.");
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("reload")) {
|
||||
module.reloadHolograms();
|
||||
player.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§aHologramme neu geladen.");
|
||||
} else {
|
||||
sendHelp(player);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void sendHelp(Player player) {
|
||||
player.sendMessage("§8§m-----------§r §6Hologramme §8§m-----------");
|
||||
player.sendMessage("§e/holo create <id> <NONE|FAST|SLOW> <text>");
|
||||
player.sendMessage("§e/holo delete <id>");
|
||||
player.sendMessage("§e/holo reload");
|
||||
player.sendMessage("§7Nutze §b; §7für neue Seiten.");
|
||||
player.sendMessage("§7Nutze §b\\n §7für Zeilenumbruch.");
|
||||
}
|
||||
}
|
||||
@@ -1,178 +1,221 @@
|
||||
package de.nexuslobby.modules.hologram;
|
||||
|
||||
import de.nexuslobby.NexusLobby;
|
||||
import de.nexuslobby.api.Module;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Interaction;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.TextDisplay;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerChangedWorldEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class HologramModule implements Module, Listener {
|
||||
|
||||
private final Map<String, NexusHologram> holograms = new ConcurrentHashMap<>();
|
||||
private File file;
|
||||
private FileConfiguration config;
|
||||
|
||||
@Override
|
||||
public String getName() { return "Holograms"; }
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
loadConfig();
|
||||
loadHolograms();
|
||||
Bukkit.getPluginManager().registerEvents(this, NexusLobby.getInstance());
|
||||
|
||||
// Render-Task: Prüft alle 5 Ticks Sichtbarkeit und Placeholder-Updates
|
||||
Bukkit.getScheduler().runTaskTimer(NexusLobby.getInstance(), () -> {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
holograms.values().forEach(h -> h.renderForPlayer(player));
|
||||
}
|
||||
}, 20L, 5L);
|
||||
}
|
||||
|
||||
private void loadConfig() {
|
||||
file = new File(NexusLobby.getInstance().getDataFolder(), "holograms.yml");
|
||||
config = YamlConfiguration.loadConfiguration(file);
|
||||
}
|
||||
|
||||
private void loadHolograms() {
|
||||
// Vorherige Instanzen säubern
|
||||
holograms.values().forEach(NexusHologram::removeAll);
|
||||
holograms.clear();
|
||||
|
||||
for (String id : config.getKeys(false)) {
|
||||
String worldName = config.getString(id + ".world");
|
||||
if (worldName == null) continue;
|
||||
|
||||
World world = Bukkit.getWorld(worldName);
|
||||
if (world == null) continue;
|
||||
|
||||
Location loc = new Location(world,
|
||||
config.getDouble(id + ".x"),
|
||||
config.getDouble(id + ".y"),
|
||||
config.getDouble(id + ".z"));
|
||||
|
||||
List<String> pages;
|
||||
if (config.isList(id + ".text")) {
|
||||
pages = config.getStringList(id + ".text");
|
||||
} else {
|
||||
pages = new ArrayList<>();
|
||||
pages.add(config.getString(id + ".text", "No Text"));
|
||||
}
|
||||
|
||||
holograms.put(id, new NexusHologram(id, loc, pages));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInteract(PlayerInteractEntityEvent event) {
|
||||
// Nur auf Interaction-Entities reagieren (Hologramm-Hitboxen)
|
||||
if (!(event.getRightClicked() instanceof Interaction)) return;
|
||||
|
||||
for (NexusHologram holo : holograms.values()) {
|
||||
if (holo.isInteractionEntity(event.getRightClicked().getUniqueId())) {
|
||||
holo.nextPage(event.getPlayer());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onQuit(PlayerQuitEvent event) {
|
||||
holograms.values().forEach(h -> h.removeForPlayer(event.getPlayer()));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onWorldChange(PlayerChangedWorldEvent event) {
|
||||
holograms.values().forEach(h -> h.removeForPlayer(event.getPlayer()));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onJoin(PlayerJoinEvent event) {
|
||||
// Cleanup alter Entity-Reste, die eventuell noch in der Welt schweben
|
||||
Bukkit.getScheduler().runTaskLater(NexusLobby.getInstance(), () -> {
|
||||
Player p = event.getPlayer();
|
||||
for (Entity entity : p.getWorld().getEntities()) {
|
||||
if (entity.getCustomName() != null && entity.getCustomName().startsWith("nexus_h_")) {
|
||||
// Wenn das Hologramm nicht exakt für diesen Spieler benannt ist -> verstecken
|
||||
if (!entity.getCustomName().endsWith("_" + p.getName())) {
|
||||
p.hideEntity(NexusLobby.getInstance(), entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 10L);
|
||||
}
|
||||
|
||||
public void createHologram(String id, Location loc, List<String> pages) {
|
||||
// Falls ID bereits existiert, altes Hologramm sauber entfernen
|
||||
if (holograms.containsKey(id)) {
|
||||
removeHologram(id);
|
||||
}
|
||||
|
||||
config.set(id + ".world", loc.getWorld().getName());
|
||||
config.set(id + ".x", loc.getX());
|
||||
config.set(id + ".y", loc.getY());
|
||||
config.set(id + ".z", loc.getZ());
|
||||
config.set(id + ".text", pages);
|
||||
saveHoloConfig();
|
||||
|
||||
NexusHologram holo = new NexusHologram(id, loc, pages);
|
||||
holograms.put(id, holo);
|
||||
}
|
||||
|
||||
public void removeHologram(String id) {
|
||||
NexusHologram holo = holograms.remove(id);
|
||||
if (holo != null) {
|
||||
// Erst für alle Spieler visuell entfernen
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
holo.removeForPlayer(player);
|
||||
}
|
||||
// Dann Entities serverseitig löschen
|
||||
holo.removeAll();
|
||||
}
|
||||
config.set(id, null);
|
||||
saveHoloConfig();
|
||||
}
|
||||
|
||||
private void saveHoloConfig() {
|
||||
try {
|
||||
config.save(file);
|
||||
} catch (IOException e) {
|
||||
NexusLobby.getInstance().getLogger().severe("Konnte holograms.yml nicht speichern!");
|
||||
NexusLobby.getInstance().getLogger().severe("Fehler beim Speichern der Hologramme: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* WICHTIG: Diese Methode wird vom LobbyTabCompleter benötigt!
|
||||
* @return Set aller registrierten Hologramm-IDs
|
||||
*/
|
||||
public Set<String> getHologramIds() {
|
||||
return holograms.keySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
holograms.values().forEach(NexusHologram::removeAll);
|
||||
holograms.clear();
|
||||
}
|
||||
package de.nexuslobby.modules.hologram;
|
||||
|
||||
import de.nexuslobby.NexusLobby;
|
||||
import de.nexuslobby.api.Module;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Interaction;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.TextDisplay;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerChangedWorldEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class HologramModule implements Module, Listener {
|
||||
|
||||
private final Map<String, NexusHologram> holograms = new ConcurrentHashMap<>();
|
||||
private File file;
|
||||
private FileConfiguration config;
|
||||
|
||||
@Override
|
||||
public String getName() { return "Holograms"; }
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
loadConfig();
|
||||
loadHolograms();
|
||||
Bukkit.getPluginManager().registerEvents(this, NexusLobby.getInstance());
|
||||
|
||||
// Render-Task: Prüft alle 5 Ticks Sichtbarkeit und Placeholder-Updates
|
||||
Bukkit.getScheduler().runTaskTimer(NexusLobby.getInstance(), () -> {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
holograms.values().forEach(h -> h.renderForPlayer(player));
|
||||
}
|
||||
}, 20L, 5L);
|
||||
}
|
||||
|
||||
private void loadConfig() {
|
||||
file = new File(NexusLobby.getInstance().getDataFolder(), "holograms.yml");
|
||||
config = YamlConfiguration.loadConfiguration(file);
|
||||
}
|
||||
|
||||
private void loadHolograms() {
|
||||
// Vorherige Instanzen säubern
|
||||
holograms.values().forEach(NexusHologram::removeAll);
|
||||
holograms.clear();
|
||||
|
||||
for (String id : config.getKeys(false)) {
|
||||
String worldName = config.getString(id + ".world");
|
||||
if (worldName == null) continue;
|
||||
|
||||
World world = Bukkit.getWorld(worldName);
|
||||
if (world == null) continue;
|
||||
|
||||
Location loc = new Location(world,
|
||||
config.getDouble(id + ".x"),
|
||||
config.getDouble(id + ".y"),
|
||||
config.getDouble(id + ".z"));
|
||||
|
||||
List<String> pages;
|
||||
if (config.isList(id + ".text")) {
|
||||
pages = config.getStringList(id + ".text");
|
||||
} else {
|
||||
pages = new ArrayList<>();
|
||||
pages.add(config.getString(id + ".text", "No Text"));
|
||||
}
|
||||
|
||||
holograms.put(id, new NexusHologram(id, loc, pages));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInteract(PlayerInteractEntityEvent event) {
|
||||
// Nur auf Interaction-Entities reagieren (Hologramm-Hitboxen)
|
||||
if (!(event.getRightClicked() instanceof Interaction)) return;
|
||||
|
||||
for (NexusHologram holo : holograms.values()) {
|
||||
if (holo.isInteractionEntity(event.getRightClicked().getUniqueId())) {
|
||||
holo.nextPage(event.getPlayer());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onQuit(PlayerQuitEvent event) {
|
||||
holograms.values().forEach(h -> h.removeForPlayer(event.getPlayer()));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onWorldChange(PlayerChangedWorldEvent event) {
|
||||
holograms.values().forEach(h -> h.removeForPlayer(event.getPlayer()));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onJoin(PlayerJoinEvent event) {
|
||||
// Cleanup alter Entity-Reste, die eventuell noch in der Welt schweben
|
||||
Bukkit.getScheduler().runTaskLater(NexusLobby.getInstance(), () -> {
|
||||
Player p = event.getPlayer();
|
||||
for (Entity entity : p.getWorld().getEntities()) {
|
||||
if (entity.getCustomName() != null && entity.getCustomName().startsWith("nexus_h_")) {
|
||||
// Wenn das Hologramm nicht exakt für diesen Spieler benannt ist -> verstecken
|
||||
if (!entity.getCustomName().endsWith("_" + p.getName())) {
|
||||
p.hideEntity(NexusLobby.getInstance(), entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 10L);
|
||||
}
|
||||
|
||||
public void createHologram(String id, Location loc, List<String> pages) {
|
||||
// Falls ID bereits existiert, altes Hologramm sauber entfernen
|
||||
if (holograms.containsKey(id)) {
|
||||
removeHologram(id);
|
||||
}
|
||||
|
||||
config.set(id + ".world", loc.getWorld().getName());
|
||||
config.set(id + ".x", loc.getX());
|
||||
config.set(id + ".y", loc.getY());
|
||||
config.set(id + ".z", loc.getZ());
|
||||
config.set(id + ".text", pages);
|
||||
saveHoloConfig();
|
||||
|
||||
NexusHologram holo = new NexusHologram(id, loc, pages);
|
||||
holograms.put(id, holo);
|
||||
}
|
||||
|
||||
public void removeHologram(String id) {
|
||||
NexusHologram holo = holograms.remove(id);
|
||||
if (holo != null) {
|
||||
// Erst für alle Spieler visuell entfernen
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
holo.removeForPlayer(player);
|
||||
}
|
||||
// Dann Entities serverseitig löschen
|
||||
holo.removeAll();
|
||||
}
|
||||
config.set(id, null);
|
||||
saveHoloConfig();
|
||||
}
|
||||
|
||||
/**
|
||||
* Lädt die holograms.yml neu und rendert alle Hologramme für Online-Spieler neu.
|
||||
* Wird von HoloCommand (/holo reload) aufgerufen.
|
||||
*/
|
||||
public void reloadHolograms() {
|
||||
// Alle aktiven Hologramme für alle Spieler entfernen
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
holograms.values().forEach(h -> h.removeForPlayer(player));
|
||||
}
|
||||
// Config neu einlesen und Hologramme neu laden
|
||||
loadConfig();
|
||||
loadHolograms();
|
||||
}
|
||||
|
||||
private void saveHoloConfig() {
|
||||
try {
|
||||
// Sicherstellen, dass Placeholder-Strings (z.B. %bungeetotal%) korrekt
|
||||
// gequotet gespeichert werden, damit SnakeYAML sie nicht als YAML-Direktive
|
||||
// missinterpretiert. Dazu speichern wir die text-Listen explizit als
|
||||
// String-Werte mit einfachen Anführungszeichen via eigener Serialisierung.
|
||||
StringBuilder yaml = new StringBuilder();
|
||||
for (String id : config.getKeys(false)) {
|
||||
yaml.append(id).append(":\n");
|
||||
yaml.append(" world: ").append(quoteIfNeeded(config.getString(id + ".world", ""))).append("\n");
|
||||
yaml.append(" x: ").append(config.getDouble(id + ".x")).append("\n");
|
||||
yaml.append(" y: ").append(config.getDouble(id + ".y")).append("\n");
|
||||
yaml.append(" z: ").append(config.getDouble(id + ".z")).append("\n");
|
||||
yaml.append(" text:\n");
|
||||
for (String line : config.getStringList(id + ".text")) {
|
||||
yaml.append(" - ").append(quoteIfNeeded(line)).append("\n");
|
||||
}
|
||||
}
|
||||
java.nio.file.Files.writeString(file.toPath(), yaml.toString());
|
||||
} catch (IOException e) {
|
||||
NexusLobby.getInstance().getLogger().severe("Konnte holograms.yml nicht speichern!");
|
||||
NexusLobby.getInstance().getLogger().severe("Fehler beim Speichern der Hologramme: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Umschließt Strings mit einfachen Anführungszeichen, wenn sie YAML-Sonderzeichen
|
||||
* wie '%', ':', '#' enthalten, um Parsing-Fehler zu vermeiden.
|
||||
*/
|
||||
private String quoteIfNeeded(String value) {
|
||||
if (value == null) return "''";
|
||||
if (value.contains("%") || value.contains(":") || value.contains("#") || value.contains("'")) {
|
||||
return "'" + value.replace("'", "''") + "'";
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* WICHTIG: Diese Methode wird vom LobbyTabCompleter benötigt!
|
||||
* @return Set aller registrierten Hologramm-IDs
|
||||
*/
|
||||
public Set<String> getHologramIds() {
|
||||
return holograms.keySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
org.bukkit.event.HandlerList.unregisterAll(this);
|
||||
holograms.values().forEach(NexusHologram::removeAll);
|
||||
holograms.clear();
|
||||
}
|
||||
}
|
||||
@@ -1,118 +1,118 @@
|
||||
package de.nexuslobby.modules.hologram;
|
||||
|
||||
import de.nexuslobby.NexusLobby;
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Display;
|
||||
import org.bukkit.entity.Interaction;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.TextDisplay;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class NexusHologram {
|
||||
|
||||
private final String id;
|
||||
private final Location location;
|
||||
private final List<String> pages;
|
||||
|
||||
private final Map<UUID, TextDisplay> playerEntities = new ConcurrentHashMap<>();
|
||||
private final Map<UUID, Interaction> playerInteractions = new ConcurrentHashMap<>();
|
||||
private final Map<UUID, Integer> currentPage = new ConcurrentHashMap<>();
|
||||
|
||||
public NexusHologram(String id, Location location, List<String> pages) {
|
||||
this.id = id;
|
||||
this.location = location;
|
||||
this.pages = pages;
|
||||
}
|
||||
|
||||
public void nextPage(Player player) {
|
||||
if (pages.size() <= 1) return;
|
||||
int next = (currentPage.getOrDefault(player.getUniqueId(), 0) + 1) % pages.size();
|
||||
currentPage.put(player.getUniqueId(), next);
|
||||
renderForPlayer(player);
|
||||
}
|
||||
|
||||
public void renderForPlayer(Player player) {
|
||||
if (!player.getWorld().equals(location.getWorld()) || player.getLocation().distanceSquared(location) > 2304) {
|
||||
removeForPlayer(player);
|
||||
return;
|
||||
}
|
||||
|
||||
int pageIdx = currentPage.getOrDefault(player.getUniqueId(), 0);
|
||||
if (pageIdx >= pages.size()) pageIdx = 0;
|
||||
|
||||
String rawText = pages.get(pageIdx);
|
||||
if (Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI")) {
|
||||
rawText = PlaceholderAPI.setPlaceholders(player, rawText);
|
||||
}
|
||||
final String finalText = rawText.replace("&", "§").replace("\\n", "\n");
|
||||
|
||||
TextDisplay display = playerEntities.get(player.getUniqueId());
|
||||
|
||||
if (display == null || !display.isValid()) {
|
||||
// Text-Display erstellen (Hier lassen wir den Namen zur internen Identifikation,
|
||||
// aber schalten ihn strikt unsichtbar)
|
||||
display = location.getWorld().spawn(location, TextDisplay.class, entity -> {
|
||||
entity.setCustomName("nexus_h_" + id + "_" + player.getName());
|
||||
entity.setCustomNameVisible(false);
|
||||
entity.setPersistent(false);
|
||||
entity.setBillboard(Display.Billboard.CENTER);
|
||||
entity.setBackgroundColor(Color.fromARGB(0, 0, 0, 0));
|
||||
entity.setText(finalText);
|
||||
entity.setInvulnerable(true);
|
||||
});
|
||||
|
||||
// Interaction Entity (Hitbox) erstellen
|
||||
// FIX: WIR SETZEN KEINEN CUSTOM NAME MEHR.
|
||||
// Das verhindert zu 100%, dass Minecraft etwas anzeigt.
|
||||
Interaction interact = location.getWorld().spawn(location, Interaction.class, entity -> {
|
||||
entity.setInteractionWidth(2.5f);
|
||||
entity.setInteractionHeight(2.0f);
|
||||
entity.setCustomNameVisible(false);
|
||||
entity.setPersistent(false);
|
||||
});
|
||||
|
||||
// Nur für den Zielspieler sichtbar machen
|
||||
for (Player other : Bukkit.getOnlinePlayers()) {
|
||||
if (!other.getUniqueId().equals(player.getUniqueId())) {
|
||||
other.hideEntity(NexusLobby.getInstance(), display);
|
||||
other.hideEntity(NexusLobby.getInstance(), interact);
|
||||
}
|
||||
}
|
||||
|
||||
playerEntities.put(player.getUniqueId(), display);
|
||||
playerInteractions.put(player.getUniqueId(), interact);
|
||||
} else {
|
||||
if (!display.getText().equals(finalText)) {
|
||||
display.setText(finalText);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void removeForPlayer(Player player) {
|
||||
TextDisplay display = playerEntities.remove(player.getUniqueId());
|
||||
if (display != null) display.remove();
|
||||
|
||||
Interaction interact = playerInteractions.remove(player.getUniqueId());
|
||||
if (interact != null) interact.remove();
|
||||
}
|
||||
|
||||
public void removeAll() {
|
||||
playerEntities.values().forEach(TextDisplay::remove);
|
||||
playerInteractions.values().forEach(Interaction::remove);
|
||||
playerEntities.clear();
|
||||
playerInteractions.clear();
|
||||
currentPage.clear();
|
||||
}
|
||||
|
||||
public boolean isInteractionEntity(UUID entityId) {
|
||||
// Da wir keinen Namen mehr nutzen, verlassen wir uns rein auf die UUID in der Map
|
||||
return playerInteractions.values().stream().anyMatch(i -> i.getUniqueId().equals(entityId));
|
||||
}
|
||||
package de.nexuslobby.modules.hologram;
|
||||
|
||||
import de.nexuslobby.NexusLobby;
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Display;
|
||||
import org.bukkit.entity.Interaction;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.TextDisplay;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class NexusHologram {
|
||||
|
||||
private final String id;
|
||||
private final Location location;
|
||||
private final List<String> pages;
|
||||
|
||||
private final Map<UUID, TextDisplay> playerEntities = new ConcurrentHashMap<>();
|
||||
private final Map<UUID, Interaction> playerInteractions = new ConcurrentHashMap<>();
|
||||
private final Map<UUID, Integer> currentPage = new ConcurrentHashMap<>();
|
||||
|
||||
public NexusHologram(String id, Location location, List<String> pages) {
|
||||
this.id = id;
|
||||
this.location = location;
|
||||
this.pages = pages;
|
||||
}
|
||||
|
||||
public void nextPage(Player player) {
|
||||
if (pages.size() <= 1) return;
|
||||
int next = (currentPage.getOrDefault(player.getUniqueId(), 0) + 1) % pages.size();
|
||||
currentPage.put(player.getUniqueId(), next);
|
||||
renderForPlayer(player);
|
||||
}
|
||||
|
||||
public void renderForPlayer(Player player) {
|
||||
if (!player.getWorld().equals(location.getWorld()) || player.getLocation().distanceSquared(location) > 2304) {
|
||||
removeForPlayer(player);
|
||||
return;
|
||||
}
|
||||
|
||||
int pageIdx = currentPage.getOrDefault(player.getUniqueId(), 0);
|
||||
if (pageIdx >= pages.size()) pageIdx = 0;
|
||||
|
||||
String rawText = pages.get(pageIdx);
|
||||
if (Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI")) {
|
||||
rawText = PlaceholderAPI.setPlaceholders(player, rawText);
|
||||
}
|
||||
final String finalText = rawText.replace("&", "§").replace("\\n", "\n");
|
||||
|
||||
TextDisplay display = playerEntities.get(player.getUniqueId());
|
||||
|
||||
if (display == null || !display.isValid()) {
|
||||
// Text-Display erstellen (Hier lassen wir den Namen zur internen Identifikation,
|
||||
// aber schalten ihn strikt unsichtbar)
|
||||
display = location.getWorld().spawn(location, TextDisplay.class, entity -> {
|
||||
entity.setCustomName("nexus_h_" + id + "_" + player.getName());
|
||||
entity.setCustomNameVisible(false);
|
||||
entity.setPersistent(false);
|
||||
entity.setBillboard(Display.Billboard.CENTER);
|
||||
entity.setBackgroundColor(Color.fromARGB(0, 0, 0, 0));
|
||||
entity.setText(finalText);
|
||||
entity.setInvulnerable(true);
|
||||
});
|
||||
|
||||
// Interaction Entity (Hitbox) erstellen
|
||||
// FIX: WIR SETZEN KEINEN CUSTOM NAME MEHR.
|
||||
// Das verhindert zu 100%, dass Minecraft etwas anzeigt.
|
||||
Interaction interact = location.getWorld().spawn(location, Interaction.class, entity -> {
|
||||
entity.setInteractionWidth(2.5f);
|
||||
entity.setInteractionHeight(2.0f);
|
||||
entity.setCustomNameVisible(false);
|
||||
entity.setPersistent(false);
|
||||
});
|
||||
|
||||
// Nur für den Zielspieler sichtbar machen
|
||||
for (Player other : Bukkit.getOnlinePlayers()) {
|
||||
if (!other.getUniqueId().equals(player.getUniqueId())) {
|
||||
other.hideEntity(NexusLobby.getInstance(), display);
|
||||
other.hideEntity(NexusLobby.getInstance(), interact);
|
||||
}
|
||||
}
|
||||
|
||||
playerEntities.put(player.getUniqueId(), display);
|
||||
playerInteractions.put(player.getUniqueId(), interact);
|
||||
} else {
|
||||
if (!display.getText().equals(finalText)) {
|
||||
display.setText(finalText);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void removeForPlayer(Player player) {
|
||||
TextDisplay display = playerEntities.remove(player.getUniqueId());
|
||||
if (display != null) display.remove();
|
||||
|
||||
Interaction interact = playerInteractions.remove(player.getUniqueId());
|
||||
if (interact != null) interact.remove();
|
||||
}
|
||||
|
||||
public void removeAll() {
|
||||
playerEntities.values().forEach(TextDisplay::remove);
|
||||
playerInteractions.values().forEach(Interaction::remove);
|
||||
playerEntities.clear();
|
||||
playerInteractions.clear();
|
||||
currentPage.clear();
|
||||
}
|
||||
|
||||
public boolean isInteractionEntity(UUID entityId) {
|
||||
// Da wir keinen Namen mehr nutzen, verlassen wir uns rein auf die UUID in der Map
|
||||
return playerInteractions.values().stream().anyMatch(i -> i.getUniqueId().equals(entityId));
|
||||
}
|
||||
}
|
||||
@@ -1,223 +1,365 @@
|
||||
package de.nexuslobby.modules.intro;
|
||||
|
||||
import de.nexuslobby.NexusLobby;
|
||||
import de.nexuslobby.api.Module;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerToggleSneakEvent;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
public class IntroModule implements Module, Listener, CommandExecutor {
|
||||
|
||||
private final Set<UUID> activeIntro = new HashSet<>();
|
||||
private final List<Location> points = new ArrayList<>();
|
||||
private File configFile;
|
||||
private FileConfiguration config;
|
||||
|
||||
// --- Einstellungen ---
|
||||
private final int TICKS_FLUG = 70; // Dauer der Fahrt zwischen zwei Punkten (3.5 Sek)
|
||||
private final int TICKS_PAUSE = 30; // Standzeit an jedem Punkt (1.5 Sek)
|
||||
|
||||
@Override
|
||||
public String getName() { return "Intro"; }
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
Bukkit.getPluginManager().registerEvents(this, NexusLobby.getInstance());
|
||||
if (NexusLobby.getInstance().getCommand("intro") != null) {
|
||||
NexusLobby.getInstance().getCommand("intro").setExecutor(this);
|
||||
}
|
||||
loadPoints();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
activeIntro.clear();
|
||||
}
|
||||
|
||||
private void loadPoints() {
|
||||
points.clear();
|
||||
configFile = new File(NexusLobby.getInstance().getDataFolder(), "intro.yml");
|
||||
if (!configFile.exists()) {
|
||||
try { configFile.createNewFile(); } catch (IOException ignored) {}
|
||||
}
|
||||
config = YamlConfiguration.loadConfiguration(configFile);
|
||||
List<?> list = config.getList("points");
|
||||
if (list != null) {
|
||||
for (Object obj : list) {
|
||||
if (obj instanceof Location loc) points.add(loc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void savePoints() {
|
||||
config.set("points", points);
|
||||
try {
|
||||
config.save(configFile);
|
||||
} catch (IOException e) {
|
||||
NexusLobby.getInstance().getLogger().severe("Fehler beim Speichern der Intro-Config: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onJoin(PlayerJoinEvent event) {
|
||||
if (!event.getPlayer().hasPlayedBefore() && points.size() >= 2) {
|
||||
startIntro(event.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onSneak(PlayerToggleSneakEvent event) {
|
||||
if (activeIntro.contains(event.getPlayer().getUniqueId()) && event.isSneaking()) {
|
||||
stopIntro(event.getPlayer(), true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||
if (!(sender instanceof Player p)) return true;
|
||||
if (!p.hasPermission("nexuslobby.admin")) return true;
|
||||
|
||||
if (args.length == 0) {
|
||||
p.sendMessage("§8§m------------------------------------");
|
||||
p.sendMessage("§6§lNexus Intro System (Cinematic)");
|
||||
p.sendMessage("§e/intro add §7- Punkt hinzufügen");
|
||||
p.sendMessage("§e/intro clear §7- Alle Punkte löschen");
|
||||
p.sendMessage("§e/intro start §7- Teste die Fahrt");
|
||||
p.sendMessage("§8§m------------------------------------");
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args[0].toLowerCase()) {
|
||||
case "add" -> {
|
||||
points.add(p.getLocation());
|
||||
savePoints();
|
||||
p.sendMessage("§8[§6Nexus§8] §aPunkt #" + points.size() + " wurde gesetzt!");
|
||||
}
|
||||
case "clear" -> {
|
||||
points.clear();
|
||||
savePoints();
|
||||
p.sendMessage("§8[§6Nexus§8] §cAlle Intro-Punkte wurden gelöscht.");
|
||||
}
|
||||
case "start" -> {
|
||||
if (points.size() < 2) {
|
||||
p.sendMessage("§8[§6Nexus§8] §cDu brauchst mindestens 2 Punkte für eine Fahrt.");
|
||||
} else {
|
||||
startIntro(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void startIntro(Player player) {
|
||||
activeIntro.add(player.getUniqueId());
|
||||
player.setGameMode(GameMode.SPECTATOR);
|
||||
|
||||
new BukkitRunnable() {
|
||||
int currentSegment = 0;
|
||||
int tickInSegment = 0;
|
||||
boolean isPausing = true;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
if (!player.isOnline() || !activeIntro.contains(player.getUniqueId())) {
|
||||
this.cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentSegment >= points.size() - 1) {
|
||||
stopIntro(player, false);
|
||||
this.cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
Location start = points.get(currentSegment);
|
||||
Location end = points.get(currentSegment + 1);
|
||||
|
||||
if (isPausing) {
|
||||
// Kamera steht am aktuellen Punkt
|
||||
player.teleport(start);
|
||||
tickInSegment++;
|
||||
if (tickInSegment >= TICKS_PAUSE) {
|
||||
isPausing = false;
|
||||
tickInSegment = 0;
|
||||
}
|
||||
} else {
|
||||
// Kamera fliegt zum nächsten Punkt
|
||||
double progress = (double) tickInSegment / (double) TICKS_FLUG;
|
||||
|
||||
// "Smooth Step" für flüssigeres Beschleunigen/Bremsen
|
||||
double smoothT = progress * progress * (3 - 2 * progress);
|
||||
|
||||
Location nextLoc = interpolate(start, end, smoothT);
|
||||
player.teleport(nextLoc);
|
||||
|
||||
tickInSegment++;
|
||||
if (tickInSegment >= TICKS_FLUG) {
|
||||
isPausing = true;
|
||||
tickInSegment = 0;
|
||||
currentSegment++;
|
||||
}
|
||||
}
|
||||
|
||||
player.spigot().sendMessage(ChatMessageType.ACTION_BAR,
|
||||
new TextComponent("§6§lINTRO-TOUR §8| §ePunkt " + (currentSegment + 1) + " §8| §7Sneak zum Abbrechen"));
|
||||
|
||||
} catch (Exception e) {
|
||||
this.cancel();
|
||||
stopIntro(player, true);
|
||||
}
|
||||
}
|
||||
}.runTaskTimer(NexusLobby.getInstance(), 0L, 1L);
|
||||
}
|
||||
|
||||
private Location interpolate(Location start, Location end, double t) {
|
||||
double x = start.getX() + (end.getX() - start.getX()) * t;
|
||||
double y = start.getY() + (end.getY() - start.getY()) * t;
|
||||
double z = start.getZ() + (end.getZ() - start.getZ()) * t;
|
||||
|
||||
// Sanfte Drehung
|
||||
float startYaw = start.getYaw();
|
||||
float endYaw = end.getYaw();
|
||||
// Verhindert ruckartige 360-Grad Dreher
|
||||
float diff = (endYaw - startYaw) % 360;
|
||||
if (diff > 180) diff -= 360;
|
||||
if (diff < -180) diff += 360;
|
||||
float yaw = startYaw + diff * (float)t;
|
||||
|
||||
float pitch = (float) (start.getPitch() + (end.getPitch() - start.getPitch()) * t);
|
||||
|
||||
return new Location(start.getWorld(), x, y, z, yaw, pitch);
|
||||
}
|
||||
|
||||
private void stopIntro(Player player, boolean canceled) {
|
||||
activeIntro.remove(player.getUniqueId());
|
||||
player.setGameMode(GameMode.ADVENTURE);
|
||||
player.teleport(player.getWorld().getSpawnLocation());
|
||||
|
||||
if (canceled) {
|
||||
player.sendMessage("§8[§6Nexus§8] §cIntro abgebrochen.");
|
||||
} else {
|
||||
player.sendMessage("§8[§6Nexus§8] §aWillkommen auf dem Netzwerk!");
|
||||
}
|
||||
}
|
||||
package de.nexuslobby.modules.intro;
|
||||
|
||||
import de.nexuslobby.NexusLobby;
|
||||
import de.nexuslobby.api.Module;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
public class IntroModule implements Module, Listener, CommandExecutor {
|
||||
|
||||
private final Set<UUID> activeIntro = new HashSet<>();
|
||||
|
||||
private final List<Location> points = new ArrayList<>();
|
||||
private final List<String> labels = new ArrayList<>();
|
||||
|
||||
// Abschluss-Titel (konfigurierbar)
|
||||
private String endTitle = "§a§lWillkommen!";
|
||||
private String endSubtitle = "§7Viel Spaß auf NexusLobby";
|
||||
|
||||
private File configFile;
|
||||
private FileConfiguration config;
|
||||
|
||||
// --- Einstellungen ---
|
||||
private final int TICKS_FLUG = 70;
|
||||
private final int TICKS_PAUSE = 30;
|
||||
|
||||
private final int TITLE_FADE_IN = 10;
|
||||
private final int TITLE_STAY = 50;
|
||||
private final int TITLE_FADE_OUT = 10;
|
||||
|
||||
@Override
|
||||
public String getName() { return "Intro"; }
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
Bukkit.getPluginManager().registerEvents(this, NexusLobby.getInstance());
|
||||
if (NexusLobby.getInstance().getCommand("intro") != null) {
|
||||
NexusLobby.getInstance().getCommand("intro").setExecutor(this);
|
||||
}
|
||||
loadConfig();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
org.bukkit.event.HandlerList.unregisterAll(this);
|
||||
activeIntro.clear();
|
||||
}
|
||||
|
||||
// ─────────────────────────────────────────────────────────────────────────
|
||||
// Persistenz
|
||||
// ─────────────────────────────────────────────────────────────────────────
|
||||
|
||||
private void loadConfig() {
|
||||
points.clear();
|
||||
labels.clear();
|
||||
configFile = new File(NexusLobby.getInstance().getDataFolder(), "intro.yml");
|
||||
if (!configFile.exists()) {
|
||||
try { configFile.createNewFile(); } catch (IOException ignored) {}
|
||||
}
|
||||
config = YamlConfiguration.loadConfiguration(configFile);
|
||||
|
||||
// Abschluss-Titel laden
|
||||
endTitle = config.getString("end-title", "§a§lWillkommen!");
|
||||
endSubtitle = config.getString("end-subtitle", "§7Viel Spaß auf NexusLobby");
|
||||
|
||||
// Punkte laden
|
||||
List<?> list = config.getList("intro-points");
|
||||
if (list != null) {
|
||||
for (Object obj : list) {
|
||||
if (obj instanceof Map<?, ?> map) {
|
||||
Object locObj = map.get("location");
|
||||
Object labelObj = map.get("label");
|
||||
if (locObj instanceof Location loc) {
|
||||
points.add(loc);
|
||||
labels.add(labelObj != null ? labelObj.toString() : "");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Rückwärts-Kompatibilität
|
||||
if (points.isEmpty()) {
|
||||
List<?> oldList = config.getList("points");
|
||||
if (oldList != null) {
|
||||
for (Object obj : oldList) {
|
||||
if (obj instanceof Location loc) {
|
||||
points.add(loc);
|
||||
labels.add("");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void saveConfig() {
|
||||
// Abschluss-Titel speichern
|
||||
config.set("end-title", endTitle);
|
||||
config.set("end-subtitle", endSubtitle);
|
||||
|
||||
// Punkte speichern
|
||||
List<Map<String, Object>> data = new ArrayList<>();
|
||||
for (int i = 0; i < points.size(); i++) {
|
||||
Map<String, Object> entry = new LinkedHashMap<>();
|
||||
entry.put("location", points.get(i));
|
||||
entry.put("label", labels.get(i));
|
||||
data.add(entry);
|
||||
}
|
||||
config.set("intro-points", data);
|
||||
config.set("points", null);
|
||||
|
||||
try {
|
||||
config.save(configFile);
|
||||
} catch (IOException e) {
|
||||
NexusLobby.getInstance().getLogger().severe("Fehler beim Speichern der Intro-Config: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// ─────────────────────────────────────────────────────────────────────────
|
||||
// Events
|
||||
// ─────────────────────────────────────────────────────────────────────────
|
||||
|
||||
@EventHandler
|
||||
public void onJoin(PlayerJoinEvent event) {
|
||||
if (!event.getPlayer().hasPlayedBefore() && points.size() >= 2) {
|
||||
startIntro(event.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
// ─────────────────────────────────────────────────────────────────────────
|
||||
// Befehle
|
||||
// ─────────────────────────────────────────────────────────────────────────
|
||||
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||
if (!(sender instanceof Player p)) return true;
|
||||
if (!p.hasPermission("nexuslobby.admin")) return true;
|
||||
|
||||
if (args.length == 0) {
|
||||
sendHelp(p);
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args[0].toLowerCase()) {
|
||||
|
||||
case "add" -> {
|
||||
String pointLabel = args.length > 1
|
||||
? String.join(" ", Arrays.copyOfRange(args, 1, args.length))
|
||||
: "";
|
||||
points.add(p.getLocation());
|
||||
labels.add(pointLabel);
|
||||
saveConfig();
|
||||
if (pointLabel.isEmpty()) {
|
||||
p.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§aPunkt §e#" + points.size() + " §awurde gesetzt.");
|
||||
} else {
|
||||
p.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§aPunkt §e#" + points.size() + " §amit Text §e\"" + pointLabel + "\" §agesetzt.");
|
||||
}
|
||||
}
|
||||
|
||||
case "clear" -> {
|
||||
points.clear();
|
||||
labels.clear();
|
||||
saveConfig();
|
||||
p.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§cAlle Intro-Punkte wurden gelöscht.");
|
||||
}
|
||||
|
||||
case "list" -> {
|
||||
if (points.isEmpty()) {
|
||||
p.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§cKeine Punkte vorhanden.");
|
||||
return true;
|
||||
}
|
||||
p.sendMessage("§8§m------------------------------------");
|
||||
p.sendMessage("§6§lIntro-Punkte (" + points.size() + ")");
|
||||
for (int i = 0; i < points.size(); i++) {
|
||||
Location loc = points.get(i);
|
||||
String lbl = labels.get(i).isEmpty() ? "§7(kein Text)" : "§e" + labels.get(i);
|
||||
p.sendMessage("§8#" + (i + 1) + " §7"
|
||||
+ String.format("%.1f", loc.getX()) + ", "
|
||||
+ String.format("%.1f", loc.getY()) + ", "
|
||||
+ String.format("%.1f", loc.getZ())
|
||||
+ " " + lbl);
|
||||
}
|
||||
p.sendMessage("§8§m------------------------------------");
|
||||
}
|
||||
|
||||
case "start" -> {
|
||||
if (points.size() < 2) {
|
||||
p.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§cDu brauchst mindestens 2 Punkte für eine Fahrt.");
|
||||
} else {
|
||||
startIntro(p);
|
||||
}
|
||||
}
|
||||
|
||||
// /intro setendtitle <Text> — setzt den großen Abschluss-Titel
|
||||
case "setendtitle" -> {
|
||||
if (args.length < 2) {
|
||||
p.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§cBenutzung: §e/intro setendtitle <Text>");
|
||||
p.sendMessage("§7Farbcodes mit §e& §7möglich. Beispiel: §e/intro setendtitle &a&lWillkommen!");
|
||||
return true;
|
||||
}
|
||||
endTitle = colorize(String.join(" ", Arrays.copyOfRange(args, 1, args.length)));
|
||||
saveConfig();
|
||||
p.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§aAbschluss-Titel gesetzt: " + endTitle);
|
||||
// Vorschau
|
||||
p.sendTitle(endTitle, endSubtitle, TITLE_FADE_IN, TITLE_STAY, TITLE_FADE_OUT);
|
||||
}
|
||||
|
||||
// /intro setendsubtitle <Text> — setzt den kleinen Abschluss-Untertitel
|
||||
case "setendsubtitle" -> {
|
||||
if (args.length < 2) {
|
||||
p.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§cBenutzung: §e/intro setendsubtitle <Text>");
|
||||
p.sendMessage("§7Farbcodes mit §e& §7möglich. Beispiel: §e/intro setendsubtitle &7Viel Spaß!");
|
||||
return true;
|
||||
}
|
||||
endSubtitle = colorize(String.join(" ", Arrays.copyOfRange(args, 1, args.length)));
|
||||
saveConfig();
|
||||
p.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§aAbschluss-Untertitel gesetzt: " + endSubtitle);
|
||||
// Vorschau
|
||||
p.sendTitle(endTitle, endSubtitle, TITLE_FADE_IN, TITLE_STAY, TITLE_FADE_OUT);
|
||||
}
|
||||
|
||||
default -> sendHelp(p);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void sendHelp(Player p) {
|
||||
p.sendMessage("§8§m------------------------------------");
|
||||
p.sendMessage("§6§lNexus Intro System (Cinematic)");
|
||||
p.sendMessage("§e/intro add [Text] §7- Punkt + optionaler Titel");
|
||||
p.sendMessage("§e/intro clear §7- Alle Punkte löschen");
|
||||
p.sendMessage("§e/intro list §7- Alle Punkte anzeigen");
|
||||
p.sendMessage("§e/intro start §7- Fahrt testen");
|
||||
p.sendMessage("§e/intro setendtitle <Text> §7- Abschluss-Titel setzen");
|
||||
p.sendMessage("§e/intro setendsubtitle <Text> §7- Abschluss-Untertitel setzen");
|
||||
p.sendMessage("§7Aktuell: §r" + endTitle + " §8/ §r" + endSubtitle);
|
||||
p.sendMessage("§8§m------------------------------------");
|
||||
}
|
||||
|
||||
// ─────────────────────────────────────────────────────────────────────────
|
||||
// Intro-Logik
|
||||
// ─────────────────────────────────────────────────────────────────────────
|
||||
|
||||
public void startIntro(Player player) {
|
||||
activeIntro.add(player.getUniqueId());
|
||||
player.setGameMode(GameMode.SPECTATOR);
|
||||
|
||||
// Titel für den ersten Punkt sofort anzeigen
|
||||
showTitleForSegment(player, 0);
|
||||
|
||||
new BukkitRunnable() {
|
||||
int currentSegment = 0;
|
||||
int tickInSegment = 0;
|
||||
boolean isPausing = true;
|
||||
int lastTitleSegment = 0;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
if (!player.isOnline() || !activeIntro.contains(player.getUniqueId())) {
|
||||
this.cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentSegment >= points.size() - 1) {
|
||||
stopIntro(player);
|
||||
this.cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
Location start = points.get(currentSegment);
|
||||
Location end = points.get(currentSegment + 1);
|
||||
|
||||
if (isPausing) {
|
||||
player.teleport(start);
|
||||
tickInSegment++;
|
||||
if (tickInSegment >= TICKS_PAUSE) {
|
||||
isPausing = false;
|
||||
tickInSegment = 0;
|
||||
}
|
||||
} else {
|
||||
double progress = (double) tickInSegment / (double) TICKS_FLUG;
|
||||
double smoothT = progress * progress * (3 - 2 * progress);
|
||||
|
||||
player.teleport(interpolate(start, end, smoothT));
|
||||
|
||||
tickInSegment++;
|
||||
if (tickInSegment >= TICKS_FLUG) {
|
||||
isPausing = true;
|
||||
tickInSegment = 0;
|
||||
currentSegment++;
|
||||
|
||||
if (currentSegment < points.size() && currentSegment != lastTitleSegment) {
|
||||
showTitleForSegment(player, currentSegment);
|
||||
lastTitleSegment = currentSegment;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
this.cancel();
|
||||
stopIntro(player);
|
||||
}
|
||||
}
|
||||
}.runTaskTimer(NexusLobby.getInstance(), 0L, 1L);
|
||||
}
|
||||
|
||||
private void showTitleForSegment(Player player, int segmentIndex) {
|
||||
if (segmentIndex < 0 || segmentIndex >= labels.size()) return;
|
||||
String lbl = labels.get(segmentIndex);
|
||||
if (lbl == null || lbl.isEmpty()) return;
|
||||
|
||||
player.sendTitle(
|
||||
"§6§l" + lbl,
|
||||
"§7✦ NexusLobby ✦",
|
||||
TITLE_FADE_IN,
|
||||
TITLE_STAY,
|
||||
TITLE_FADE_OUT
|
||||
);
|
||||
}
|
||||
|
||||
private Location interpolate(Location start, Location end, double t) {
|
||||
double x = start.getX() + (end.getX() - start.getX()) * t;
|
||||
double y = start.getY() + (end.getY() - start.getY()) * t;
|
||||
double z = start.getZ() + (end.getZ() - start.getZ()) * t;
|
||||
|
||||
float startYaw = start.getYaw();
|
||||
float endYaw = end.getYaw();
|
||||
float diff = (endYaw - startYaw) % 360;
|
||||
if (diff > 180) diff -= 360;
|
||||
if (diff < -180) diff += 360;
|
||||
float yaw = startYaw + diff * (float) t;
|
||||
float pitch = (float) (start.getPitch() + (end.getPitch() - start.getPitch()) * t);
|
||||
|
||||
return new Location(start.getWorld(), x, y, z, yaw, pitch);
|
||||
}
|
||||
|
||||
private void stopIntro(Player player) {
|
||||
activeIntro.remove(player.getUniqueId());
|
||||
player.setGameMode(GameMode.ADVENTURE);
|
||||
player.teleport(player.getWorld().getSpawnLocation());
|
||||
|
||||
// Abschluss-Titel — komplett konfigurierbar
|
||||
player.sendTitle(endTitle, endSubtitle, 10, 60, 20);
|
||||
}
|
||||
|
||||
/** Ersetzt &-Farbcodes durch §-Codes */
|
||||
private String colorize(String input) {
|
||||
return input.replace("&", "§");
|
||||
}
|
||||
}
|
||||
@@ -1,298 +1,310 @@
|
||||
package de.nexuslobby.modules.mapart;
|
||||
|
||||
import de.nexuslobby.NexusLobby;
|
||||
import de.nexuslobby.api.Module;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.ItemFrame;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.MapMeta;
|
||||
import org.bukkit.map.MapCanvas;
|
||||
import org.bukkit.map.MapRenderer;
|
||||
import org.bukkit.map.MapView;
|
||||
import org.bukkit.util.RayTraceResult;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Image;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class MapArtModule implements Module, CommandExecutor {
|
||||
|
||||
private File storageFile;
|
||||
private FileConfiguration storageConfig;
|
||||
|
||||
// RAM-Schutz: Cache für bereits geladene Bild-Kacheln
|
||||
private final Map<String, BufferedImage> tileCache = new ConcurrentHashMap<>();
|
||||
// Hilfs-Set um parallele Downloads der gleichen URL zu verhindern
|
||||
private final Map<String, Boolean> loadingShield = new ConcurrentHashMap<>();
|
||||
|
||||
@Override
|
||||
public String getName() { return "MapArt"; }
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
if (NexusLobby.getInstance().getCommand("mapart") != null) {
|
||||
NexusLobby.getInstance().getCommand("mapart").setExecutor(this);
|
||||
}
|
||||
initStorage();
|
||||
reloadMaps();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
saveStorage();
|
||||
tileCache.clear();
|
||||
}
|
||||
|
||||
private void initStorage() {
|
||||
storageFile = new File(NexusLobby.getInstance().getDataFolder(), "mapart.yml");
|
||||
if (!storageFile.exists()) {
|
||||
try {
|
||||
storageFile.createNewFile();
|
||||
} catch (IOException e) {
|
||||
NexusLobby.getInstance().getLogger().severe("Fehler beim Erstellen der mapart.yml: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
storageConfig = YamlConfiguration.loadConfiguration(storageFile);
|
||||
}
|
||||
|
||||
private void saveStorage() {
|
||||
try {
|
||||
storageConfig.save(storageFile);
|
||||
} catch (IOException e) {
|
||||
NexusLobby.getInstance().getLogger().severe("Fehler beim Speichern der mapart.yml: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private void reloadMaps() {
|
||||
ConfigurationSection section = storageConfig.getConfigurationSection("active_maps");
|
||||
if (section == null) return;
|
||||
|
||||
for (String idStr : section.getKeys(false)) {
|
||||
try {
|
||||
int mapId = Integer.parseInt(idStr);
|
||||
String url = section.getString(idStr + ".url");
|
||||
int x = section.getInt(idStr + ".x");
|
||||
int y = section.getInt(idStr + ".y");
|
||||
int totalW = section.getInt(idStr + ".totalW");
|
||||
int totalH = section.getInt(idStr + ".totalH");
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
MapView view = Bukkit.getMap(mapId);
|
||||
if (view != null) {
|
||||
applyRenderer(view, url, x, y, totalW, totalH);
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||
if (!(sender instanceof Player player)) return true;
|
||||
if (!player.hasPermission("nexuslobby.mapart")) {
|
||||
player.sendMessage("§8[§6Nexus§8] §cKeine Rechte.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length == 0) {
|
||||
sendHelp(player);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("delete")) {
|
||||
int radius = 3;
|
||||
if (args.length == 2) {
|
||||
try {
|
||||
radius = Integer.parseInt(args[1]);
|
||||
} catch (NumberFormatException e) {
|
||||
player.sendMessage("§8[§6Nexus§8] §cUngültiger Radius.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
deleteNearbyMaps(player, radius);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length != 2) {
|
||||
sendHelp(player);
|
||||
return true;
|
||||
}
|
||||
|
||||
RayTraceResult rayTrace = player.rayTraceBlocks(5);
|
||||
if (rayTrace == null || rayTrace.getHitBlock() == null || rayTrace.getHitBlockFace() == null) {
|
||||
player.sendMessage("§8[§6Nexus§8] §cBitte schaue eine Wand direkt an.");
|
||||
return true;
|
||||
}
|
||||
|
||||
Block targetBlock = rayTrace.getHitBlock();
|
||||
BlockFace hitFace = rayTrace.getHitBlockFace();
|
||||
|
||||
if (hitFace == BlockFace.UP || hitFace == BlockFace.DOWN) {
|
||||
player.sendMessage("§8[§6Nexus§8] §cAktuell nur an vertikalen Wänden möglich.");
|
||||
return true;
|
||||
}
|
||||
|
||||
String url = args[0];
|
||||
int width, height;
|
||||
try {
|
||||
String[] parts = args[1].toLowerCase().split("x");
|
||||
width = Integer.parseInt(parts[0]);
|
||||
height = Integer.parseInt(parts[1]);
|
||||
} catch (Exception e) {
|
||||
player.sendMessage("§8[§6Nexus§8] §cUngültiges Format (z.B. 6x4).");
|
||||
return true;
|
||||
}
|
||||
|
||||
player.sendMessage("§8[§6Nexus§8] §7Bild wird verarbeitet...");
|
||||
createRaster(player, targetBlock, hitFace, url, width, height);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void sendHelp(Player p) {
|
||||
p.sendMessage("§8§m------------------------------------");
|
||||
p.sendMessage("§6§lNexus MapArt");
|
||||
p.sendMessage("§e/mapart <URL> <BxH> §7- Bild erstellen");
|
||||
p.sendMessage("§e/mapart delete [Radius] §7- Bilder in der Nähe löschen");
|
||||
p.sendMessage("§8§m------------------------------------");
|
||||
}
|
||||
|
||||
private void deleteNearbyMaps(Player player, int radius) {
|
||||
AtomicInteger count = new AtomicInteger(0);
|
||||
player.getNearbyEntities(radius, radius, radius).forEach(entity -> {
|
||||
if (entity instanceof ItemFrame frame) {
|
||||
ItemStack item = frame.getItem();
|
||||
if (item != null && item.getType() == Material.FILLED_MAP && item.getItemMeta() instanceof MapMeta meta) {
|
||||
if (meta.hasMapView()) {
|
||||
int id = meta.getMapView().getId();
|
||||
if (storageConfig.contains("active_maps." + id)) {
|
||||
storageConfig.set("active_maps." + id, null);
|
||||
frame.remove();
|
||||
count.incrementAndGet();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
saveStorage();
|
||||
player.sendMessage("§8[§6Nexus§8] §aErfolgreich §e" + count.get() + " §aKartenelemente gelöscht.");
|
||||
}
|
||||
|
||||
private void createRaster(Player player, Block startBlock, BlockFace face, String url, int gridW, int gridH) {
|
||||
BlockFace rightDirection;
|
||||
switch (face) {
|
||||
case NORTH: rightDirection = BlockFace.WEST; break;
|
||||
case SOUTH: rightDirection = BlockFace.EAST; break;
|
||||
case EAST: rightDirection = BlockFace.NORTH; break;
|
||||
case WEST: rightDirection = BlockFace.SOUTH; break;
|
||||
default: rightDirection = BlockFace.EAST;
|
||||
}
|
||||
|
||||
Block origin = startBlock.getRelative(face);
|
||||
|
||||
for (int y = 0; y < gridH; y++) {
|
||||
for (int x = 0; x < gridW; x++) {
|
||||
Block currentPos = origin.getRelative(rightDirection, x).getRelative(BlockFace.DOWN, y);
|
||||
spawnPersistentFrame(player, currentPos, face, url, x, y, gridW, gridH);
|
||||
}
|
||||
}
|
||||
player.sendMessage("§8[§6Nexus§8] §aBild-Raster wurde permanent platziert!");
|
||||
}
|
||||
|
||||
private void spawnPersistentFrame(Player player, Block pos, BlockFace face, String url, int x, int y, int totalW, int totalH) {
|
||||
MapView view = Bukkit.createMap(player.getWorld());
|
||||
applyRenderer(view, url, x, y, totalW, totalH);
|
||||
|
||||
String path = "active_maps." + view.getId();
|
||||
storageConfig.set(path + ".url", url);
|
||||
storageConfig.set(path + ".x", x);
|
||||
storageConfig.set(path + ".y", y);
|
||||
storageConfig.set(path + ".totalW", totalW);
|
||||
storageConfig.set(path + ".totalH", totalH);
|
||||
saveStorage();
|
||||
|
||||
ItemStack mapStack = new ItemStack(Material.FILLED_MAP);
|
||||
MapMeta meta = (MapMeta) mapStack.getItemMeta();
|
||||
if (meta != null) {
|
||||
meta.setMapView(view);
|
||||
mapStack.setItemMeta(meta);
|
||||
}
|
||||
|
||||
try {
|
||||
ItemFrame frame = player.getWorld().spawn(pos.getLocation(), ItemFrame.class);
|
||||
frame.setFacingDirection(face);
|
||||
frame.setItem(mapStack);
|
||||
frame.setVisible(false);
|
||||
frame.setFixed(true);
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
|
||||
private void applyRenderer(MapView view, String url, int tileX, int tileY, int totalW, int totalH) {
|
||||
view.getRenderers().forEach(view::removeRenderer);
|
||||
view.addRenderer(new MapRenderer() {
|
||||
private final String cacheKey = url + "_" + totalW + "x" + totalH + "_" + tileX + "_" + tileY;
|
||||
private boolean errorLogged = false;
|
||||
|
||||
@Override
|
||||
public void render(@NotNull MapView map, @NotNull MapCanvas canvas, @NotNull Player p) {
|
||||
// 1. Wenn Kachel im Cache, sofort zeichnen (extrem schnell)
|
||||
if (tileCache.containsKey(cacheKey)) {
|
||||
canvas.drawImage(0, 0, tileCache.get(cacheKey));
|
||||
return;
|
||||
}
|
||||
|
||||
// 2. Wenn bereits ein Thread für diese URL lädt, abbrechen (verhindert Spam)
|
||||
if (loadingShield.containsKey(url)) return;
|
||||
|
||||
// 3. Bild asynchron laden
|
||||
loadingShield.put(url, true);
|
||||
Bukkit.getScheduler().runTaskAsynchronously(NexusLobby.getInstance(), () -> {
|
||||
try {
|
||||
BufferedImage original = ImageIO.read(new URL(url));
|
||||
if (original != null) {
|
||||
int targetW = totalW * 128;
|
||||
int targetH = totalH * 128;
|
||||
|
||||
BufferedImage fullScaled = new BufferedImage(targetW, targetH, BufferedImage.TYPE_INT_ARGB);
|
||||
Graphics2D g = fullScaled.createGraphics();
|
||||
g.drawImage(original.getScaledInstance(targetW, targetH, Image.SCALE_SMOOTH), 0, 0, null);
|
||||
g.dispose();
|
||||
|
||||
// Alle benötigten Kacheln für dieses Bild in den Cache legen
|
||||
for (int ty = 0; ty < totalH; ty++) {
|
||||
for (int tx = 0; tx < totalW; tx++) {
|
||||
String key = url + "_" + totalW + "x" + totalH + "_" + tx + "_" + ty;
|
||||
tileCache.put(key, fullScaled.getSubimage(tx * 128, ty * 128, 128, 128));
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
if (!errorLogged) {
|
||||
NexusLobby.getInstance().getLogger().warning("Fehler beim Laden von MapArt: " + url);
|
||||
errorLogged = true;
|
||||
}
|
||||
} finally {
|
||||
loadingShield.remove(url);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
package de.nexuslobby.modules.mapart;
|
||||
|
||||
import de.nexuslobby.NexusLobby;
|
||||
import de.nexuslobby.api.Module;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.ItemFrame;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.MapMeta;
|
||||
import org.bukkit.map.MapCanvas;
|
||||
import org.bukkit.map.MapRenderer;
|
||||
import org.bukkit.map.MapView;
|
||||
import org.bukkit.util.RayTraceResult;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Image;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class MapArtModule implements Module, CommandExecutor {
|
||||
|
||||
private File storageFile;
|
||||
private FileConfiguration storageConfig;
|
||||
|
||||
// FIX: Unbegrenzter Cache führt bei vielen verschiedenen Bild-URLs zu einem
|
||||
// OutOfMemoryError. Stattdessen nutzen wir einen LRU-Cache mit max. 50 Einträgen.
|
||||
// Älteste Kacheln werden automatisch verdrängt.
|
||||
private static final int MAX_CACHE_SIZE = 50;
|
||||
private final Map<String, BufferedImage> tileCache = Collections.synchronizedMap(
|
||||
new LinkedHashMap<String, BufferedImage>(MAX_CACHE_SIZE + 1, 0.75f, true) {
|
||||
@Override
|
||||
protected boolean removeEldestEntry(Map.Entry<String, BufferedImage> eldest) {
|
||||
return size() > MAX_CACHE_SIZE;
|
||||
}
|
||||
}
|
||||
);
|
||||
// Hilfs-Set um parallele Downloads der gleichen URL zu verhindern
|
||||
private final Map<String, Boolean> loadingShield = new ConcurrentHashMap<>();
|
||||
|
||||
@Override
|
||||
public String getName() { return "MapArt"; }
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
if (NexusLobby.getInstance().getCommand("mapart") != null) {
|
||||
NexusLobby.getInstance().getCommand("mapart").setExecutor(this);
|
||||
}
|
||||
initStorage();
|
||||
reloadMaps();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
saveStorage();
|
||||
tileCache.clear();
|
||||
}
|
||||
|
||||
private void initStorage() {
|
||||
storageFile = new File(NexusLobby.getInstance().getDataFolder(), "mapart.yml");
|
||||
if (!storageFile.exists()) {
|
||||
try {
|
||||
storageFile.createNewFile();
|
||||
} catch (IOException e) {
|
||||
NexusLobby.getInstance().getLogger().severe("Fehler beim Erstellen der mapart.yml: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
storageConfig = YamlConfiguration.loadConfiguration(storageFile);
|
||||
}
|
||||
|
||||
private void saveStorage() {
|
||||
try {
|
||||
storageConfig.save(storageFile);
|
||||
} catch (IOException e) {
|
||||
NexusLobby.getInstance().getLogger().severe("Fehler beim Speichern der mapart.yml: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private void reloadMaps() {
|
||||
ConfigurationSection section = storageConfig.getConfigurationSection("active_maps");
|
||||
if (section == null) return;
|
||||
|
||||
for (String idStr : section.getKeys(false)) {
|
||||
try {
|
||||
int mapId = Integer.parseInt(idStr);
|
||||
String url = section.getString(idStr + ".url");
|
||||
int x = section.getInt(idStr + ".x");
|
||||
int y = section.getInt(idStr + ".y");
|
||||
int totalW = section.getInt(idStr + ".totalW");
|
||||
int totalH = section.getInt(idStr + ".totalH");
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
MapView view = Bukkit.getMap(mapId);
|
||||
if (view != null) {
|
||||
applyRenderer(view, url, x, y, totalW, totalH);
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||
if (!(sender instanceof Player player)) return true;
|
||||
if (!player.hasPermission("nexuslobby.mapart")) {
|
||||
player.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§cKeine Rechte.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length == 0) {
|
||||
sendHelp(player);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("delete")) {
|
||||
int radius = 3;
|
||||
if (args.length == 2) {
|
||||
try {
|
||||
radius = Integer.parseInt(args[1]);
|
||||
} catch (NumberFormatException e) {
|
||||
player.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§cUngültiger Radius.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
deleteNearbyMaps(player, radius);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length != 2) {
|
||||
sendHelp(player);
|
||||
return true;
|
||||
}
|
||||
|
||||
RayTraceResult rayTrace = player.rayTraceBlocks(5);
|
||||
if (rayTrace == null || rayTrace.getHitBlock() == null || rayTrace.getHitBlockFace() == null) {
|
||||
player.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§cBitte schaue eine Wand direkt an.");
|
||||
return true;
|
||||
}
|
||||
|
||||
Block targetBlock = rayTrace.getHitBlock();
|
||||
BlockFace hitFace = rayTrace.getHitBlockFace();
|
||||
|
||||
if (hitFace == BlockFace.UP || hitFace == BlockFace.DOWN) {
|
||||
player.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§cAktuell nur an vertikalen Wänden möglich.");
|
||||
return true;
|
||||
}
|
||||
|
||||
String url = args[0];
|
||||
int width, height;
|
||||
try {
|
||||
String[] parts = args[1].toLowerCase().split("x");
|
||||
width = Integer.parseInt(parts[0]);
|
||||
height = Integer.parseInt(parts[1]);
|
||||
} catch (Exception e) {
|
||||
player.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§cUngültiges Format (z.B. 6x4).");
|
||||
return true;
|
||||
}
|
||||
|
||||
player.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§7Bild wird verarbeitet...");
|
||||
createRaster(player, targetBlock, hitFace, url, width, height);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void sendHelp(Player p) {
|
||||
p.sendMessage("§8§m------------------------------------");
|
||||
p.sendMessage("§6§lNexus MapArt");
|
||||
p.sendMessage("§e/mapart <URL> <BxH> §7- Bild erstellen");
|
||||
p.sendMessage("§e/mapart delete [Radius] §7- Bilder in der Nähe löschen");
|
||||
p.sendMessage("§8§m------------------------------------");
|
||||
}
|
||||
|
||||
private void deleteNearbyMaps(Player player, int radius) {
|
||||
AtomicInteger count = new AtomicInteger(0);
|
||||
player.getNearbyEntities(radius, radius, radius).forEach(entity -> {
|
||||
if (entity instanceof ItemFrame frame) {
|
||||
ItemStack item = frame.getItem();
|
||||
if (item != null && item.getType() == Material.FILLED_MAP && item.getItemMeta() instanceof MapMeta meta) {
|
||||
if (meta.hasMapView()) {
|
||||
int id = meta.getMapView().getId();
|
||||
if (storageConfig.contains("active_maps." + id)) {
|
||||
storageConfig.set("active_maps." + id, null);
|
||||
frame.remove();
|
||||
count.incrementAndGet();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
saveStorage();
|
||||
player.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§aErfolgreich §e" + count.get() + " §aKartenelemente gelöscht.");
|
||||
}
|
||||
|
||||
private void createRaster(Player player, Block startBlock, BlockFace face, String url, int gridW, int gridH) {
|
||||
BlockFace rightDirection;
|
||||
switch (face) {
|
||||
case NORTH: rightDirection = BlockFace.WEST; break;
|
||||
case SOUTH: rightDirection = BlockFace.EAST; break;
|
||||
case EAST: rightDirection = BlockFace.NORTH; break;
|
||||
case WEST: rightDirection = BlockFace.SOUTH; break;
|
||||
default: rightDirection = BlockFace.EAST;
|
||||
}
|
||||
|
||||
Block origin = startBlock.getRelative(face);
|
||||
|
||||
for (int y = 0; y < gridH; y++) {
|
||||
for (int x = 0; x < gridW; x++) {
|
||||
Block currentPos = origin.getRelative(rightDirection, x).getRelative(BlockFace.DOWN, y);
|
||||
spawnPersistentFrame(player, currentPos, face, url, x, y, gridW, gridH);
|
||||
}
|
||||
}
|
||||
player.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§aBild-Raster wurde permanent platziert!");
|
||||
}
|
||||
|
||||
private void spawnPersistentFrame(Player player, Block pos, BlockFace face, String url, int x, int y, int totalW, int totalH) {
|
||||
MapView view = Bukkit.createMap(player.getWorld());
|
||||
applyRenderer(view, url, x, y, totalW, totalH);
|
||||
|
||||
String path = "active_maps." + view.getId();
|
||||
storageConfig.set(path + ".url", url);
|
||||
storageConfig.set(path + ".x", x);
|
||||
storageConfig.set(path + ".y", y);
|
||||
storageConfig.set(path + ".totalW", totalW);
|
||||
storageConfig.set(path + ".totalH", totalH);
|
||||
saveStorage();
|
||||
|
||||
ItemStack mapStack = new ItemStack(Material.FILLED_MAP);
|
||||
MapMeta meta = (MapMeta) mapStack.getItemMeta();
|
||||
if (meta != null) {
|
||||
meta.setMapView(view);
|
||||
mapStack.setItemMeta(meta);
|
||||
}
|
||||
|
||||
try {
|
||||
ItemFrame frame = player.getWorld().spawn(pos.getLocation(), ItemFrame.class);
|
||||
frame.setFacingDirection(face);
|
||||
frame.setItem(mapStack);
|
||||
frame.setVisible(false);
|
||||
frame.setFixed(true);
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
|
||||
private void applyRenderer(MapView view, String url, int tileX, int tileY, int totalW, int totalH) {
|
||||
view.getRenderers().forEach(view::removeRenderer);
|
||||
view.addRenderer(new MapRenderer() {
|
||||
private final String cacheKey = url + "_" + totalW + "x" + totalH + "_" + tileX + "_" + tileY;
|
||||
private boolean errorLogged = false;
|
||||
|
||||
@Override
|
||||
public void render(@NotNull MapView map, @NotNull MapCanvas canvas, @NotNull Player p) {
|
||||
// 1. Wenn Kachel im Cache, sofort zeichnen (extrem schnell)
|
||||
if (tileCache.containsKey(cacheKey)) {
|
||||
canvas.drawImage(0, 0, tileCache.get(cacheKey));
|
||||
return;
|
||||
}
|
||||
|
||||
// 2. Wenn bereits ein Thread für diese URL lädt, abbrechen (verhindert Spam)
|
||||
if (loadingShield.containsKey(url)) return;
|
||||
|
||||
// 3. Bild asynchron laden
|
||||
loadingShield.put(url, true);
|
||||
Bukkit.getScheduler().runTaskAsynchronously(NexusLobby.getInstance(), () -> {
|
||||
try {
|
||||
BufferedImage original = ImageIO.read(new URL(url));
|
||||
if (original != null) {
|
||||
int targetW = totalW * 128;
|
||||
int targetH = totalH * 128;
|
||||
|
||||
BufferedImage fullScaled = new BufferedImage(targetW, targetH, BufferedImage.TYPE_INT_ARGB);
|
||||
Graphics2D g = fullScaled.createGraphics();
|
||||
g.drawImage(original.getScaledInstance(targetW, targetH, Image.SCALE_SMOOTH), 0, 0, null);
|
||||
g.dispose();
|
||||
|
||||
// Alle benötigten Kacheln für dieses Bild in den Cache legen
|
||||
for (int ty = 0; ty < totalH; ty++) {
|
||||
for (int tx = 0; tx < totalW; tx++) {
|
||||
String key = url + "_" + totalW + "x" + totalH + "_" + tx + "_" + ty;
|
||||
tileCache.put(key, fullScaled.getSubimage(tx * 128, ty * 128, 128, 128));
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
if (!errorLogged) {
|
||||
NexusLobby.getInstance().getLogger().warning("Fehler beim Laden von MapArt: " + url);
|
||||
errorLogged = true;
|
||||
}
|
||||
} finally {
|
||||
loadingShield.remove(url);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,113 +1,107 @@
|
||||
package de.nexuslobby.modules.parkour;
|
||||
|
||||
import de.nexuslobby.NexusLobby;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class ParkourListener implements Listener {
|
||||
|
||||
private final ParkourManager manager;
|
||||
private final String NPC_TAG = "parkour_npc";
|
||||
private final HashMap<UUID, Long> startCooldown = new HashMap<>();
|
||||
|
||||
public ParkourListener(ParkourManager manager) {
|
||||
this.manager = manager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Startet den Parkour per Rechtsklick auf den ArmorStand
|
||||
*/
|
||||
@EventHandler
|
||||
public void onInteract(PlayerInteractAtEntityEvent event) {
|
||||
if (!(event.getRightClicked() instanceof ArmorStand as)) return;
|
||||
|
||||
// Prüfen, ob der ArmorStand den richtigen Tag hat
|
||||
if (as.getScoreboardTags().contains(NPC_TAG)) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
// Abbrechen, wenn der Spieler schon im Parkour ist
|
||||
if (manager.isIngame(player)) return;
|
||||
|
||||
// Cooldown-Check (3 Sekunden)
|
||||
if (startCooldown.containsKey(player.getUniqueId())) {
|
||||
if (System.currentTimeMillis() - startCooldown.get(player.getUniqueId()) < 3000) {
|
||||
player.sendMessage("§cBitte warte einen Moment, bevor du erneut startest.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Parkour starten
|
||||
manager.startParkour(player, as.getLocation());
|
||||
player.sendMessage("§8[§6Parkour§8] §eViel Erfolg! Erreiche das Ziel so schnell wie möglich.");
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1f, 1f);
|
||||
|
||||
// Event abbrechen, damit man keine Ausrüstung vom ArmorStand klaut
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onMove(PlayerMoveEvent event) {
|
||||
// Performance: Nur berechnen, wenn ein voller Block gewechselt wurde
|
||||
if (event.getFrom().getBlockX() == event.getTo().getBlockX() &&
|
||||
event.getFrom().getBlockY() == event.getTo().getBlockY() &&
|
||||
event.getFrom().getBlockZ() == event.getTo().getBlockZ()) return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
if (!manager.isIngame(player)) return;
|
||||
|
||||
Location loc = player.getLocation();
|
||||
|
||||
// --- 1. ABSTURZ-CHECK ---
|
||||
// Passe die Höhe '50' an deine Map an!
|
||||
if (loc.getY() < 50) {
|
||||
Location lastCp = manager.getCheckpoint(player);
|
||||
if (lastCp != null) {
|
||||
player.teleport(lastCp);
|
||||
player.sendMessage("§8[§6Parkour§8] §cAbgestürzt! Zurück zum Checkpoint.");
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_ENDERMAN_TELEPORT, 0.5f, 1.0f);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// --- 2. CHECKPOINT-CHECK ---
|
||||
List<Location> cps = manager.getOrderedCheckpoints();
|
||||
for (int i = 0; i < cps.size(); i++) {
|
||||
if (isNearby(loc, cps.get(i))) {
|
||||
manager.reachCheckpoint(player, i);
|
||||
}
|
||||
}
|
||||
|
||||
// --- 3. ZIEL-CHECK ---
|
||||
Location finish = manager.getFinishLocation();
|
||||
if (finish != null && isNearby(loc, finish)) {
|
||||
manager.finishParkour(player);
|
||||
// Nach dem Ziel setzen wir einen Cooldown
|
||||
startCooldown.put(player.getUniqueId(), System.currentTimeMillis());
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isNearby(Location playerLoc, Location targetLoc) {
|
||||
if (playerLoc.getWorld() == null || !playerLoc.getWorld().equals(targetLoc.getWorld())) return false;
|
||||
// 2.25 entspricht einem Radius von ca. 1.5 Blöcken
|
||||
return playerLoc.distanceSquared(targetLoc) <= 2.25;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onQuit(PlayerQuitEvent event) {
|
||||
UUID uuid = event.getPlayer().getUniqueId();
|
||||
manager.stopParkour(event.getPlayer());
|
||||
startCooldown.remove(uuid);
|
||||
}
|
||||
package de.nexuslobby.modules.parkour;
|
||||
|
||||
import de.nexuslobby.NexusLobby;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class ParkourListener implements Listener {
|
||||
|
||||
private final ParkourManager manager;
|
||||
private final String NPC_TAG = "parkour_npc";
|
||||
private final HashMap<UUID, Long> startCooldown = new HashMap<>();
|
||||
|
||||
public ParkourListener(ParkourManager manager) {
|
||||
this.manager = manager;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInteract(PlayerInteractAtEntityEvent event) {
|
||||
if (!(event.getRightClicked() instanceof ArmorStand as)) return;
|
||||
if (!as.getScoreboardTags().contains(NPC_TAG)) return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
event.setCancelled(true);
|
||||
|
||||
if (manager.isIngame(player)) return;
|
||||
|
||||
// Cooldown-Check (3 Sekunden)
|
||||
if (startCooldown.containsKey(player.getUniqueId())) {
|
||||
if (System.currentTimeMillis() - startCooldown.get(player.getUniqueId()) < 3000) {
|
||||
player.sendMessage("§cBitte warte einen Moment, bevor du erneut startest.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
manager.startParkour(player, as.getLocation());
|
||||
// Strecken-Nummer dem Spieler mitteilen
|
||||
int track = manager.getActiveTrack(player);
|
||||
if (track != -1) {
|
||||
player.sendMessage("§8[§6Parkour§8] §eViel Erfolg auf §bStrecke " + track + "§e! Erreiche das Ziel so schnell wie möglich.");
|
||||
}
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1f, 1f);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onMove(PlayerMoveEvent event) {
|
||||
// Performance: Nur bei Block-Wechsel berechnen
|
||||
if (event.getFrom().getBlockX() == event.getTo().getBlockX() &&
|
||||
event.getFrom().getBlockY() == event.getTo().getBlockY() &&
|
||||
event.getFrom().getBlockZ() == event.getTo().getBlockZ()) return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
if (!manager.isIngame(player)) return;
|
||||
|
||||
Location loc = player.getLocation();
|
||||
|
||||
// --- 1. ABSTURZ-CHECK ---
|
||||
// Absturz-Y aus config lesen (Standard: 50), damit Maps unter Y=50 korrekt funktionieren
|
||||
double fallY = NexusLobby.getInstance().getConfig().getDouble("parkour.fall_y", 50.0);
|
||||
if (loc.getY() < fallY) {
|
||||
Location lastCp = manager.getCheckpoint(player);
|
||||
if (lastCp != null) {
|
||||
player.teleport(lastCp);
|
||||
player.sendMessage("§8[§6Parkour§8] §cAbgestürzt! Zurück zum Checkpoint.");
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_ENDERMAN_TELEPORT, 0.5f, 1.0f);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// --- 2. CHECKPOINT-CHECK (Track-spezifisch) ---
|
||||
List<Location> cps = manager.getOrderedCheckpoints(player);
|
||||
for (int i = 0; i < cps.size(); i++) {
|
||||
if (isNearby(loc, cps.get(i))) {
|
||||
manager.reachCheckpoint(player, i);
|
||||
}
|
||||
}
|
||||
|
||||
// --- 3. ZIEL-CHECK (Track-spezifisch) ---
|
||||
Location finish = manager.getFinishLocation(player);
|
||||
if (finish != null && isNearby(loc, finish)) {
|
||||
manager.finishParkour(player);
|
||||
startCooldown.put(player.getUniqueId(), System.currentTimeMillis());
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isNearby(Location playerLoc, Location targetLoc) {
|
||||
if (playerLoc.getWorld() == null || !playerLoc.getWorld().equals(targetLoc.getWorld())) return false;
|
||||
return playerLoc.distanceSquared(targetLoc) <= 2.25; // ~1.5 Blöcke Radius
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onQuit(PlayerQuitEvent event) {
|
||||
UUID uuid = event.getPlayer().getUniqueId();
|
||||
manager.stopParkour(event.getPlayer());
|
||||
startCooldown.remove(uuid);
|
||||
}
|
||||
}
|
||||
@@ -1,241 +1,464 @@
|
||||
package de.nexuslobby.modules.parkour;
|
||||
|
||||
import de.nexuslobby.NexusLobby;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ParkourManager {
|
||||
|
||||
private final NexusLobby plugin;
|
||||
private final File file;
|
||||
private FileConfiguration config;
|
||||
|
||||
private final Map<UUID, Long> startTime = new HashMap<>();
|
||||
private final Map<UUID, Location> lastCheckpointLoc = new HashMap<>();
|
||||
private final Map<UUID, Integer> nextCheckpointIndex = new HashMap<>();
|
||||
|
||||
public ParkourManager(NexusLobby plugin) {
|
||||
this.plugin = plugin;
|
||||
this.file = new File(plugin.getDataFolder(), "parkour.yml");
|
||||
loadConfig();
|
||||
startParticleTask();
|
||||
}
|
||||
|
||||
private void loadConfig() {
|
||||
if (!file.exists()) {
|
||||
file.getParentFile().mkdirs();
|
||||
try {
|
||||
file.createNewFile();
|
||||
} catch (IOException e) {
|
||||
plugin.getLogger().severe("Fehler beim Erstellen der Parkour-Datei: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
config = YamlConfiguration.loadConfiguration(file);
|
||||
}
|
||||
|
||||
public void setCheckpoint(Player player, Location loc) {
|
||||
int nextId = 1;
|
||||
if (config.contains("locations.checkpoints") && config.getConfigurationSection("locations.checkpoints") != null) {
|
||||
nextId = config.getConfigurationSection("locations.checkpoints").getKeys(false).size() + 1;
|
||||
}
|
||||
|
||||
addCheckpointLocation(String.valueOf(nextId), loc);
|
||||
player.sendMessage("§8[§6Parkour§8] §7Checkpoint §e#" + nextId + " §7an deiner Position gesetzt.");
|
||||
player.playSound(player.getLocation(), Sound.BLOCK_AMETHYST_BLOCK_CHIME, 1.0f, 1.5f);
|
||||
}
|
||||
|
||||
/**
|
||||
* Löscht die gesamte Strecke (Checkpoints und Ziel) und bricht aktuelle Läufe ab.
|
||||
*/
|
||||
public void removeAllPoints() {
|
||||
config.set("locations.checkpoints", null);
|
||||
config.set("locations.finish", null);
|
||||
save();
|
||||
|
||||
// Alle Spieler aus dem Parkour werfen, damit keine Partikel zu gelöschten Zielen führen
|
||||
for (UUID uuid : new HashSet<>(startTime.keySet())) {
|
||||
Player p = Bukkit.getPlayer(uuid);
|
||||
if (p != null) {
|
||||
stopParkour(p);
|
||||
p.sendMessage("§8[§6Parkour§8] §cDie aktuelle Strecke wurde soeben gelöscht.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void startParkour(Player player, Location startLoc) {
|
||||
if (startTime.containsKey(player.getUniqueId())) return;
|
||||
|
||||
startTime.put(player.getUniqueId(), System.currentTimeMillis());
|
||||
lastCheckpointLoc.put(player.getUniqueId(), startLoc);
|
||||
nextCheckpointIndex.put(player.getUniqueId(), 0);
|
||||
|
||||
player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_CHIME, 1.0f, 1.2f);
|
||||
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!isIngame(player) || !player.isOnline()) {
|
||||
this.cancel();
|
||||
return;
|
||||
}
|
||||
long diff = System.currentTimeMillis() - startTime.get(player.getUniqueId());
|
||||
double sec = diff / 1000.0;
|
||||
player.spigot().sendMessage(ChatMessageType.ACTION_BAR,
|
||||
new TextComponent("§6⏱ Zeit: §e" + String.format("%.2f", sec) + "s §8| §bNächster Punkt: §7Partikel folgen"));
|
||||
}
|
||||
}.runTaskTimer(plugin, 0L, 1L);
|
||||
}
|
||||
|
||||
private void startParticleTask() {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (UUID uuid : startTime.keySet()) {
|
||||
Player p = Bukkit.getPlayer(uuid);
|
||||
if (p == null) continue;
|
||||
|
||||
int nextIdx = nextCheckpointIndex.getOrDefault(uuid, 0);
|
||||
List<Location> cps = getOrderedCheckpoints();
|
||||
|
||||
if (nextIdx < cps.size()) {
|
||||
Location nextCp = cps.get(nextIdx);
|
||||
if (nextCp != null && p.getWorld().equals(nextCp.getWorld())) {
|
||||
p.spawnParticle(Particle.SOUL_FIRE_FLAME, nextCp.clone().add(0, 0.5, 0), 5, 0.1, 0.3, 0.1, 0.02);
|
||||
}
|
||||
} else {
|
||||
Location finish = getFinishLocation();
|
||||
if (finish != null && p.getWorld().equals(finish.getWorld())) {
|
||||
p.spawnParticle(Particle.HAPPY_VILLAGER, finish.clone().add(0, 0.5, 0), 8, 0.2, 0.5, 0.2, 0.02);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}.runTaskTimer(plugin, 0L, 6L);
|
||||
}
|
||||
|
||||
public void reachCheckpoint(Player player, int reachedIndex) {
|
||||
int currentNext = nextCheckpointIndex.getOrDefault(player.getUniqueId(), 0);
|
||||
|
||||
if (reachedIndex == currentNext) {
|
||||
List<Location> cps = getOrderedCheckpoints();
|
||||
if (reachedIndex < cps.size()) {
|
||||
lastCheckpointLoc.put(player.getUniqueId(), cps.get(reachedIndex));
|
||||
nextCheckpointIndex.put(player.getUniqueId(), reachedIndex + 1);
|
||||
|
||||
player.sendMessage("§8[§6Parkour§8] §bCheckpoint #" + (reachedIndex + 1) + " erreicht!");
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 0.8f, 1.5f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void finishParkour(Player player) {
|
||||
if (!startTime.containsKey(player.getUniqueId())) return;
|
||||
|
||||
if (nextCheckpointIndex.getOrDefault(player.getUniqueId(), 0) < getOrderedCheckpoints().size()) {
|
||||
player.sendMessage("§cDu hast Checkpoints übersprungen! Folge den Partikeln.");
|
||||
return;
|
||||
}
|
||||
|
||||
long duration = System.currentTimeMillis() - startTime.get(player.getUniqueId());
|
||||
double seconds = duration / 1000.0;
|
||||
|
||||
player.sendMessage("§8§m--------------------------------------");
|
||||
player.sendMessage("§8[§6Parkour§8] §a§lZiel erreicht!");
|
||||
player.sendMessage("§7Deine Zeit: §e" + String.format("%.2f", seconds) + "s");
|
||||
player.sendMessage("§8§m--------------------------------------");
|
||||
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1.0f, 1.0f);
|
||||
|
||||
saveBestTime(player, seconds);
|
||||
stopParkour(player);
|
||||
}
|
||||
|
||||
public void stopParkour(Player player) {
|
||||
startTime.remove(player.getUniqueId());
|
||||
lastCheckpointLoc.remove(player.getUniqueId());
|
||||
nextCheckpointIndex.remove(player.getUniqueId());
|
||||
}
|
||||
|
||||
public void setStartLocation(Location loc) { config.set("locations.start", loc); save(); }
|
||||
public void setFinishLocation(Location loc) { config.set("locations.finish", loc); save(); }
|
||||
public void addCheckpointLocation(String id, Location loc) { config.set("locations.checkpoints." + id, loc); save(); }
|
||||
|
||||
public Location getStartLocation() { return config.getLocation("locations.start"); }
|
||||
public Location getFinishLocation() { return config.getLocation("locations.finish"); }
|
||||
|
||||
public List<Location> getOrderedCheckpoints() {
|
||||
if (!config.contains("locations.checkpoints") || config.getConfigurationSection("locations.checkpoints") == null)
|
||||
return new ArrayList<>();
|
||||
|
||||
return config.getConfigurationSection("locations.checkpoints").getKeys(false).stream()
|
||||
.sorted(Comparator.comparingInt(Integer::parseInt))
|
||||
.map(key -> config.getLocation("locations.checkpoints." + key))
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private void save() {
|
||||
try {
|
||||
config.save(file);
|
||||
} catch (IOException e) {
|
||||
plugin.getLogger().severe("Fehler beim Speichern der Parkour-Config: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void clearStats() {
|
||||
config.set("besttimes", null);
|
||||
config.set("names", null);
|
||||
save();
|
||||
}
|
||||
|
||||
public boolean isIngame(Player player) { return startTime.containsKey(player.getUniqueId()); }
|
||||
public Location getCheckpoint(Player player) { return lastCheckpointLoc.get(player.getUniqueId()); }
|
||||
|
||||
private void saveBestTime(Player player, double time) {
|
||||
String path = "besttimes." + player.getUniqueId();
|
||||
double currentTime = config.getDouble(path, 99999.9);
|
||||
if (time < currentTime) {
|
||||
config.set(path, time);
|
||||
config.set("names." + player.getUniqueId(), player.getName());
|
||||
save();
|
||||
player.sendMessage("§8[§6Parkour§8] §6§lNeuer Rekord! §7Du hast dich verbessert.");
|
||||
}
|
||||
}
|
||||
|
||||
public String getTopTen() {
|
||||
if (!config.contains("besttimes") || config.getConfigurationSection("besttimes") == null)
|
||||
return "§6§l🏆 TOP 10 PARKOUR 🏆\n§7Noch keine Rekorde.";
|
||||
|
||||
Map<String, Double> allTimes = new HashMap<>();
|
||||
for (String uuidStr : config.getConfigurationSection("besttimes").getKeys(false)) {
|
||||
allTimes.put(uuidStr, config.getDouble("besttimes." + uuidStr));
|
||||
}
|
||||
|
||||
List<Map.Entry<String, Double>> sortedList = allTimes.entrySet().stream()
|
||||
.sorted(Map.Entry.comparingByValue())
|
||||
.limit(10)
|
||||
.toList();
|
||||
|
||||
StringBuilder builder = new StringBuilder("§6§l🏆 TOP 10 PARKOUR 🏆");
|
||||
int rank = 1;
|
||||
for (Map.Entry<String, Double> entry : sortedList) {
|
||||
String name = config.getString("names." + entry.getKey(), "Unbekannt");
|
||||
builder.append("\n§e#").append(rank).append(" §f").append(name).append(" §8» §a").append(String.format("%.2f", entry.getValue())).append("s");
|
||||
rank++;
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
package de.nexuslobby.modules.parkour;
|
||||
|
||||
import de.nexuslobby.NexusLobby;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* ParkourManager – unterstützt zwei Strecken (Track 1 & 2).
|
||||
*
|
||||
* Config-Struktur (parkour.yml):
|
||||
* tracks:
|
||||
* 1:
|
||||
* start: <Location>
|
||||
* finish: <Location>
|
||||
* checkpoints:
|
||||
* 1: <Location>
|
||||
* 2: <Location>
|
||||
* ...
|
||||
* 2:
|
||||
* start: <Location>
|
||||
* finish: <Location>
|
||||
* checkpoints:
|
||||
* 1: <Location>
|
||||
* ...
|
||||
* besttimes:
|
||||
* <uuid>: <seconds>
|
||||
* names:
|
||||
* <uuid>: <playerName>
|
||||
*
|
||||
* Beim Start wird zufällig eine der beiden konfigurierten Strecken ausgewählt.
|
||||
* Beide Strecken müssen die gleiche Anzahl an Checkpoints haben – andernfalls
|
||||
* wird nur die vollständige gewählt.
|
||||
*/
|
||||
public class ParkourManager {
|
||||
|
||||
private final NexusLobby plugin;
|
||||
private final File file;
|
||||
private FileConfiguration config;
|
||||
|
||||
// Aktive Läufe
|
||||
private final Map<UUID, Long> startTime = new HashMap<>();
|
||||
private final Map<UUID, Location> lastCheckpointLoc = new HashMap<>();
|
||||
private final Map<UUID, Integer> nextCheckpointIndex= new HashMap<>();
|
||||
/** Welche Track-Nummer (1 oder 2) der Spieler gerade läuft */
|
||||
private final Map<UUID, Integer> activeTrack = new HashMap<>();
|
||||
|
||||
private final Random random = new Random();
|
||||
|
||||
public ParkourManager(NexusLobby plugin) {
|
||||
this.plugin = plugin;
|
||||
this.file = new File(plugin.getDataFolder(), "parkour.yml");
|
||||
loadConfig();
|
||||
migrateLegacyBestTimes();
|
||||
startParticleTask();
|
||||
}
|
||||
|
||||
// ─────────────────────────────────────────────────────────────────────────
|
||||
// Config I/O
|
||||
// ─────────────────────────────────────────────────────────────────────────
|
||||
|
||||
private void loadConfig() {
|
||||
if (!file.exists()) {
|
||||
file.getParentFile().mkdirs();
|
||||
try {
|
||||
file.createNewFile();
|
||||
} catch (IOException e) {
|
||||
plugin.getLogger().severe("Fehler beim Erstellen der Parkour-Datei: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
config = YamlConfiguration.loadConfiguration(file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Migriert Bestzeiten vom alten Format (besttimes.<uuid>) ins neue Format
|
||||
* (besttimes.<track>.<uuid>). Alte Zeiten werden Track 1 zugeordnet, da vor
|
||||
* dieser Änderung nur ein Track existierte.
|
||||
* Läuft einmalig beim Start; tut nichts wenn keine alten Daten vorhanden sind.
|
||||
*/
|
||||
private void migrateLegacyBestTimes() {
|
||||
if (!config.contains("besttimes")) return;
|
||||
|
||||
// Prüfen ob es direkte UUID-Keys unter besttimes gibt (altes Format)
|
||||
// Im neuen Format wären hier nur "1" und "2" als Keys
|
||||
var section = config.getConfigurationSection("besttimes");
|
||||
if (section == null) return;
|
||||
|
||||
int migrated = 0;
|
||||
for (String key : new java.util.HashSet<>(section.getKeys(false))) {
|
||||
// Neue Keys sind "1" oder "2" – alte Keys sind UUID-Strings (36 Zeichen, enthalten "-")
|
||||
if (!key.equals("1") && !key.equals("2") && key.contains("-")) {
|
||||
double time = config.getDouble("besttimes." + key);
|
||||
// Nur migrieren wenn unter besttimes.1.<uuid> noch kein besserer Wert steht
|
||||
String newPath = "besttimes.1." + key;
|
||||
double existingTime = config.getDouble(newPath, 99999.9);
|
||||
if (time < existingTime) {
|
||||
config.set(newPath, time);
|
||||
}
|
||||
// Alten Key entfernen
|
||||
config.set("besttimes." + key, null);
|
||||
migrated++;
|
||||
}
|
||||
}
|
||||
|
||||
if (migrated > 0) {
|
||||
save();
|
||||
plugin.getLogger().info("[Parkour] Migration: " + migrated
|
||||
+ " Bestzeit(en) von altem Format nach Strecke 1 übertragen.");
|
||||
}
|
||||
}
|
||||
|
||||
private void save() {
|
||||
try {
|
||||
config.save(file);
|
||||
} catch (IOException e) {
|
||||
plugin.getLogger().severe("Fehler beim Speichern der Parkour-Config: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// ─────────────────────────────────────────────────────────────────────────
|
||||
// Setup-Befehle (Admin)
|
||||
// ─────────────────────────────────────────────────────────────────────────
|
||||
|
||||
public void setStartLocation(Player player, int track) {
|
||||
config.set("tracks." + track + ".start", player.getLocation());
|
||||
save();
|
||||
player.sendMessage("§8[§6Parkour§8] §7Start von §eStrecke " + track + " §7an deiner Position gesetzt.");
|
||||
}
|
||||
|
||||
public void setFinishLocation(Player player, int track) {
|
||||
config.set("tracks." + track + ".finish", player.getLocation());
|
||||
save();
|
||||
player.sendMessage("§8[§6Parkour§8] §7Ziel von §eStrecke " + track + " §7an deiner Position gesetzt.");
|
||||
}
|
||||
|
||||
public void setCheckpoint(Player player, int track) {
|
||||
String cpBase = "tracks." + track + ".checkpoints";
|
||||
int nextId = 1;
|
||||
if (config.contains(cpBase) && config.getConfigurationSection(cpBase) != null) {
|
||||
nextId = config.getConfigurationSection(cpBase).getKeys(false).size() + 1;
|
||||
}
|
||||
config.set(cpBase + "." + nextId, player.getLocation());
|
||||
save();
|
||||
player.sendMessage("§8[§6Parkour§8] §7Checkpoint §e#" + nextId + " §7(Strecke " + track + ") §7gesetzt.");
|
||||
player.playSound(player.getLocation(), Sound.BLOCK_AMETHYST_BLOCK_CHIME, 1.0f, 1.5f);
|
||||
}
|
||||
|
||||
/**
|
||||
* Löscht alle Punkte beider Strecken und bricht laufende Runs ab.
|
||||
*/
|
||||
public void removeAllPoints() {
|
||||
config.set("tracks", null);
|
||||
save();
|
||||
for (UUID uuid : new HashSet<>(startTime.keySet())) {
|
||||
Player p = Bukkit.getPlayer(uuid);
|
||||
if (p != null) {
|
||||
stopParkour(p);
|
||||
p.sendMessage("§8[§6Parkour§8] §cDie Strecken wurden soeben gelöscht.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ─────────────────────────────────────────────────────────────────────────
|
||||
// Getter (Track-spezifisch)
|
||||
// ─────────────────────────────────────────────────────────────────────────
|
||||
|
||||
public Location getStartLocation(int track) {
|
||||
return config.getLocation("tracks." + track + ".start");
|
||||
}
|
||||
|
||||
public Location getFinishLocation(int track) {
|
||||
return config.getLocation("tracks." + track + ".finish");
|
||||
}
|
||||
|
||||
public List<Location> getOrderedCheckpoints(int track) {
|
||||
String cpBase = "tracks." + track + ".checkpoints";
|
||||
if (!config.contains(cpBase) || config.getConfigurationSection(cpBase) == null)
|
||||
return new ArrayList<>();
|
||||
|
||||
return config.getConfigurationSection(cpBase).getKeys(false).stream()
|
||||
.sorted(Comparator.comparingInt(Integer::parseInt))
|
||||
.map(key -> config.getLocation(cpBase + "." + key))
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gibt die aktive Track-Nummer des Spielers zurück (1 oder 2), oder -1 wenn nicht aktiv.
|
||||
*/
|
||||
public int getActiveTrack(Player player) {
|
||||
return activeTrack.getOrDefault(player.getUniqueId(), -1);
|
||||
}
|
||||
|
||||
// Convenience-Wrapper für ParkourListener (nutzt den aktiven Track des Spielers)
|
||||
public List<Location> getOrderedCheckpoints(Player player) {
|
||||
return getOrderedCheckpoints(getActiveTrack(player));
|
||||
}
|
||||
|
||||
public Location getFinishLocation(Player player) {
|
||||
return getFinishLocation(getActiveTrack(player));
|
||||
}
|
||||
|
||||
// ─────────────────────────────────────────────────────────────────────────
|
||||
// Parkour-Ablauf
|
||||
// ─────────────────────────────────────────────────────────────────────────
|
||||
|
||||
/**
|
||||
* Startet den Parkour für den Spieler.
|
||||
* Es wird zufällig eine der beiden Strecken gewählt, sofern beide vollständig
|
||||
* konfiguriert sind (Start + Finish + mindestens gleiche Checkpoint-Anzahl).
|
||||
* Falls nur eine Strecke konfiguriert ist, wird diese gewählt.
|
||||
*/
|
||||
public void startParkour(Player player, Location npcLocation) {
|
||||
if (startTime.containsKey(player.getUniqueId())) return;
|
||||
|
||||
int chosenTrack = pickRandomTrack();
|
||||
if (chosenTrack == -1) {
|
||||
player.sendMessage("§8[§6Parkour§8] §cKeine Strecke konfiguriert. Bitte einen Admin kontaktieren.");
|
||||
return;
|
||||
}
|
||||
|
||||
startTime.put(player.getUniqueId(), System.currentTimeMillis());
|
||||
lastCheckpointLoc.put(player.getUniqueId(), npcLocation);
|
||||
nextCheckpointIndex.put(player.getUniqueId(), 0);
|
||||
activeTrack.put(player.getUniqueId(), chosenTrack);
|
||||
|
||||
player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_CHIME, 1.0f, 1.2f);
|
||||
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!isIngame(player) || !player.isOnline()) {
|
||||
this.cancel();
|
||||
return;
|
||||
}
|
||||
long diff = System.currentTimeMillis() - startTime.get(player.getUniqueId());
|
||||
double sec = diff / 1000.0;
|
||||
player.spigot().sendMessage(ChatMessageType.ACTION_BAR,
|
||||
new TextComponent("§6⏱ Zeit: §e" + String.format("%.2f", sec) + "s §8| §bNächster Punkt: §7Partikel folgen"));
|
||||
}
|
||||
}.runTaskTimer(plugin, 0L, 1L);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wählt zufällig einen validen Track (1 oder 2).
|
||||
* Bevorzugt Tracks mit gleichem Checkpoint-Count; fällt auf jeden konfigurierten zurück.
|
||||
* Gibt -1 zurück, wenn kein Track konfiguriert ist.
|
||||
*/
|
||||
private int pickRandomTrack() {
|
||||
boolean t1 = isTrackReady(1);
|
||||
boolean t2 = isTrackReady(2);
|
||||
|
||||
if (t1 && t2) {
|
||||
// Beide vollständig – prüfen ob gleiche Länge
|
||||
int len1 = getOrderedCheckpoints(1).size();
|
||||
int len2 = getOrderedCheckpoints(2).size();
|
||||
if (len1 != len2) {
|
||||
// Warnung ins Log, aber trotzdem zufällig wählen
|
||||
plugin.getLogger().warning("[Parkour] Strecke 1 hat " + len1 + " Checkpoints, Strecke 2 hat " + len2 + ". Bitte angleichen!");
|
||||
}
|
||||
return random.nextBoolean() ? 1 : 2;
|
||||
} else if (t1) {
|
||||
return 1;
|
||||
} else if (t2) {
|
||||
return 2;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/** Gibt zurück, ob Start, Finish und mindestens 1 Checkpoint für den Track gesetzt sind. */
|
||||
public boolean isTrackReady(int track) {
|
||||
return getStartLocation(track) != null
|
||||
&& getFinishLocation(track) != null
|
||||
&& !getOrderedCheckpoints(track).isEmpty();
|
||||
}
|
||||
|
||||
private void startParticleTask() {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (UUID uuid : startTime.keySet()) {
|
||||
Player p = Bukkit.getPlayer(uuid);
|
||||
if (p == null) continue;
|
||||
|
||||
int track = activeTrack.getOrDefault(uuid, 1);
|
||||
int nextIdx = nextCheckpointIndex.getOrDefault(uuid, 0);
|
||||
List<Location> cps = getOrderedCheckpoints(track);
|
||||
|
||||
if (nextIdx < cps.size()) {
|
||||
Location nextCp = cps.get(nextIdx);
|
||||
if (nextCp != null && p.getWorld().equals(nextCp.getWorld())) {
|
||||
p.spawnParticle(Particle.SOUL_FIRE_FLAME, nextCp.clone().add(0, 0.5, 0), 5, 0.1, 0.3, 0.1, 0.02);
|
||||
}
|
||||
} else {
|
||||
Location finish = getFinishLocation(track);
|
||||
if (finish != null && p.getWorld().equals(finish.getWorld())) {
|
||||
p.spawnParticle(Particle.HAPPY_VILLAGER, finish.clone().add(0, 0.5, 0), 8, 0.2, 0.5, 0.2, 0.02);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}.runTaskTimer(plugin, 0L, 6L);
|
||||
}
|
||||
|
||||
public void reachCheckpoint(Player player, int reachedIndex) {
|
||||
int currentNext = nextCheckpointIndex.getOrDefault(player.getUniqueId(), 0);
|
||||
if (reachedIndex != currentNext) return;
|
||||
|
||||
int track = activeTrack.getOrDefault(player.getUniqueId(), 1);
|
||||
List<Location> cps = getOrderedCheckpoints(track);
|
||||
if (reachedIndex >= cps.size()) return;
|
||||
|
||||
lastCheckpointLoc.put(player.getUniqueId(), cps.get(reachedIndex));
|
||||
nextCheckpointIndex.put(player.getUniqueId(), reachedIndex + 1);
|
||||
|
||||
player.sendMessage("§8[§6Parkour§8] §bCheckpoint #" + (reachedIndex + 1) + " erreicht!");
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 0.8f, 1.5f);
|
||||
}
|
||||
|
||||
public void finishParkour(Player player) {
|
||||
if (!startTime.containsKey(player.getUniqueId())) return;
|
||||
|
||||
int track = activeTrack.getOrDefault(player.getUniqueId(), 1);
|
||||
if (nextCheckpointIndex.getOrDefault(player.getUniqueId(), 0) < getOrderedCheckpoints(track).size()) {
|
||||
player.sendMessage("§cDu hast Checkpoints übersprungen! Folge den Partikeln.");
|
||||
return;
|
||||
}
|
||||
|
||||
long duration = System.currentTimeMillis() - startTime.get(player.getUniqueId());
|
||||
double seconds = duration / 1000.0;
|
||||
|
||||
player.sendMessage("§8§m--------------------------------------");
|
||||
player.sendMessage("§8[§6Parkour§8] §a§lZiel erreicht! §8(Strecke " + track + ")");
|
||||
player.sendMessage("§7Deine Zeit: §e" + String.format("%.2f", seconds) + "s");
|
||||
player.sendMessage("§8§m--------------------------------------");
|
||||
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1.0f, 1.0f);
|
||||
|
||||
saveBestTime(player, seconds);
|
||||
stopParkour(player);
|
||||
}
|
||||
|
||||
public void stopParkour(Player player) {
|
||||
startTime.remove(player.getUniqueId());
|
||||
lastCheckpointLoc.remove(player.getUniqueId());
|
||||
nextCheckpointIndex.remove(player.getUniqueId());
|
||||
activeTrack.remove(player.getUniqueId());
|
||||
}
|
||||
|
||||
// ─────────────────────────────────────────────────────────────────────────
|
||||
// Bestzeiten
|
||||
// ─────────────────────────────────────────────────────────────────────────
|
||||
|
||||
private void saveBestTime(Player player, double time) {
|
||||
int track = activeTrack.getOrDefault(player.getUniqueId(), 1);
|
||||
String path = "besttimes." + track + "." + player.getUniqueId();
|
||||
double currentTime = config.getDouble(path, 99999.9);
|
||||
if (time < currentTime) {
|
||||
config.set(path, time);
|
||||
config.set("names." + player.getUniqueId(), player.getName());
|
||||
save();
|
||||
player.sendMessage("§8[§6Parkour§8] §6§lNeuer Rekord! §7Du hast dich verbessert.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Löscht NUR die Bestzeiten-Liste (besttimes + names).
|
||||
* Die Strecken-Konfiguration (tracks) bleibt vollständig erhalten.
|
||||
* Wird durch "/nexus parkour clear" aufgerufen.
|
||||
*/
|
||||
public void clearStats() {
|
||||
config.set("besttimes", null);
|
||||
config.set("names", null);
|
||||
save();
|
||||
}
|
||||
|
||||
public void clearStats(int track) {
|
||||
config.set("besttimes." + track, null);
|
||||
save();
|
||||
}
|
||||
|
||||
public String getTopTen() {
|
||||
// Fallback: kombiniert beide Tracks (Legacy-Support für %nexuslobby_parkour_top%)
|
||||
return getTopTen(0);
|
||||
}
|
||||
|
||||
public String getTopTen(int track) {
|
||||
String trackLabel = track == 1 ? " §8(Strecke 1)" : track == 2 ? " §8(Strecke 2)" : "";
|
||||
|
||||
Map<String, Double> allTimes = new HashMap<>();
|
||||
|
||||
if (track == 0) {
|
||||
// Alle Tracks kombiniert (nimmt die beste Zeit je Spieler über alle Tracks)
|
||||
for (int t = 1; t <= 2; t++) {
|
||||
String section = "besttimes." + t;
|
||||
if (config.contains(section) && config.getConfigurationSection(section) != null) {
|
||||
for (String uuidStr : config.getConfigurationSection(section).getKeys(false)) {
|
||||
double time = config.getDouble(section + "." + uuidStr);
|
||||
allTimes.merge(uuidStr, time, Math::min);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
String section = "besttimes." + track;
|
||||
if (!config.contains(section) || config.getConfigurationSection(section) == null) {
|
||||
return "§6§l🏆 TOP 10 PARKOUR" + trackLabel + "\n§7Noch keine Rekorde.";
|
||||
}
|
||||
for (String uuidStr : config.getConfigurationSection(section).getKeys(false)) {
|
||||
allTimes.put(uuidStr, config.getDouble(section + "." + uuidStr));
|
||||
}
|
||||
}
|
||||
|
||||
if (allTimes.isEmpty())
|
||||
return "§6§l🏆 TOP 10 PARKOUR" + trackLabel + "\n§7Noch keine Rekorde.";
|
||||
|
||||
List<Map.Entry<String, Double>> sortedList = allTimes.entrySet().stream()
|
||||
.sorted(Map.Entry.comparingByValue())
|
||||
.limit(10)
|
||||
.toList();
|
||||
|
||||
StringBuilder builder = new StringBuilder("§6§l🏆 TOP 10 PARKOUR" + trackLabel);
|
||||
int rank = 1;
|
||||
for (Map.Entry<String, Double> entry : sortedList) {
|
||||
String name = config.getString("names." + entry.getKey(), "Unbekannt");
|
||||
builder.append("\n§e#").append(rank).append(" §f").append(name)
|
||||
.append(" §8» §a").append(String.format("%.2f", entry.getValue())).append("s");
|
||||
rank++;
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
// ─────────────────────────────────────────────────────────────────────────
|
||||
// Hilfsmethoden
|
||||
// ─────────────────────────────────────────────────────────────────────────
|
||||
|
||||
public boolean isIngame(Player player) { return startTime.containsKey(player.getUniqueId()); }
|
||||
public Location getCheckpoint(Player player) { return lastCheckpointLoc.get(player.getUniqueId()); }
|
||||
|
||||
/** Gibt die Strecken-Info als lesbaren String aus (für Admin-Feedback). */
|
||||
public String getTrackInfo() {
|
||||
StringBuilder sb = new StringBuilder("§8[§6Parkour§8] §7Track-Status:\n");
|
||||
for (int t = 1; t <= 2; t++) {
|
||||
int cps = getOrderedCheckpoints(t).size();
|
||||
boolean ready = isTrackReady(t);
|
||||
sb.append(" §eStrecke ").append(t).append(": ")
|
||||
.append(ready ? "§a✔" : "§c✘")
|
||||
.append(" §7(").append(cps).append(" Checkpoints)");
|
||||
if (t < 2) sb.append("\n");
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
@@ -1,194 +1,196 @@
|
||||
package de.nexuslobby.modules.player;
|
||||
|
||||
import de.nexuslobby.NexusLobby;
|
||||
import de.nexuslobby.api.Module;
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Statistic;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Modul zur Inspektion von Spielern in der Lobby.
|
||||
* Zeigt detaillierte Statistiken in einer interaktiven GUI an.
|
||||
*/
|
||||
public class PlayerInspectModule implements Module, Listener {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "PlayerInspect";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
Bukkit.getPluginManager().registerEvents(this, NexusLobby.getInstance());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerInteract(PlayerInteractEntityEvent event) {
|
||||
// Prüfen, ob ein Spieler rechtsgeklickt wurde
|
||||
if (event.getRightClicked() instanceof Player target) {
|
||||
Player viewer = event.getPlayer();
|
||||
|
||||
// GUI nur öffnen, wenn die Hand leer ist (verhindert Konflikte mit Items)
|
||||
if (viewer.getInventory().getItemInMainHand().getType() == Material.AIR) {
|
||||
openDetailedInspectGUI(viewer, target);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryClick(InventoryClickEvent event) {
|
||||
// Sicherstellen, dass es unser Statistik-Inventar ist anhand des Titels
|
||||
if (event.getView().getTitle().contains("Statistiken")) {
|
||||
event.setCancelled(true); // Verhindert, dass Items herausgenommen werden
|
||||
|
||||
ItemStack clickedItem = event.getCurrentItem();
|
||||
if (clickedItem == null || clickedItem.getType() == Material.AIR) return;
|
||||
|
||||
// Logik für den Schließen-Button (Barriere)
|
||||
if (clickedItem.getType() == Material.BARRIER) {
|
||||
event.getWhoClicked().closeInventory();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void openDetailedInspectGUI(Player viewer, Player target) {
|
||||
// Titel mit Farbcodes
|
||||
String title = "§8» §3Statistiken: §b" + target.getName();
|
||||
Inventory gui = Bukkit.createInventory(null, 45, title);
|
||||
|
||||
// --- Design: Hintergrund mit Glasscheiben füllen ---
|
||||
ItemStack separator = createSimpleItem(Material.GRAY_STAINED_GLASS_PANE, " ");
|
||||
int[] borderSlots = {
|
||||
0,1,2,3,4,5,6,7,8,
|
||||
9,17,
|
||||
18,26,
|
||||
27,35,
|
||||
36,37,38,39,41,42,43,44
|
||||
};
|
||||
for (int slot : borderSlots) gui.setItem(slot, separator);
|
||||
|
||||
// --- Kopf des Spielers mit LuckPerms Prefix via PAPI ---
|
||||
ItemStack head = new ItemStack(Material.PLAYER_HEAD);
|
||||
SkullMeta headMeta = (SkullMeta) head.getItemMeta();
|
||||
if (headMeta != null) {
|
||||
headMeta.setOwningPlayer(target);
|
||||
headMeta.setDisplayName("§e§l" + target.getName());
|
||||
|
||||
List<String> lore = new ArrayList<>();
|
||||
lore.add("§8§m-----------------------");
|
||||
|
||||
// LuckPerms Prefix über PlaceholderAPI auslesen (falls vorhanden)
|
||||
String prefix = "%luckperms_prefix%";
|
||||
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
|
||||
try {
|
||||
prefix = PlaceholderAPI.setPlaceholders(target, prefix);
|
||||
} catch (NoClassDefFoundError ignored) {
|
||||
// PlaceholderAPI fehlt zur Laufzeit
|
||||
}
|
||||
}
|
||||
|
||||
// KORREKTUR: Farbcodes (&) in echte Minecraft-Farben (§) umwandeln
|
||||
prefix = ChatColor.translateAlternateColorCodes('&', prefix);
|
||||
|
||||
lore.add("§7Rang: " + (prefix.isEmpty() ? "§fSpieler" : prefix));
|
||||
lore.add("§7Level: §a" + target.getLevel());
|
||||
lore.add("§7Status: §aOnline");
|
||||
lore.add("§8§m-----------------------");
|
||||
|
||||
headMeta.setLore(lore);
|
||||
head.setItemMeta(headMeta);
|
||||
}
|
||||
gui.setItem(4, head);
|
||||
|
||||
// --- Statistik Kategorie: KAMPF (Slot 19) ---
|
||||
gui.setItem(19, createStatsItem(Material.DIAMOND_SWORD, "§c§lKampf-Statistiken",
|
||||
"§8» §7Spieler-Kills: §f" + target.getStatistic(Statistic.PLAYER_KILLS),
|
||||
"§8» §7Mob-Kills: §f" + target.getStatistic(Statistic.MOB_KILLS),
|
||||
"§8» §7Tode gesamt: §f" + target.getStatistic(Statistic.DEATHS),
|
||||
"§8» §7Schaden verursacht: §f" + (target.getStatistic(Statistic.DAMAGE_DEALT) / 10) + " ❤"));
|
||||
|
||||
// --- Statistik Kategorie: ARBEIT (Slot 21) ---
|
||||
// Optimierte Abfrage für wichtige Blöcke
|
||||
int totalBlocks = target.getStatistic(Statistic.MINE_BLOCK, Material.STONE) +
|
||||
target.getStatistic(Statistic.MINE_BLOCK, Material.DIRT) +
|
||||
target.getStatistic(Statistic.MINE_BLOCK, Material.COBBLESTONE);
|
||||
|
||||
gui.setItem(21, createStatsItem(Material.IRON_PICKAXE, "§e§lHandwerk & Fleiß",
|
||||
"§8» §7Blöcke (S/D/C): §f" + totalBlocks,
|
||||
"§8» §7Items gedroppt: §f" + target.getStatistic(Statistic.DROP_COUNT),
|
||||
"§8» §7Fische gefangen: §f" + target.getStatistic(Statistic.FISH_CAUGHT),
|
||||
"§8» §7Glocken geläutet: §f" + target.getStatistic(Statistic.BELL_RING)));
|
||||
|
||||
// --- Statistik Kategorie: BEWEGUNG (Slot 23) ---
|
||||
double walkKm = target.getStatistic(Statistic.WALK_ONE_CM) / 100000.0;
|
||||
double flyKm = target.getStatistic(Statistic.FLY_ONE_CM) / 100000.0;
|
||||
gui.setItem(23, createStatsItem(Material.GOLDEN_BOOTS, "§b§lReise-Statistiken",
|
||||
"§8» §7Gelaufen: §f" + String.format("%.2f", walkKm) + " km",
|
||||
"§8» §7Geflogen: §f" + String.format("%.2f", flyKm) + " km",
|
||||
"§8» §7Sprünge: §f" + target.getStatistic(Statistic.JUMP)));
|
||||
|
||||
// --- Statistik Kategorie: ZEIT (Slot 25) ---
|
||||
long ticks = target.getStatistic(Statistic.PLAY_ONE_MINUTE);
|
||||
long hours = ticks / 72000;
|
||||
long mins = (ticks % 72000) / 1200;
|
||||
gui.setItem(25, createStatsItem(Material.CLOCK, "§a§lZeit-Statistiken",
|
||||
"§8» §7Spielzeit: §f" + hours + " Std. " + mins + " Min.",
|
||||
"§8» §7Letzter Tod vor: §f" + (target.getStatistic(Statistic.TIME_SINCE_DEATH) / 1200) + " Min.",
|
||||
"§8» §7Tage auf Server: §f" + (target.getStatistic(Statistic.PLAY_ONE_MINUTE) / 1728000)));
|
||||
|
||||
// --- Schließen Button (Slot 40) ---
|
||||
gui.setItem(40, createSimpleItem(Material.BARRIER, "§c§lMenü schließen"));
|
||||
|
||||
// Inventar für den Zuschauer öffnen
|
||||
viewer.openInventory(gui);
|
||||
}
|
||||
|
||||
/**
|
||||
* Erstellt ein ItemStack mit Name und Lore-Zeilen inklusive einer Leerzeile am Anfang.
|
||||
*/
|
||||
private ItemStack createStatsItem(Material material, String displayName, String... loreLines) {
|
||||
ItemStack item = new ItemStack(material);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
if (meta != null) {
|
||||
meta.setDisplayName(displayName);
|
||||
List<String> lore = new ArrayList<>();
|
||||
lore.add(" "); // Leerzeile für sauberes Design
|
||||
for (String line : loreLines) {
|
||||
lore.add(line);
|
||||
}
|
||||
meta.setLore(lore);
|
||||
item.setItemMeta(meta);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
/**
|
||||
* Erstellt ein einfaches ItemStack ohne Lore für Designzwecke.
|
||||
*/
|
||||
private ItemStack createSimpleItem(Material material, String displayName) {
|
||||
ItemStack item = new ItemStack(material);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
if (meta != null) {
|
||||
meta.setDisplayName(displayName);
|
||||
item.setItemMeta(meta);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
package de.nexuslobby.modules.player;
|
||||
|
||||
import de.nexuslobby.NexusLobby;
|
||||
import de.nexuslobby.api.Module;
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Statistic;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Modul zur Inspektion von Spielern in der Lobby.
|
||||
* Zeigt detaillierte Statistiken in einer interaktiven GUI an.
|
||||
*/
|
||||
public class PlayerInspectModule implements Module, Listener {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "PlayerInspect";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
Bukkit.getPluginManager().registerEvents(this, NexusLobby.getInstance());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
org.bukkit.event.HandlerList.unregisterAll(this);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerInteract(PlayerInteractEntityEvent event) {
|
||||
// Prüfen, ob ein Spieler rechtsgeklickt wurde
|
||||
if (event.getRightClicked() instanceof Player target) {
|
||||
Player viewer = event.getPlayer();
|
||||
|
||||
// GUI nur öffnen, wenn die Hand leer ist (verhindert Konflikte mit Items)
|
||||
if (viewer.getInventory().getItemInMainHand().getType() == Material.AIR) {
|
||||
openDetailedInspectGUI(viewer, target);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryClick(InventoryClickEvent event) {
|
||||
// Sicherstellen, dass es unser Statistik-Inventar ist anhand des Titels
|
||||
if (event.getView().getTitle().contains("Statistiken")) {
|
||||
event.setCancelled(true); // Verhindert, dass Items herausgenommen werden
|
||||
|
||||
ItemStack clickedItem = event.getCurrentItem();
|
||||
if (clickedItem == null || clickedItem.getType() == Material.AIR) return;
|
||||
|
||||
// Logik für den Schließen-Button (Barriere)
|
||||
if (clickedItem.getType() == Material.BARRIER) {
|
||||
event.getWhoClicked().closeInventory();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void openDetailedInspectGUI(Player viewer, Player target) {
|
||||
// Titel mit Farbcodes
|
||||
String title = "§8» §3Statistiken: §b" + target.getName();
|
||||
Inventory gui = Bukkit.createInventory(null, 45, title);
|
||||
|
||||
// --- Design: Hintergrund mit Glasscheiben füllen ---
|
||||
ItemStack separator = createSimpleItem(Material.GRAY_STAINED_GLASS_PANE, " ");
|
||||
int[] borderSlots = {
|
||||
0,1,2,3,4,5,6,7,8,
|
||||
9,17,
|
||||
18,26,
|
||||
27,35,
|
||||
36,37,38,39,41,42,43,44
|
||||
};
|
||||
for (int slot : borderSlots) gui.setItem(slot, separator);
|
||||
|
||||
// --- Kopf des Spielers mit LuckPerms Prefix via PAPI ---
|
||||
ItemStack head = new ItemStack(Material.PLAYER_HEAD);
|
||||
SkullMeta headMeta = (SkullMeta) head.getItemMeta();
|
||||
if (headMeta != null) {
|
||||
headMeta.setOwningPlayer(target);
|
||||
headMeta.setDisplayName("§e§l" + target.getName());
|
||||
|
||||
List<String> lore = new ArrayList<>();
|
||||
lore.add("§8§m-----------------------");
|
||||
|
||||
// LuckPerms Prefix über PlaceholderAPI auslesen (falls vorhanden)
|
||||
String prefix = "%luckperms_prefix%";
|
||||
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
|
||||
try {
|
||||
prefix = PlaceholderAPI.setPlaceholders(target, prefix);
|
||||
} catch (NoClassDefFoundError ignored) {
|
||||
// PlaceholderAPI fehlt zur Laufzeit
|
||||
}
|
||||
}
|
||||
|
||||
// KORREKTUR: Farbcodes (&) in echte Minecraft-Farben (§) umwandeln
|
||||
prefix = ChatColor.translateAlternateColorCodes('&', prefix);
|
||||
|
||||
lore.add("§7Rang: " + (prefix.isEmpty() ? "§fSpieler" : prefix));
|
||||
lore.add("§7Level: §a" + target.getLevel());
|
||||
lore.add("§7Status: §aOnline");
|
||||
lore.add("§8§m-----------------------");
|
||||
|
||||
headMeta.setLore(lore);
|
||||
head.setItemMeta(headMeta);
|
||||
}
|
||||
gui.setItem(4, head);
|
||||
|
||||
// --- Statistik Kategorie: KAMPF (Slot 19) ---
|
||||
gui.setItem(19, createStatsItem(Material.DIAMOND_SWORD, "§c§lKampf-Statistiken",
|
||||
"§8» §7Spieler-Kills: §f" + target.getStatistic(Statistic.PLAYER_KILLS),
|
||||
"§8» §7Mob-Kills: §f" + target.getStatistic(Statistic.MOB_KILLS),
|
||||
"§8» §7Tode gesamt: §f" + target.getStatistic(Statistic.DEATHS),
|
||||
"§8» §7Schaden verursacht: §f" + (target.getStatistic(Statistic.DAMAGE_DEALT) / 10) + " ❤"));
|
||||
|
||||
// --- Statistik Kategorie: ARBEIT (Slot 21) ---
|
||||
// Optimierte Abfrage für wichtige Blöcke
|
||||
int totalBlocks = target.getStatistic(Statistic.MINE_BLOCK, Material.STONE) +
|
||||
target.getStatistic(Statistic.MINE_BLOCK, Material.DIRT) +
|
||||
target.getStatistic(Statistic.MINE_BLOCK, Material.COBBLESTONE);
|
||||
|
||||
gui.setItem(21, createStatsItem(Material.IRON_PICKAXE, "§e§lHandwerk & Fleiß",
|
||||
"§8» §7Blöcke (S/D/C): §f" + totalBlocks,
|
||||
"§8» §7Items gedroppt: §f" + target.getStatistic(Statistic.DROP_COUNT),
|
||||
"§8» §7Fische gefangen: §f" + target.getStatistic(Statistic.FISH_CAUGHT),
|
||||
"§8» §7Glocken geläutet: §f" + target.getStatistic(Statistic.BELL_RING)));
|
||||
|
||||
// --- Statistik Kategorie: BEWEGUNG (Slot 23) ---
|
||||
double walkKm = target.getStatistic(Statistic.WALK_ONE_CM) / 100000.0;
|
||||
double flyKm = target.getStatistic(Statistic.FLY_ONE_CM) / 100000.0;
|
||||
gui.setItem(23, createStatsItem(Material.GOLDEN_BOOTS, "§b§lReise-Statistiken",
|
||||
"§8» §7Gelaufen: §f" + String.format("%.2f", walkKm) + " km",
|
||||
"§8» §7Geflogen: §f" + String.format("%.2f", flyKm) + " km",
|
||||
"§8» §7Sprünge: §f" + target.getStatistic(Statistic.JUMP)));
|
||||
|
||||
// --- Statistik Kategorie: ZEIT (Slot 25) ---
|
||||
long ticks = target.getStatistic(Statistic.PLAY_ONE_MINUTE);
|
||||
long hours = ticks / 72000;
|
||||
long mins = (ticks % 72000) / 1200;
|
||||
gui.setItem(25, createStatsItem(Material.CLOCK, "§a§lZeit-Statistiken",
|
||||
"§8» §7Spielzeit: §f" + hours + " Std. " + mins + " Min.",
|
||||
"§8» §7Letzter Tod vor: §f" + (target.getStatistic(Statistic.TIME_SINCE_DEATH) / 1200) + " Min.",
|
||||
"§8» §7Tage auf Server: §f" + (target.getStatistic(Statistic.PLAY_ONE_MINUTE) / 1728000)));
|
||||
|
||||
// --- Schließen Button (Slot 40) ---
|
||||
gui.setItem(40, createSimpleItem(Material.BARRIER, "§c§lMenü schließen"));
|
||||
|
||||
// Inventar für den Zuschauer öffnen
|
||||
viewer.openInventory(gui);
|
||||
}
|
||||
|
||||
/**
|
||||
* Erstellt ein ItemStack mit Name und Lore-Zeilen inklusive einer Leerzeile am Anfang.
|
||||
*/
|
||||
private ItemStack createStatsItem(Material material, String displayName, String... loreLines) {
|
||||
ItemStack item = new ItemStack(material);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
if (meta != null) {
|
||||
meta.setDisplayName(displayName);
|
||||
List<String> lore = new ArrayList<>();
|
||||
lore.add(" "); // Leerzeile für sauberes Design
|
||||
for (String line : loreLines) {
|
||||
lore.add(line);
|
||||
}
|
||||
meta.setLore(lore);
|
||||
item.setItemMeta(meta);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
/**
|
||||
* Erstellt ein einfaches ItemStack ohne Lore für Designzwecke.
|
||||
*/
|
||||
private ItemStack createSimpleItem(Material material, String displayName) {
|
||||
ItemStack item = new ItemStack(material);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
if (meta != null) {
|
||||
meta.setDisplayName(displayName);
|
||||
item.setItemMeta(meta);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
}
|
||||
@@ -5,12 +5,15 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class PortalCommand implements CommandExecutor {
|
||||
public class PortalCommand implements CommandExecutor, Listener {
|
||||
|
||||
private final PortalManager portalManager;
|
||||
|
||||
@@ -20,6 +23,17 @@ public class PortalCommand implements CommandExecutor {
|
||||
|
||||
public PortalCommand(PortalManager portalManager) {
|
||||
this.portalManager = portalManager;
|
||||
// FIX: Listener registrieren, damit Selektionen beim Verlassen bereinigt werden
|
||||
de.nexuslobby.NexusLobby.getInstance().getServer().getPluginManager()
|
||||
.registerEvents(this, de.nexuslobby.NexusLobby.getInstance());
|
||||
}
|
||||
|
||||
// FIX: Selektionen beim Quit entfernen – statische Maps wuchsen sonst ewig
|
||||
@EventHandler
|
||||
public void onQuit(PlayerQuitEvent event) {
|
||||
UUID uuid = event.getPlayer().getUniqueId();
|
||||
selection1.remove(uuid);
|
||||
selection2.remove(uuid);
|
||||
}
|
||||
|
||||
// Statische Hilfsmethoden für andere Klassen
|
||||
|
||||
@@ -31,7 +31,12 @@ import java.util.UUID;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* PortalManager - Verwaltet Portale, Markierungen und den globalen Grenzschutz.
|
||||
* PortalManager - Verwaltet Portale und Wand-Markierungen.
|
||||
*
|
||||
* FIX: Die doppelte Border-Logik wurde entfernt. Der BorderModule ist
|
||||
* der alleinige Verantwortliche für die Lobby-Grenze. Hätte der
|
||||
* PortalManager die Border ebenfalls geprüft, wären Spieler doppelt
|
||||
* teleportiert worden und hätten zwei Nachrichten erhalten.
|
||||
*/
|
||||
public class PortalManager implements Module, Listener {
|
||||
|
||||
@@ -42,12 +47,6 @@ public class PortalManager implements Module, Listener {
|
||||
private final NamespacedKey wandKey;
|
||||
private BukkitTask particleTask;
|
||||
|
||||
// Boundary Cache
|
||||
private Location borderMin;
|
||||
private Location borderMax;
|
||||
private boolean borderEnabled = false;
|
||||
private String borderType;
|
||||
|
||||
public PortalManager(NexusLobby plugin) {
|
||||
this.plugin = plugin;
|
||||
this.wandKey = new NamespacedKey(plugin, "nexuslobby_portal_wand");
|
||||
@@ -61,7 +60,6 @@ public class PortalManager implements Module, Listener {
|
||||
@Override
|
||||
public void onEnable() {
|
||||
loadPortals();
|
||||
loadBorderSettings();
|
||||
Bukkit.getPluginManager().registerEvents(this, plugin);
|
||||
startParticleTask();
|
||||
}
|
||||
@@ -76,28 +74,6 @@ public class PortalManager implements Module, Listener {
|
||||
plugin.getLogger().info("PortalManager deaktiviert.");
|
||||
}
|
||||
|
||||
public void loadBorderSettings() {
|
||||
this.borderType = plugin.getConfig().getString("worldborder.type", "SQUARE");
|
||||
boolean enabled = plugin.getConfig().getBoolean("worldborder.enabled", false);
|
||||
if (!enabled || !"SQUARE".equalsIgnoreCase(borderType)) {
|
||||
this.borderEnabled = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (plugin.getConfig().contains("worldborder.pos1") && plugin.getConfig().contains("worldborder.pos2")) {
|
||||
Location p1 = plugin.getConfig().getLocation("worldborder.pos1");
|
||||
Location p2 = plugin.getConfig().getLocation("worldborder.pos2");
|
||||
if (p1 != null && p2 != null) {
|
||||
this.borderMin = getMinLocation(p1, p2);
|
||||
this.borderMax = getMaxLocation(p1, p2);
|
||||
this.borderEnabled = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
this.borderEnabled = false;
|
||||
}
|
||||
|
||||
public Set<String> getPortalNames() {
|
||||
return portals.keySet();
|
||||
}
|
||||
@@ -135,30 +111,30 @@ public class PortalManager implements Module, Listener {
|
||||
if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
|
||||
selectionMap.get(uuid)[0] = clickedLoc;
|
||||
PortalCommand.setSelection1(p, clickedLoc);
|
||||
|
||||
|
||||
p.playSound(p.getLocation(), Sound.BLOCK_NOTE_BLOCK_PLING, 1.0f, 2.0f);
|
||||
p.sendMessage("§aPosition 1 gesetzt: " + clickedLoc.getBlockX() + ", " + clickedLoc.getBlockY() + ", " + clickedLoc.getBlockZ());
|
||||
|
||||
|
||||
} else if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||
selectionMap.get(uuid)[1] = clickedLoc;
|
||||
PortalCommand.setSelection2(p, clickedLoc);
|
||||
|
||||
|
||||
p.playSound(p.getLocation(), Sound.BLOCK_NOTE_BLOCK_PLING, 1.0f, 1.0f);
|
||||
p.sendMessage("§bPosition 2 gesetzt: " + clickedLoc.getBlockX() + ", " + clickedLoc.getBlockY() + ", " + clickedLoc.getBlockZ());
|
||||
|
||||
Location loc1 = selectionMap.get(uuid)[0];
|
||||
if (loc1 != null) {
|
||||
int width = Math.abs(loc1.getBlockX() - clickedLoc.getBlockX()) + 1;
|
||||
int width = Math.abs(loc1.getBlockX() - clickedLoc.getBlockX()) + 1;
|
||||
int height = Math.abs(loc1.getBlockY() - clickedLoc.getBlockY()) + 1;
|
||||
int length = Math.abs(loc1.getBlockZ() - clickedLoc.getBlockZ()) + 1;
|
||||
long volume = (long) width * height * length;
|
||||
|
||||
p.sendMessage("§7§m----------------------------------");
|
||||
if (volume < 500) {
|
||||
p.sendMessage("§e[Nexus] Kleiner Bereich erkannt (Portal-Größe)");
|
||||
p.sendMessage("§fBefehl: §b/portal create <Name> <server|world>");
|
||||
p.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§eKleiner Bereich erkannt (Portal-Größe)");
|
||||
p.sendMessage("§fBefehl: §b/portal create <n> <server|world>");
|
||||
} else {
|
||||
p.sendMessage("§6[Nexus] Großer Bereich erkannt (WorldBorder-Größe)");
|
||||
p.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§6Großer Bereich erkannt (WorldBorder-Größe)");
|
||||
p.sendMessage("§fBefehl: §a/border square");
|
||||
}
|
||||
p.sendMessage("§7§m----------------------------------");
|
||||
@@ -190,12 +166,9 @@ public class PortalManager implements Module, Listener {
|
||||
String type = portalConfig.getString("portals." + key + ".type", "WORLD");
|
||||
Portal portal = new Portal(key, type);
|
||||
|
||||
if (portalConfig.contains("portals." + key + ".pos1")) {
|
||||
portal.setPos1(portalConfig.getLocation("portals." + key + ".pos1"));
|
||||
}
|
||||
if (portalConfig.contains("portals." + key + ".pos2")) {
|
||||
portal.setPos2(portalConfig.getLocation("portals." + key + ".pos2"));
|
||||
}
|
||||
portal.setPos1(loadLocation(portalConfig, "portals." + key + ".pos1"));
|
||||
portal.setPos2(loadLocation(portalConfig, "portals." + key + ".pos2"));
|
||||
portal.setReturnSpawn(loadLocation(portalConfig, "portals." + key + ".returnSpawn"));
|
||||
|
||||
portal.setDestination(portalConfig.getString("portals." + key + ".destination", ""));
|
||||
try {
|
||||
@@ -204,10 +177,6 @@ public class PortalManager implements Module, Listener {
|
||||
portal.setParticle(Particle.PORTAL);
|
||||
}
|
||||
|
||||
if (portalConfig.contains("portals." + key + ".returnSpawn")) {
|
||||
portal.setReturnSpawn(portalConfig.getLocation("portals." + key + ".returnSpawn"));
|
||||
}
|
||||
|
||||
portals.put(key, portal);
|
||||
}
|
||||
}
|
||||
@@ -219,11 +188,11 @@ public class PortalManager implements Module, Listener {
|
||||
for (Portal portal : portals.values()) {
|
||||
String path = "portals." + portal.getName() + ".";
|
||||
config.set(path + "type", portal.getType());
|
||||
config.set(path + "pos1", portal.getPos1());
|
||||
config.set(path + "pos2", portal.getPos2());
|
||||
saveLocation(config, path + "pos1", portal.getPos1());
|
||||
saveLocation(config, path + "pos2", portal.getPos2());
|
||||
config.set(path + "destination", portal.getDestination());
|
||||
config.set(path + "particle", portal.getParticle() != null ? portal.getParticle().name() : "PORTAL");
|
||||
config.set(path + "returnSpawn", portal.getReturnSpawn());
|
||||
saveLocation(config, path + "returnSpawn", portal.getReturnSpawn());
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -233,6 +202,35 @@ public class PortalManager implements Module, Listener {
|
||||
}
|
||||
}
|
||||
|
||||
// FIX: Hilfsmethoden für robustes Location-Speichern/Laden.
|
||||
// Speichert world + x/y/z als einzelne Keys statt als serialisiertes
|
||||
// Location-Objekt, was nach Neustarts zu null führen kann.
|
||||
private void saveLocation(YamlConfiguration config, String path, Location loc) {
|
||||
if (loc == null || loc.getWorld() == null) return;
|
||||
config.set(path + ".world", loc.getWorld().getName());
|
||||
config.set(path + ".x", loc.getX());
|
||||
config.set(path + ".y", loc.getY());
|
||||
config.set(path + ".z", loc.getZ());
|
||||
config.set(path + ".yaw", (double) loc.getYaw());
|
||||
config.set(path + ".pitch", (double) loc.getPitch());
|
||||
}
|
||||
|
||||
private Location loadLocation(YamlConfiguration config, String path) {
|
||||
if (!config.contains(path + ".world")) return null;
|
||||
String worldName = config.getString(path + ".world");
|
||||
World world = Bukkit.getWorld(worldName);
|
||||
if (world == null) {
|
||||
plugin.getLogger().warning("Welt '" + worldName + "' nicht gefunden für Pfad: " + path);
|
||||
return null;
|
||||
}
|
||||
return new Location(world,
|
||||
config.getDouble(path + ".x"),
|
||||
config.getDouble(path + ".y"),
|
||||
config.getDouble(path + ".z"),
|
||||
(float) config.getDouble(path + ".yaw"),
|
||||
(float) config.getDouble(path + ".pitch"));
|
||||
}
|
||||
|
||||
// --- CRUD ---
|
||||
public boolean createPortal(String name, String type, Player creator) {
|
||||
Location[] sel = selectionMap.getOrDefault(creator.getUniqueId(), new Location[2]);
|
||||
@@ -295,7 +293,7 @@ public class PortalManager implements Module, Listener {
|
||||
return true;
|
||||
}
|
||||
|
||||
// --- Movement / Teleport / Boundary Logic ---
|
||||
// --- Movement / Teleport Logic ---
|
||||
@org.bukkit.event.EventHandler
|
||||
public void onPlayerMove(PlayerMoveEvent event) {
|
||||
if (event.getFrom().getX() == event.getTo().getX() &&
|
||||
@@ -307,20 +305,7 @@ public class PortalManager implements Module, Listener {
|
||||
Player player = event.getPlayer();
|
||||
Location loc = event.getTo();
|
||||
|
||||
// 1. Grenzschutz (Boundary Protection)
|
||||
if (borderEnabled && !player.hasPermission("nexuslobby.border.bypass")) {
|
||||
if (!isWithinBorder(loc)) {
|
||||
Location spawn = getMainSpawnLocation();
|
||||
if (spawn != null) {
|
||||
player.teleport(spawn);
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_ENDERMAN_TELEPORT, 1.0f, 0.5f);
|
||||
player.sendMessage("§c§lHEY! §7Du hast den erlaubten Bereich verlassen.");
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// 2. Portal Logik
|
||||
// Portal-Logik
|
||||
for (Portal portal : portals.values()) {
|
||||
if (portal.getPos1() == null || portal.getPos2() == null) continue;
|
||||
if (!isInArea(loc, portal.getPos1(), portal.getPos2())) continue;
|
||||
@@ -336,14 +321,6 @@ public class PortalManager implements Module, Listener {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isWithinBorder(Location loc) {
|
||||
if (borderMin == null || borderMax == null) return true;
|
||||
if (!loc.getWorld().equals(borderMin.getWorld())) return true;
|
||||
return loc.getX() >= borderMin.getX() && loc.getX() <= borderMax.getX() &&
|
||||
loc.getY() >= borderMin.getY() && loc.getY() <= borderMax.getY() &&
|
||||
loc.getZ() >= borderMin.getZ() && loc.getZ() <= borderMax.getZ();
|
||||
}
|
||||
|
||||
private void executeTeleport(Player player, Portal portal) {
|
||||
if ("SERVER".equalsIgnoreCase(portal.getType())) {
|
||||
String serverName = portal.getDestination();
|
||||
@@ -352,17 +329,17 @@ public class PortalManager implements Module, Listener {
|
||||
Location loc = portal.getReturnSpawn();
|
||||
if (loc == null) {
|
||||
Location pos2 = portal.getPos2();
|
||||
loc = player.getLocation();
|
||||
loc = player.getLocation().clone();
|
||||
if (pos2 != null) {
|
||||
double dx = loc.getX() - pos2.getX();
|
||||
double dz = loc.getZ() - pos2.getZ();
|
||||
double length = Math.sqrt(dx*dx + dz*dz);
|
||||
double length = Math.sqrt(dx * dx + dz * dz);
|
||||
if (length == 0) length = 1;
|
||||
dx = (dx / length) * 2;
|
||||
dz = (dz / length) * 2;
|
||||
loc.add(dx, 0, dz);
|
||||
} else {
|
||||
loc.add(0,0,2);
|
||||
loc.add(0, 0, 2);
|
||||
}
|
||||
}
|
||||
player.teleport(loc);
|
||||
@@ -393,7 +370,7 @@ public class PortalManager implements Module, Listener {
|
||||
double x = Double.parseDouble(parts[1]);
|
||||
double y = Double.parseDouble(parts[2]);
|
||||
double z = Double.parseDouble(parts[3]);
|
||||
float yaw = parts.length >= 6 ? Float.parseFloat(parts[4]) : 0f;
|
||||
float yaw = parts.length >= 5 ? Float.parseFloat(parts[4]) : 0f;
|
||||
float pitch = parts.length >= 6 ? Float.parseFloat(parts[5]) : 0f;
|
||||
player.teleport(new Location(world, x, y, z, yaw, pitch));
|
||||
player.sendMessage("§aDu wurdest teleportiert!");
|
||||
@@ -418,11 +395,11 @@ public class PortalManager implements Module, Listener {
|
||||
if (worldName != null) {
|
||||
World w = Bukkit.getWorld(worldName);
|
||||
if (w != null) {
|
||||
return new Location(w,
|
||||
plugin.getConfig().getDouble("spawn.x"),
|
||||
plugin.getConfig().getDouble("spawn.y"),
|
||||
return new Location(w,
|
||||
plugin.getConfig().getDouble("spawn.x"),
|
||||
plugin.getConfig().getDouble("spawn.y"),
|
||||
plugin.getConfig().getDouble("spawn.z"),
|
||||
(float) plugin.getConfig().getDouble("spawn.yaw"),
|
||||
(float) plugin.getConfig().getDouble("spawn.yaw"),
|
||||
(float) plugin.getConfig().getDouble("spawn.pitch"));
|
||||
}
|
||||
}
|
||||
@@ -461,6 +438,7 @@ public class PortalManager implements Module, Listener {
|
||||
Location min = getMinLocation(portal.getPos1(), portal.getPos2());
|
||||
Location max = getMaxLocation(portal.getPos1(), portal.getPos2());
|
||||
World world = portal.getPos1().getWorld();
|
||||
if (world == null) return;
|
||||
for (int i = 0; i < 15; i++) {
|
||||
double x = min.getX() + Math.random() * (max.getX() - min.getX() + 1);
|
||||
double y = min.getY() + Math.random() * (max.getY() - min.getY() + 1);
|
||||
|
||||
@@ -115,5 +115,7 @@ public class SecurityModule implements Module, Listener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {}
|
||||
public void onDisable() {
|
||||
org.bukkit.event.HandlerList.unregisterAll(this);
|
||||
}
|
||||
}
|
||||
@@ -1,135 +1,135 @@
|
||||
package de.nexuslobby.modules.servers;
|
||||
|
||||
import de.nexuslobby.NexusLobby;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Socket;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class ServerChecker {
|
||||
|
||||
private static BukkitTask globalCheckerTask = null;
|
||||
|
||||
/**
|
||||
* Prüft asynchron, ob ein Server unter der angegebenen IP und Port erreichbar ist.
|
||||
*/
|
||||
public static CompletableFuture<Boolean> isOnline(String ip, int port) {
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
try (Socket socket = new Socket()) {
|
||||
// 500ms Timeout für stabilere Erkennung
|
||||
socket.connect(new InetSocketAddress(ip, port), 500);
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Startet den Scheduler, der alle ArmorStands in allen Welten regelmäßig prüft.
|
||||
*/
|
||||
public static void startGlobalChecker() {
|
||||
// Cancel alten Task falls vorhanden
|
||||
stopGlobalChecker();
|
||||
|
||||
// WICHTIG: runTaskTimer (synchron), um den Main-Thread für getEntitiesByClass zu nutzen
|
||||
globalCheckerTask = Bukkit.getScheduler().runTaskTimer(NexusLobby.getInstance(), () -> {
|
||||
for (World world : Bukkit.getWorlds()) {
|
||||
// Das Abrufen der Entities muss auf dem Main-Thread passieren
|
||||
for (ArmorStand as : world.getEntitiesByClass(ArmorStand.class)) {
|
||||
checkAndUpdateArmorStand(as);
|
||||
}
|
||||
}
|
||||
}, 100L, 200L);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stoppt den Server-Checker Task
|
||||
*/
|
||||
public static void stopGlobalChecker() {
|
||||
if (globalCheckerTask != null && !globalCheckerTask.isCancelled()) {
|
||||
globalCheckerTask.cancel();
|
||||
globalCheckerTask = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Analysiert die Tags eines ArmorStands und aktualisiert den Namen basierend auf dem Serverstatus.
|
||||
*/
|
||||
private static void checkAndUpdateArmorStand(ArmorStand as) {
|
||||
for (String tag : as.getScoreboardTags()) {
|
||||
// Erwartetes Format: ascmd:slot1:slot2:type:command
|
||||
if (tag.startsWith("ascmd:")) {
|
||||
String[] parts = tag.split(":");
|
||||
if (parts.length < 5) continue;
|
||||
|
||||
String type = parts[3].toLowerCase();
|
||||
if (!type.equals("bungee")) continue;
|
||||
|
||||
String serverName = parts[4];
|
||||
|
||||
// Suche den passenden Key in der Config
|
||||
String configKey = null;
|
||||
if (NexusLobby.getInstance().getConfig().getConfigurationSection("servers") != null) {
|
||||
for (String key : NexusLobby.getInstance().getConfig().getConfigurationSection("servers").getKeys(false)) {
|
||||
if (key.equalsIgnoreCase(serverName)) {
|
||||
configKey = key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (configKey == null) continue;
|
||||
|
||||
String ip = NexusLobby.getInstance().getConfig().getString("servers." + configKey + ".ip");
|
||||
int port = NexusLobby.getInstance().getConfig().getInt("servers." + configKey + ".port");
|
||||
|
||||
if (ip == null) continue;
|
||||
|
||||
// Der Ping selbst läuft asynchron weg vom Main-Thread
|
||||
isOnline(ip, port).thenAccept(online -> {
|
||||
// Zurück zum Main-Thread für die Änderung des ArmorStands
|
||||
Bukkit.getScheduler().runTask(NexusLobby.getInstance(), () -> {
|
||||
if (!as.isValid()) return; // Sicherheitscheck falls AS gelöscht wurde
|
||||
|
||||
if (online) {
|
||||
restoreName(as);
|
||||
} else {
|
||||
String offlineText = "§c● §lOFFLINE §c●";
|
||||
if (!offlineText.equals(as.getCustomName())) {
|
||||
as.setCustomName(offlineText);
|
||||
as.setCustomNameVisible(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stellt den ursprünglichen Namen des ArmorStands wieder her.
|
||||
* Nutzt den Tag "asname:NAME" als Backup.
|
||||
*/
|
||||
private static void restoreName(ArmorStand as) {
|
||||
for (String t : as.getScoreboardTags()) {
|
||||
if (t.startsWith("asname:")) {
|
||||
String originalName = t.substring(7);
|
||||
String translatedName = ChatColor.translateAlternateColorCodes('&', originalName);
|
||||
|
||||
if (!translatedName.equals(as.getCustomName())) {
|
||||
as.setCustomName(translatedName);
|
||||
as.setCustomNameVisible(true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
package de.nexuslobby.modules.servers;
|
||||
|
||||
import de.nexuslobby.NexusLobby;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Socket;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class ServerChecker {
|
||||
|
||||
private static BukkitTask globalCheckerTask = null;
|
||||
|
||||
/**
|
||||
* Prüft asynchron, ob ein Server unter der angegebenen IP und Port erreichbar ist.
|
||||
*/
|
||||
public static CompletableFuture<Boolean> isOnline(String ip, int port) {
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
try (Socket socket = new Socket()) {
|
||||
// 500ms Timeout für stabilere Erkennung
|
||||
socket.connect(new InetSocketAddress(ip, port), 500);
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Startet den Scheduler, der alle ArmorStands in allen Welten regelmäßig prüft.
|
||||
*/
|
||||
public static void startGlobalChecker() {
|
||||
// Cancel alten Task falls vorhanden
|
||||
stopGlobalChecker();
|
||||
|
||||
// WICHTIG: runTaskTimer (synchron), um den Main-Thread für getEntitiesByClass zu nutzen
|
||||
globalCheckerTask = Bukkit.getScheduler().runTaskTimer(NexusLobby.getInstance(), () -> {
|
||||
for (World world : Bukkit.getWorlds()) {
|
||||
// Das Abrufen der Entities muss auf dem Main-Thread passieren
|
||||
for (ArmorStand as : world.getEntitiesByClass(ArmorStand.class)) {
|
||||
checkAndUpdateArmorStand(as);
|
||||
}
|
||||
}
|
||||
}, 100L, 200L);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stoppt den Server-Checker Task
|
||||
*/
|
||||
public static void stopGlobalChecker() {
|
||||
if (globalCheckerTask != null && !globalCheckerTask.isCancelled()) {
|
||||
globalCheckerTask.cancel();
|
||||
globalCheckerTask = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Analysiert die Tags eines ArmorStands und aktualisiert den Namen basierend auf dem Serverstatus.
|
||||
*/
|
||||
private static void checkAndUpdateArmorStand(ArmorStand as) {
|
||||
for (String tag : as.getScoreboardTags()) {
|
||||
// Erwartetes Format: ascmd:slot1:slot2:type:command
|
||||
if (tag.startsWith("ascmd:")) {
|
||||
String[] parts = tag.split(":");
|
||||
if (parts.length < 5) continue;
|
||||
|
||||
String type = parts[3].toLowerCase();
|
||||
if (!type.equals("bungee")) continue;
|
||||
|
||||
String serverName = parts[4];
|
||||
|
||||
// Suche den passenden Key in der Config
|
||||
String configKey = null;
|
||||
if (NexusLobby.getInstance().getConfig().getConfigurationSection("servers") != null) {
|
||||
for (String key : NexusLobby.getInstance().getConfig().getConfigurationSection("servers").getKeys(false)) {
|
||||
if (key.equalsIgnoreCase(serverName)) {
|
||||
configKey = key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (configKey == null) continue;
|
||||
|
||||
String ip = NexusLobby.getInstance().getConfig().getString("servers." + configKey + ".ip");
|
||||
int port = NexusLobby.getInstance().getConfig().getInt("servers." + configKey + ".port");
|
||||
|
||||
if (ip == null) continue;
|
||||
|
||||
// Der Ping selbst läuft asynchron weg vom Main-Thread
|
||||
isOnline(ip, port).thenAccept(online -> {
|
||||
// Zurück zum Main-Thread für die Änderung des ArmorStands
|
||||
Bukkit.getScheduler().runTask(NexusLobby.getInstance(), () -> {
|
||||
if (!as.isValid()) return; // Sicherheitscheck falls AS gelöscht wurde
|
||||
|
||||
if (online) {
|
||||
restoreName(as);
|
||||
} else {
|
||||
String offlineText = "§c● §lOFFLINE §c●";
|
||||
if (!offlineText.equals(as.getCustomName())) {
|
||||
as.setCustomName(offlineText);
|
||||
as.setCustomNameVisible(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stellt den ursprünglichen Namen des ArmorStands wieder her.
|
||||
* Nutzt den Tag "asname:NAME" als Backup.
|
||||
*/
|
||||
private static void restoreName(ArmorStand as) {
|
||||
for (String t : as.getScoreboardTags()) {
|
||||
if (t.startsWith("asname:")) {
|
||||
String originalName = t.substring(7);
|
||||
String translatedName = ChatColor.translateAlternateColorCodes('&', originalName);
|
||||
|
||||
if (!translatedName.equals(as.getCustomName())) {
|
||||
as.setCustomName(translatedName);
|
||||
as.setCustomNameVisible(true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -146,20 +146,50 @@ public class ServerSwitcherListener implements Listener, CommandExecutor {
|
||||
int clickedSlot = e.getSlot();
|
||||
ConfigurationSection serversSection = NexusLobby.getInstance().getConfig().getConfigurationSection("compass.servers");
|
||||
|
||||
if (serversSection != null) {
|
||||
for (String serverId : serversSection.getKeys(false)) {
|
||||
String path = "compass.servers." + serverId;
|
||||
int configSlot = NexusLobby.getInstance().getConfig().getInt(path + ".slot", -1);
|
||||
if (serversSection == null) return;
|
||||
|
||||
if (configSlot == clickedSlot) {
|
||||
String command = NexusLobby.getInstance().getConfig().getString(path + ".command");
|
||||
if (command != null && !command.isEmpty()) {
|
||||
p.closeInventory();
|
||||
p.chat("/" + command);
|
||||
return;
|
||||
}
|
||||
}
|
||||
for (String serverId : serversSection.getKeys(false)) {
|
||||
String path = "compass.servers." + serverId;
|
||||
int configSlot = NexusLobby.getInstance().getConfig().getInt(path + ".slot", -1);
|
||||
|
||||
if (configSlot != clickedSlot) continue;
|
||||
|
||||
String command = NexusLobby.getInstance().getConfig().getString(path + ".command", "").trim();
|
||||
if (command.isEmpty()) return;
|
||||
|
||||
p.closeInventory();
|
||||
|
||||
// "server <name>" → BungeeCord Connect Plugin-Message
|
||||
if (command.toLowerCase().startsWith("server ")) {
|
||||
String serverName = command.substring(7).trim();
|
||||
connectBungee(p, serverName);
|
||||
} else {
|
||||
// Alle anderen Befehle als Konsolen-Befehl ausführen
|
||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(),
|
||||
command.replace("%player%", p.getName()));
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sendet den Spieler per BungeeCord Plugin-Message an einen anderen Server.
|
||||
*/
|
||||
private void connectBungee(Player player, String serverName) {
|
||||
if (!Bukkit.getMessenger().isOutgoingChannelRegistered(
|
||||
NexusLobby.getInstance(), "BungeeCord")) {
|
||||
player.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§cKein BungeeCord-Kanal registriert.");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
java.io.ByteArrayOutputStream b = new java.io.ByteArrayOutputStream();
|
||||
java.io.DataOutputStream out = new java.io.DataOutputStream(b);
|
||||
out.writeUTF("Connect");
|
||||
out.writeUTF(serverName);
|
||||
player.sendPluginMessage(NexusLobby.getInstance(), "BungeeCord", b.toByteArray());
|
||||
player.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§7Verbinde mit §e" + serverName + "§7...");
|
||||
} catch (java.io.IOException ex) {
|
||||
player.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§cFehler beim Verbinden: " + ex.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -231,5 +231,8 @@ public class LobbySettingsModule implements Module, Listener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() { saveSettings(); }
|
||||
public void onDisable() {
|
||||
org.bukkit.event.HandlerList.unregisterAll(this);
|
||||
saveSettings();
|
||||
}
|
||||
}
|
||||
@@ -47,6 +47,7 @@ public class GlobalChatSuppressor implements Module, PluginMessageListener, List
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
org.bukkit.event.HandlerList.unregisterAll(this);
|
||||
plugin.getServer().getMessenger().unregisterIncomingPluginChannel(plugin, CHANNEL_CONTROL);
|
||||
plugin.getServer().getMessenger().unregisterIncomingPluginChannel(plugin, CHANNEL_CHAT);
|
||||
plugin.getServer().getMessenger().unregisterOutgoingPluginChannel(plugin, CHANNEL_CONTROL);
|
||||
@@ -105,4 +106,4 @@ public class GlobalChatSuppressor implements Module, PluginMessageListener, List
|
||||
SuppressManager.unsuppress(uuid);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,155 +1,156 @@
|
||||
package de.nexuslobby.utils;
|
||||
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Validiert Config-Werte und setzt Default-Werte wenn nötig
|
||||
*/
|
||||
public class ConfigValidator {
|
||||
|
||||
private final JavaPlugin plugin;
|
||||
private final FileConfiguration config;
|
||||
private final List<String> warnings = new ArrayList<>();
|
||||
private boolean modified = false;
|
||||
|
||||
public ConfigValidator(JavaPlugin plugin, FileConfiguration config) {
|
||||
this.plugin = plugin;
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validiert alle Config-Werte und gibt Warnings aus
|
||||
*/
|
||||
public void validate() {
|
||||
validateSpawn();
|
||||
validateLobbySettings();
|
||||
validateTablist();
|
||||
validateBall();
|
||||
validateModules();
|
||||
|
||||
// Warnings ausgeben
|
||||
if (!warnings.isEmpty()) {
|
||||
plugin.getLogger().warning("=== Config-Validierung ===");
|
||||
warnings.forEach(msg -> plugin.getLogger().warning(" " + msg));
|
||||
plugin.getLogger().warning("=========================");
|
||||
}
|
||||
|
||||
// Config speichern wenn Änderungen vorgenommen wurden
|
||||
if (modified) {
|
||||
plugin.saveConfig();
|
||||
plugin.getLogger().info("Config wurde mit Default-Werten aktualisiert.");
|
||||
}
|
||||
}
|
||||
|
||||
private void validateSpawn() {
|
||||
ensureDefault("spawn.world", "world");
|
||||
ensureDefault("spawn.x", 0.5);
|
||||
ensureDefault("spawn.y", 64.0);
|
||||
ensureDefault("spawn.z", 0.5);
|
||||
ensureDefault("spawn.yaw", 0.0);
|
||||
ensureDefault("spawn.pitch", 0.0);
|
||||
|
||||
// Validiere Y-Koordinate
|
||||
double y = config.getDouble("spawn.y", 64.0);
|
||||
if (y < -64 || y > 320) {
|
||||
warnings.add("spawn.y (" + y + ") außerhalb des gültigen Bereichs (-64 bis 320)");
|
||||
}
|
||||
}
|
||||
|
||||
private void validateLobbySettings() {
|
||||
ensureDefault("lobby.allow-fly", false);
|
||||
ensureDefault("lobby.pvp-enabled", false);
|
||||
ensureDefault("lobby.build-enabled", false);
|
||||
ensureDefault("lobby.default-gamemode", "Adventure");
|
||||
ensureDefault("lobby.clear-inventory-on-join", true);
|
||||
|
||||
// Validiere GameMode
|
||||
String gamemode = config.getString("lobby.default-gamemode", "Adventure");
|
||||
if (!isValidGameMode(gamemode)) {
|
||||
warnings.add("lobby.default-gamemode '" + gamemode + "' ist ungültig. Nutze: Survival, Creative, Adventure oder Spectator");
|
||||
}
|
||||
}
|
||||
|
||||
private void validateTablist() {
|
||||
ensureDefault("tablist.enabled", true);
|
||||
ensureDefault("tablist.header", "&6Willkommen auf &eNexusLobby");
|
||||
ensureDefault("tablist.footer", "&7Viel Spaß!");
|
||||
ensureDefault("tablist.refresh-interval", 40);
|
||||
|
||||
// Validiere Refresh-Interval
|
||||
int interval = config.getInt("tablist.refresh-interval", 40);
|
||||
if (interval < 1) {
|
||||
warnings.add("tablist.refresh-interval (" + interval + ") ist zu klein. Minimum ist 1 Tick.");
|
||||
config.set("tablist.refresh-interval", 1);
|
||||
modified = true;
|
||||
} else if (interval > 200) {
|
||||
warnings.add("tablist.refresh-interval (" + interval + ") ist sehr hoch. Empfohlen: 20-100 Ticks.");
|
||||
}
|
||||
}
|
||||
|
||||
private void validateBall() {
|
||||
ensureDefault("ball.respawn_delay", 60);
|
||||
|
||||
// Validiere Respawn-Delay
|
||||
long delay = config.getLong("ball.respawn_delay", 60);
|
||||
if (delay < 5) {
|
||||
warnings.add("ball.respawn_delay (" + delay + "s) ist zu kurz. Minimum empfohlen: 5 Sekunden.");
|
||||
} else if (delay > 600) {
|
||||
warnings.add("ball.respawn_delay (" + delay + "s) ist sehr lang. Empfohlen: 30-120 Sekunden.");
|
||||
}
|
||||
|
||||
// Prüfe ob Spawn gesetzt ist
|
||||
if (!config.contains("ball.spawn")) {
|
||||
warnings.add("ball.spawn nicht gesetzt. Nutze /nexuslobby ball setspawn");
|
||||
}
|
||||
}
|
||||
|
||||
private void validateModules() {
|
||||
// Worldborder
|
||||
if (config.contains("worldborder.enabled")) {
|
||||
ensureDefault("worldborder.type", "SQUARE");
|
||||
ensureDefault("worldborder.radius", 50.0);
|
||||
|
||||
double radius = config.getDouble("worldborder.radius", 50.0);
|
||||
if (radius < 10) {
|
||||
warnings.add("worldborder.radius (" + radius + ") ist sehr klein. Minimum empfohlen: 10 Blöcke.");
|
||||
} else if (radius > 10000) {
|
||||
warnings.add("worldborder.radius (" + radius + ") ist extrem groß. Performance-Warnung!");
|
||||
}
|
||||
|
||||
String type = config.getString("worldborder.type", "SQUARE");
|
||||
if (!type.equalsIgnoreCase("SQUARE") && !type.equalsIgnoreCase("CIRCLE")) {
|
||||
warnings.add("worldborder.type '" + type + "' ist ungültig. Nutze: SQUARE oder CIRCLE");
|
||||
}
|
||||
}
|
||||
|
||||
// Items Modul
|
||||
if (config.contains("items.lobby-tools")) {
|
||||
// Prüfe ob Slot-Nummern gültig sind (0-8)
|
||||
for (String toolKey : config.getConfigurationSection("items.lobby-tools").getKeys(false)) {
|
||||
int slot = config.getInt("items.lobby-tools." + toolKey + ".slot", -1);
|
||||
if (slot < 0 || slot > 8) {
|
||||
warnings.add("items.lobby-tools." + toolKey + ".slot (" + slot + ") ist ungültig (0-8)");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ensureDefault(String path, Object defaultValue) {
|
||||
if (!config.contains(path)) {
|
||||
config.set(path, defaultValue);
|
||||
modified = true;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isValidGameMode(String mode) {
|
||||
return mode.equalsIgnoreCase("Survival") ||
|
||||
mode.equalsIgnoreCase("Creative") ||
|
||||
mode.equalsIgnoreCase("Adventure") ||
|
||||
mode.equalsIgnoreCase("Spectator");
|
||||
}
|
||||
}
|
||||
package de.nexuslobby.utils;
|
||||
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Validiert Config-Werte und setzt Default-Werte wenn nötig
|
||||
*/
|
||||
public class ConfigValidator {
|
||||
|
||||
private final JavaPlugin plugin;
|
||||
private final FileConfiguration config;
|
||||
private final List<String> warnings = new ArrayList<>();
|
||||
private boolean modified = false;
|
||||
|
||||
public ConfigValidator(JavaPlugin plugin, FileConfiguration config) {
|
||||
this.plugin = plugin;
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validiert alle Config-Werte und gibt Warnings aus
|
||||
*/
|
||||
public void validate() {
|
||||
ensureDefault("prefix", "&8[&6Nexus&8] ");
|
||||
validateSpawn();
|
||||
validateLobbySettings();
|
||||
validateTablist();
|
||||
validateBall();
|
||||
validateModules();
|
||||
|
||||
// Warnings ausgeben
|
||||
if (!warnings.isEmpty()) {
|
||||
plugin.getLogger().warning("=== Config-Validierung ===");
|
||||
warnings.forEach(msg -> plugin.getLogger().warning(" " + msg));
|
||||
plugin.getLogger().warning("=========================");
|
||||
}
|
||||
|
||||
// Config speichern wenn Änderungen vorgenommen wurden
|
||||
if (modified) {
|
||||
plugin.saveConfig();
|
||||
plugin.getLogger().info("Config wurde mit Default-Werten aktualisiert.");
|
||||
}
|
||||
}
|
||||
|
||||
private void validateSpawn() {
|
||||
ensureDefault("spawn.world", "world");
|
||||
ensureDefault("spawn.x", 0.5);
|
||||
ensureDefault("spawn.y", 64.0);
|
||||
ensureDefault("spawn.z", 0.5);
|
||||
ensureDefault("spawn.yaw", 0.0);
|
||||
ensureDefault("spawn.pitch", 0.0);
|
||||
|
||||
// Validiere Y-Koordinate
|
||||
double y = config.getDouble("spawn.y", 64.0);
|
||||
if (y < -64 || y > 320) {
|
||||
warnings.add("spawn.y (" + y + ") außerhalb des gültigen Bereichs (-64 bis 320)");
|
||||
}
|
||||
}
|
||||
|
||||
private void validateLobbySettings() {
|
||||
ensureDefault("lobby.allow-fly", false);
|
||||
ensureDefault("lobby.pvp-enabled", false);
|
||||
ensureDefault("lobby.build-enabled", false);
|
||||
ensureDefault("lobby.default-gamemode", "Adventure");
|
||||
ensureDefault("lobby.clear-inventory-on-join", true);
|
||||
|
||||
// Validiere GameMode
|
||||
String gamemode = config.getString("lobby.default-gamemode", "Adventure");
|
||||
if (!isValidGameMode(gamemode)) {
|
||||
warnings.add("lobby.default-gamemode '" + gamemode + "' ist ungültig. Nutze: Survival, Creative, Adventure oder Spectator");
|
||||
}
|
||||
}
|
||||
|
||||
private void validateTablist() {
|
||||
ensureDefault("tablist.enabled", true);
|
||||
ensureDefault("tablist.header", "&6Willkommen auf &eNexusLobby");
|
||||
ensureDefault("tablist.footer", "&7Viel Spaß!");
|
||||
ensureDefault("tablist.refresh-interval", 40);
|
||||
|
||||
// Validiere Refresh-Interval
|
||||
int interval = config.getInt("tablist.refresh-interval", 40);
|
||||
if (interval < 1) {
|
||||
warnings.add("tablist.refresh-interval (" + interval + ") ist zu klein. Minimum ist 1 Tick.");
|
||||
config.set("tablist.refresh-interval", 1);
|
||||
modified = true;
|
||||
} else if (interval > 200) {
|
||||
warnings.add("tablist.refresh-interval (" + interval + ") ist sehr hoch. Empfohlen: 20-100 Ticks.");
|
||||
}
|
||||
}
|
||||
|
||||
private void validateBall() {
|
||||
ensureDefault("ball.respawn_delay", 60);
|
||||
|
||||
// Validiere Respawn-Delay
|
||||
long delay = config.getLong("ball.respawn_delay", 60);
|
||||
if (delay < 5) {
|
||||
warnings.add("ball.respawn_delay (" + delay + "s) ist zu kurz. Minimum empfohlen: 5 Sekunden.");
|
||||
} else if (delay > 600) {
|
||||
warnings.add("ball.respawn_delay (" + delay + "s) ist sehr lang. Empfohlen: 30-120 Sekunden.");
|
||||
}
|
||||
|
||||
// Prüfe ob Spawn gesetzt ist
|
||||
if (!config.contains("ball.spawn")) {
|
||||
warnings.add("ball.spawn nicht gesetzt. Nutze /nexuslobby ball setspawn");
|
||||
}
|
||||
}
|
||||
|
||||
private void validateModules() {
|
||||
// Worldborder
|
||||
if (config.contains("worldborder.enabled")) {
|
||||
ensureDefault("worldborder.type", "SQUARE");
|
||||
ensureDefault("worldborder.radius", 50.0);
|
||||
|
||||
double radius = config.getDouble("worldborder.radius", 50.0);
|
||||
if (radius < 10) {
|
||||
warnings.add("worldborder.radius (" + radius + ") ist sehr klein. Minimum empfohlen: 10 Blöcke.");
|
||||
} else if (radius > 10000) {
|
||||
warnings.add("worldborder.radius (" + radius + ") ist extrem groß. Performance-Warnung!");
|
||||
}
|
||||
|
||||
String type = config.getString("worldborder.type", "SQUARE");
|
||||
if (!type.equalsIgnoreCase("SQUARE") && !type.equalsIgnoreCase("CIRCLE")) {
|
||||
warnings.add("worldborder.type '" + type + "' ist ungültig. Nutze: SQUARE oder CIRCLE");
|
||||
}
|
||||
}
|
||||
|
||||
// Items Modul
|
||||
if (config.contains("items.lobby-tools")) {
|
||||
// Prüfe ob Slot-Nummern gültig sind (0-8)
|
||||
for (String toolKey : config.getConfigurationSection("items.lobby-tools").getKeys(false)) {
|
||||
int slot = config.getInt("items.lobby-tools." + toolKey + ".slot", -1);
|
||||
if (slot < 0 || slot > 8) {
|
||||
warnings.add("items.lobby-tools." + toolKey + ".slot (" + slot + ") ist ungültig (0-8)");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ensureDefault(String path, Object defaultValue) {
|
||||
if (!config.contains(path)) {
|
||||
config.set(path, defaultValue);
|
||||
modified = true;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isValidGameMode(String mode) {
|
||||
return mode.equalsIgnoreCase("Survival") ||
|
||||
mode.equalsIgnoreCase("Creative") ||
|
||||
mode.equalsIgnoreCase("Adventure") ||
|
||||
mode.equalsIgnoreCase("Spectator");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public class DoubleJump implements Listener {
|
||||
@EventHandler
|
||||
public void onMove(PlayerMoveEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (player.getGameMode() != GameMode.CREATIVE && player.getLocation().subtract(0, 0.1, 0).getBlock().getType() != Material.AIR) {
|
||||
if (player.getGameMode() != GameMode.CREATIVE && player.getGameMode() != GameMode.SPECTATOR && player.getLocation().subtract(0, 0.1, 0).getBlock().getType() != Material.AIR) {
|
||||
if (NexusLobby.getInstance().getConfig().getBoolean("doublejump.enabled", true)) {
|
||||
player.setAllowFlight(true);
|
||||
}
|
||||
|
||||
@@ -1,32 +1,43 @@
|
||||
package de.nexuslobby.utils;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.Map;
|
||||
|
||||
public class LangManager {
|
||||
private static Map<String, Map<String, String>> langMap;
|
||||
private static String currentLang = "de";
|
||||
|
||||
public static void load(JavaPlugin plugin) {
|
||||
Yaml yaml = new Yaml();
|
||||
try (InputStream in = plugin.getResource("lang.yml")) {
|
||||
langMap = yaml.load(in);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void setLanguage(String lang) {
|
||||
currentLang = lang;
|
||||
}
|
||||
|
||||
public static String get(String key) {
|
||||
if (langMap == null) return key;
|
||||
Map<String, String> translations = langMap.get(key);
|
||||
if (translations == null) return key;
|
||||
return translations.getOrDefault(currentLang, key);
|
||||
}
|
||||
}
|
||||
package de.nexuslobby.utils;
|
||||
|
||||
import de.nexuslobby.NexusLobby;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.Map;
|
||||
|
||||
public class LangManager {
|
||||
private static Map<String, Map<String, String>> langMap;
|
||||
private static String currentLang = "de";
|
||||
|
||||
public static void load(JavaPlugin plugin) {
|
||||
Yaml yaml = new Yaml();
|
||||
try (InputStream in = plugin.getResource("lang.yml")) {
|
||||
langMap = yaml.load(in);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void setLanguage(String lang) {
|
||||
currentLang = lang;
|
||||
}
|
||||
|
||||
public static String get(String key) {
|
||||
if (langMap == null) return key;
|
||||
Map<String, String> translations = langMap.get(key);
|
||||
if (translations == null) return key;
|
||||
return translations.getOrDefault(currentLang, key)
|
||||
.replace("§8[§6Nexus§8] ", getPrefix());
|
||||
}
|
||||
|
||||
public static String getPrefix() {
|
||||
NexusLobby plugin = NexusLobby.getInstance();
|
||||
String prefix = plugin == null
|
||||
? "&8[&6Nexus&8] "
|
||||
: plugin.getConfig().getString("prefix", "&8[&6Nexus&8] ");
|
||||
return ChatColor.translateAlternateColorCodes('&', prefix);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
@@ -84,4 +85,9 @@ public class PlayerHider implements Listener {
|
||||
private String colorize(String s) {
|
||||
return s == null ? "" : s.replace("&", "§");
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onQuit(PlayerQuitEvent event) {
|
||||
hidden.remove(event.getPlayer().getUniqueId());
|
||||
}
|
||||
}
|
||||
@@ -1,85 +1,36 @@
|
||||
package de.nexuslobby.utils;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import de.nexuslobby.NexusLobby;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class UpdateChecker {
|
||||
|
||||
private final NexusLobby plugin;
|
||||
private static final String API_URL = "https://git.viper.ipv64.net/api/v1/repos/M_Viper/NexusLobby/releases/latest";
|
||||
private static final int TIMEOUT_MS = 5000;
|
||||
|
||||
public UpdateChecker(NexusLobby plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public void getVersion(final Consumer<String> consumer) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(this.plugin, () -> {
|
||||
HttpURLConnection connection = null;
|
||||
try {
|
||||
URL url = new URL(API_URL);
|
||||
connection = (HttpURLConnection) url.openConnection();
|
||||
connection.setRequestMethod("GET");
|
||||
connection.setConnectTimeout(TIMEOUT_MS);
|
||||
connection.setReadTimeout(TIMEOUT_MS);
|
||||
connection.setRequestProperty("Accept", "application/json");
|
||||
connection.setRequestProperty("User-Agent", "NexusLobby-UpdateChecker");
|
||||
|
||||
int responseCode = connection.getResponseCode();
|
||||
if (responseCode != HttpURLConnection.HTTP_OK) {
|
||||
plugin.getLogger().warning("Update-Check fehlgeschlagen: HTTP " + responseCode);
|
||||
return;
|
||||
}
|
||||
|
||||
try (BufferedReader reader = new BufferedReader(
|
||||
new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8))) {
|
||||
|
||||
StringBuilder response = new StringBuilder();
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
response.append(line);
|
||||
}
|
||||
|
||||
parseAndNotify(response.toString(), consumer);
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
plugin.getLogger().warning("Update-Check fehlgeschlagen: " + e.getMessage());
|
||||
} finally {
|
||||
if (connection != null) {
|
||||
connection.disconnect();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void parseAndNotify(String jsonResponse, Consumer<String> consumer) {
|
||||
try {
|
||||
JsonObject json = JsonParser.parseString(jsonResponse).getAsJsonObject();
|
||||
|
||||
if (json.has("tag_name")) {
|
||||
String version = json.get("tag_name").getAsString();
|
||||
// Entferne 'v' Präfix falls vorhanden (z.B. v1.0.0 -> 1.0.0)
|
||||
if (version.startsWith("v")) {
|
||||
version = version.substring(1);
|
||||
}
|
||||
consumer.accept(version);
|
||||
} else {
|
||||
plugin.getLogger().warning("Update-Check: 'tag_name' nicht in API-Response gefunden");
|
||||
}
|
||||
} catch (JsonSyntaxException e) {
|
||||
plugin.getLogger().warning("Update-Check: Ungültiges JSON-Format - " + e.getMessage());
|
||||
}
|
||||
}
|
||||
package de.nexuslobby.utils;
|
||||
|
||||
import de.nexuslobby.NexusLobby;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.util.Scanner;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class UpdateChecker {
|
||||
|
||||
private final NexusLobby plugin;
|
||||
private static final int RESOURCE_ID = 132388;
|
||||
|
||||
public UpdateChecker(NexusLobby plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public void getVersion(final Consumer<String> consumer) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(this.plugin, () -> {
|
||||
try (InputStream is = new URL(
|
||||
"https://api.spigotmc.org/legacy/update.php?resource=" + RESOURCE_ID + "/~").openStream();
|
||||
Scanner scanner = new Scanner(is)) {
|
||||
|
||||
if (scanner.hasNext()) {
|
||||
consumer.accept(scanner.next());
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
plugin.getLogger().warning("Update-Check fehlgeschlagen: " + e.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,8 @@ package de.nexuslobby.utils;
|
||||
import de.nexuslobby.NexusLobby;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
@@ -17,7 +19,21 @@ public class VoidProtection implements Listener {
|
||||
Player player = event.getPlayer();
|
||||
if (player.getLocation().getY() < 0) {
|
||||
if (NexusLobby.getInstance().getConfig().getBoolean("void_protection.teleport_to_spawn", true)) {
|
||||
Location spawn = player.getWorld().getSpawnLocation();
|
||||
FileConfiguration config = NexusLobby.getInstance().getConfig();
|
||||
Location spawn;
|
||||
if (config.contains("spawn.world")) {
|
||||
String worldName = config.getString("spawn.world");
|
||||
World world = Bukkit.getWorld(worldName);
|
||||
if (world != null) {
|
||||
spawn = new Location(world,
|
||||
config.getDouble("spawn.x"), config.getDouble("spawn.y"), config.getDouble("spawn.z"),
|
||||
(float) config.getDouble("spawn.yaw"), (float) config.getDouble("spawn.pitch"));
|
||||
} else {
|
||||
spawn = player.getWorld().getSpawnLocation();
|
||||
}
|
||||
} else {
|
||||
spawn = player.getWorld().getSpawnLocation();
|
||||
}
|
||||
player.teleport(spawn);
|
||||
String msg = de.nexuslobby.utils.LangManager.get("void_protection_message");
|
||||
if (msg != null && !msg.isEmpty()) {
|
||||
|
||||
@@ -20,6 +20,9 @@
|
||||
# Verfügbare Optionen: de (Deutsch), en (Englisch), fr (Französisch)
|
||||
language: de
|
||||
|
||||
# Prefix vor Plugin-Nachrichten im Chat (&-Farbcodes sind erlaubt)
|
||||
prefix: "&8[&6Nexus&8] "
|
||||
|
||||
# ══════════════════════════════════════════════════════════════════════════════
|
||||
# SPAWN EINSTELLUNGEN
|
||||
# ══════════════════════════════════════════════════════════════════════════════
|
||||
@@ -65,12 +68,12 @@ worldborder:
|
||||
|
||||
# Zentrum der Weltgrenze (optional, kann leer bleiben)
|
||||
# Wenn nicht gesetzt, wird der Spawn-Punkt als Zentrum verwendet
|
||||
center:
|
||||
# center wird automatisch über /border circle gesetzt
|
||||
|
||||
# Alternative: Definiere Eckpunkte (für rechteckige Border)
|
||||
# Format: x,y,z
|
||||
pos1:
|
||||
pos2:
|
||||
# pos1 wird automatisch über /border square gesetzt
|
||||
# pos2 wird automatisch über /border square gesetzt
|
||||
|
||||
# ══════════════════════════════════════════════════════════════════════════════
|
||||
# LOBBY EINSTELLUNGEN
|
||||
@@ -162,7 +165,7 @@ items:
|
||||
# Kompass (Server-Auswahl / Teleporter)
|
||||
compass:
|
||||
# Aktiviert das Kompass-Item (true = an, false = aus)
|
||||
enabled: true
|
||||
enabled: false
|
||||
|
||||
# Anzeigename des Items (unterstützt Farbcodes)
|
||||
displayname: "&eTeleporter"
|
||||
@@ -184,7 +187,7 @@ items:
|
||||
# Gadget-Menü (Spezialeffekte und Extras)
|
||||
gadget:
|
||||
# Aktiviert das Gadget-Item (true = an, false = aus)
|
||||
enabled: false
|
||||
enabled: true
|
||||
|
||||
# Anzeigename des Items (unterstützt Farbcodes)
|
||||
displayname: "&bGadgets"
|
||||
@@ -283,7 +286,7 @@ player_inspect:
|
||||
# Join/Quit-Nachrichten Unterdrückung und BungeeCord-Messaging
|
||||
suppressor:
|
||||
# Aktiviert das Suppressor-System (true = an, false = aus)
|
||||
enabled: true
|
||||
enabled: false
|
||||
|
||||
# Unterdrückt Join- und Quit-Nachrichten für neue Spieler temporär
|
||||
# true = Nachrichten werden unterdrückt, false = normale Anzeige
|
||||
@@ -402,7 +405,7 @@ ball:
|
||||
enabled: true
|
||||
|
||||
# Spawn-Position des Balls
|
||||
# Tipp: Nutze /nexus ball setspawn um diese Position automatisch zu setzen
|
||||
# Tipp: Nutze /nexuslobby ball setspawn um diese Position automatisch zu setzen
|
||||
spawn:
|
||||
# Name der Welt in der der Ball spawnt
|
||||
world: "world"
|
||||
@@ -425,12 +428,62 @@ ball:
|
||||
# 0 = Kein automatischer Respawn
|
||||
respawn_delay: 60
|
||||
|
||||
# ══════════════════════════════════════════════════════════════════════════
|
||||
# TOR-DEFINITIONEN
|
||||
# ══════════════════════════════════════════════════════════════════════════
|
||||
# Tore werden automatisch per Befehl gesetzt und hier gespeichert.
|
||||
# Manuell bearbeiten ist möglich, aber der Befehlsweg ist empfohlen.
|
||||
#
|
||||
# Anleitung zum Einrichten eines Tores:
|
||||
# 1. Gehe zur INNEREN Ecke des Torrahmens (z.B. linke untere Ecke)
|
||||
# /nexuslobby ball goal pos1
|
||||
# 2. Gehe zur GEGENÜBERLIEGENDEN Ecke (rechte obere Ecke, auch 1-2 Blöcke
|
||||
# hinter dem Tor in Schussrichtung für bessere Erkennung!)
|
||||
# /nexuslobby ball goal pos2
|
||||
# 3. Speichern (Team 1 = Blau, Team 2 = Rot):
|
||||
# /nexuslobby ball goal save torBlau 1
|
||||
#
|
||||
# WICHTIG für zuverlässige Erkennung:
|
||||
# - Die Box muss MINDESTENS 1.5 Blöcke Tiefe in Schussrichtung haben
|
||||
# - Die Box muss MINDESTENS 3 Blöcke hoch sein (Y-Achse)
|
||||
# - Nutze /nexuslobby ball goal show um die Box sichtbar zu machen
|
||||
# - Nutze /nexuslobby ball goal debug um die Ball-Position live zu prüfen
|
||||
#
|
||||
# Beispiel-Eintrag (wird vom Plugin automatisch befüllt):
|
||||
# goals:
|
||||
# torBlau:
|
||||
# pos1:
|
||||
# world: world
|
||||
# x: 100.0
|
||||
# y: 64.0
|
||||
# z: 198.0
|
||||
# pos2:
|
||||
# world: world
|
||||
# x: 106.0
|
||||
# y: 68.0
|
||||
# z: 200.5 # <-- 2.5 Blöcke Tiefe in Z-Richtung!
|
||||
# team: 1
|
||||
# torRot:
|
||||
# pos1:
|
||||
# world: world
|
||||
# x: 100.0
|
||||
# y: 64.0
|
||||
# z: -198.0
|
||||
# pos2:
|
||||
# world: world
|
||||
# x: 106.0
|
||||
# y: 68.0
|
||||
# z: -200.5
|
||||
# team: 2
|
||||
#
|
||||
# Tore werden hier automatisch eingetragen sobald du den save-Befehl nutzt:
|
||||
goals: {}
|
||||
|
||||
# ══════════════════════════════════════════════════════════════════════════════
|
||||
# Links
|
||||
# ══════════════════════════════════════════════════════════════════════════════
|
||||
#
|
||||
# Benötigst du Hilfe oder Support?
|
||||
# - Webseite: https://m-viper.de
|
||||
# - Dokumentation: https://git.viper.ipv64.net/M_Viper/NexusLobby/wiki
|
||||
# - Discord: https://discord.com/invite/FdRs4BRd8D
|
||||
# - GitHub: https://git.viper.ipv64.net/M_Viper/NexusLobby
|
||||
# - Dokumentation: https://viper-network.de/wiki/NexusLobby/
|
||||
# - Discord: https://discord.com/invite/FdRs4BRd8D
|
||||
+203
-203
@@ -1,203 +1,203 @@
|
||||
# _ __ __ __ __
|
||||
# / | / /__ _ ____ _______/ / ____ / /_ / /_ __ __
|
||||
# / |/ / _ \| |/_/ / / / ___/ / / __ \/ __ \/ __ \/ / / /
|
||||
# / /| / __/> </ /_/ (__ ) /___/ /_/ / /_/ / /_/ / /_/ /
|
||||
# /_/ |_/\___/_/|_|\__,_/____/_____/\____/_.___/_.___/\__, /
|
||||
# /____/
|
||||
#
|
||||
# =====================================================
|
||||
# DEFAULT Language
|
||||
# =====================================================
|
||||
|
||||
soccer_module_not_loaded:
|
||||
de: "§cDas Fußball-Modul ist nicht geladen."
|
||||
en: "§cThe soccer module is not loaded."
|
||||
parkour_usage:
|
||||
de: "§8[§6Nexus§8] §7Nutze: §e/nexus parkour <setstart|setfinish|setcheckpoint|reset|clear|removeall>"
|
||||
en: "§8[§6Nexus§8] §7Usage: §e/nexus parkour <setstart|setfinish|setcheckpoint|reset|clear|removeall>"
|
||||
parkour_run_aborted:
|
||||
de: "§8[§6Nexus§8] §7Dein aktueller Lauf wurde abgebrochen."
|
||||
en: "§8[§6Nexus§8] §7Your current run was aborted."
|
||||
parkour_besttimes_cleared:
|
||||
de: "§8[§6Nexus§8] §aAlle Parkour-Bestzeiten wurden gelöscht!"
|
||||
en: "§8[§6Nexus§8] §aAll parkour best times have been cleared!"
|
||||
parkour_track_removed:
|
||||
de: "§8[§6Nexus§8] §cDie gesamte Strecke (Checkpoints & Ziel) wurde gelöscht!"
|
||||
en: "§8[§6Nexus§8] §cThe entire track (checkpoints & finish) has been removed!"
|
||||
unknown_subcommand:
|
||||
de: "§cUnbekannter Unterbefehl."
|
||||
en: "§cUnknown subcommand."
|
||||
parkour_npc_marked:
|
||||
de: "§8[§6Nexus§8] §aArmorStand als Parkour-NPC markiert!"
|
||||
en: "§8[§6Nexus§8] §aArmorStand marked as parkour NPC!"
|
||||
parkour_start_set:
|
||||
de: "§8[§6Nexus§8] §aParkour-Startpunkt an deiner Position gesetzt!"
|
||||
en: "§8[§6Nexus§8] §aParkour start set at your position!"
|
||||
scoreboard_usage:
|
||||
de: "§cBenutzung: /nexus sb <on|off|admin|spieler>"
|
||||
en: "§cUsage: /nexus sb <on|off|admin|player>"
|
||||
scoreboard_module_disabled:
|
||||
de: "§cScoreboard-Modul ist deaktiviert."
|
||||
en: "§cScoreboard module is disabled."
|
||||
info_header:
|
||||
de: "§8§m--------------------------------------"
|
||||
en: "§8§m--------------------------------------"
|
||||
info_title:
|
||||
de: "§6§lNexusLobby §7- Informationen"
|
||||
en: "§6§lNexusLobby §7- Information"
|
||||
info_spawn:
|
||||
de: "§f/spawn §7- Zum Spawn"
|
||||
en: "§f/spawn §7- To spawn"
|
||||
info_parkour:
|
||||
de: "§f/setstart §8| §f/setcheckpoint §8| §f/setfinish"
|
||||
en: "§f/setstart §8| §f/setcheckpoint §8| §f/setfinish"
|
||||
info_removeall:
|
||||
de: "§f/nexus parkour removeall §7- Strecke löschen"
|
||||
en: "§f/nexus parkour removeall §7- Remove track"
|
||||
info_ball:
|
||||
de: "§f/nexus ball setspawn §7- Fußball Spawn setzen"
|
||||
en: "§f/nexus ball setspawn §7- Set soccer spawn"
|
||||
info_setspawn:
|
||||
de: "§f/nexus setspawn §7- Spawn setzen"
|
||||
en: "§f/nexus setspawn §7- Set spawn"
|
||||
info_scoreboard:
|
||||
de: "§f/nexus sb <on|off> §7- Scoreboard"
|
||||
en: "§f/nexus sb <on|off> §7- Scoreboard"
|
||||
info_reload:
|
||||
de: "§f/nexus reload §7- Config laden"
|
||||
en: "§f/nexus reload §7- Reload config"
|
||||
info_footer:
|
||||
de: "§8§m--------------------------------------"
|
||||
en: "§8§m--------------------------------------"
|
||||
parkour_trainer_greeting:
|
||||
de: "§6§lTrainer §8» §aViel Erfolg beim Parkour! Gib dein Bestes!"
|
||||
en: "§6§lTrainer §8» §aGood luck with the parkour! Give it your best!"
|
||||
update_available:
|
||||
de: "§8[§6Nexus§8] §aEin neues §6Update §afür §eNexusLobby §aist verfügbar!"
|
||||
en: "§8[§6Nexus§8] §aA new §6update §afor §eNexusLobby §ais available!"
|
||||
update_version:
|
||||
de: "§8» §7Version: §c{old} §8-> §a{new}"
|
||||
en: "§8» §7Version: §c{old} §8-> §a{new}"
|
||||
update_download_link:
|
||||
de: "§8» §6Klicke §e§l[HIER] §6zum Herunterladen."
|
||||
en: "§8» §6Click §e§l[HERE] §6to download."
|
||||
update_download_hover:
|
||||
de: "§7Öffnet die Release-Seite"
|
||||
en: "§7Opens the release page"
|
||||
hider_all:
|
||||
de: "§aAlle Spieler"
|
||||
en: "§aAll players"
|
||||
hider_none:
|
||||
de: "§cKeine Spieler"
|
||||
en: "§cNo players"
|
||||
void_protection_message:
|
||||
de: "§cDu wurdest vor dem Void gerettet!"
|
||||
en: "§cYou were saved from the void!"
|
||||
proxy_not_registered:
|
||||
de: "§cProxy-Verbindung nicht möglich (BungeeCord Kanal nicht registriert)."
|
||||
en: "§cProxy connection not possible (BungeeCord channel not registered)."
|
||||
connecting_to_server:
|
||||
de: "§eVerbinde zu: §f{server}"
|
||||
en: "§eConnecting to: §f{server}"
|
||||
server_connect_error:
|
||||
de: "§cFehler beim Verbinden zum Server."
|
||||
en: "§cError connecting to server."
|
||||
proxy_connect_error:
|
||||
de: "§cProxy-Verbindung nicht möglich."
|
||||
en: "§cProxy connection not possible."
|
||||
armorstand_lookat_required:
|
||||
de: "§cDu musst einen ArmorStand direkt anschauen (Fadenkreuz)!"
|
||||
en: "§cYou must look directly at an ArmorStand (crosshair)!"
|
||||
conv_link_usage:
|
||||
de: "§cNutze: /nexuscmd conv link <Dialog-ID>"
|
||||
en: "§cUsage: /nexuscmd conv link <Dialog-ID>"
|
||||
conv_mark_npcs:
|
||||
de: "§cBitte markiere mindestens die ersten beiden NPCs (select1 & select2)!"
|
||||
en: "§cPlease mark at least the first two NPCs (select1 & select2)!"
|
||||
conv_link_created:
|
||||
de: "§a§lDauerhafte Verknüpfung erstellt!"
|
||||
en: "§a§lPermanent link created!"
|
||||
conv_link_npcs:
|
||||
de: "§7Beteiligte NPCs: §e{count}"
|
||||
en: "§7Linked NPCs: §e{count}"
|
||||
conv_speaker_not_found:
|
||||
de: "§cFehler: Sprecher 1 nicht gefunden."
|
||||
en: "§cError: Speaker 1 not found."
|
||||
conv_unlink_lookat:
|
||||
de: "§cSchau den NPC an, dessen Verknüpfung du lösen willst!"
|
||||
en: "§cLook at the NPC you want to unlink!"
|
||||
conv_unlinked:
|
||||
de: "§eNPC-Verknüpfung wurde aufgehoben."
|
||||
en: "§eNPC link has been removed."
|
||||
conv_start_usage:
|
||||
de: "§cNutze: /nexuscmd conv start <ID>"
|
||||
en: "§cUsage: /nexuscmd conv start <ID>"
|
||||
conv_mark_two_npcs:
|
||||
de: "§cBitte markiere mindestens zwei NPCs!"
|
||||
en: "§cPlease mark at least two NPCs!"
|
||||
npc_bubble_sent:
|
||||
de: "§aNPC-Sprechblase gesendet."
|
||||
en: "§aNPC speech bubble sent."
|
||||
lookat_off:
|
||||
de: "§cBlickkontakt aus."
|
||||
en: "§cLook-at disabled."
|
||||
lookat_on:
|
||||
de: "§aBlickkontakt an."
|
||||
en: "§aLook-at enabled."
|
||||
name_removed:
|
||||
de: "§eName entfernt."
|
||||
en: "§eName removed."
|
||||
name_set:
|
||||
de: "§7Name gesetzt: {name}"
|
||||
en: "§7Name set: {name}"
|
||||
status_backup_saved:
|
||||
de: "§8(Status-Backup wurde gespeichert)"
|
||||
en: "§8(Status backup saved)"
|
||||
command_bound:
|
||||
de: "§aBefehl gebunden."
|
||||
en: "§aCommand bound."
|
||||
no_target:
|
||||
de: "§cKein Ziel!"
|
||||
en: "§cNo target!"
|
||||
commands_and_tags:
|
||||
de: "§6§lBefehle & Tags:"
|
||||
en: "§6§lCommands & Tags:"
|
||||
commands_removed:
|
||||
de: "§eAlle Befehle gelöscht."
|
||||
en: "§eAll commands removed."
|
||||
welcome:
|
||||
de: "Willkommen auf dem Server!"
|
||||
en: "Welcome to the server!"
|
||||
no_permission:
|
||||
de: "§cKeine Berechtigung."
|
||||
en: "§cNo permission."
|
||||
only_player:
|
||||
de: "§cDieser Befehl ist nur für Spieler!"
|
||||
en: "§cThis command is for players only!"
|
||||
parkour_checkpoint_set:
|
||||
de: "§8[§6Nexus§8] §aParkour-Checkpoint gesetzt!"
|
||||
en: "§8[§6Nexus§8] §aParkour checkpoint set!"
|
||||
parkour_finish_set:
|
||||
de: "§8[§6Nexus§8] §aParkour-Zielpunkt gesetzt!"
|
||||
en: "§8[§6Nexus§8] §aParkour finish set!"
|
||||
teleport_spawn:
|
||||
de: "§8[§6Nexus§8] §aDu wurdest zum Spawn teleportiert."
|
||||
en: "§8[§6Nexus§8] §aYou have been teleported to spawn."
|
||||
spawn_world_missing:
|
||||
de: "§cFehler: Die Spawn-Welt existiert nicht."
|
||||
en: "§cError: The spawn world does not exist."
|
||||
spawn_not_set:
|
||||
de: "§cEs wurde noch kein Spawn gesetzt."
|
||||
en: "§cNo spawn has been set yet."
|
||||
plugin_reloaded:
|
||||
de: "§8[§6Nexus§8] §aPlugin erfolgreich neu geladen!"
|
||||
en: "§8[§6Nexus§8] §aPlugin successfully reloaded!"
|
||||
spawn_set:
|
||||
de: "§8[§6Nexus§8] §aLobby-Spawn erfolgreich gesetzt!"
|
||||
en: "§8[§6Nexus§8] §aLobby spawn set successfully!"
|
||||
silentjoin_on:
|
||||
de: "§8[§6Nexus§8] §7Silent Join: §aAktiviert"
|
||||
en: "§8[§6Nexus§8] §7Silent Join: §aEnabled"
|
||||
silentjoin_off:
|
||||
de: "§8[§6Nexus§8] §7Silent Join: §cDeaktiviert"
|
||||
en: "§8[§6Nexus§8] §7Silent Join: §cDisabled"
|
||||
# _ __ __ __ __
|
||||
# / | / /__ _ ____ _______/ / ____ / /_ / /_ __ __
|
||||
# / |/ / _ \| |/_/ / / / ___/ / / __ \/ __ \/ __ \/ / / /
|
||||
# / /| / __/> </ /_/ (__ ) /___/ /_/ / /_/ / /_/ / /_/ /
|
||||
# /_/ |_/\___/_/|_|\__,_/____/_____/\____/_.___/_.___/\__, /
|
||||
# /____/
|
||||
#
|
||||
# =====================================================
|
||||
# DEFAULT Language
|
||||
# =====================================================
|
||||
|
||||
soccer_module_not_loaded:
|
||||
de: "§cDas Fußball-Modul ist nicht geladen."
|
||||
en: "§cThe soccer module is not loaded."
|
||||
parkour_usage:
|
||||
de: "§8[§6Nexus§8] §7Nutze: §e/nexus parkour <setstart|setfinish|setcheckpoint|reset|clear|removeall>"
|
||||
en: "§8[§6Nexus§8] §7Usage: §e/nexus parkour <setstart|setfinish|setcheckpoint|reset|clear|removeall>"
|
||||
parkour_run_aborted:
|
||||
de: "§8[§6Nexus§8] §7Dein aktueller Lauf wurde abgebrochen."
|
||||
en: "§8[§6Nexus§8] §7Your current run was aborted."
|
||||
parkour_besttimes_cleared:
|
||||
de: "§8[§6Nexus§8] §aAlle Parkour-Bestzeiten wurden gelöscht!"
|
||||
en: "§8[§6Nexus§8] §aAll parkour best times have been cleared!"
|
||||
parkour_track_removed:
|
||||
de: "§8[§6Nexus§8] §cDie gesamte Strecke (Checkpoints & Ziel) wurde gelöscht!"
|
||||
en: "§8[§6Nexus§8] §cThe entire track (checkpoints & finish) has been removed!"
|
||||
unknown_subcommand:
|
||||
de: "§cUnbekannter Unterbefehl."
|
||||
en: "§cUnknown subcommand."
|
||||
parkour_npc_marked:
|
||||
de: "§8[§6Nexus§8] §aArmorStand als Parkour-NPC markiert!"
|
||||
en: "§8[§6Nexus§8] §aArmorStand marked as parkour NPC!"
|
||||
parkour_start_set:
|
||||
de: "§8[§6Nexus§8] §aParkour-Startpunkt an deiner Position gesetzt!"
|
||||
en: "§8[§6Nexus§8] §aParkour start set at your position!"
|
||||
scoreboard_usage:
|
||||
de: "§cBenutzung: /nexus sb <on|off|admin|spieler>"
|
||||
en: "§cUsage: /nexus sb <on|off|admin|player>"
|
||||
scoreboard_module_disabled:
|
||||
de: "§cScoreboard-Modul ist deaktiviert."
|
||||
en: "§cScoreboard module is disabled."
|
||||
info_header:
|
||||
de: "§8§m--------------------------------------"
|
||||
en: "§8§m--------------------------------------"
|
||||
info_title:
|
||||
de: "§6§lNexusLobby §7- Informationen"
|
||||
en: "§6§lNexusLobby §7- Information"
|
||||
info_spawn:
|
||||
de: "§f/spawn §7- Zum Spawn"
|
||||
en: "§f/spawn §7- To spawn"
|
||||
info_parkour:
|
||||
de: "§f/setstart §8| §f/setcheckpoint §8| §f/setfinish"
|
||||
en: "§f/setstart §8| §f/setcheckpoint §8| §f/setfinish"
|
||||
info_removeall:
|
||||
de: "§f/nexus parkour removeall §7- Strecke löschen"
|
||||
en: "§f/nexus parkour removeall §7- Remove track"
|
||||
info_ball:
|
||||
de: "§f/nexus ball setspawn §7- Fußball Spawn setzen"
|
||||
en: "§f/nexus ball setspawn §7- Set soccer spawn"
|
||||
info_setspawn:
|
||||
de: "§f/nexus setspawn §7- Spawn setzen"
|
||||
en: "§f/nexus setspawn §7- Set spawn"
|
||||
info_scoreboard:
|
||||
de: "§f/nexus sb <on|off> §7- Scoreboard"
|
||||
en: "§f/nexus sb <on|off> §7- Scoreboard"
|
||||
info_reload:
|
||||
de: "§f/nexus reload §7- Config laden"
|
||||
en: "§f/nexus reload §7- Reload config"
|
||||
info_footer:
|
||||
de: "§8§m--------------------------------------"
|
||||
en: "§8§m--------------------------------------"
|
||||
parkour_trainer_greeting:
|
||||
de: "§6§lTrainer §8» §aViel Erfolg beim Parkour! Gib dein Bestes!"
|
||||
en: "§6§lTrainer §8» §aGood luck with the parkour! Give it your best!"
|
||||
update_available:
|
||||
de: "§8[§6Nexus§8] §aEin neues §6Update §afür §eNexusLobby §aist verfügbar!"
|
||||
en: "§8[§6Nexus§8] §aA new §6update §afor §eNexusLobby §ais available!"
|
||||
update_version:
|
||||
de: "§8» §7Version: §c{old} §8-> §a{new}"
|
||||
en: "§8» §7Version: §c{old} §8-> §a{new}"
|
||||
update_download_link:
|
||||
de: "§8» §6Klicke §e§l[HIER] §6zum Herunterladen."
|
||||
en: "§8» §6Click §e§l[HERE] §6to download."
|
||||
update_download_hover:
|
||||
de: "§7Öffnet die Release-Seite"
|
||||
en: "§7Opens the release page"
|
||||
hider_all:
|
||||
de: "§aAlle Spieler"
|
||||
en: "§aAll players"
|
||||
hider_none:
|
||||
de: "§cKeine Spieler"
|
||||
en: "§cNo players"
|
||||
void_protection_message:
|
||||
de: "§cDu wurdest vor dem Void gerettet!"
|
||||
en: "§cYou were saved from the void!"
|
||||
proxy_not_registered:
|
||||
de: "§cProxy-Verbindung nicht möglich (BungeeCord Kanal nicht registriert)."
|
||||
en: "§cProxy connection not possible (BungeeCord channel not registered)."
|
||||
connecting_to_server:
|
||||
de: "§eVerbinde zu: §f{server}"
|
||||
en: "§eConnecting to: §f{server}"
|
||||
server_connect_error:
|
||||
de: "§cFehler beim Verbinden zum Server."
|
||||
en: "§cError connecting to server."
|
||||
proxy_connect_error:
|
||||
de: "§cProxy-Verbindung nicht möglich."
|
||||
en: "§cProxy connection not possible."
|
||||
armorstand_lookat_required:
|
||||
de: "§cDu musst einen ArmorStand direkt anschauen (Fadenkreuz)!"
|
||||
en: "§cYou must look directly at an ArmorStand (crosshair)!"
|
||||
conv_link_usage:
|
||||
de: "§cNutze: /nexuscmd conv link <Dialog-ID>"
|
||||
en: "§cUsage: /nexuscmd conv link <Dialog-ID>"
|
||||
conv_mark_npcs:
|
||||
de: "§cBitte markiere mindestens die ersten beiden NPCs (select1 & select2)!"
|
||||
en: "§cPlease mark at least the first two NPCs (select1 & select2)!"
|
||||
conv_link_created:
|
||||
de: "§a§lDauerhafte Verknüpfung erstellt!"
|
||||
en: "§a§lPermanent link created!"
|
||||
conv_link_npcs:
|
||||
de: "§7Beteiligte NPCs: §e{count}"
|
||||
en: "§7Linked NPCs: §e{count}"
|
||||
conv_speaker_not_found:
|
||||
de: "§cFehler: Sprecher 1 nicht gefunden."
|
||||
en: "§cError: Speaker 1 not found."
|
||||
conv_unlink_lookat:
|
||||
de: "§cSchau den NPC an, dessen Verknüpfung du lösen willst!"
|
||||
en: "§cLook at the NPC you want to unlink!"
|
||||
conv_unlinked:
|
||||
de: "§eNPC-Verknüpfung wurde aufgehoben."
|
||||
en: "§eNPC link has been removed."
|
||||
conv_start_usage:
|
||||
de: "§cNutze: /nexuscmd conv start <ID>"
|
||||
en: "§cUsage: /nexuscmd conv start <ID>"
|
||||
conv_mark_two_npcs:
|
||||
de: "§cBitte markiere mindestens zwei NPCs!"
|
||||
en: "§cPlease mark at least two NPCs!"
|
||||
npc_bubble_sent:
|
||||
de: "§aNPC-Sprechblase gesendet."
|
||||
en: "§aNPC speech bubble sent."
|
||||
lookat_off:
|
||||
de: "§cBlickkontakt aus."
|
||||
en: "§cLook-at disabled."
|
||||
lookat_on:
|
||||
de: "§aBlickkontakt an."
|
||||
en: "§aLook-at enabled."
|
||||
name_removed:
|
||||
de: "§eName entfernt."
|
||||
en: "§eName removed."
|
||||
name_set:
|
||||
de: "§7Name gesetzt: {name}"
|
||||
en: "§7Name set: {name}"
|
||||
status_backup_saved:
|
||||
de: "§8(Status-Backup wurde gespeichert)"
|
||||
en: "§8(Status backup saved)"
|
||||
command_bound:
|
||||
de: "§aBefehl gebunden."
|
||||
en: "§aCommand bound."
|
||||
no_target:
|
||||
de: "§cKein Ziel!"
|
||||
en: "§cNo target!"
|
||||
commands_and_tags:
|
||||
de: "§6§lBefehle & Tags:"
|
||||
en: "§6§lCommands & Tags:"
|
||||
commands_removed:
|
||||
de: "§eAlle Befehle gelöscht."
|
||||
en: "§eAll commands removed."
|
||||
welcome:
|
||||
de: "Willkommen auf dem Server!"
|
||||
en: "Welcome to the server!"
|
||||
no_permission:
|
||||
de: "§cKeine Berechtigung."
|
||||
en: "§cNo permission."
|
||||
only_player:
|
||||
de: "§cDieser Befehl ist nur für Spieler!"
|
||||
en: "§cThis command is for players only!"
|
||||
parkour_checkpoint_set:
|
||||
de: "§8[§6Nexus§8] §aParkour-Checkpoint gesetzt!"
|
||||
en: "§8[§6Nexus§8] §aParkour checkpoint set!"
|
||||
parkour_finish_set:
|
||||
de: "§8[§6Nexus§8] §aParkour-Zielpunkt gesetzt!"
|
||||
en: "§8[§6Nexus§8] §aParkour finish set!"
|
||||
teleport_spawn:
|
||||
de: "§8[§6Nexus§8] §aDu wurdest zum Spawn teleportiert."
|
||||
en: "§8[§6Nexus§8] §aYou have been teleported to spawn."
|
||||
spawn_world_missing:
|
||||
de: "§cFehler: Die Spawn-Welt existiert nicht."
|
||||
en: "§cError: The spawn world does not exist."
|
||||
spawn_not_set:
|
||||
de: "§cEs wurde noch kein Spawn gesetzt."
|
||||
en: "§cNo spawn has been set yet."
|
||||
plugin_reloaded:
|
||||
de: "§8[§6Nexus§8] §aPlugin erfolgreich neu geladen!"
|
||||
en: "§8[§6Nexus§8] §aPlugin successfully reloaded!"
|
||||
spawn_set:
|
||||
de: "§8[§6Nexus§8] §aLobby-Spawn erfolgreich gesetzt!"
|
||||
en: "§8[§6Nexus§8] §aLobby spawn set successfully!"
|
||||
silentjoin_on:
|
||||
de: "§8[§6Nexus§8] §7Silent Join: §aAktiviert"
|
||||
en: "§8[§6Nexus§8] §7Silent Join: §aEnabled"
|
||||
silentjoin_off:
|
||||
de: "§8[§6Nexus§8] §7Silent Join: §cDeaktiviert"
|
||||
en: "§8[§6Nexus§8] §7Silent Join: §cDisabled"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
name: NexusLobby
|
||||
main: de.nexuslobby.NexusLobby
|
||||
version: "1.1.1"
|
||||
version: "2.0"
|
||||
api-version: "1.21"
|
||||
author: M_Viper
|
||||
description: Modular Lobby Plugin with an invisible Particle-Parkour system.
|
||||
|
||||
Reference in New Issue
Block a user