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>
|
<groupId>de.nexuslobby</groupId>
|
||||||
<artifactId>NexusLobby</artifactId>
|
<artifactId>NexusLobby</artifactId>
|
||||||
<version>1.1.1</version>
|
<version>2.0</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>NexusLobby</name>
|
<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 BorderModule borderModule;
|
||||||
private ParkourManager parkourManager;
|
private ParkourManager parkourManager;
|
||||||
private SoccerModule soccerModule;
|
private SoccerModule soccerModule;
|
||||||
|
private ArmorStandLookAtModule armorStandLookAtModule;
|
||||||
|
|
||||||
private ConversationManager conversationManager;
|
private ConversationManager conversationManager;
|
||||||
|
|
||||||
@@ -135,7 +136,7 @@ public class NexusLobby extends JavaPlugin implements Listener {
|
|||||||
|
|
||||||
ServerChecker.startGlobalChecker();
|
ServerChecker.startGlobalChecker();
|
||||||
|
|
||||||
new ArmorStandLookAtModule();
|
armorStandLookAtModule = new ArmorStandLookAtModule();
|
||||||
|
|
||||||
startAutoConversationTimer();
|
startAutoConversationTimer();
|
||||||
|
|
||||||
@@ -192,7 +193,10 @@ public class NexusLobby extends JavaPlugin implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ServerChecker.startGlobalChecker();
|
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();
|
startAutoConversationTimer();
|
||||||
|
|
||||||
getLogger().info("Plugin Reload abgeschlossen. Änderungen wurden übernommen.");
|
getLogger().info("Plugin Reload abgeschlossen. Änderungen wurden übernommen.");
|
||||||
@@ -200,18 +204,55 @@ public class NexusLobby extends JavaPlugin implements Listener {
|
|||||||
|
|
||||||
private void checkUpdates() {
|
private void checkUpdates() {
|
||||||
new UpdateChecker(this).getVersion(version -> {
|
new UpdateChecker(this).getVersion(version -> {
|
||||||
if (!this.getDescription().getVersion().equalsIgnoreCase(version)) {
|
String currentVersion = this.getDescription().getVersion();
|
||||||
|
if (isRemoteVersionNewer(currentVersion, version)) {
|
||||||
this.updateAvailable = true;
|
this.updateAvailable = true;
|
||||||
this.latestVersion = version;
|
this.latestVersion = version;
|
||||||
getLogger().warning("====================================================");
|
getLogger().warning("====================================================");
|
||||||
getLogger().warning("Update gefunden! v" + getDescription().getVersion() + " -> v" + version);
|
getLogger().warning("Update gefunden! v" + currentVersion + " -> v" + version);
|
||||||
getLogger().warning("====================================================");
|
getLogger().warning("====================================================");
|
||||||
} else {
|
} 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() {
|
private void registerModules() {
|
||||||
moduleManager.registerModule(new ProtectionModule());
|
moduleManager.registerModule(new ProtectionModule());
|
||||||
moduleManager.registerModule(new ScoreboardModule());
|
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_available"));
|
||||||
player.sendMessage(de.nexuslobby.utils.LangManager.get("update_version").replace("{old}", getDescription().getVersion()).replace("{new}", latestVersion));
|
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"));
|
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,
|
link.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT,
|
||||||
new ComponentBuilder(de.nexuslobby.utils.LangManager.get("update_download_hover")).create()));
|
new ComponentBuilder(de.nexuslobby.utils.LangManager.get("update_download_hover")).create()));
|
||||||
player.spigot().sendMessage(link);
|
player.spigot().sendMessage(link);
|
||||||
@@ -488,6 +529,12 @@ public class NexusLobby extends JavaPlugin implements Listener {
|
|||||||
if (params.equalsIgnoreCase("parkour_top")) {
|
if (params.equalsIgnoreCase("parkour_top")) {
|
||||||
return parkourManager != null ? parkourManager.getTopTen() : "N/A";
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ public class LobbyTabCompleter implements TabCompleter {
|
|||||||
private final HologramModule hologramModule;
|
private final HologramModule hologramModule;
|
||||||
|
|
||||||
public LobbyTabCompleter(PortalManager portalManager, HologramModule hologramModule) {
|
public LobbyTabCompleter(PortalManager portalManager, HologramModule hologramModule) {
|
||||||
this.portalManager = portalManager;
|
this.portalManager = portalManager;
|
||||||
this.hologramModule = hologramModule;
|
this.hologramModule = hologramModule;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -28,65 +28,117 @@ public class LobbyTabCompleter implements TabCompleter {
|
|||||||
List<String> suggestions = new ArrayList<>();
|
List<String> suggestions = new ArrayList<>();
|
||||||
String cmdName = command.getName().toLowerCase();
|
String cmdName = command.getName().toLowerCase();
|
||||||
|
|
||||||
// --- NexusLobby Hauptbefehl (/nexus) ---
|
// ── NexusLobby Hauptbefehl (/nexus oder /nexuslobby) ──────────────────
|
||||||
if (cmdName.equals("nexuslobby") || cmdName.equals("nexus")) {
|
if (cmdName.equals("nexuslobby") || cmdName.equals("nexus")) {
|
||||||
|
|
||||||
|
// /nexuslobby <?>
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
if (sender.hasPermission("nexuslobby.admin")) {
|
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");
|
suggestions.add("sb");
|
||||||
|
|
||||||
|
// /nexuslobby <sub> <?>
|
||||||
} else if (args.length == 2) {
|
} else if (args.length == 2) {
|
||||||
if (args[0].equalsIgnoreCase("sb")) {
|
switch (args[0].toLowerCase()) {
|
||||||
suggestions.addAll(Arrays.asList("on", "off"));
|
case "sb" -> {
|
||||||
if (sender.hasPermission("nexuslobby.scoreboard.admin")) {
|
suggestions.addAll(Arrays.asList("on", "off"));
|
||||||
suggestions.addAll(Arrays.asList("admin", "spieler"));
|
if (sender.hasPermission("nexuslobby.scoreboard.admin"))
|
||||||
|
suggestions.addAll(Arrays.asList("admin", "spieler"));
|
||||||
}
|
}
|
||||||
} else if (args[0].equalsIgnoreCase("silentjoin")) {
|
case "silentjoin" -> suggestions.addAll(Arrays.asList("on", "off"));
|
||||||
suggestions.addAll(Arrays.asList("on", "off"));
|
case "parkour" -> {
|
||||||
} else if (args[0].equalsIgnoreCase("parkour")) {
|
if (sender.hasPermission("nexuslobby.admin")) {
|
||||||
suggestions.addAll(Arrays.asList("setstart", "setfinish", "setcheckpoint", "reset", "clear", "removeall"));
|
suggestions.addAll(Arrays.asList(
|
||||||
} else if (args[0].equalsIgnoreCase("ball")) {
|
"setstart", "setfinish", "setcheckpoint",
|
||||||
if (sender.hasPermission("nexuslobby.admin")) {
|
"holo", "reset", "clear", "removeall", "info"
|
||||||
suggestions.addAll(Arrays.asList("setspawn", "respawn", "remove"));
|
));
|
||||||
|
} 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) {
|
} else if (args.length == 3) {
|
||||||
if (args[0].equalsIgnoreCase("parkour") && args[1].equalsIgnoreCase("setcheckpoint")) {
|
switch (args[0].toLowerCase()) {
|
||||||
suggestions.addAll(Arrays.asList("1", "2", "3", "4", "5", "6", "7", "8", "9"));
|
// 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")) {
|
else if (cmdName.equals("holo")) {
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
suggestions.addAll(Arrays.asList("create", "delete"));
|
suggestions.addAll(Arrays.asList("create", "delete"));
|
||||||
} else if (args.length == 2 && args[0].equalsIgnoreCase("delete")) {
|
} else if (args.length == 2 && args[0].equalsIgnoreCase("delete")) {
|
||||||
if (hologramModule != null) {
|
if (hologramModule != null) suggestions.addAll(hologramModule.getHologramIds());
|
||||||
suggestions.addAll(hologramModule.getHologramIds());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- Wartungsmodus ---
|
// ── Wartungsmodus ─────────────────────────────────────────────────────
|
||||||
else if (cmdName.equals("maintenance")) {
|
else if (cmdName.equals("maintenance")) {
|
||||||
if (args.length == 1) {
|
if (args.length == 1) suggestions.addAll(Arrays.asList("on", "off"));
|
||||||
suggestions.addAll(Arrays.asList("on", "off"));
|
}
|
||||||
}
|
|
||||||
}
|
// ── Portalsystem ──────────────────────────────────────────────────────
|
||||||
|
|
||||||
// --- Portalsystem ---
|
|
||||||
else if (cmdName.equals("portal")) {
|
else if (cmdName.equals("portal")) {
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
suggestions.addAll(Arrays.asList("create", "delete", "list"));
|
suggestions.addAll(Arrays.asList("create", "delete", "list"));
|
||||||
} else if (args.length == 2 && args[0].equalsIgnoreCase("delete")) {
|
} else if (args.length == 2 && args[0].equalsIgnoreCase("delete")) {
|
||||||
if (portalManager != null) {
|
if (portalManager != null) suggestions.addAll(portalManager.getPortalNames());
|
||||||
suggestions.addAll(portalManager.getPortalNames());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- MapArt ---
|
// ── MapArt ────────────────────────────────────────────────────────────
|
||||||
else if (cmdName.equals("mapart")) {
|
else if (cmdName.equals("mapart")) {
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
suggestions.add("https://");
|
suggestions.add("https://");
|
||||||
@@ -95,14 +147,12 @@ public class LobbyTabCompleter implements TabCompleter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- Intro System ---
|
// ── Intro System ──────────────────────────────────────────────────────
|
||||||
else if (cmdName.equals("intro")) {
|
else if (cmdName.equals("intro")) {
|
||||||
if (args.length == 1) {
|
if (args.length == 1) suggestions.addAll(Arrays.asList("add", "clear", "start"));
|
||||||
suggestions.addAll(Arrays.asList("add", "clear", "start"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- WorldBorder ---
|
// ── WorldBorder ───────────────────────────────────────────────────────
|
||||||
else if (cmdName.equals("border")) {
|
else if (cmdName.equals("border")) {
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
suggestions.addAll(Arrays.asList("circle", "square", "disable"));
|
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"));
|
suggestions.addAll(Arrays.asList("10", "25", "50", "100", "250"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- NexusCmd / ArmorStandTools ---
|
// ── NexusCmd / ArmorStandTools ────────────────────────────────────────
|
||||||
else if (cmdName.equals("nexuscmd") || cmdName.equals("ncmd") || cmdName.equals("ascmd") || cmdName.equals("conv")) {
|
else if (cmdName.equals("nexuscmd") || cmdName.equals("ncmd")
|
||||||
|
|| cmdName.equals("ascmd") || cmdName.equals("conv")) {
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
suggestions.addAll(Arrays.asList("add", "remove", "list", "name", "lookat", "conv", "say"));
|
suggestions.addAll(Arrays.asList("add", "remove", "list", "name", "lookat", "conv", "say", "clearbubbles"));
|
||||||
}
|
} else if (args.length == 2) {
|
||||||
else if (args.length == 2) {
|
switch (args[0].toLowerCase()) {
|
||||||
if (args[0].equalsIgnoreCase("add")) {
|
case "add" -> suggestions.addAll(Arrays.asList("0","1","2","3","4","5","6","7","8","9"));
|
||||||
suggestions.addAll(Arrays.asList("0", "1", "2", "3", "4", "5", "6", "7", "8", "9"));
|
case "name" -> suggestions.addAll(Arrays.asList("<Anzeigename>", "none"));
|
||||||
} else if (args[0].equalsIgnoreCase("name")) {
|
case "conv" -> suggestions.addAll(Arrays.asList("select1","select2","select3","select4","link","unlink","start"));
|
||||||
suggestions.addAll(Arrays.asList("<Anzeigename>", "none"));
|
case "remove" -> suggestions.addAll(Arrays.asList("0","1","2","3","4","5","6","7","8","9","all"));
|
||||||
} else if (args[0].equalsIgnoreCase("conv")) {
|
case "say" -> suggestions.add("<Nachricht>");
|
||||||
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>");
|
|
||||||
}
|
}
|
||||||
}
|
} else if (args.length == 3) {
|
||||||
else if (args.length == 3) {
|
|
||||||
if (args[0].equalsIgnoreCase("add")) {
|
if (args[0].equalsIgnoreCase("add")) {
|
||||||
suggestions.addAll(Arrays.asList("0", "1", "2", "3", "4", "5", "6", "7", "8", "9"));
|
suggestions.addAll(Arrays.asList("0","1","2","3","4","5","6","7","8","9"));
|
||||||
} else if (args[0].equalsIgnoreCase("conv")) {
|
} else if (args[0].equalsIgnoreCase("conv")
|
||||||
if (args[1].equalsIgnoreCase("start") || args[1].equalsIgnoreCase("link")) {
|
&& (args[1].equalsIgnoreCase("start") || args[1].equalsIgnoreCase("link"))) {
|
||||||
if (NexusLobby.getInstance().getConversationManager() != null) {
|
if (NexusLobby.getInstance().getConversationManager() != null)
|
||||||
suggestions.addAll(NexusLobby.getInstance().getConversationManager().getConversationIds());
|
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"));
|
suggestions.addAll(Arrays.asList("bungee", "console", "player"));
|
||||||
}
|
} else if (args.length == 5 && args[0].equalsIgnoreCase("add")
|
||||||
else if (args.length == 5 && args[0].equalsIgnoreCase("add") && args[3].equalsIgnoreCase("bungee")) {
|
&& args[3].equalsIgnoreCase("bungee")) {
|
||||||
if (NexusLobby.getInstance().getConfig().getConfigurationSection("servers") != null) {
|
var section = NexusLobby.getInstance().getConfig().getConfigurationSection("servers");
|
||||||
suggestions.addAll(NexusLobby.getInstance().getConfig().getConfigurationSection("servers").getKeys(false));
|
if (section != null) suggestions.addAll(section.getKeys(false));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- ArmorStandTools Alternate ---
|
// ── ArmorStandTools Alternate ─────────────────────────────────────────
|
||||||
else if (cmdName.equals("astools") || cmdName.equals("nt") || cmdName.equals("ntools")) {
|
else if (cmdName.equals("astools") || cmdName.equals("nt") || cmdName.equals("ntools")) {
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
suggestions.addAll(Arrays.asList("dynamic", "lookat", "addplayer", "addconsole", "remove", "reload", "say"));
|
suggestions.addAll(Arrays.asList("dynamic","lookat","addplayer","addconsole","remove","reload","say"));
|
||||||
}
|
} else if (args.length == 2) {
|
||||||
else if (args.length == 2 && args[0].equalsIgnoreCase("say")) {
|
if (args[0].equalsIgnoreCase("say"))
|
||||||
suggestions.add("<Nachricht>");
|
suggestions.add("<Nachricht>");
|
||||||
}
|
else if (args[0].equalsIgnoreCase("addplayer") || args[0].equalsIgnoreCase("addconsole"))
|
||||||
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"));
|
||||||
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"))
|
||||||
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("0", "1", "2", "3", "4", "5", "6", "7", "8", "9"));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Filtert die Liste basierend auf der bisherigen Eingabe
|
|
||||||
return suggestions.stream()
|
return suggestions.stream()
|
||||||
.filter(s -> s.toLowerCase().startsWith(args[args.length - 1].toLowerCase()))
|
.filter(s -> s.toLowerCase().startsWith(args[args.length - 1].toLowerCase()))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package de.nexuslobby.commands;
|
|||||||
|
|
||||||
import de.nexuslobby.NexusLobby;
|
import de.nexuslobby.NexusLobby;
|
||||||
import de.nexuslobby.modules.ScoreboardModule;
|
import de.nexuslobby.modules.ScoreboardModule;
|
||||||
|
import de.nexuslobby.modules.hologram.HologramModule;
|
||||||
import de.nexuslobby.modules.parkour.ParkourManager;
|
import de.nexuslobby.modules.parkour.ParkourManager;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@@ -22,7 +23,7 @@ public class NexusLobbyCommand implements CommandExecutor {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||||
|
|
||||||
if (!(sender instanceof Player player)) {
|
if (!(sender instanceof Player player)) {
|
||||||
sender.sendMessage(de.nexuslobby.utils.LangManager.get("only_player"));
|
sender.sendMessage(de.nexuslobby.utils.LangManager.get("only_player"));
|
||||||
return true;
|
return true;
|
||||||
@@ -34,19 +35,18 @@ public class NexusLobbyCommand implements CommandExecutor {
|
|||||||
// --- DIREKTE KURZ-BEFEHLE ---
|
// --- DIREKTE KURZ-BEFEHLE ---
|
||||||
if (cmdName.equalsIgnoreCase("setstart")) {
|
if (cmdName.equalsIgnoreCase("setstart")) {
|
||||||
if (!player.hasPermission("nexuslobby.admin")) return noPerm(player);
|
if (!player.hasPermission("nexuslobby.admin")) return noPerm(player);
|
||||||
handleSetStart(player, pm);
|
// Standard: Strecke 1 setzen
|
||||||
|
pm.setStartLocation(player, 1);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (cmdName.equalsIgnoreCase("setcheckpoint")) {
|
if (cmdName.equalsIgnoreCase("setcheckpoint")) {
|
||||||
if (!player.hasPermission("nexuslobby.admin")) return noPerm(player);
|
if (!player.hasPermission("nexuslobby.admin")) return noPerm(player);
|
||||||
pm.setCheckpoint(player, player.getLocation());
|
pm.setCheckpoint(player, 1);
|
||||||
player.sendMessage(de.nexuslobby.utils.LangManager.get("parkour_checkpoint_set"));
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (cmdName.equalsIgnoreCase("setfinish")) {
|
if (cmdName.equalsIgnoreCase("setfinish")) {
|
||||||
if (!player.hasPermission("nexuslobby.admin")) return noPerm(player);
|
if (!player.hasPermission("nexuslobby.admin")) return noPerm(player);
|
||||||
pm.setFinishLocation(player.getLocation());
|
pm.setFinishLocation(player, 1);
|
||||||
player.sendMessage(de.nexuslobby.utils.LangManager.get("parkour_finish_set"));
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,6 +75,7 @@ public class NexusLobbyCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (args[0].toLowerCase()) {
|
switch (args[0].toLowerCase()) {
|
||||||
|
|
||||||
case "reload":
|
case "reload":
|
||||||
if (!player.hasPermission("nexuslobby.admin")) return noPerm(player);
|
if (!player.hasPermission("nexuslobby.admin")) return noPerm(player);
|
||||||
NexusLobby.getInstance().reloadPlugin();
|
NexusLobby.getInstance().reloadPlugin();
|
||||||
@@ -82,6 +83,11 @@ public class NexusLobbyCommand implements CommandExecutor {
|
|||||||
player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1f, 1.5f);
|
player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1f, 1.5f);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case "cleanbubbles":
|
||||||
|
if (!player.hasPermission("nexuslobby.admin")) return noPerm(player);
|
||||||
|
handleCleanBubbles(player);
|
||||||
|
break;
|
||||||
|
|
||||||
case "setspawn":
|
case "setspawn":
|
||||||
if (!player.hasPermission("nexuslobby.admin")) return noPerm(player);
|
if (!player.hasPermission("nexuslobby.admin")) return noPerm(player);
|
||||||
Location loc = player.getLocation();
|
Location loc = player.getLocation();
|
||||||
@@ -90,7 +96,7 @@ public class NexusLobbyCommand implements CommandExecutor {
|
|||||||
config.set("spawn.x", loc.getX());
|
config.set("spawn.x", loc.getX());
|
||||||
config.set("spawn.y", loc.getY());
|
config.set("spawn.y", loc.getY());
|
||||||
config.set("spawn.z", loc.getZ());
|
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());
|
config.set("spawn.pitch", (double) loc.getPitch());
|
||||||
NexusLobby.getInstance().saveConfig();
|
NexusLobby.getInstance().saveConfig();
|
||||||
player.sendMessage(de.nexuslobby.utils.LangManager.get("spawn_set"));
|
player.sendMessage(de.nexuslobby.utils.LangManager.get("spawn_set"));
|
||||||
@@ -111,7 +117,12 @@ public class NexusLobbyCommand implements CommandExecutor {
|
|||||||
handleScoreboard(player, args);
|
handleScoreboard(player, args);
|
||||||
break;
|
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) {
|
if (NexusLobby.getInstance().getSoccerModule() != null) {
|
||||||
return NexusLobby.getInstance().getSoccerModule().onCommand(sender, command, label, args);
|
return NexusLobby.getInstance().getSoccerModule().onCommand(sender, command, label, args);
|
||||||
}
|
}
|
||||||
@@ -119,42 +130,7 @@ public class NexusLobbyCommand implements CommandExecutor {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case "parkour":
|
case "parkour":
|
||||||
if (args.length < 2) {
|
handleParkour(player, args, pm);
|
||||||
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;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -165,13 +141,128 @@ public class NexusLobbyCommand implements CommandExecutor {
|
|||||||
return true;
|
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;
|
ArmorStand targetAs = null;
|
||||||
List<Entity> nearby = player.getNearbyEntities(4, 4, 4);
|
List<Entity> nearby = player.getNearbyEntities(4, 4, 4);
|
||||||
for (Entity e : nearby) {
|
for (Entity e : nearby) {
|
||||||
if (e instanceof ArmorStand as) {
|
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) {
|
if (dot > 0.9) {
|
||||||
targetAs = as;
|
targetAs = as;
|
||||||
break;
|
break;
|
||||||
@@ -183,8 +274,23 @@ public class NexusLobbyCommand implements CommandExecutor {
|
|||||||
targetAs.addScoreboardTag("parkour_npc");
|
targetAs.addScoreboardTag("parkour_npc");
|
||||||
player.sendMessage(de.nexuslobby.utils.LangManager.get("parkour_npc_marked"));
|
player.sendMessage(de.nexuslobby.utils.LangManager.get("parkour_npc_marked"));
|
||||||
}
|
}
|
||||||
pm.setStartLocation(player.getLocation());
|
pm.setStartLocation(player, track);
|
||||||
player.sendMessage(de.nexuslobby.utils.LangManager.get("parkour_start_set"));
|
}
|
||||||
|
|
||||||
|
// ─────────────────────────────────────────────────────────────────────────
|
||||||
|
// 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) {
|
private boolean noPerm(Player player) {
|
||||||
@@ -202,18 +308,17 @@ public class NexusLobbyCommand implements CommandExecutor {
|
|||||||
player.sendMessage(de.nexuslobby.utils.LangManager.get("scoreboard_module_disabled"));
|
player.sendMessage(de.nexuslobby.utils.LangManager.get("scoreboard_module_disabled"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String sub = args[1].toLowerCase();
|
switch (args[1].toLowerCase()) {
|
||||||
switch (sub) {
|
case "on" -> sbModule.setVisibility(player, true);
|
||||||
case "on": sbModule.setVisibility(player, true); break;
|
case "off" -> sbModule.setVisibility(player, false);
|
||||||
case "off": sbModule.setVisibility(player, false); break;
|
case "admin" -> {
|
||||||
case "admin":
|
|
||||||
if (player.hasPermission("nexuslobby.scoreboard.admin")) sbModule.setAdminMode(player, true);
|
if (player.hasPermission("nexuslobby.scoreboard.admin")) sbModule.setAdminMode(player, true);
|
||||||
else player.sendMessage(de.nexuslobby.utils.LangManager.get("no_permission"));
|
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);
|
if (player.hasPermission("nexuslobby.scoreboard.admin")) sbModule.setAdminMode(player, false);
|
||||||
else player.sendMessage(de.nexuslobby.utils.LangManager.get("no_permission"));
|
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(de.nexuslobby.utils.LangManager.get("info_title"));
|
||||||
player.sendMessage("");
|
player.sendMessage("");
|
||||||
player.sendMessage(de.nexuslobby.utils.LangManager.get("info_spawn"));
|
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_removeall"));
|
||||||
player.sendMessage(de.nexuslobby.utils.LangManager.get("info_ball"));
|
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_setspawn"));
|
||||||
player.sendMessage(de.nexuslobby.utils.LangManager.get("info_scoreboard"));
|
player.sendMessage(de.nexuslobby.utils.LangManager.get("info_scoreboard"));
|
||||||
player.sendMessage(de.nexuslobby.utils.LangManager.get("info_reload"));
|
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"));
|
player.sendMessage(de.nexuslobby.utils.LangManager.get("info_footer"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,47 +1,47 @@
|
|||||||
package de.nexuslobby.modules;
|
package de.nexuslobby.modules;
|
||||||
|
|
||||||
import de.nexuslobby.NexusLobby;
|
import de.nexuslobby.NexusLobby;
|
||||||
import de.nexuslobby.api.Module;
|
import de.nexuslobby.api.Module;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class BuildModule implements Module {
|
public class BuildModule implements Module {
|
||||||
|
|
||||||
private final ArrayList<UUID> buildModePlayers = new ArrayList<>();
|
private final ArrayList<UUID> buildModePlayers = new ArrayList<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "Build";
|
return "Build";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
// Falls du hier den Command registrierst, achte darauf,
|
// Falls du hier den Command registrierst, achte darauf,
|
||||||
// dass er nicht doppelt in der NexusLobby.java registriert wird.
|
// dass er nicht doppelt in der NexusLobby.java registriert wird.
|
||||||
}
|
}
|
||||||
|
|
||||||
public void toggleBuildMode(Player player) {
|
public void toggleBuildMode(Player player) {
|
||||||
if (!player.hasPermission("nexuslobby.build")) return;
|
if (!player.hasPermission("nexuslobby.build")) return;
|
||||||
|
|
||||||
if (buildModePlayers.contains(player.getUniqueId())) {
|
if (buildModePlayers.contains(player.getUniqueId())) {
|
||||||
buildModePlayers.remove(player.getUniqueId());
|
buildModePlayers.remove(player.getUniqueId());
|
||||||
player.setGameMode(GameMode.SURVIVAL);
|
player.setGameMode(GameMode.SURVIVAL);
|
||||||
player.getInventory().clear();
|
player.getInventory().clear();
|
||||||
|
|
||||||
// KORREKTUR: Hier muss getItemsModule() mit "s" stehen!
|
// KORREKTUR: Hier muss getItemsModule() mit "s" stehen!
|
||||||
if (NexusLobby.getInstance().getItemsModule() != null) {
|
if (NexusLobby.getInstance().getItemsModule() != null) {
|
||||||
NexusLobby.getInstance().getItemsModule().giveLobbyItems(player);
|
NexusLobby.getInstance().getItemsModule().giveLobbyItems(player);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
buildModePlayers.add(player.getUniqueId());
|
buildModePlayers.add(player.getUniqueId());
|
||||||
player.setGameMode(GameMode.CREATIVE);
|
player.setGameMode(GameMode.CREATIVE);
|
||||||
player.getInventory().clear();
|
player.getInventory().clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {}
|
public void onDisable() {}
|
||||||
}
|
}
|
||||||
@@ -6,11 +6,14 @@ import de.nexuslobby.commands.BuildCommand;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.block.BlockBreakEvent;
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
|
import org.bukkit.event.block.BlockExplodeEvent;
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
|
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||||
import org.bukkit.event.entity.EntityPickupItemEvent;
|
import org.bukkit.event.entity.EntityPickupItemEvent;
|
||||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
@@ -30,7 +33,11 @@ public class ProtectionModule implements Module, Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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
|
@EventHandler
|
||||||
public void onBlockBreak(BlockBreakEvent event) {
|
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.NexusLobby;
|
||||||
import de.nexuslobby.api.Module;
|
import de.nexuslobby.api.Module;
|
||||||
|
import io.papermc.paper.scoreboard.numbers.NumberFormat;
|
||||||
import me.clip.placeholderapi.PlaceholderAPI;
|
import me.clip.placeholderapi.PlaceholderAPI;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@@ -9,9 +10,12 @@ import org.bukkit.configuration.file.FileConfiguration;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
import org.bukkit.scoreboard.*;
|
import org.bukkit.scoreboard.*;
|
||||||
|
import org.bukkit.scoreboard.Criteria;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@@ -23,10 +27,12 @@ public class ScoreboardModule implements Module, Listener {
|
|||||||
|
|
||||||
private final NexusLobby plugin = NexusLobby.getInstance();
|
private final NexusLobby plugin = NexusLobby.getInstance();
|
||||||
private boolean placeholderAPIEnabled;
|
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> hiddenPlayers = new HashSet<>();
|
||||||
private final Set<UUID> adminModePlayers = 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
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
@@ -38,7 +44,6 @@ public class ScoreboardModule implements Module, Listener {
|
|||||||
FileConfiguration vConfig = plugin.getVisualsConfig();
|
FileConfiguration vConfig = plugin.getVisualsConfig();
|
||||||
if (!vConfig.getBoolean("scoreboard.enabled", true)) return;
|
if (!vConfig.getBoolean("scoreboard.enabled", true)) return;
|
||||||
|
|
||||||
// Listener registrieren
|
|
||||||
Bukkit.getPluginManager().registerEvents(this, plugin);
|
Bukkit.getPluginManager().registerEvents(this, plugin);
|
||||||
|
|
||||||
placeholderAPIEnabled = Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null;
|
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));
|
}.runTaskTimer(plugin, 0L, vConfig.getLong("scoreboard.update_ticks", 20L));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Setzt Scoreboard-Status beim Join gemäß config.yml (scoreboard-default-visible)
|
|
||||||
*/
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
@@ -63,13 +65,19 @@ public class ScoreboardModule implements Module, Listener {
|
|||||||
if (!defaultVisible) {
|
if (!defaultVisible) {
|
||||||
hiddenPlayers.add(player.getUniqueId());
|
hiddenPlayers.add(player.getUniqueId());
|
||||||
player.setScoreboard(Bukkit.getScoreboardManager().getMainScoreboard());
|
player.setScoreboard(Bukkit.getScoreboardManager().getMainScoreboard());
|
||||||
|
// Sicherstellen, dass kein altes Board gespeichert ist
|
||||||
|
playerBoards.remove(player.getUniqueId());
|
||||||
} else {
|
} else {
|
||||||
hiddenPlayers.remove(player.getUniqueId());
|
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) {
|
private void updateSidebar(Player player) {
|
||||||
// 1. Prüfen, ob der Spieler das Scoreboard ausgeblendet hat
|
|
||||||
if (hiddenPlayers.contains(player.getUniqueId())) {
|
if (hiddenPlayers.contains(player.getUniqueId())) {
|
||||||
if (player.getScoreboard() != Bukkit.getScoreboardManager().getMainScoreboard()) {
|
if (player.getScoreboard() != Bukkit.getScoreboardManager().getMainScoreboard()) {
|
||||||
player.setScoreboard(Bukkit.getScoreboardManager().getMainScoreboard());
|
player.setScoreboard(Bukkit.getScoreboardManager().getMainScoreboard());
|
||||||
@@ -78,49 +86,81 @@ public class ScoreboardModule implements Module, Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
FileConfiguration vConfig = plugin.getVisualsConfig();
|
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();
|
board = Bukkit.getScoreboardManager().getNewScoreboard();
|
||||||
|
playerBoards.put(player.getUniqueId(), board);
|
||||||
player.setScoreboard(board);
|
player.setScoreboard(board);
|
||||||
}
|
}
|
||||||
|
|
||||||
Objective obj = board.getObjective("lobby");
|
// Altes Objective entfernen
|
||||||
if (obj == null) {
|
Objective oldObj = board.getObjective("lobby");
|
||||||
obj = board.registerNewObjective("lobby", "dummy", "title");
|
if (oldObj != null) oldObj.unregister();
|
||||||
obj.setDisplaySlot(DisplaySlot.SIDEBAR);
|
|
||||||
|
// 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)
|
// Paper 1.21: Objective mit Component-Titel registrieren
|
||||||
String configPath = "scoreboard.default";
|
String translatedTitle = translate(player, title);
|
||||||
|
Objective obj = board.registerNewObjective(
|
||||||
// Wenn im Admin-Modus UND Rechte vorhanden -> owner Sektion
|
"lobby",
|
||||||
if (adminModePlayers.contains(player.getUniqueId()) && player.hasPermission("nexuslobby.scoreboard.admin")) {
|
Criteria.DUMMY,
|
||||||
configPath = "scoreboard.owner";
|
net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer
|
||||||
} else {
|
.legacySection()
|
||||||
// Standardmäßig default nutzen
|
.deserialize(translatedTitle)
|
||||||
configPath = "scoreboard.default";
|
);
|
||||||
}
|
obj.setDisplaySlot(DisplaySlot.SIDEBAR);
|
||||||
|
|
||||||
String title = vConfig.getString(configPath + ".title", "&6&lNexusLobby");
|
|
||||||
obj.setDisplayName(translate(player, title));
|
|
||||||
|
|
||||||
List<String> lines = vConfig.getStringList(configPath + ".lines");
|
// Zahlen global für dieses Objective ausblenden (Paper 1.20.4+ API)
|
||||||
|
obj.numberFormat(NumberFormat.blank());
|
||||||
// Scores zurücksetzen um Duplikate zu vermeiden
|
|
||||||
board.getEntries().forEach(board::resetScores);
|
|
||||||
|
|
||||||
for (int i = 0; i < lines.size(); i++) {
|
for (int i = 0; i < lines.size(); i++) {
|
||||||
String line = translate(player, lines.get(i));
|
String lineText = translate(player, lines.get(i));
|
||||||
|
|
||||||
// Verhindert das Verschwinden leerer Zeilen
|
// Eindeutiger unsichtbarer Entry pro Zeile via Farb-Code
|
||||||
if (line.isEmpty() || line.trim().isEmpty()) {
|
String entry = ChatColor.values()[i % ChatColor.values().length].toString()
|
||||||
line = "" + ChatColor.values()[i] + ChatColor.RESET;
|
+ 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.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 ---
|
// --- Methoden für den /nexus sb Befehl ---
|
||||||
@@ -128,23 +168,28 @@ public class ScoreboardModule implements Module, Listener {
|
|||||||
public void setVisibility(Player player, boolean visible) {
|
public void setVisibility(Player player, boolean visible) {
|
||||||
if (visible) {
|
if (visible) {
|
||||||
hiddenPlayers.remove(player.getUniqueId());
|
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 {
|
} else {
|
||||||
hiddenPlayers.add(player.getUniqueId());
|
hiddenPlayers.add(player.getUniqueId());
|
||||||
player.setScoreboard(Bukkit.getScoreboardManager().getMainScoreboard());
|
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) {
|
public void setAdminMode(Player player, boolean admin) {
|
||||||
if (admin) {
|
if (admin) {
|
||||||
adminModePlayers.add(player.getUniqueId());
|
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 {
|
} else {
|
||||||
adminModePlayers.remove(player.getUniqueId());
|
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);
|
updateSidebar(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -153,19 +198,19 @@ public class ScoreboardModule implements Module, Listener {
|
|||||||
if (placeholderAPIEnabled) {
|
if (placeholderAPIEnabled) {
|
||||||
try {
|
try {
|
||||||
translated = PlaceholderAPI.setPlaceholders(player, text);
|
translated = PlaceholderAPI.setPlaceholders(player, text);
|
||||||
} catch (NoClassDefFoundError ignored) {
|
} catch (NoClassDefFoundError ignored) {}
|
||||||
// PlaceholderAPI fehlt zur Laufzeit
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return ChatColor.translateAlternateColorCodes('&', translated);
|
return ChatColor.translateAlternateColorCodes('&', translated);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
|
org.bukkit.event.HandlerList.unregisterAll(this);
|
||||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
player.setScoreboard(Bukkit.getScoreboardManager().getMainScoreboard());
|
player.setScoreboard(Bukkit.getScoreboardManager().getMainScoreboard());
|
||||||
}
|
}
|
||||||
hiddenPlayers.clear();
|
hiddenPlayers.clear();
|
||||||
adminModePlayers.clear();
|
adminModePlayers.clear();
|
||||||
|
playerBoards.clear(); // Speicher freigeben
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6,11 +6,15 @@ import de.nexuslobby.NexusLobby;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.ArmorStand;
|
import org.bukkit.entity.ArmorStand;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.entity.Projectile;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
|
import org.bukkit.event.player.PlayerArmorStandManipulateEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
|
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
|
||||||
import org.bukkit.inventory.EquipmentSlot;
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@@ -20,6 +24,41 @@ import java.util.UUID;
|
|||||||
|
|
||||||
public class ASTListener implements Listener {
|
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)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onInteract(PlayerInteractAtEntityEvent event) {
|
public void onInteract(PlayerInteractAtEntityEvent event) {
|
||||||
if (event.getHand() != EquipmentSlot.HAND) return;
|
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.
|
* 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) {
|
private void checkAndTriggerDialog(ArmorStand as, Player p) {
|
||||||
String groupName = null;
|
String groupName = null;
|
||||||
String partnerUUIDString = null;
|
String partner1 = null, partner2 = null, partner3 = null;
|
||||||
|
|
||||||
for (String tag : as.getScoreboardTags()) {
|
for (String tag : as.getScoreboardTags()) {
|
||||||
// conv_id enthält jetzt den Gruppennamen aus der conversations.yml
|
if (tag.startsWith("conv_id:")) groupName = tag.split(":", 2)[1];
|
||||||
if (tag.startsWith("conv_id:")) groupName = tag.split(":")[1];
|
if (tag.startsWith("conv_partner:")) partner1 = tag.split(":", 2)[1];
|
||||||
if (tag.startsWith("conv_partner:")) partnerUUIDString = tag.split(":")[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) {
|
if (groupName == null || partner1 == null) return;
|
||||||
try {
|
|
||||||
UUID partnerUUID = UUID.fromString(partnerUUIDString);
|
try {
|
||||||
|
java.util.List<UUID> participants = new java.util.ArrayList<>();
|
||||||
// Wir rufen playConversation auf. Der Manager entscheidet selbst
|
participants.add(as.getUniqueId());
|
||||||
// anhand der Uhrzeit, ob er morgens, mittags oder nachts abspielt.
|
participants.add(UUID.fromString(partner1));
|
||||||
NexusLobby.getInstance().getConversationManager().playConversation(
|
if (partner2 != null) participants.add(UUID.fromString(partner2));
|
||||||
as.getUniqueId(),
|
if (partner3 != null) participants.add(UUID.fromString(partner3));
|
||||||
partnerUUID,
|
|
||||||
groupName
|
NexusLobby.getInstance().getConversationManager()
|
||||||
);
|
.playConversationGroup(participants, groupName);
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
// Falls die UUID oder Gruppe ungültig ist
|
// Ungültige UUID oder fehlende Gruppe – still ignorieren
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,7 +148,7 @@ public class ASTListener implements Listener {
|
|||||||
out.writeUTF("Connect");
|
out.writeUTF("Connect");
|
||||||
out.writeUTF(server);
|
out.writeUTF(server);
|
||||||
player.sendPluginMessage(NexusLobby.getInstance(), "BungeeCord", out.toByteArray());
|
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)
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
@@ -117,6 +158,9 @@ public class ASTListener implements Listener {
|
|||||||
if (!title.equals("Nexus ArmorStand Editor") &&
|
if (!title.equals("Nexus ArmorStand Editor") &&
|
||||||
!title.equals("Pose: Körperteil wählen") &&
|
!title.equals("Pose: Körperteil wählen") &&
|
||||||
!title.startsWith("Achsen:")) return;
|
!title.startsWith("Achsen:")) return;
|
||||||
|
|
||||||
|
// Amboss-GUI wird von AnvilRenameGUI selbst verwaltet — hier nicht anfassen
|
||||||
|
if (title.equals("§6Name ändern")) return;
|
||||||
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
if (!(event.getWhoClicked() instanceof Player p)) return;
|
if (!(event.getWhoClicked() instanceof Player p)) return;
|
||||||
@@ -134,8 +178,11 @@ public class ASTListener implements Listener {
|
|||||||
ArmorStandTool tool = ArmorStandTool.get(item);
|
ArmorStandTool tool = ArmorStandTool.get(item);
|
||||||
if (tool != null) {
|
if (tool != null) {
|
||||||
tool.execute(as, p);
|
tool.execute(as, p);
|
||||||
// Menü aktualisieren, falls wir noch im selben Editor sind
|
// Editor nur neu öffnen wenn kein Chat-Input-Modus aktiv ist
|
||||||
if (p.getOpenInventory().getTitle().equals(title)) {
|
// 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);
|
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 {
|
public class ArmorStandCmdExecutor implements CommandExecutor {
|
||||||
|
|
||||||
private final String prefix = "§8[§6Nexus§8] ";
|
private String prefix() { return de.nexuslobby.utils.LangManager.getPrefix(); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||||
if (!(sender instanceof Player p)) return true;
|
if (!(sender instanceof Player p)) return true;
|
||||||
|
|
||||||
if (!p.hasPermission("nexuslobby.armorstand.cmd")) {
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,7 +53,7 @@ public class ArmorStandCmdExecutor implements CommandExecutor {
|
|||||||
case "select4":
|
case "select4":
|
||||||
ArmorStand target = getTargetArmorStand(p);
|
ArmorStand target = getTargetArmorStand(p);
|
||||||
if (target == null) {
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,17 +63,17 @@ public class ArmorStandCmdExecutor implements CommandExecutor {
|
|||||||
UUID targetUUID = target.getUniqueId();
|
UUID targetUUID = target.getUniqueId();
|
||||||
|
|
||||||
p.setMetadata(metaKey, new FixedMetadataValue(NexusLobby.getInstance(), targetUUID.toString()));
|
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);
|
p.spawnParticle(Particle.WITCH, target.getLocation().add(0, 1.0, 0), 15, 0.2, 0.2, 0.2, 0.05);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "link":
|
case "link":
|
||||||
if (args.length < 3) {
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
if (!p.hasMetadata("conv_npc1") || !p.hasMetadata("conv_npc2")) {
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,8 +101,8 @@ public class ArmorStandCmdExecutor implements CommandExecutor {
|
|||||||
// Im Manager speichern (Nutzt die erweiterte Methode für Gruppen)
|
// Im Manager speichern (Nutzt die erweiterte Methode für Gruppen)
|
||||||
NexusLobby.getInstance().getConversationManager().saveLinkExtended(id1, id2, id3, id4, dialogId);
|
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_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_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);
|
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
|
// Metadaten nach dem Linken aufräumen
|
||||||
@@ -111,14 +111,14 @@ public class ArmorStandCmdExecutor implements CommandExecutor {
|
|||||||
p.removeMetadata("conv_npc3", NexusLobby.getInstance());
|
p.removeMetadata("conv_npc3", NexusLobby.getInstance());
|
||||||
p.removeMetadata("conv_npc4", NexusLobby.getInstance());
|
p.removeMetadata("conv_npc4", NexusLobby.getInstance());
|
||||||
} else {
|
} 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;
|
break;
|
||||||
|
|
||||||
case "unlink":
|
case "unlink":
|
||||||
ArmorStand targetUnlink = getTargetArmorStand(p);
|
ArmorStand targetUnlink = getTargetArmorStand(p);
|
||||||
if (targetUnlink == null) {
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,17 +128,17 @@ public class ArmorStandCmdExecutor implements CommandExecutor {
|
|||||||
// Aus Konfiguration löschen
|
// Aus Konfiguration löschen
|
||||||
NexusLobby.getInstance().getConversationManager().removeLink(targetUnlink.getUniqueId());
|
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);
|
p.spawnParticle(Particle.SMOKE, targetUnlink.getLocation().add(0, 1.0, 0), 20, 0.2, 0.2, 0.2, 0.02);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "start":
|
case "start":
|
||||||
if (args.length < 3) {
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
if (!p.hasMetadata("conv_npc1") || !p.hasMetadata("conv_npc2")) {
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,7 +163,7 @@ public class ArmorStandCmdExecutor implements CommandExecutor {
|
|||||||
ArmorStand target = getTargetArmorStand(p);
|
ArmorStand target = getTargetArmorStand(p);
|
||||||
|
|
||||||
if (args[0].equalsIgnoreCase("say") && args.length >= 2) {
|
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 text = buildString(args, 1);
|
||||||
String colored = ChatColor.translateAlternateColorCodes('&', text);
|
String colored = ChatColor.translateAlternateColorCodes('&', text);
|
||||||
@@ -171,25 +171,25 @@ public class ArmorStandCmdExecutor implements CommandExecutor {
|
|||||||
// Nutzt die showBubble-Logik aus dem ConversationManager (Ohne Partner-Zwang)
|
// Nutzt die showBubble-Logik aus dem ConversationManager (Ohne Partner-Zwang)
|
||||||
NexusLobby.getInstance().getConversationManager().showBubble(target, colored);
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args[0].equalsIgnoreCase("lookat")) {
|
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")) {
|
if (target.getScoreboardTags().contains("as_lookat")) {
|
||||||
target.removeScoreboardTag("as_lookat");
|
target.removeScoreboardTag("as_lookat");
|
||||||
target.setHeadPose(new EulerAngle(0, 0, 0));
|
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 {
|
} else {
|
||||||
target.addScoreboardTag("as_lookat");
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args[0].equalsIgnoreCase("name") && args.length >= 2) {
|
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);
|
String nameInput = buildString(args, 1);
|
||||||
|
|
||||||
// Wichtig: Alle alten Namens-Tags entfernen für Konsistenz
|
// Wichtig: Alle alten Namens-Tags entfernen für Konsistenz
|
||||||
@@ -198,7 +198,7 @@ public class ArmorStandCmdExecutor implements CommandExecutor {
|
|||||||
if (nameInput.equalsIgnoreCase("none")) {
|
if (nameInput.equalsIgnoreCase("none")) {
|
||||||
target.setCustomName("");
|
target.setCustomName("");
|
||||||
target.setCustomNameVisible(false);
|
target.setCustomNameVisible(false);
|
||||||
p.sendMessage(prefix + de.nexuslobby.utils.LangManager.get("name_removed"));
|
p.sendMessage(prefix() + de.nexuslobby.utils.LangManager.get("name_removed"));
|
||||||
} else {
|
} else {
|
||||||
String colored = ChatColor.translateAlternateColorCodes('&', nameInput);
|
String colored = ChatColor.translateAlternateColorCodes('&', nameInput);
|
||||||
target.setCustomName(colored);
|
target.setCustomName(colored);
|
||||||
@@ -208,19 +208,19 @@ public class ArmorStandCmdExecutor implements CommandExecutor {
|
|||||||
// ":" wird durch "§§" ersetzt, um Probleme in Scoreboard-Tags zu vermeiden
|
// ":" wird durch "§§" ersetzt, um Probleme in Scoreboard-Tags zu vermeiden
|
||||||
target.addScoreboardTag("as_displayname:" + nameInput.replace(":", "§§"));
|
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("name_set").replace("{name}", colored));
|
||||||
p.sendMessage(prefix + de.nexuslobby.utils.LangManager.get("status_backup_saved"));
|
p.sendMessage(prefix() + de.nexuslobby.utils.LangManager.get("status_backup_saved"));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args[0].equalsIgnoreCase("add") && args.length >= 5) {
|
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 slot1 = args[1], slot2 = args[2], type = args[3].toLowerCase();
|
||||||
String cmdStr = buildString(args, 4);
|
String cmdStr = buildString(args, 4);
|
||||||
|
|
||||||
target.addScoreboardTag("ascmd:" + slot1 + ":" + slot2 + ":" + type + ":" + cmdStr);
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -234,7 +234,19 @@ public class ArmorStandCmdExecutor implements CommandExecutor {
|
|||||||
if (args[0].equalsIgnoreCase("remove")) {
|
if (args[0].equalsIgnoreCase("remove")) {
|
||||||
if (target == null) { p.sendMessage(de.nexuslobby.utils.LangManager.get("no_target")); return true; }
|
if (target == null) { p.sendMessage(de.nexuslobby.utils.LangManager.get("no_target")); return true; }
|
||||||
target.getScoreboardTags().removeIf(tag -> tag.startsWith("ascmd:"));
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -284,6 +296,7 @@ public class ArmorStandCmdExecutor implements CommandExecutor {
|
|||||||
p.sendMessage("§e/nexuscmd conv §7- Gesprächs-Menü");
|
p.sendMessage("§e/nexuscmd conv §7- Gesprächs-Menü");
|
||||||
p.sendMessage("§e/nexuscmd list §7- Zeigt alle Tags");
|
p.sendMessage("§e/nexuscmd list §7- Zeigt alle Tags");
|
||||||
p.sendMessage("§e/nexuscmd remove §7- Löscht Befehle");
|
p.sendMessage("§e/nexuscmd remove §7- Löscht Befehle");
|
||||||
|
p.sendMessage("§e/nexuscmd clearbubbles §7- Entfernt hängende Sprechblasen");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -50,7 +50,7 @@ public class ArmorStandCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Fester Prefix für maximale Build-Sicherheit
|
// 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")) {
|
if (!p.hasPermission("nexuslobby.armorstand.use")) {
|
||||||
p.sendMessage(prefix + ChatColor.RED + "Dazu hast du keine Rechte!");
|
p.sendMessage(prefix + ChatColor.RED + "Dazu hast du keine Rechte!");
|
||||||
|
|||||||
@@ -1,113 +1,113 @@
|
|||||||
package de.nexuslobby.modules.armorstandtools;
|
package de.nexuslobby.modules.armorstandtools;
|
||||||
|
|
||||||
import de.nexuslobby.NexusLobby;
|
import de.nexuslobby.NexusLobby;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.ArmorStand;
|
import org.bukkit.entity.ArmorStand;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
import org.bukkit.util.EulerAngle;
|
import org.bukkit.util.EulerAngle;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
public class ArmorStandLookAtModule {
|
public class ArmorStandLookAtModule {
|
||||||
|
|
||||||
public ArmorStandLookAtModule() {
|
public ArmorStandLookAtModule() {
|
||||||
startRotationTask();
|
startRotationTask();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startRotationTask() {
|
private void startRotationTask() {
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
// Wir gehen alle Welten durch, um markierte ArmorStands zu finden
|
// Wir gehen alle Welten durch, um markierte ArmorStands zu finden
|
||||||
for (World world : Bukkit.getWorlds()) {
|
for (World world : Bukkit.getWorlds()) {
|
||||||
for (ArmorStand as : world.getEntitiesByClass(ArmorStand.class)) {
|
for (ArmorStand as : world.getEntitiesByClass(ArmorStand.class)) {
|
||||||
|
|
||||||
// Nur ArmorStands mit dem Tag "as_lookat"
|
// Nur ArmorStands mit dem Tag "as_lookat"
|
||||||
if (as.getScoreboardTags().contains("as_lookat")) {
|
if (as.getScoreboardTags().contains("as_lookat")) {
|
||||||
|
|
||||||
// Suche den nächsten Spieler im Umkreis von 7 Blöcken
|
// Suche den nächsten Spieler im Umkreis von 7 Blöcken
|
||||||
Player nearest = getNearestPlayer(as, 7.0);
|
Player nearest = getNearestPlayer(as, 7.0);
|
||||||
|
|
||||||
if (nearest != null) {
|
if (nearest != null) {
|
||||||
// Spieler gefunden -> Kopf zum Spieler drehen
|
// Spieler gefunden -> Kopf zum Spieler drehen
|
||||||
updateLookAt(as, nearest);
|
updateLookAt(as, nearest);
|
||||||
} else {
|
} else {
|
||||||
// Kein Spieler da -> Kopf sanft auf 0,0,0 zurücksetzen
|
// Kein Spieler da -> Kopf sanft auf 0,0,0 zurücksetzen
|
||||||
resetHeadPose(as);
|
resetHeadPose(as);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.runTaskTimer(NexusLobby.getInstance(), 0L, 1L);
|
}.runTaskTimer(NexusLobby.getInstance(), 0L, 1L);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateLookAt(ArmorStand as, Player player) {
|
private void updateLookAt(ArmorStand as, Player player) {
|
||||||
Location asLoc = as.getEyeLocation();
|
Location asLoc = as.getEyeLocation();
|
||||||
Location target = player.getEyeLocation();
|
Location target = player.getEyeLocation();
|
||||||
|
|
||||||
Vector direction = target.toVector().subtract(asLoc.toVector()).normalize();
|
Vector direction = target.toVector().subtract(asLoc.toVector()).normalize();
|
||||||
|
|
||||||
// Ziel-Winkel aus Vektor berechnen
|
// Ziel-Winkel aus Vektor berechnen
|
||||||
double targetYaw = Math.toDegrees(Math.atan2(-direction.getX(), direction.getZ()));
|
double targetYaw = Math.toDegrees(Math.atan2(-direction.getX(), direction.getZ()));
|
||||||
double targetPitch = Math.toDegrees(Math.asin(direction.getY()));
|
double targetPitch = Math.toDegrees(Math.asin(direction.getY()));
|
||||||
|
|
||||||
// Relativer Yaw zum Körper-Yaw
|
// Relativer Yaw zum Körper-Yaw
|
||||||
double relativeYaw = targetYaw - as.getLocation().getYaw();
|
double relativeYaw = targetYaw - as.getLocation().getYaw();
|
||||||
relativeYaw = ((relativeYaw + 180) % 360 + 360) % 360 - 180;
|
relativeYaw = ((relativeYaw + 180) % 360 + 360) % 360 - 180;
|
||||||
|
|
||||||
double yawRad = Math.toRadians(relativeYaw);
|
double yawRad = Math.toRadians(relativeYaw);
|
||||||
double pitchRad = Math.toRadians(-targetPitch);
|
double pitchRad = Math.toRadians(-targetPitch);
|
||||||
|
|
||||||
// Begrenzung (Nacken-Schutz)
|
// Begrenzung (Nacken-Schutz)
|
||||||
if (yawRad > 1.2) yawRad = 1.2;
|
if (yawRad > 1.2) yawRad = 1.2;
|
||||||
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;
|
||||||
if (pitchRad < -0.8) pitchRad = -0.8;
|
if (pitchRad < -0.8) pitchRad = -0.8;
|
||||||
|
|
||||||
applySmoothPose(as, pitchRad, yawRad);
|
applySmoothPose(as, pitchRad, yawRad);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void resetHeadPose(ArmorStand as) {
|
private void resetHeadPose(ArmorStand as) {
|
||||||
EulerAngle current = as.getHeadPose();
|
EulerAngle current = as.getHeadPose();
|
||||||
// Wenn der Kopf schon (fast) gerade ist, nichts tun
|
// Wenn der Kopf schon (fast) gerade ist, nichts tun
|
||||||
if (Math.abs(current.getX()) < 0.01 && Math.abs(current.getY()) < 0.01) {
|
if (Math.abs(current.getX()) < 0.01 && Math.abs(current.getY()) < 0.01) {
|
||||||
if (current.getX() != 0 || current.getY() != 0) {
|
if (current.getX() != 0 || current.getY() != 0) {
|
||||||
as.setHeadPose(new EulerAngle(0, 0, 0));
|
as.setHeadPose(new EulerAngle(0, 0, 0));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ziel: 0, 0, 0 (Geradeaus schauen)
|
// Ziel: 0, 0, 0 (Geradeaus schauen)
|
||||||
applySmoothPose(as, 0, 0);
|
applySmoothPose(as, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void applySmoothPose(ArmorStand as, double pitchRad, double yawRad) {
|
private void applySmoothPose(ArmorStand as, double pitchRad, double yawRad) {
|
||||||
EulerAngle current = as.getHeadPose();
|
EulerAngle current = as.getHeadPose();
|
||||||
double lerp = 0.15; // Geschmeidigkeit
|
double lerp = 0.15; // Geschmeidigkeit
|
||||||
|
|
||||||
double finalPitch = current.getX() + (pitchRad - current.getX()) * lerp;
|
double finalPitch = current.getX() + (pitchRad - current.getX()) * lerp;
|
||||||
double finalYaw = current.getY() + (yawRad - current.getY()) * lerp;
|
double finalYaw = current.getY() + (yawRad - current.getY()) * lerp;
|
||||||
|
|
||||||
as.setHeadPose(new EulerAngle(finalPitch, finalYaw, 0));
|
as.setHeadPose(new EulerAngle(finalPitch, finalYaw, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Player getNearestPlayer(ArmorStand as, double range) {
|
private Player getNearestPlayer(ArmorStand as, double range) {
|
||||||
Player nearest = null;
|
Player nearest = null;
|
||||||
double dSquared = range * range;
|
double dSquared = range * range;
|
||||||
|
|
||||||
for (Player p : as.getWorld().getPlayers()) {
|
for (Player p : as.getWorld().getPlayers()) {
|
||||||
// Falls Spieler im Vanish/Spectator ist, ignorieren (optional)
|
// Falls Spieler im Vanish/Spectator ist, ignorieren (optional)
|
||||||
if (p.getGameMode().name().equals("SPECTATOR")) continue;
|
if (p.getGameMode().name().equals("SPECTATOR")) continue;
|
||||||
|
|
||||||
double dist = p.getLocation().distanceSquared(as.getLocation());
|
double dist = p.getLocation().distanceSquared(as.getLocation());
|
||||||
if (dist < dSquared) {
|
if (dist < dSquared) {
|
||||||
dSquared = dist;
|
dSquared = dist;
|
||||||
nearest = p;
|
nearest = p;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nearest;
|
return nearest;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,111 +1,111 @@
|
|||||||
package de.nexuslobby.modules.armorstandtools;
|
package de.nexuslobby.modules.armorstandtools;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.ArmorStand;
|
import org.bukkit.entity.ArmorStand;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.bukkit.util.EulerAngle;
|
import org.bukkit.util.EulerAngle;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
public class ArmorStandPoseGUI {
|
public class ArmorStandPoseGUI {
|
||||||
|
|
||||||
// Schritt 1: Auswahl welches Körperteil (Die "letzte Reihe" ist jetzt hier)
|
// Schritt 1: Auswahl welches Körperteil (Die "letzte Reihe" ist jetzt hier)
|
||||||
public static void openPartSelectionMenu(Player p, ArmorStand as) {
|
public static void openPartSelectionMenu(Player p, ArmorStand as) {
|
||||||
Inventory inv = Bukkit.createInventory(null, 45, "Pose: Körperteil wählen");
|
Inventory inv = Bukkit.createInventory(null, 45, "Pose: Körperteil wählen");
|
||||||
ItemStack filler = new ItemStack(Material.BLACK_STAINED_GLASS_PANE);
|
ItemStack filler = new ItemStack(Material.BLACK_STAINED_GLASS_PANE);
|
||||||
for (int i = 0; i < 45; i++) inv.setItem(i, filler);
|
for (int i = 0; i < 45; i++) inv.setItem(i, filler);
|
||||||
|
|
||||||
inv.setItem(10, createPartIcon(Material.PLAYER_HEAD, "§eKopf", as.getHeadPose()));
|
inv.setItem(10, createPartIcon(Material.PLAYER_HEAD, "§eKopf", as.getHeadPose()));
|
||||||
inv.setItem(12, createPartIcon(Material.IRON_CHESTPLATE, "§eTorso", as.getBodyPose()));
|
inv.setItem(12, createPartIcon(Material.IRON_CHESTPLATE, "§eTorso", as.getBodyPose()));
|
||||||
inv.setItem(14, createPartIcon(Material.STICK, "§eLinker Arm", as.getLeftArmPose()));
|
inv.setItem(14, createPartIcon(Material.STICK, "§eLinker Arm", as.getLeftArmPose()));
|
||||||
inv.setItem(16, createPartIcon(Material.STICK, "§eRechter Arm", as.getRightArmPose()));
|
inv.setItem(16, createPartIcon(Material.STICK, "§eRechter Arm", as.getRightArmPose()));
|
||||||
inv.setItem(28, createPartIcon(Material.LEATHER_BOOTS, "§eLinkes Bein", as.getLeftLegPose()));
|
inv.setItem(28, createPartIcon(Material.LEATHER_BOOTS, "§eLinkes Bein", as.getLeftLegPose()));
|
||||||
inv.setItem(30, createPartIcon(Material.LEATHER_BOOTS, "§eRechtes Bein", as.getRightLegPose()));
|
inv.setItem(30, createPartIcon(Material.LEATHER_BOOTS, "§eRechtes Bein", as.getRightLegPose()));
|
||||||
|
|
||||||
inv.setItem(40, createNamedItem(Material.BARRIER, "§cZurück zum Hauptmenü"));
|
inv.setItem(40, createNamedItem(Material.BARRIER, "§cZurück zum Hauptmenü"));
|
||||||
p.openInventory(inv);
|
p.openInventory(inv);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Schritt 2: Detail-Einstellung der Achsen (X, Y, Z)
|
// Schritt 2: Detail-Einstellung der Achsen (X, Y, Z)
|
||||||
public static void openAxisDetailMenu(Player p, ArmorStand as, String partName) {
|
public static void openAxisDetailMenu(Player p, ArmorStand as, String partName) {
|
||||||
Inventory inv = Bukkit.createInventory(null, 27, "Achsen: " + partName);
|
Inventory inv = Bukkit.createInventory(null, 27, "Achsen: " + partName);
|
||||||
ItemStack filler = new ItemStack(Material.GRAY_STAINED_GLASS_PANE);
|
ItemStack filler = new ItemStack(Material.GRAY_STAINED_GLASS_PANE);
|
||||||
for (int i = 0; i < 27; i++) inv.setItem(i, filler);
|
for (int i = 0; i < 27; i++) inv.setItem(i, filler);
|
||||||
|
|
||||||
ArmorStandTool tool = ArmorStandTool.valueOf(partName);
|
ArmorStandTool tool = ArmorStandTool.valueOf(partName);
|
||||||
EulerAngle angle = getAngleForPart(as, tool);
|
EulerAngle angle = getAngleForPart(as, tool);
|
||||||
|
|
||||||
inv.setItem(11, createAxisItem(Material.RED_DYE, "§c§lX-Achse (Pitch)", angle.getX()));
|
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(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(15, createAxisItem(Material.BLUE_DYE, "§b§lZ-Achse (Roll)", angle.getZ()));
|
||||||
|
|
||||||
inv.setItem(22, createNamedItem(Material.ARROW, "§7Zurück zur Auswahl"));
|
inv.setItem(22, createNamedItem(Material.ARROW, "§7Zurück zur Auswahl"));
|
||||||
p.openInventory(inv);
|
p.openInventory(inv);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ItemStack createPartIcon(Material mat, String name, EulerAngle angle) {
|
private static ItemStack createPartIcon(Material mat, String name, EulerAngle angle) {
|
||||||
ItemStack item = new ItemStack(mat);
|
ItemStack item = new ItemStack(mat);
|
||||||
ItemMeta meta = item.getItemMeta();
|
ItemMeta meta = item.getItemMeta();
|
||||||
if (meta == null) return item;
|
if (meta == null) return item;
|
||||||
meta.setDisplayName(name);
|
meta.setDisplayName(name);
|
||||||
meta.setLore(Arrays.asList(
|
meta.setLore(Arrays.asList(
|
||||||
"§8Rotation:",
|
"§8Rotation:",
|
||||||
"§7X: §f" + Math.round(Math.toDegrees(angle.getX())) + "°",
|
"§7X: §f" + Math.round(Math.toDegrees(angle.getX())) + "°",
|
||||||
"§7Y: §f" + Math.round(Math.toDegrees(angle.getY())) + "°",
|
"§7Y: §f" + Math.round(Math.toDegrees(angle.getY())) + "°",
|
||||||
"§7Z: §f" + Math.round(Math.toDegrees(angle.getZ())) + "°",
|
"§7Z: §f" + Math.round(Math.toDegrees(angle.getZ())) + "°",
|
||||||
"", "§6Klicken zum Justieren"
|
"", "§6Klicken zum Justieren"
|
||||||
));
|
));
|
||||||
item.setItemMeta(meta);
|
item.setItemMeta(meta);
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ItemStack createAxisItem(Material mat, String name, double angleRad) {
|
private static ItemStack createAxisItem(Material mat, String name, double angleRad) {
|
||||||
ItemStack item = new ItemStack(mat);
|
ItemStack item = new ItemStack(mat);
|
||||||
ItemMeta meta = item.getItemMeta();
|
ItemMeta meta = item.getItemMeta();
|
||||||
if (meta == null) return item;
|
if (meta == null) return item;
|
||||||
meta.setDisplayName(name);
|
meta.setDisplayName(name);
|
||||||
meta.setLore(Arrays.asList(
|
meta.setLore(Arrays.asList(
|
||||||
"§7Aktueller Winkel: §f" + Math.round(Math.toDegrees(angleRad)) + "°",
|
"§7Aktueller Winkel: §f" + Math.round(Math.toDegrees(angleRad)) + "°",
|
||||||
"",
|
"",
|
||||||
"§eLinksklick: §f+15° §8| §eRechtsklick: §f-15°",
|
"§eLinksklick: §f+15° §8| §eRechtsklick: §f-15°",
|
||||||
"§6Shift-Klick: §f+1° §8| §6Shift-Rechts: §f-1°"
|
"§6Shift-Klick: §f+1° §8| §6Shift-Rechts: §f-1°"
|
||||||
));
|
));
|
||||||
item.setItemMeta(meta);
|
item.setItemMeta(meta);
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ItemStack createNamedItem(Material mat, String name) {
|
private static ItemStack createNamedItem(Material mat, String name) {
|
||||||
ItemStack item = new ItemStack(mat);
|
ItemStack item = new ItemStack(mat);
|
||||||
ItemMeta meta = item.getItemMeta();
|
ItemMeta meta = item.getItemMeta();
|
||||||
if (meta == null) return item;
|
if (meta == null) return item;
|
||||||
meta.setDisplayName(name);
|
meta.setDisplayName(name);
|
||||||
item.setItemMeta(meta);
|
item.setItemMeta(meta);
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static EulerAngle getAngleForPart(ArmorStand as, ArmorStandTool part) {
|
public static EulerAngle getAngleForPart(ArmorStand as, ArmorStandTool part) {
|
||||||
return switch (part) {
|
return switch (part) {
|
||||||
case HEAD_ROT -> as.getHeadPose();
|
case HEAD_ROT -> as.getHeadPose();
|
||||||
case BODY_ROT -> as.getBodyPose();
|
case BODY_ROT -> as.getBodyPose();
|
||||||
case L_ARM_ROT -> as.getLeftArmPose();
|
case L_ARM_ROT -> as.getLeftArmPose();
|
||||||
case R_ARM_ROT -> as.getRightArmPose();
|
case R_ARM_ROT -> as.getRightArmPose();
|
||||||
case L_LEG_ROT -> as.getLeftLegPose();
|
case L_LEG_ROT -> as.getLeftLegPose();
|
||||||
case R_LEG_ROT -> as.getRightLegPose();
|
case R_LEG_ROT -> as.getRightLegPose();
|
||||||
default -> EulerAngle.ZERO;
|
default -> EulerAngle.ZERO;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setAngleForPart(ArmorStand as, ArmorStandTool part, EulerAngle angle) {
|
public static void setAngleForPart(ArmorStand as, ArmorStandTool part, EulerAngle angle) {
|
||||||
switch (part) {
|
switch (part) {
|
||||||
case HEAD_ROT -> as.setHeadPose(angle);
|
case HEAD_ROT -> as.setHeadPose(angle);
|
||||||
case BODY_ROT -> as.setBodyPose(angle);
|
case BODY_ROT -> as.setBodyPose(angle);
|
||||||
case L_ARM_ROT -> as.setLeftArmPose(angle);
|
case L_ARM_ROT -> as.setLeftArmPose(angle);
|
||||||
case R_ARM_ROT -> as.setRightArmPose(angle);
|
case R_ARM_ROT -> as.setRightArmPose(angle);
|
||||||
case L_LEG_ROT -> as.setLeftLegPose(angle);
|
case L_LEG_ROT -> as.setLeftLegPose(angle);
|
||||||
case R_LEG_ROT -> as.setRightLegPose(angle);
|
case R_LEG_ROT -> as.setRightLegPose(angle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,135 +1,135 @@
|
|||||||
package de.nexuslobby.modules.armorstandtools;
|
package de.nexuslobby.modules.armorstandtools;
|
||||||
|
|
||||||
import de.nexuslobby.NexusLobby;
|
import de.nexuslobby.NexusLobby;
|
||||||
import de.nexuslobby.api.Module;
|
import de.nexuslobby.api.Module;
|
||||||
import de.nexuslobby.modules.servers.ServerChecker;
|
import de.nexuslobby.modules.servers.ServerChecker;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.entity.ArmorStand;
|
import org.bukkit.entity.ArmorStand;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ArmorStandStatusModule - Optimierte Statusanzeige für Java & Bedrock.
|
* ArmorStandStatusModule - Optimierte Statusanzeige für Java & Bedrock.
|
||||||
* - Schaltet zwischen Servername und "Offline" um.
|
* - Schaltet zwischen Servername und "Offline" um.
|
||||||
* - Anti-Blink-Logik für Java-Spieler.
|
* - Anti-Blink-Logik für Java-Spieler.
|
||||||
* - Force-Refresh-Logik für Bedrock-Spieler (Geyser).
|
* - Force-Refresh-Logik für Bedrock-Spieler (Geyser).
|
||||||
*/
|
*/
|
||||||
public class ArmorStandStatusModule implements Module {
|
public class ArmorStandStatusModule implements Module {
|
||||||
|
|
||||||
private final Map<UUID, Boolean> lastStatus = new HashMap<>();
|
private final Map<UUID, Boolean> lastStatus = new HashMap<>();
|
||||||
private final Map<String, Integer> failCount = new HashMap<>();
|
private final Map<String, Integer> failCount = new HashMap<>();
|
||||||
|
|
||||||
// Zähler für den Force-Refresh (Bedrock-Sicherheit)
|
// Zähler für den Force-Refresh (Bedrock-Sicherheit)
|
||||||
private int refreshTicks = 0;
|
private int refreshTicks = 0;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "ArmorStandStatus";
|
return "ArmorStandStatus";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
// Alle 10 Sekunden (200 Ticks)
|
// Alle 10 Sekunden (200 Ticks)
|
||||||
Bukkit.getScheduler().runTaskTimer(NexusLobby.getInstance(), () -> {
|
Bukkit.getScheduler().runTaskTimer(NexusLobby.getInstance(), () -> {
|
||||||
refreshTicks++;
|
refreshTicks++;
|
||||||
updateAllServerArmorStands();
|
updateAllServerArmorStands();
|
||||||
}, 100L, 200L);
|
}, 100L, 200L);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
lastStatus.clear();
|
lastStatus.clear();
|
||||||
failCount.clear();
|
failCount.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateAllServerArmorStands() {
|
private void updateAllServerArmorStands() {
|
||||||
// Alle 6 Durchgänge (ca. jede Minute) erzwingen wir ein Update für Bedrock
|
// Alle 6 Durchgänge (ca. jede Minute) erzwingen wir ein Update für Bedrock
|
||||||
boolean forceRefresh = (refreshTicks >= 6);
|
boolean forceRefresh = (refreshTicks >= 6);
|
||||||
if (forceRefresh) refreshTicks = 0;
|
if (forceRefresh) refreshTicks = 0;
|
||||||
|
|
||||||
for (World world : Bukkit.getWorlds()) {
|
for (World world : Bukkit.getWorlds()) {
|
||||||
for (Entity entity : world.getEntitiesByClass(ArmorStand.class)) {
|
for (Entity entity : world.getEntitiesByClass(ArmorStand.class)) {
|
||||||
if (entity instanceof ArmorStand as) {
|
if (entity instanceof ArmorStand as) {
|
||||||
checkAndRefreshStatus(as, forceRefresh);
|
checkAndRefreshStatus(as, forceRefresh);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkAndRefreshStatus(ArmorStand as, boolean forceRefresh) {
|
private void checkAndRefreshStatus(ArmorStand as, boolean forceRefresh) {
|
||||||
String serverName = null;
|
String serverName = null;
|
||||||
|
|
||||||
for (String tag : as.getScoreboardTags()) {
|
for (String tag : as.getScoreboardTags()) {
|
||||||
if (tag.startsWith("ascmd:")) {
|
if (tag.startsWith("ascmd:")) {
|
||||||
if (tag.contains(":bungee:")) {
|
if (tag.contains(":bungee:")) {
|
||||||
String[] parts = tag.split(":");
|
String[] parts = tag.split(":");
|
||||||
if (parts.length >= 5) {
|
if (parts.length >= 5) {
|
||||||
serverName = parts[4].toLowerCase();
|
serverName = parts[4].toLowerCase();
|
||||||
} else if (tag.startsWith("ascmd:bungee:")) {
|
} else if (tag.startsWith("ascmd:bungee:")) {
|
||||||
serverName = tag.replace("ascmd:bungee:", "").toLowerCase();
|
serverName = tag.replace("ascmd:bungee:", "").toLowerCase();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (serverName != null) break;
|
if (serverName != null) break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (serverName == null) return;
|
if (serverName == null) return;
|
||||||
|
|
||||||
final String finalServerName = serverName;
|
final String finalServerName = serverName;
|
||||||
String ip = NexusLobby.getInstance().getConfig().getString("servers." + serverName + ".ip", "127.0.0.1");
|
String ip = NexusLobby.getInstance().getConfig().getString("servers." + serverName + ".ip", "127.0.0.1");
|
||||||
int port = NexusLobby.getInstance().getConfig().getInt("servers." + serverName + ".port", 25565);
|
int port = NexusLobby.getInstance().getConfig().getInt("servers." + serverName + ".port", 25565);
|
||||||
|
|
||||||
ServerChecker.isOnline(ip, port).thenAccept(isOnline -> {
|
ServerChecker.isOnline(ip, port).thenAccept(isOnline -> {
|
||||||
Bukkit.getScheduler().runTask(NexusLobby.getInstance(), () -> {
|
Bukkit.getScheduler().runTask(NexusLobby.getInstance(), () -> {
|
||||||
|
|
||||||
// Toleranz-Logik gegen kurzes Flackern
|
// Toleranz-Logik gegen kurzes Flackern
|
||||||
if (isOnline) {
|
if (isOnline) {
|
||||||
failCount.put(finalServerName, 0);
|
failCount.put(finalServerName, 0);
|
||||||
} else {
|
} else {
|
||||||
int fails = failCount.getOrDefault(finalServerName, 0) + 1;
|
int fails = failCount.getOrDefault(finalServerName, 0) + 1;
|
||||||
failCount.put(finalServerName, fails);
|
failCount.put(finalServerName, fails);
|
||||||
if (fails < 2) return;
|
if (fails < 2) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String originalDisplayName = getOriginalName(as);
|
String originalDisplayName = getOriginalName(as);
|
||||||
if (originalDisplayName == null) return;
|
if (originalDisplayName == null) return;
|
||||||
|
|
||||||
// Status-Check: Hat sich etwas geändert?
|
// Status-Check: Hat sich etwas geändert?
|
||||||
Boolean lastKnown = lastStatus.get(as.getUniqueId());
|
Boolean lastKnown = lastStatus.get(as.getUniqueId());
|
||||||
|
|
||||||
// Nur wenn Status neu ODER Force-Refresh (für Bedrock) aktiv ist
|
// Nur wenn Status neu ODER Force-Refresh (für Bedrock) aktiv ist
|
||||||
if (!forceRefresh && lastKnown != null && lastKnown == isOnline) {
|
if (!forceRefresh && lastKnown != null && lastKnown == isOnline) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Namen setzen
|
// Namen setzen
|
||||||
if (isOnline) {
|
if (isOnline) {
|
||||||
String translatedName = ChatColor.translateAlternateColorCodes('&', originalDisplayName);
|
String translatedName = ChatColor.translateAlternateColorCodes('&', originalDisplayName);
|
||||||
as.setCustomName(translatedName);
|
as.setCustomName(translatedName);
|
||||||
} else {
|
} else {
|
||||||
as.setCustomName("§cOffline");
|
as.setCustomName("§cOffline");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bedrock-Fix: Sichtbarkeit explizit triggern
|
// Bedrock-Fix: Sichtbarkeit explizit triggern
|
||||||
as.setCustomNameVisible(true);
|
as.setCustomNameVisible(true);
|
||||||
|
|
||||||
// Status speichern
|
// Status speichern
|
||||||
lastStatus.put(as.getUniqueId(), isOnline);
|
lastStatus.put(as.getUniqueId(), isOnline);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getOriginalName(ArmorStand as) {
|
private String getOriginalName(ArmorStand as) {
|
||||||
for (String tag : as.getScoreboardTags()) {
|
for (String tag : as.getScoreboardTags()) {
|
||||||
if (tag.startsWith("as_displayname:")) {
|
if (tag.startsWith("as_displayname:")) {
|
||||||
return tag.replace("as_displayname:", "").replace("§§", ":");
|
return tag.replace("as_displayname:", "").replace("§§", ":");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -51,19 +51,19 @@ public enum ArmorStandTool {
|
|||||||
case GRAV -> as.setGravity(!as.hasGravity());
|
case GRAV -> as.setGravity(!as.hasGravity());
|
||||||
case INVUL -> as.setInvulnerable(!as.isInvulnerable());
|
case INVUL -> as.setInvulnerable(!as.isInvulnerable());
|
||||||
case SET_NAME -> {
|
case SET_NAME -> {
|
||||||
p.closeInventory();
|
|
||||||
p.sendMessage("§8[§6Nexus§8] §7Nutze §e/nexuscmd name <Text>");
|
|
||||||
AST.selectedArmorStand.put(p.getUniqueId(), as);
|
AST.selectedArmorStand.put(p.getUniqueId(), as);
|
||||||
|
AST.chatInputMode.put(p.getUniqueId(), as);
|
||||||
|
new AnvilRenameGUI(p, as); // schließt Inventar intern
|
||||||
}
|
}
|
||||||
case CONV_SETUP -> {
|
case CONV_SETUP -> {
|
||||||
// Automatisches Markieren via GUI
|
// Automatisches Markieren via GUI
|
||||||
if (!p.hasMetadata("conv_npc1")) {
|
if (!p.hasMetadata("conv_npc1")) {
|
||||||
p.setMetadata("conv_npc1", new FixedMetadataValue(NexusLobby.getInstance(), as.getUniqueId().toString()));
|
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 {
|
} else {
|
||||||
p.setMetadata("conv_npc2", new FixedMetadataValue(NexusLobby.getInstance(), as.getUniqueId().toString()));
|
p.setMetadata("conv_npc2", new FixedMetadataValue(NexusLobby.getInstance(), as.getUniqueId().toString()));
|
||||||
p.sendMessage("§8[§6Nexus§8] §aNPC als Sprecher 2 markiert.");
|
p.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§aNPC als Sprecher 2 markiert.");
|
||||||
p.sendMessage("§8[§6Nexus§8] §7Nutze nun §e/nexuscmd conv start <ID>");
|
p.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§7Nutze nun §e/nexuscmd conv start <ID>");
|
||||||
}
|
}
|
||||||
p.closeInventory();
|
p.closeInventory();
|
||||||
}
|
}
|
||||||
@@ -99,8 +99,11 @@ public enum ArmorStandTool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static ArmorStandTool get(ItemStack item) {
|
public static ArmorStandTool get(ItemStack item) {
|
||||||
if (item == null || !item.hasItemMeta() || !item.getItemMeta().hasDisplayName()) return null;
|
if (item == null || !item.hasItemMeta()) return null;
|
||||||
String name = ChatColor.stripColor(item.getItemMeta().getDisplayName()).replace(" ", "_");
|
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("Pose_Editor_öffnen")) return OPEN_POSE_EDITOR;
|
||||||
if (name.equals("Gesprächs-Setup")) return CONV_SETUP;
|
if (name.equals("Gesprächs-Setup")) return CONV_SETUP;
|
||||||
try { return valueOf(name); } catch (Exception e) { return null; }
|
try { return valueOf(name); } catch (Exception e) { return null; }
|
||||||
|
|||||||
@@ -1,280 +1,297 @@
|
|||||||
package de.nexuslobby.modules.armorstandtools;
|
package de.nexuslobby.modules.armorstandtools;
|
||||||
|
|
||||||
import de.nexuslobby.NexusLobby;
|
import de.nexuslobby.NexusLobby;
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.entity.ArmorStand;
|
import org.bukkit.entity.ArmorStand;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class ConversationManager {
|
public class ConversationManager {
|
||||||
|
|
||||||
private final NexusLobby plugin;
|
private final NexusLobby plugin;
|
||||||
private File file;
|
private File file;
|
||||||
private FileConfiguration config;
|
private FileConfiguration config;
|
||||||
|
|
||||||
// Verhindert Mehrfach-Gespräche und regelt die 60s Pause
|
// Verhindert Mehrfach-Gespräche und regelt die 60s Pause
|
||||||
private final Set<UUID> activeSpeakers = new HashSet<>();
|
private final Set<UUID> activeSpeakers = new HashSet<>();
|
||||||
|
// Alle aktiven Bubble-Entities tracken – für zuverlässiges Cleanup bei Reload/Crash
|
||||||
public ConversationManager(NexusLobby plugin) {
|
private final Set<UUID> activeBubbles = new HashSet<>();
|
||||||
this.plugin = plugin;
|
|
||||||
setupFile();
|
public ConversationManager(NexusLobby plugin) {
|
||||||
clearHangingBubbles();
|
this.plugin = plugin;
|
||||||
}
|
setupFile();
|
||||||
|
clearHangingBubbles();
|
||||||
/**
|
}
|
||||||
* Gibt alle verfügbaren IDs zurück.
|
|
||||||
*/
|
/**
|
||||||
public List<String> getConversationIds() {
|
* Gibt alle verfügbaren IDs zurück.
|
||||||
if (config == null || !config.contains("conversations")) {
|
*/
|
||||||
return new ArrayList<>();
|
public List<String> getConversationIds() {
|
||||||
}
|
if (config == null || !config.contains("conversations")) {
|
||||||
ConfigurationSection section = config.getConfigurationSection("conversations");
|
return new ArrayList<>();
|
||||||
if (section == null) return new ArrayList<>();
|
}
|
||||||
|
ConfigurationSection section = config.getConfigurationSection("conversations");
|
||||||
return new ArrayList<>(section.getKeys(false));
|
if (section == null) return new ArrayList<>();
|
||||||
}
|
|
||||||
|
return new ArrayList<>(section.getKeys(false));
|
||||||
/**
|
}
|
||||||
* Entfernt alle verwaisten Sprechblasen in allen Welten.
|
|
||||||
*/
|
/**
|
||||||
public void clearHangingBubbles() {
|
* Entfernt alle verwaisten Sprechblasen in allen Welten.
|
||||||
int count = 0;
|
* FIX: Nur ArmorStands mit dem Tag "nexus_bubble" werden entfernt.
|
||||||
for (World world : Bukkit.getWorlds()) {
|
* Die alte Bedingung (!isVisible && isMarker && customName != null) war
|
||||||
for (ArmorStand as : world.getEntitiesByClass(ArmorStand.class)) {
|
* zu breit und hätte auch legitime Marker-ArmorStands anderer Systeme gelöscht.
|
||||||
if (as.getScoreboardTags().contains("nexus_bubble") ||
|
*/
|
||||||
(!as.isVisible() && as.isMarker() && as.getCustomName() != null)) {
|
public void clearHangingBubbles() {
|
||||||
as.remove();
|
// Zuerst: Alle getrackte Bubble-Entities direkt entfernen (schnell, kein World-Scan nötig)
|
||||||
count++;
|
for (UUID uuid : new HashSet<>(activeBubbles)) {
|
||||||
}
|
Entity e = Bukkit.getEntity(uuid);
|
||||||
}
|
if (e != null) e.remove();
|
||||||
}
|
}
|
||||||
if (count > 0) {
|
activeBubbles.clear();
|
||||||
Bukkit.getLogger().info("[NexusLobby] Cleanup: " + count + " verwaiste Sprechblasen entfernt.");
|
|
||||||
}
|
// Danach: Vollständiger World-Scan als Fallback (fängt Bubbles nach Crash/Reload ab)
|
||||||
}
|
int count = 0;
|
||||||
|
for (World world : Bukkit.getWorlds()) {
|
||||||
public void setupFile() {
|
for (ArmorStand as : world.getEntitiesByClass(ArmorStand.class)) {
|
||||||
this.file = new File(plugin.getDataFolder(), "conversations.yml");
|
if (as.getScoreboardTags().contains("nexus_bubble")) {
|
||||||
if (!file.exists()) {
|
as.remove();
|
||||||
plugin.saveResource("conversations.yml", false);
|
count++;
|
||||||
}
|
}
|
||||||
this.config = YamlConfiguration.loadConfiguration(file);
|
}
|
||||||
}
|
}
|
||||||
|
if (count > 0) {
|
||||||
/**
|
Bukkit.getLogger().info("[NexusLobby] Cleanup: " + count + " verwaiste Sprechblasen entfernt.");
|
||||||
* Ermittelt die Tageszeit für die YAML-Pfade.
|
}
|
||||||
*/
|
}
|
||||||
private String getDaytimeSuffix() {
|
|
||||||
if (Bukkit.getWorlds().isEmpty()) return "mittags";
|
public void setupFile() {
|
||||||
World world = Bukkit.getWorlds().get(0);
|
this.file = new File(plugin.getDataFolder(), "conversations.yml");
|
||||||
long time = world.getTime();
|
if (!file.exists()) {
|
||||||
|
plugin.saveResource("conversations.yml", false);
|
||||||
if (time >= 0 && time < 12000) return "morgens";
|
}
|
||||||
if (time >= 12000 && time < 13000) return "abends";
|
this.config = YamlConfiguration.loadConfiguration(file);
|
||||||
if (time >= 13000 && time < 23000) return "nacht";
|
}
|
||||||
return "mittags";
|
|
||||||
}
|
/**
|
||||||
|
* Ermittelt die Tageszeit für die YAML-Pfade.
|
||||||
/**
|
*/
|
||||||
* Pool-Logik für zufällige Dialog-Varianten oder zeitbasierte IDs.
|
private String getDaytimeSuffix() {
|
||||||
*/
|
if (Bukkit.getWorlds().isEmpty()) return "mittags";
|
||||||
private String resolveDialogKey(String key) {
|
World world = Bukkit.getWorlds().get(0);
|
||||||
ConfigurationSection section = config.getConfigurationSection("conversations");
|
long time = world.getTime();
|
||||||
if (section == null) return key;
|
|
||||||
|
if (time >= 0 && time < 12000) return "morgens";
|
||||||
String daytimeKey = key + "_" + getDaytimeSuffix();
|
if (time >= 12000 && time < 13000) return "abends";
|
||||||
if (section.contains(daytimeKey)) return daytimeKey;
|
if (time >= 13000 && time < 23000) return "nacht";
|
||||||
|
return "mittags";
|
||||||
List<String> pool = section.getKeys(false).stream()
|
}
|
||||||
.filter(s -> s.startsWith(key))
|
|
||||||
.collect(Collectors.toList());
|
/**
|
||||||
|
* Pool-Logik für zufällige Dialog-Varianten oder zeitbasierte IDs.
|
||||||
if (pool.isEmpty()) return key;
|
*/
|
||||||
|
private String resolveDialogKey(String key) {
|
||||||
return pool.get(new Random().nextInt(pool.size()));
|
ConfigurationSection section = config.getConfigurationSection("conversations");
|
||||||
}
|
if (section == null) return key;
|
||||||
|
|
||||||
/**
|
String daytimeKey = key + "_" + getDaytimeSuffix();
|
||||||
* Automatische Prüfung für NPCs in Spieler-Nähe (Unterstützt bis zu 4 Partner).
|
if (section.contains(daytimeKey)) return daytimeKey;
|
||||||
*/
|
|
||||||
public void startAllAutomatedConversations() {
|
List<String> pool = section.getKeys(false).stream()
|
||||||
ConfigurationSection links = config.getConfigurationSection("links");
|
.filter(s -> s.startsWith(key))
|
||||||
if (links == null) return;
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
for (String npc1String : links.getKeys(false)) {
|
if (pool.isEmpty()) return key;
|
||||||
try {
|
|
||||||
UUID id1 = UUID.fromString(npc1String);
|
return pool.get(new Random().nextInt(pool.size()));
|
||||||
if (activeSpeakers.contains(id1)) continue;
|
}
|
||||||
|
|
||||||
ConfigurationSection npcLink = links.getConfigurationSection(npc1String);
|
/**
|
||||||
if (npcLink == null) continue;
|
* Automatische Prüfung für NPCs in Spieler-Nähe (Unterstützt bis zu 4 Partner).
|
||||||
|
*/
|
||||||
String dialogId = npcLink.getString("dialog");
|
public void startAllAutomatedConversations() {
|
||||||
List<UUID> partners = new ArrayList<>();
|
ConfigurationSection links = config.getConfigurationSection("links");
|
||||||
partners.add(id1); // Der Starter ist immer Teilnehmer 0
|
if (links == null) return;
|
||||||
|
|
||||||
// Partner 1 bis 3 einsammeln (Max 4 Teilnehmer insgesamt)
|
for (String npc1String : links.getKeys(false)) {
|
||||||
if (npcLink.contains("partner")) partners.add(UUID.fromString(npcLink.getString("partner")));
|
try {
|
||||||
if (npcLink.contains("partner2")) partners.add(UUID.fromString(npcLink.getString("partner2")));
|
UUID id1 = UUID.fromString(npc1String);
|
||||||
if (npcLink.contains("partner3")) partners.add(UUID.fromString(npcLink.getString("partner3")));
|
if (activeSpeakers.contains(id1)) continue;
|
||||||
|
|
||||||
Entity starter = Bukkit.getEntity(id1);
|
ConfigurationSection npcLink = links.getConfigurationSection(npc1String);
|
||||||
if (starter instanceof ArmorStand as1) {
|
if (npcLink == null) continue;
|
||||||
if (as1.getNearbyEntities(15, 15, 15).stream().anyMatch(e -> e instanceof Player)) {
|
|
||||||
String finalDialogId = resolveDialogKey(dialogId);
|
String dialogId = npcLink.getString("dialog");
|
||||||
playConversationGroup(partners, finalDialogId);
|
List<UUID> partners = new ArrayList<>();
|
||||||
}
|
partners.add(id1); // Der Starter ist immer Teilnehmer 0
|
||||||
}
|
|
||||||
} catch (Exception ignored) {}
|
// 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")));
|
||||||
/**
|
|
||||||
* Neue Gruppen-Logik: Spielt Dialoge für 2, 3 oder 4 Teilnehmer ab.
|
Entity starter = Bukkit.getEntity(id1);
|
||||||
*/
|
if (starter instanceof ArmorStand as1) {
|
||||||
public void playConversationGroup(List<UUID> participants, String key) {
|
if (as1.getNearbyEntities(15, 15, 15).stream().anyMatch(e -> e instanceof Player)) {
|
||||||
String daytime = getDaytimeSuffix();
|
String finalDialogId = resolveDialogKey(dialogId);
|
||||||
|
playConversationGroup(partners, finalDialogId);
|
||||||
// Pfad-Ermittlung
|
}
|
||||||
String path = "conversations." + key + "." + daytime;
|
}
|
||||||
if (!config.contains(path + ".dialogue")) {
|
} catch (Exception ignored) {}
|
||||||
path = "conversations." + key + ".mittags";
|
}
|
||||||
}
|
}
|
||||||
if (!config.contains(path + ".dialogue")) {
|
|
||||||
path = "conversations." + key;
|
/**
|
||||||
}
|
* Neue Gruppen-Logik: Spielt Dialoge für 2, 3 oder 4 Teilnehmer ab.
|
||||||
|
*/
|
||||||
if (!config.contains(path + ".dialogue")) return;
|
public void playConversationGroup(List<UUID> participants, String key) {
|
||||||
|
String daytime = getDaytimeSuffix();
|
||||||
List<String> lines = config.getStringList(path + ".dialogue");
|
|
||||||
if (lines.isEmpty()) return;
|
// Pfad-Ermittlung
|
||||||
|
String path = "conversations." + key + "." + daytime;
|
||||||
// Alle Teilnehmer blockieren
|
if (!config.contains(path + ".dialogue")) {
|
||||||
for (UUID id : participants) activeSpeakers.add(id);
|
path = "conversations." + key + ".mittags";
|
||||||
|
}
|
||||||
new BukkitRunnable() {
|
if (!config.contains(path + ".dialogue")) {
|
||||||
int step = 0;
|
path = "conversations." + key;
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public void run() {
|
if (!config.contains(path + ".dialogue")) return;
|
||||||
if (step >= lines.size()) {
|
|
||||||
// 60 SEKUNDEN COOLDOWN
|
List<String> lines = config.getStringList(path + ".dialogue");
|
||||||
Bukkit.getScheduler().runTaskLater(plugin, () -> {
|
if (lines.isEmpty()) return;
|
||||||
for (UUID id : participants) activeSpeakers.remove(id);
|
|
||||||
}, 1200L);
|
// Alle Teilnehmer blockieren
|
||||||
|
for (UUID id : participants) activeSpeakers.add(id);
|
||||||
this.cancel();
|
|
||||||
return;
|
new BukkitRunnable() {
|
||||||
}
|
int step = 0;
|
||||||
|
|
||||||
// Rotations-Logik: Teilnehmer 0 -> 1 -> 2 -> 3 -> 0 ...
|
@Override
|
||||||
UUID speakerUUID = participants.get(step % participants.size());
|
public void run() {
|
||||||
Entity entity = Bukkit.getEntity(speakerUUID);
|
if (step >= lines.size()) {
|
||||||
|
// 60 SEKUNDEN COOLDOWN
|
||||||
if (entity instanceof ArmorStand as) {
|
Bukkit.getScheduler().runTaskLater(plugin, () -> {
|
||||||
playDynamicSound(as);
|
for (UUID id : participants) activeSpeakers.remove(id);
|
||||||
showBubble(as, lines.get(step));
|
}, 1200L);
|
||||||
} else {
|
|
||||||
for (UUID id : participants) activeSpeakers.remove(id);
|
this.cancel();
|
||||||
this.cancel();
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
step++;
|
// Rotations-Logik: Teilnehmer 0 -> 1 -> 2 -> 3 -> 0 ...
|
||||||
}
|
UUID speakerUUID = participants.get(step % participants.size());
|
||||||
}.runTaskTimer(plugin, 0L, 90L); // 4.5s Intervall
|
Entity entity = Bukkit.getEntity(speakerUUID);
|
||||||
}
|
|
||||||
|
if (entity instanceof ArmorStand as) {
|
||||||
/**
|
playDynamicSound(as);
|
||||||
* Spielt einen Sound ab, dessen Pitch (Tonhöhe) zum Namen des ArmorStands passt.
|
showBubble(as, lines.get(step));
|
||||||
*/
|
} else {
|
||||||
private void playDynamicSound(ArmorStand as) {
|
for (UUID id : participants) activeSpeakers.remove(id);
|
||||||
float pitch = 1.0f;
|
this.cancel();
|
||||||
String name = as.getCustomName() != null ? as.getCustomName() : "";
|
return;
|
||||||
|
}
|
||||||
if (name.contains("Timmy") || name.contains("Mia") || name.contains("Lotte")) {
|
step++;
|
||||||
pitch = 1.5f + (new Random().nextFloat() * 0.3f); // Hoch (Kind/Frau)
|
}
|
||||||
} else if (name.contains("Schmidt") || name.contains("Vater") || name.contains("Trainer")) {
|
}.runTaskTimer(plugin, 0L, 90L); // 4.5s Intervall
|
||||||
pitch = 0.6f + (new Random().nextFloat() * 0.2f); // Tief (Mann)
|
}
|
||||||
} else {
|
|
||||||
pitch = 0.9f + (new Random().nextFloat() * 0.4f); // Neutral
|
/**
|
||||||
}
|
* Spielt einen Sound ab, dessen Pitch (Tonhöhe) zum Namen des ArmorStands passt.
|
||||||
as.getWorld().playSound(as.getLocation(), Sound.ENTITY_VILLAGER_AMBIENT, 0.5f, pitch);
|
*/
|
||||||
}
|
private void playDynamicSound(ArmorStand as) {
|
||||||
|
float pitch = 1.0f;
|
||||||
/**
|
String name = as.getCustomName() != null ? as.getCustomName() : "";
|
||||||
* Erzeugt die Sprechblase und einen visuellen Effekt (Partikel).
|
|
||||||
*/
|
if (name.contains("Timmy") || name.contains("Mia") || name.contains("Lotte")) {
|
||||||
public void showBubble(ArmorStand as, String text) {
|
pitch = 1.5f + (new Random().nextFloat() * 0.3f); // Hoch (Kind/Frau)
|
||||||
Location loc = as.getEyeLocation().add(0, 0.8, 0);
|
} else if (name.contains("Schmidt") || name.contains("Vater") || name.contains("Trainer")) {
|
||||||
|
pitch = 0.6f + (new Random().nextFloat() * 0.2f); // Tief (Mann)
|
||||||
// Kleiner Partikel-Effekt ("Sprechwolke")
|
} else {
|
||||||
as.getWorld().spawnParticle(Particle.CLOUD, loc, 3, 0.1, 0.1, 0.1, 0.02);
|
pitch = 0.9f + (new Random().nextFloat() * 0.4f); // Neutral
|
||||||
|
}
|
||||||
ArmorStand bubble = as.getWorld().spawn(loc, ArmorStand.class, s -> {
|
as.getWorld().playSound(as.getLocation(), Sound.ENTITY_VILLAGER_AMBIENT, 0.5f, pitch);
|
||||||
s.setMarker(true);
|
}
|
||||||
s.setVisible(false);
|
|
||||||
s.setGravity(false);
|
/**
|
||||||
s.setCustomName(ChatColorTranslate(text));
|
* Erzeugt die Sprechblase und einen visuellen Effekt (Partikel).
|
||||||
s.setCustomNameVisible(true);
|
*/
|
||||||
s.setInvulnerable(true);
|
public void showBubble(ArmorStand as, String text) {
|
||||||
s.addScoreboardTag("nexus_bubble");
|
Location loc = as.getEyeLocation().add(0, 0.8, 0);
|
||||||
});
|
|
||||||
|
// Kleiner Partikel-Effekt ("Sprechwolke")
|
||||||
Bukkit.getScheduler().runTaskLater(plugin, bubble::remove, 80L); // 4s Sichtbarkeit
|
as.getWorld().spawnParticle(Particle.CLOUD, loc, 3, 0.1, 0.1, 0.1, 0.02);
|
||||||
}
|
|
||||||
|
ArmorStand bubble = as.getWorld().spawn(loc, ArmorStand.class, s -> {
|
||||||
// --- Legacy Support & Config Methoden ---
|
s.setMarker(true);
|
||||||
|
s.setVisible(false);
|
||||||
public void playConversation(UUID id1, UUID id2, String key) {
|
s.setGravity(false);
|
||||||
playConversationGroup(Arrays.asList(id1, id2), key);
|
s.setCustomName(ChatColorTranslate(text));
|
||||||
}
|
s.setCustomNameVisible(true);
|
||||||
|
s.setInvulnerable(true);
|
||||||
/**
|
s.setPersistent(false); // Überlebt keinen Server-Neustart/-Absturz
|
||||||
* Neue erweiterte Speicher-Methode für bis zu 4 Partner.
|
s.addScoreboardTag("nexus_bubble");
|
||||||
*/
|
});
|
||||||
public void saveLinkExtended(UUID id1, UUID id2, UUID id3, UUID id4, String dialogId) {
|
|
||||||
String path = "links." + id1.toString();
|
activeBubbles.add(bubble.getUniqueId());
|
||||||
config.set(path + ".dialog", dialogId);
|
Bukkit.getScheduler().runTaskLater(plugin, () -> {
|
||||||
config.set(path + ".partner", id2.toString());
|
bubble.remove();
|
||||||
if (id3 != null) config.set(path + ".partner2", id3.toString());
|
activeBubbles.remove(bubble.getUniqueId());
|
||||||
if (id4 != null) config.set(path + ".partner3", id4.toString());
|
}, 80L); // 4s Sichtbarkeit
|
||||||
saveConfig();
|
}
|
||||||
}
|
|
||||||
|
// --- Legacy Support & Config Methoden ---
|
||||||
public void saveLink(UUID id1, UUID id2, String dialogId) {
|
|
||||||
saveLinkExtended(id1, id2, null, null, dialogId);
|
public void playConversation(UUID id1, UUID id2, String key) {
|
||||||
}
|
playConversationGroup(Arrays.asList(id1, id2), key);
|
||||||
|
}
|
||||||
public void removeLink(UUID id) {
|
|
||||||
config.set("links." + id.toString(), null);
|
/**
|
||||||
saveConfig();
|
* Neue erweiterte Speicher-Methode für bis zu 4 Partner.
|
||||||
}
|
*/
|
||||||
|
public void saveLinkExtended(UUID id1, UUID id2, UUID id3, UUID id4, String dialogId) {
|
||||||
private String ChatColorTranslate(String text) {
|
String path = "links." + id1.toString();
|
||||||
if (text == null) return "";
|
config.set(path + ".dialog", dialogId);
|
||||||
return text.replace("&", "§");
|
config.set(path + ".partner", id2.toString());
|
||||||
}
|
if (id3 != null) config.set(path + ".partner2", id3.toString());
|
||||||
|
if (id4 != null) config.set(path + ".partner3", id4.toString());
|
||||||
private void saveConfig() {
|
saveConfig();
|
||||||
try {
|
}
|
||||||
config.save(file);
|
|
||||||
} catch (IOException e) {
|
public void saveLink(UUID id1, UUID id2, String dialogId) {
|
||||||
Bukkit.getLogger().severe("Fehler beim Speichern der Conversations: " + e.getMessage());
|
saveLinkExtended(id1, id2, null, null, dialogId);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
public void removeLink(UUID id) {
|
||||||
public void reload() {
|
config.set("links." + id.toString(), null);
|
||||||
setupFile();
|
saveConfig();
|
||||||
activeSpeakers.clear();
|
}
|
||||||
clearHangingBubbles();
|
|
||||||
}
|
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;
|
package de.nexuslobby.modules.armorstandtools;
|
||||||
|
|
||||||
import de.nexuslobby.NexusLobby;
|
import de.nexuslobby.NexusLobby;
|
||||||
import de.nexuslobby.api.Module;
|
import de.nexuslobby.api.Module;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.NamespacedKey;
|
import org.bukkit.NamespacedKey;
|
||||||
import org.bukkit.Particle;
|
import org.bukkit.Particle;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.ArmorStand;
|
import org.bukkit.entity.ArmorStand;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.persistence.PersistentDataType;
|
import org.bukkit.persistence.PersistentDataType;
|
||||||
import org.bukkit.util.EulerAngle;
|
import org.bukkit.util.EulerAngle;
|
||||||
|
|
||||||
public class DynamicArmorStandModule implements Module {
|
public class DynamicArmorStandModule implements Module {
|
||||||
|
|
||||||
private final NamespacedKey npcKey = new NamespacedKey(NexusLobby.getInstance(), "dynamic_npc");
|
private final NamespacedKey npcKey = new NamespacedKey(NexusLobby.getInstance(), "dynamic_npc");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "DynamicArmorStands";
|
return "DynamicArmorStands";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
startUpdateTask();
|
startUpdateTask();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startUpdateTask() {
|
private void startUpdateTask() {
|
||||||
// Alle 5 Ticks (0.25s) für flüssige Partikel
|
// Alle 5 Ticks (0.25s) für flüssige Partikel
|
||||||
Bukkit.getScheduler().runTaskTimer(NexusLobby.getInstance(), this::updateAllArmorStands, 20L, 5L);
|
Bukkit.getScheduler().runTaskTimer(NexusLobby.getInstance(), this::updateAllArmorStands, 20L, 5L);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateAllArmorStands() {
|
public void updateAllArmorStands() {
|
||||||
for (World world : Bukkit.getWorlds()) {
|
for (World world : Bukkit.getWorlds()) {
|
||||||
long time = world.getTime();
|
long time = world.getTime();
|
||||||
boolean isIngameNight = (time >= 13000 && time <= 23000);
|
boolean isIngameNight = (time >= 13000 && time <= 23000);
|
||||||
|
|
||||||
for (Entity entity : world.getEntities()) {
|
for (Entity entity : world.getEntities()) {
|
||||||
if (entity instanceof ArmorStand as) {
|
if (entity instanceof ArmorStand as) {
|
||||||
if (as.getPersistentDataContainer().has(npcKey, PersistentDataType.BYTE) ||
|
if (as.getPersistentDataContainer().has(npcKey, PersistentDataType.BYTE) ||
|
||||||
as.getScoreboardTags().contains("as_dynamic")) {
|
as.getScoreboardTags().contains("as_dynamic")) {
|
||||||
|
|
||||||
applyDynamicChanges(as, isIngameNight);
|
applyDynamicChanges(as, isIngameNight);
|
||||||
|
|
||||||
if (isIngameNight && as.getEquipment().getItemInOffHand().getType() == Material.TORCH) {
|
if (isIngameNight && as.getEquipment().getItemInOffHand().getType() == Material.TORCH) {
|
||||||
spawnStarParticles(as);
|
spawnStarParticles(as);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void applyDynamicChanges(ArmorStand as, boolean isNight) {
|
private void applyDynamicChanges(ArmorStand as, boolean isNight) {
|
||||||
if (!as.hasArms()) as.setArms(true);
|
if (!as.hasArms()) as.setArms(true);
|
||||||
|
|
||||||
// --- SPIELER-NÄHE ---
|
// --- SPIELER-NÄHE ---
|
||||||
boolean playerNearby = false;
|
boolean playerNearby = false;
|
||||||
for (Entity nearby : as.getNearbyEntities(2.0, 2.0, 2.0)) {
|
for (Entity nearby : as.getNearbyEntities(2.0, 2.0, 2.0)) {
|
||||||
if (nearby instanceof Player) { playerNearby = true; break; }
|
if (nearby instanceof Player) { playerNearby = true; break; }
|
||||||
}
|
}
|
||||||
|
|
||||||
if (playerNearby) {
|
if (playerNearby) {
|
||||||
if (as.getEquipment().getItemInMainHand().getType() != Material.STONE_SWORD) {
|
if (as.getEquipment().getItemInMainHand().getType() != Material.STONE_SWORD) {
|
||||||
as.getEquipment().setItemInMainHand(new ItemStack(Material.STONE_SWORD));
|
as.getEquipment().setItemInMainHand(new ItemStack(Material.STONE_SWORD));
|
||||||
as.setRightArmPose(new EulerAngle(Math.toRadians(-80), Math.toRadians(-10), 0));
|
as.setRightArmPose(new EulerAngle(Math.toRadians(-80), Math.toRadians(-10), 0));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (as.getEquipment().getItemInMainHand().getType() == Material.STONE_SWORD) {
|
if (as.getEquipment().getItemInMainHand().getType() == Material.STONE_SWORD) {
|
||||||
as.getEquipment().setItemInMainHand(null);
|
as.getEquipment().setItemInMainHand(null);
|
||||||
as.setRightArmPose(EulerAngle.ZERO);
|
as.setRightArmPose(EulerAngle.ZERO);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- INGAME-ZEIT ---
|
// --- INGAME-ZEIT ---
|
||||||
if (isNight) {
|
if (isNight) {
|
||||||
if (as.getEquipment().getItemInOffHand().getType() != Material.TORCH) {
|
if (as.getEquipment().getItemInOffHand().getType() != Material.TORCH) {
|
||||||
as.getEquipment().setItemInOffHand(new ItemStack(Material.TORCH));
|
as.getEquipment().setItemInOffHand(new ItemStack(Material.TORCH));
|
||||||
as.setLeftArmPose(new EulerAngle(Math.toRadians(-50), Math.toRadians(15), 0));
|
as.setLeftArmPose(new EulerAngle(Math.toRadians(-50), Math.toRadians(15), 0));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (as.getEquipment().getItemInOffHand().getType() == Material.TORCH) {
|
if (as.getEquipment().getItemInOffHand().getType() == Material.TORCH) {
|
||||||
as.getEquipment().setItemInOffHand(null);
|
as.getEquipment().setItemInOffHand(null);
|
||||||
as.setLeftArmPose(EulerAngle.ZERO);
|
as.setLeftArmPose(EulerAngle.ZERO);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void spawnStarParticles(ArmorStand as) {
|
private void spawnStarParticles(ArmorStand as) {
|
||||||
Location loc = as.getLocation();
|
Location loc = as.getLocation();
|
||||||
double yawRad = Math.toRadians(loc.getYaw());
|
double yawRad = Math.toRadians(loc.getYaw());
|
||||||
|
|
||||||
// Vektoren für Blickrichtung und Seite
|
// Vektoren für Blickrichtung und Seite
|
||||||
double dirX = -Math.sin(yawRad);
|
double dirX = -Math.sin(yawRad);
|
||||||
double dirZ = Math.cos(yawRad);
|
double dirZ = Math.cos(yawRad);
|
||||||
double sideX = Math.cos(yawRad);
|
double sideX = Math.cos(yawRad);
|
||||||
double sideZ = Math.sin(yawRad);
|
double sideZ = Math.sin(yawRad);
|
||||||
|
|
||||||
// Position: Vorne (0.4), Links (0.5), Oben (1.45)
|
// Position: Vorne (0.4), Links (0.5), Oben (1.45)
|
||||||
double finalX = loc.getX() + (dirX * 0.8) + (sideX * 0.2);
|
double finalX = loc.getX() + (dirX * 0.8) + (sideX * 0.2);
|
||||||
double finalY = loc.getY() + 1.45;
|
double finalY = loc.getY() + 1.45;
|
||||||
double finalZ = loc.getZ() + (dirZ * 0.8) + (sideZ * 0.2);
|
double finalZ = loc.getZ() + (dirZ * 0.8) + (sideZ * 0.2);
|
||||||
|
|
||||||
Location particleLoc = new Location(as.getWorld(), finalX, finalY, finalZ);
|
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);
|
as.getWorld().spawnParticle(Particle.WAX_OFF, particleLoc, 2, 0.05, 0.05, 0.05, 0.01);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void toggleDynamicStatus(ArmorStand as) {
|
public void toggleDynamicStatus(ArmorStand as) {
|
||||||
if (as.getPersistentDataContainer().has(npcKey, PersistentDataType.BYTE)) {
|
if (as.getPersistentDataContainer().has(npcKey, PersistentDataType.BYTE)) {
|
||||||
as.getPersistentDataContainer().remove(npcKey);
|
as.getPersistentDataContainer().remove(npcKey);
|
||||||
as.removeScoreboardTag("as_dynamic");
|
as.removeScoreboardTag("as_dynamic");
|
||||||
as.getEquipment().setItemInMainHand(null);
|
as.getEquipment().setItemInMainHand(null);
|
||||||
as.getEquipment().setItemInOffHand(null);
|
as.getEquipment().setItemInOffHand(null);
|
||||||
as.setRightArmPose(EulerAngle.ZERO);
|
as.setRightArmPose(EulerAngle.ZERO);
|
||||||
as.setLeftArmPose(EulerAngle.ZERO);
|
as.setLeftArmPose(EulerAngle.ZERO);
|
||||||
} else {
|
} else {
|
||||||
as.getPersistentDataContainer().set(npcKey, PersistentDataType.BYTE, (byte) 1);
|
as.getPersistentDataContainer().set(npcKey, PersistentDataType.BYTE, (byte) 1);
|
||||||
as.addScoreboardTag("as_dynamic");
|
as.addScoreboardTag("as_dynamic");
|
||||||
applyDynamicChanges(as, (as.getWorld().getTime() >= 13000 && as.getWorld().getTime() <= 23000));
|
applyDynamicChanges(as, (as.getWorld().getTime() >= 13000 && as.getWorld().getTime() <= 23000));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
// Bereinigung falls nötig
|
// Bereinigung falls nötig
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,86 +1,108 @@
|
|||||||
package de.nexuslobby.commands;
|
package de.nexuslobby.commands;
|
||||||
|
|
||||||
import de.nexuslobby.NexusLobby;
|
import de.nexuslobby.NexusLobby;
|
||||||
import de.nexuslobby.modules.portal.PortalCommand;
|
import de.nexuslobby.modules.portal.PortalCommand;
|
||||||
import de.nexuslobby.modules.border.BorderModule;
|
import de.nexuslobby.modules.border.BorderModule;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class BorderCommand implements CommandExecutor {
|
public class BorderCommand implements CommandExecutor {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||||
if (!(sender instanceof Player p)) return true;
|
if (!(sender instanceof Player p)) return true;
|
||||||
if (!p.hasPermission("nexuslobby.admin")) {
|
if (!p.hasPermission("nexuslobby.admin")) {
|
||||||
p.sendMessage("§8[§6Nexus§8] §cKeine Rechte.");
|
p.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§cKeine Rechte.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
p.sendMessage("§8§m------------------------------------");
|
p.sendMessage("§8§m------------------------------------");
|
||||||
p.sendMessage("§6§lNexus WorldBorder Setup");
|
p.sendMessage("§6§lNexus WorldBorder Setup");
|
||||||
p.sendMessage("§e/border circle <Radius> §7- Kreis um dich herum");
|
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 square §7- Nutzt Axt-Markierung (Viereck)");
|
||||||
p.sendMessage("§e/border disable §7- Grenze deaktivieren");
|
p.sendMessage("§e/border disable §7- Grenze deaktivieren");
|
||||||
p.sendMessage("§8§m------------------------------------");
|
p.sendMessage("§8§m------------------------------------");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var config = NexusLobby.getInstance().getConfig();
|
var config = NexusLobby.getInstance().getConfig();
|
||||||
|
|
||||||
switch (args[0].toLowerCase()) {
|
switch (args[0].toLowerCase()) {
|
||||||
case "circle" -> {
|
case "circle" -> {
|
||||||
if (args.length < 2) {
|
if (args.length < 2) {
|
||||||
p.sendMessage("§cBitte gib einen Radius an.");
|
p.sendMessage("§cBitte gib einen Radius an.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
double radius = Double.parseDouble(args[1]);
|
double radius = Double.parseDouble(args[1]);
|
||||||
config.set("worldborder.type", "CIRCLE");
|
Location loc = p.getLocation();
|
||||||
config.set("worldborder.center", p.getLocation());
|
|
||||||
config.set("worldborder.radius", radius);
|
config.set("worldborder.type", "CIRCLE");
|
||||||
config.set("worldborder.enabled", true);
|
config.set("worldborder.enabled", true);
|
||||||
p.sendMessage("§8[§6Nexus§8] §aKreis-Grenze (Radius: " + radius + ") gesetzt.");
|
config.set("worldborder.radius", radius);
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
p.sendMessage("§cUngültige Zahl.");
|
// FIX: Location als einzelne Werte speichern statt als Objekt.
|
||||||
return true;
|
// config.set(key, Location) ist nach Neustarts unzuverlässig,
|
||||||
}
|
// weil config.getLocation() die Welt zum Deserialisierungs-
|
||||||
}
|
// zeitpunkt auflösen muss und das fehlschlagen kann.
|
||||||
case "square" -> {
|
config.set("worldborder.center.world", loc.getWorld().getName());
|
||||||
Location l1 = PortalCommand.getSelection1(p);
|
config.set("worldborder.center.x", loc.getX());
|
||||||
Location l2 = PortalCommand.getSelection2(p);
|
config.set("worldborder.center.y", loc.getY());
|
||||||
if (l1 == null || l2 == null) {
|
config.set("worldborder.center.z", loc.getZ());
|
||||||
p.sendMessage("§8[§6Nexus§8] §cBitte markiere erst 2 Punkte mit der Portalwand!");
|
|
||||||
return true;
|
p.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§aKreis-Grenze (Radius: " + radius + ") gesetzt.");
|
||||||
}
|
} catch (NumberFormatException e) {
|
||||||
config.set("worldborder.type", "SQUARE");
|
p.sendMessage("§cUngültige Zahl.");
|
||||||
config.set("worldborder.pos1", l1);
|
return true;
|
||||||
config.set("worldborder.pos2", l2);
|
}
|
||||||
config.set("worldborder.enabled", true);
|
}
|
||||||
p.sendMessage("§8[§6Nexus§8] §aViereckige Grenze erfolgreich gesetzt.");
|
case "square" -> {
|
||||||
}
|
Location l1 = PortalCommand.getSelection1(p);
|
||||||
case "disable" -> {
|
Location l2 = PortalCommand.getSelection2(p);
|
||||||
config.set("worldborder.enabled", false);
|
if (l1 == null || l2 == null) {
|
||||||
p.sendMessage("§8[§6Nexus§8] §cGrenze wurde deaktiviert.");
|
p.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§cBitte markiere erst 2 Punkte mit der Portalwand!");
|
||||||
}
|
return true;
|
||||||
default -> {
|
}
|
||||||
p.sendMessage("§cUnbekannter Unterbefehl.");
|
|
||||||
return true;
|
config.set("worldborder.type", "SQUARE");
|
||||||
}
|
config.set("worldborder.enabled", true);
|
||||||
}
|
|
||||||
|
// FIX: Beide Positionen als einzelne Werte speichern
|
||||||
NexusLobby.getInstance().saveConfig();
|
config.set("worldborder.pos1.world", l1.getWorld().getName());
|
||||||
|
config.set("worldborder.pos1.x", l1.getX());
|
||||||
// Update das Modul direkt im RAM
|
config.set("worldborder.pos1.y", l1.getY());
|
||||||
BorderModule module = NexusLobby.getInstance().getModuleManager().getModule(BorderModule.class);
|
config.set("worldborder.pos1.z", l1.getZ());
|
||||||
if (module != null) {
|
|
||||||
module.reloadConfig();
|
config.set("worldborder.pos2.world", l2.getWorld().getName());
|
||||||
}
|
config.set("worldborder.pos2.x", l2.getX());
|
||||||
|
config.set("worldborder.pos2.y", l2.getY());
|
||||||
return true;
|
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;
|
package de.nexuslobby.modules.border;
|
||||||
|
|
||||||
import de.nexuslobby.NexusLobby;
|
import de.nexuslobby.NexusLobby;
|
||||||
import de.nexuslobby.api.Module;
|
import de.nexuslobby.api.Module;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.bukkit.event.player.PlayerMoveEvent;
|
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'.
|
* Verwaltet die Lobby-Begrenzung (Kreis oder Rechteck).
|
||||||
*/
|
* Speichert Daten in der Haupt-config.yml unter 'worldborder'.
|
||||||
public class BorderModule implements Module, Listener {
|
*
|
||||||
|
* FIX: Locations werden als einzelne Werte (worldName, x, y, z) gespeichert
|
||||||
private String type;
|
* statt als serialisiertes Location-Objekt, da config.getLocation()
|
||||||
private Location pos1, pos2, center;
|
* nach einem Neustart unzuverlässig ist.
|
||||||
private double radius;
|
*/
|
||||||
private boolean enabled;
|
public class BorderModule implements Module, Listener {
|
||||||
|
|
||||||
@Override
|
private String type;
|
||||||
public String getName() { return "WorldBorder"; }
|
// FIX: Statt Location-Objekte die rohen Werte cachen
|
||||||
|
private String pos1World, pos2World, centerWorld;
|
||||||
@Override
|
private double pos1X, pos1Y, pos1Z;
|
||||||
public void onEnable() {
|
private double pos2X, pos2Y, pos2Z;
|
||||||
reloadConfig();
|
private double centerX, centerZ;
|
||||||
Bukkit.getPluginManager().registerEvents(this, NexusLobby.getInstance());
|
private double radius;
|
||||||
}
|
private boolean enabled;
|
||||||
|
private boolean hasPos1, hasPos2, hasCenter;
|
||||||
@Override
|
|
||||||
public void onDisable() {
|
@Override
|
||||||
// Aufräumarbeiten falls nötig
|
public String getName() { return "WorldBorder"; }
|
||||||
}
|
|
||||||
|
@Override
|
||||||
/**
|
public void onEnable() {
|
||||||
* Lädt die Border-Einstellungen aus der config.yml.
|
reloadConfig();
|
||||||
* Wird auch von NexusLobby.reloadPlugin() aufgerufen.
|
Bukkit.getPluginManager().registerEvents(this, NexusLobby.getInstance());
|
||||||
*/
|
}
|
||||||
public void reloadConfig() {
|
|
||||||
FileConfiguration config = NexusLobby.getInstance().getConfig();
|
@Override
|
||||||
|
public void onDisable() {
|
||||||
// Pfad in der config.yml: worldborder.enabled etc.
|
// FIX: Listener beim Deaktivieren abmelden, damit nach /reload
|
||||||
this.enabled = config.getBoolean("worldborder.enabled", false);
|
// keine doppelten Events gefeuert werden.
|
||||||
this.type = config.getString("worldborder.type", "CIRCLE");
|
HandlerList.unregisterAll(this);
|
||||||
this.radius = config.getDouble("worldborder.radius", 50.0);
|
}
|
||||||
|
|
||||||
// Locations laden
|
/**
|
||||||
this.center = config.getLocation("worldborder.center");
|
* Lädt die Border-Einstellungen aus der config.yml.
|
||||||
this.pos1 = config.getLocation("worldborder.pos1");
|
* Wird auch von BorderCommand und NexusLobby.reloadPlugin() aufgerufen.
|
||||||
this.pos2 = config.getLocation("worldborder.pos2");
|
*
|
||||||
}
|
* FIX: Robuste Methode - liest world-Name und einzelne Koordinaten,
|
||||||
|
* kein config.getLocation() mehr (das nach Neustarts versagen kann).
|
||||||
@EventHandler
|
*/
|
||||||
public void onMove(PlayerMoveEvent event) {
|
public void reloadConfig() {
|
||||||
if (!enabled || event.getTo() == null) return;
|
FileConfiguration config = NexusLobby.getInstance().getConfig();
|
||||||
|
|
||||||
// Performance: Nur prüfen, wenn sich die Block-Koordinaten ändern
|
this.enabled = config.getBoolean("worldborder.enabled", false);
|
||||||
if (event.getFrom().getBlockX() == event.getTo().getBlockX() &&
|
this.type = config.getString("worldborder.type", "CIRCLE").toUpperCase();
|
||||||
event.getFrom().getBlockZ() == event.getTo().getBlockZ() &&
|
this.radius = config.getDouble("worldborder.radius", 50.0);
|
||||||
event.getFrom().getBlockY() == event.getTo().getBlockY()) return;
|
|
||||||
|
// --- CIRCLE-Daten laden ---
|
||||||
Player player = event.getPlayer();
|
this.hasCenter = config.contains("worldborder.center.world");
|
||||||
|
if (hasCenter) {
|
||||||
// Admins und Spectators ignorieren
|
this.centerWorld = config.getString("worldborder.center.world");
|
||||||
if (player.hasPermission("nexuslobby.admin") || player.getGameMode().name().equals("SPECTATOR")) return;
|
this.centerX = config.getDouble("worldborder.center.x");
|
||||||
|
this.centerZ = config.getDouble("worldborder.center.z");
|
||||||
Location to = event.getTo();
|
}
|
||||||
boolean outside = false;
|
|
||||||
|
// --- SQUARE-Daten laden ---
|
||||||
// --- Prüfung: Kreis-Border ---
|
this.hasPos1 = config.contains("worldborder.pos1.world");
|
||||||
if (type.equalsIgnoreCase("CIRCLE") && center != null) {
|
this.hasPos2 = config.contains("worldborder.pos2.world");
|
||||||
if (to.getWorld().equals(center.getWorld())) {
|
if (hasPos1) {
|
||||||
double distSq = Math.pow(to.getX() - center.getX(), 2) + Math.pow(to.getZ() - center.getZ(), 2);
|
this.pos1World = config.getString("worldborder.pos1.world");
|
||||||
if (distSq > Math.pow(radius, 2)) outside = true;
|
this.pos1X = config.getDouble("worldborder.pos1.x");
|
||||||
}
|
this.pos1Y = config.getDouble("worldborder.pos1.y");
|
||||||
}
|
this.pos1Z = config.getDouble("worldborder.pos1.z");
|
||||||
// --- Prüfung: Rechteck-Border (Square) ---
|
}
|
||||||
else if (type.equalsIgnoreCase("SQUARE") && pos1 != null && pos2 != null) {
|
if (hasPos2) {
|
||||||
if (to.getWorld().equals(pos1.getWorld())) {
|
this.pos2World = config.getString("worldborder.pos2.world");
|
||||||
double minX = Math.min(pos1.getX(), pos2.getX());
|
this.pos2X = config.getDouble("worldborder.pos2.x");
|
||||||
double maxX = Math.max(pos1.getX(), pos2.getX());
|
this.pos2Y = config.getDouble("worldborder.pos2.y");
|
||||||
double minZ = Math.min(pos1.getZ(), pos2.getZ());
|
this.pos2Z = config.getDouble("worldborder.pos2.z");
|
||||||
double maxZ = Math.max(pos1.getZ(), pos2.getZ());
|
}
|
||||||
|
}
|
||||||
if (to.getX() < minX || to.getX() > maxX || to.getZ() < minZ || to.getZ() > maxZ) {
|
|
||||||
outside = true;
|
@EventHandler
|
||||||
}
|
public void onMove(PlayerMoveEvent event) {
|
||||||
}
|
if (!enabled || event.getTo() == null) return;
|
||||||
}
|
|
||||||
|
// Performance: Nur prüfen wenn sich Block-Koordinaten ändern
|
||||||
// --- Aktion wenn außerhalb ---
|
if (event.getFrom().getBlockX() == event.getTo().getBlockX() &&
|
||||||
if (outside) {
|
event.getFrom().getBlockZ() == event.getTo().getBlockZ() &&
|
||||||
Location spawnLocation = getMainSpawnLocation();
|
event.getFrom().getBlockY() == event.getTo().getBlockY()) return;
|
||||||
|
|
||||||
if (spawnLocation != null) {
|
Player player = event.getPlayer();
|
||||||
// Sofortiger Teleport zum definierten Spawn
|
|
||||||
player.teleport(spawnLocation);
|
// FIX: nexuslobby.border.bypass statt nur nexuslobby.admin prüfen
|
||||||
|
if (player.hasPermission("nexuslobby.border.bypass") ||
|
||||||
// Feedback an den Spieler
|
player.hasPermission("nexuslobby.admin") ||
|
||||||
player.playSound(player.getLocation(), Sound.ENTITY_ENDERMAN_TELEPORT, 1.0f, 0.5f);
|
player.getGameMode().name().equals("SPECTATOR")) return;
|
||||||
player.sendMessage("§8[§6Nexus§8] §cDu hast den Lobby-Bereich verlassen!");
|
|
||||||
}
|
Location to = event.getTo();
|
||||||
}
|
boolean outside = false;
|
||||||
}
|
|
||||||
|
// --- Prüfung: Kreis-Border ---
|
||||||
/**
|
if (type.equals("CIRCLE") && hasCenter) {
|
||||||
* Holt den zentralen Spawnpunkt aus der Config (Pfad: spawn.world, spawn.x, etc.)
|
World cWorld = Bukkit.getWorld(centerWorld);
|
||||||
*/
|
if (cWorld != null && to.getWorld().equals(cWorld)) {
|
||||||
private Location getMainSpawnLocation() {
|
double distSq = Math.pow(to.getX() - centerX, 2) + Math.pow(to.getZ() - centerZ, 2);
|
||||||
FileConfiguration config = NexusLobby.getInstance().getConfig();
|
if (distSq > radius * radius) outside = true;
|
||||||
String worldName = config.getString("spawn.world");
|
}
|
||||||
|
}
|
||||||
if (worldName != null) {
|
// --- Prüfung: Rechteck-Border (Square) ---
|
||||||
World w = Bukkit.getWorld(worldName);
|
else if (type.equals("SQUARE") && hasPos1 && hasPos2) {
|
||||||
if (w != null) {
|
World bWorld = Bukkit.getWorld(pos1World);
|
||||||
return new Location(w,
|
if (bWorld != null && to.getWorld().equals(bWorld)) {
|
||||||
config.getDouble("spawn.x"),
|
double minX = Math.min(pos1X, pos2X);
|
||||||
config.getDouble("spawn.y"),
|
double maxX = Math.max(pos1X, pos2X);
|
||||||
config.getDouble("spawn.z"),
|
double minZ = Math.min(pos1Z, pos2Z);
|
||||||
(float) config.getDouble("spawn.yaw"),
|
double maxZ = Math.max(pos1Z, pos2Z);
|
||||||
(float) config.getDouble("spawn.pitch"));
|
if (to.getX() < minX || to.getX() > maxX ||
|
||||||
}
|
to.getZ() < minZ || to.getZ() > maxZ) {
|
||||||
}
|
outside = true;
|
||||||
// Fallback falls kein Spawn gesetzt ist
|
}
|
||||||
return Bukkit.getWorlds().isEmpty() ? null : Bukkit.getWorlds().get(0).getSpawnLocation();
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
package de.nexuslobby.modules.gadgets;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.ArmorStand;
|
import org.bukkit.entity.ArmorStand;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class Balloon {
|
public class Balloon {
|
||||||
|
private final UUID playerUUID;
|
||||||
|
private final LivingEntity balloonEntity;
|
||||||
|
private final ArmorStand headStand;
|
||||||
|
|
||||||
private final UUID playerUUID;
|
public Balloon(Player player, Material balloonMaterial) {
|
||||||
private final LivingEntity balloonEntity;
|
this.playerUUID = player.getUniqueId();
|
||||||
private final ArmorStand headStand;
|
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) {
|
public void update() {
|
||||||
this.playerUUID = player.getUniqueId();
|
Player player = Bukkit.getPlayer(this.playerUUID);
|
||||||
Location loc = player.getLocation().add(0, 2, 0);
|
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.headStand.teleport(this.balloonEntity.getLocation().clone().subtract((double)0.0F, (double)1.5F, (double)0.0F));
|
||||||
this.balloonEntity = (LivingEntity) loc.getWorld().spawnEntity(loc, EntityType.PIG);
|
}
|
||||||
this.balloonEntity.setInvisible(true);
|
} else {
|
||||||
this.balloonEntity.setSilent(true);
|
this.remove();
|
||||||
this.balloonEntity.setInvulnerable(true);
|
}
|
||||||
this.balloonEntity.setGravity(false);
|
}
|
||||||
this.balloonEntity.setLeashHolder(player);
|
|
||||||
|
|
||||||
// Der ArmorStand, der den farbigen Block trägt
|
public void remove() {
|
||||||
this.headStand = (ArmorStand) loc.getWorld().spawnEntity(loc, EntityType.ARMOR_STAND);
|
if (this.balloonEntity != null) {
|
||||||
this.headStand.setVisible(false);
|
this.balloonEntity.setLeashHolder((Entity)null);
|
||||||
this.headStand.setGravity(false);
|
this.balloonEntity.remove();
|
||||||
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 update() {
|
if (this.headStand != null) {
|
||||||
Player player = org.bukkit.Bukkit.getPlayer(playerUUID);
|
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;
|
package de.nexuslobby.modules.gadgets;
|
||||||
|
|
||||||
import de.nexuslobby.NexusLobby;
|
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.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Particle;
|
import org.bukkit.Particle;
|
||||||
@@ -10,45 +15,40 @@ import org.bukkit.entity.EntityType;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
public class ChickenRain {
|
public class ChickenRain {
|
||||||
|
private static final Set<UUID> activeRains = Collections.synchronizedSet(new HashSet());
|
||||||
|
|
||||||
public static void start(Player player) {
|
public static void start(final Player player) {
|
||||||
new BukkitRunnable() {
|
if (!activeRains.contains(player.getUniqueId())) {
|
||||||
|
activeRains.add(player.getUniqueId());
|
||||||
|
(new BukkitRunnable() {
|
||||||
int ticks = 0;
|
int ticks = 0;
|
||||||
final Random random = new Random();
|
final Random random = new Random();
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
public void run() {
|
||||||
if (!player.isOnline() || ticks > 100) { // 100 Ticks = 5 Sekunden
|
if (player.isOnline() && this.ticks <= 100) {
|
||||||
this.cancel();
|
if (this.ticks % 2 == 0) {
|
||||||
return;
|
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();
|
||||||
// Alle 2 Ticks ein Huhn spawnen
|
chicken.setInvulnerable(true);
|
||||||
if (ticks % 2 == 0) {
|
Bukkit.getScheduler().runTaskLater(NexusLobby.getInstance(), () -> {
|
||||||
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 (chicken.isValid()) {
|
if (chicken.isValid()) {
|
||||||
chicken.getWorld().spawnParticle(Particle.CLOUD, chicken.getLocation(), 5, 0.2, 0.2, 0.2, 0.1);
|
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.getWorld().playSound(chicken.getLocation(), Sound.ENTITY_CHICKEN_EGG, 1.0F, 1.5F);
|
||||||
chicken.remove();
|
chicken.remove();
|
||||||
}
|
}
|
||||||
}, 30L);
|
|
||||||
}
|
}, 30L);
|
||||||
ticks++;
|
}
|
||||||
|
|
||||||
|
++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;
|
package de.nexuslobby.modules.gadgets;
|
||||||
|
|
||||||
import de.nexuslobby.NexusLobby;
|
import de.nexuslobby.NexusLobby;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Particle;
|
import org.bukkit.Particle;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class FreezeRay {
|
public class FreezeRay {
|
||||||
// Auf public gesetzt, damit das GadgetModule im PlayerMoveEvent darauf prüfen kann
|
private static final Set<UUID> frozenPlayers = new HashSet();
|
||||||
public static final Set<UUID> frozenPlayers = new HashSet<>();
|
|
||||||
|
|
||||||
public static void shoot(Player shooter) {
|
public static boolean isFrozen(UUID uuid) {
|
||||||
Location start = shooter.getEyeLocation();
|
return frozenPlayers.contains(uuid);
|
||||||
Vector direction = start.getDirection();
|
}
|
||||||
|
|
||||||
// Sound beim Schießen
|
public static void unfreeze(UUID uuid) {
|
||||||
shooter.getWorld().playSound(start, Sound.ENTITY_SNOW_GOLEM_SHOOT, 1.0f, 1.5f);
|
frozenPlayers.remove(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
// Wir prüfen in 0.3er Schritten bis zu 15 Blöcke weit
|
public static void shoot(Player shooter) {
|
||||||
for (double d = 0; d < 15; d += 0.3) {
|
Location start = shooter.getEyeLocation();
|
||||||
Location point = start.clone().add(direction.clone().multiply(d));
|
Vector direction = start.getDirection();
|
||||||
|
shooter.getWorld().playSound(start, Sound.ENTITY_SNOW_GOLEM_SHOOT, 1.0F, 1.5F);
|
||||||
// Partikel-Strahl sichtbar machen
|
|
||||||
point.getWorld().spawnParticle(Particle.SNOWFLAKE, point, 1, 0, 0, 0, 0);
|
|
||||||
|
|
||||||
// Prüfung auf Spieler im Umkreis von 0.8 Blöcken (etwas großzügiger)
|
for(double d = (double)0.0F; d < (double)15.0F; d += 0.3) {
|
||||||
for (Entity entity : point.getWorld().getNearbyEntities(point, 0.8, 0.8, 0.8)) {
|
Location point = start.clone().add(direction.clone().multiply(d));
|
||||||
if (entity instanceof Player target && target != shooter) {
|
point.getWorld().spawnParticle(Particle.SNOWFLAKE, point, 1, (double)0.0F, (double)0.0F, (double)0.0F, (double)0.0F);
|
||||||
applyFreeze(target);
|
|
||||||
return; // Stoppt den Strahl beim ersten Treffer
|
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 (point.getBlock().getType().isSolid()) {
|
||||||
if (frozenPlayers.contains(target.getUniqueId())) return;
|
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;
|
int ticks = 0;
|
||||||
@Override
|
|
||||||
public void run() {
|
public void run() {
|
||||||
// Sicherheitscheck: Ist der Spieler noch online?
|
if (target.isOnline() && this.ticks < 60) {
|
||||||
if (!target.isOnline() || ticks >= 60) {
|
if (GadgetShield.isProtected(target)) {
|
||||||
frozenPlayers.remove(target.getUniqueId());
|
FreezeRay.frozenPlayers.remove(target.getUniqueId());
|
||||||
this.cancel();
|
this.cancel();
|
||||||
return;
|
} else {
|
||||||
}
|
target.setVelocity(new Vector(0, 0, 0));
|
||||||
|
Location current = target.getLocation();
|
||||||
// Stasis-Effekt: Bewegung auf 0 setzen und Position fixieren
|
if (current.getX() != freezeLocation.getX() || current.getZ() != freezeLocation.getZ()) {
|
||||||
target.setVelocity(new Vector(0, 0, 0));
|
freezeLocation.setYaw(current.getYaw());
|
||||||
|
freezeLocation.setPitch(current.getPitch());
|
||||||
// Alle 2 Ticks zurückteleportieren, falls er versucht zu laufen
|
target.teleport(freezeLocation);
|
||||||
// (Behält die Blickrichtung des Spielers bei)
|
}
|
||||||
Location current = target.getLocation();
|
|
||||||
if (current.getX() != freezeLocation.getX() || current.getZ() != freezeLocation.getZ()) {
|
Location loc = target.getLocation();
|
||||||
freezeLocation.setYaw(current.getYaw());
|
|
||||||
freezeLocation.setPitch(current.getPitch());
|
for(int i = 0; i < 8; ++i) {
|
||||||
target.teleport(freezeLocation);
|
double angle = (double)i * Math.PI / (double)4.0F;
|
||||||
}
|
double x = Math.cos(angle) * 0.7;
|
||||||
|
double z = Math.sin(angle) * 0.7;
|
||||||
// Optischer Käfig (Ring-Effekt)
|
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);
|
||||||
Location loc = target.getLocation();
|
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);
|
||||||
for (int i = 0; i < 8; i++) {
|
}
|
||||||
double angle = i * Math.PI / 4;
|
|
||||||
double x = Math.cos(angle) * 0.7;
|
this.ticks += 2;
|
||||||
double z = Math.sin(angle) * 0.7;
|
}
|
||||||
loc.getWorld().spawnParticle(Particle.SNOWFLAKE, loc.clone().add(x, 1, z), 1, 0, 0, 0, 0);
|
} else {
|
||||||
loc.getWorld().spawnParticle(Particle.SNOWFLAKE, loc.clone().add(x, 0.2, z), 1, 0, 0, 0, 0);
|
FreezeRay.frozenPlayers.remove(target.getUniqueId());
|
||||||
}
|
this.cancel();
|
||||||
|
}
|
||||||
ticks += 2;
|
|
||||||
}
|
}
|
||||||
}.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;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
public class GrapplingHook {
|
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) {
|
player.setVelocity(v);
|
||||||
Location playerLoc = player.getLocation();
|
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);
|
||||||
// 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -6,21 +6,19 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
public class HatManager {
|
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) {
|
player.getInventory().setHelmet(hat);
|
||||||
ItemStack hat = new ItemStack(material);
|
player.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§aDu trägst nun: " + name);
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void removeHat(Player player) {
|
public static void removeHat(Player player) {
|
||||||
player.getInventory().setHelmet(null);
|
player.getInventory().setHelmet((ItemStack)null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package de.nexuslobby.modules.gadgets;
|
package de.nexuslobby.modules.gadgets;
|
||||||
|
|
||||||
import de.nexuslobby.NexusLobby;
|
import de.nexuslobby.NexusLobby;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Particle;
|
import org.bukkit.Particle;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
@@ -9,39 +10,45 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
public class MeteorStrike {
|
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) {
|
for(double d = (double)0.0F; d < (double)30.0F; d += (double)0.5F) {
|
||||||
Location target = null;
|
Location point = start.clone().add(direction.clone().multiply(d));
|
||||||
Location start = shooter.getEyeLocation();
|
if (point.getBlock().getType().isSolid()) {
|
||||||
Vector direction = start.getDirection();
|
target = point;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (double d = 0; d < 30; d += 0.5) {
|
if (target != null) {
|
||||||
Location point = start.clone().add(direction.clone().multiply(d));
|
Location finalTarget = target.clone().add((double)0.0F, (double)0.5F, (double)0.0F);
|
||||||
if (point.getBlock().getType().isSolid()) {
|
finalTarget.getWorld().spawnParticle(Particle.FLAME, finalTarget, 20, (double)0.5F, 0.1, (double)0.5F, 0.05);
|
||||||
target = point;
|
shooter.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§cMeteorit im Anflug...");
|
||||||
break;
|
Bukkit.getScheduler().runTaskLater(NexusLobby.getInstance(), () -> {
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
|
||||||
finalTarget.getWorld().spawnParticle(Particle.EXPLOSION_EMITTER, finalTarget, 1);
|
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().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);
|
finalTarget.getWorld().playSound(finalTarget, Sound.ENTITY_GENERIC_EXPLODE, 1.0F, 0.8F);
|
||||||
|
|
||||||
for (Entity entity : finalTarget.getWorld().getNearbyEntities(finalTarget, 4, 4, 4)) {
|
for(Entity entity : finalTarget.getWorld().getNearbyEntities(finalTarget, (double)4.0F, (double)4.0F, (double)4.0F)) {
|
||||||
if (entity instanceof Player p) {
|
if (entity instanceof Player p) {
|
||||||
Vector v = p.getLocation().toVector().subtract(finalTarget.toVector()).normalize().multiply(1.5).setY(0.5);
|
if (GadgetShield.isProtected(p)) {
|
||||||
p.setVelocity(v);
|
if (GadgetShield.isAdminShielded(p)) {
|
||||||
p.sendMessage("§cBUMM!");
|
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;
|
package de.nexuslobby.modules.gadgets;
|
||||||
|
|
||||||
import de.nexuslobby.NexusLobby;
|
import de.nexuslobby.NexusLobby;
|
||||||
|
import java.util.Random;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@@ -10,80 +11,65 @@ import org.bukkit.block.Block;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
public class PaintballGun {
|
public class PaintballGun {
|
||||||
private static final Random random = new Random();
|
private static final Random random = new Random();
|
||||||
|
private static final Material[] COLORS;
|
||||||
// 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
|
|
||||||
};
|
|
||||||
|
|
||||||
public static void shoot(Player shooter) {
|
public static void shoot(Player shooter) {
|
||||||
Location start = shooter.getEyeLocation();
|
Location start = shooter.getEyeLocation();
|
||||||
Vector direction = start.getDirection();
|
Vector direction = start.getDirection();
|
||||||
Material randomColor = COLORS[random.nextInt(COLORS.length)];
|
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();
|
private static void impact(Block centerBlock, Material color) {
|
||||||
if (block.getType().isSolid()) {
|
Location centerLoc = centerBlock.getLocation();
|
||||||
impact(block, randomColor);
|
centerLoc.getWorld().playSound(centerLoc, Sound.ENTITY_SLIME_SQUISH, 1.0F, 1.2F);
|
||||||
break;
|
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
|
private static void applyColor(Block block, Material color) {
|
||||||
for (int x = -radius; x <= radius; x++) {
|
Location loc = block.getLocation();
|
||||||
for (int y = -radius; y <= radius; y++) {
|
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());
|
||||||
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) {
|
for(Player online : Bukkit.getOnlinePlayers()) {
|
||||||
Location loc = block.getLocation();
|
online.sendBlockChange(loc, color.createBlockData());
|
||||||
|
}
|
||||||
// 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());
|
|
||||||
|
|
||||||
// Block-Änderung an alle senden
|
Bukkit.getScheduler().runTaskLater(NexusLobby.getInstance(), () -> {
|
||||||
for (Player online : Bukkit.getOnlinePlayers()) {
|
for(Player online : Bukkit.getOnlinePlayers()) {
|
||||||
online.sendBlockChange(loc, color.createBlockData());
|
online.sendBlockChange(loc, block.getBlockData());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Nach 10 Sekunden zurücksetzen
|
}, 400L);
|
||||||
Bukkit.getScheduler().runTaskLater(NexusLobby.getInstance(), () -> {
|
}
|
||||||
for (Player online : Bukkit.getOnlinePlayers()) {
|
|
||||||
online.sendBlockChange(loc, block.getBlockData());
|
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};
|
||||||
}, 400L);
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|||||||
@@ -5,27 +5,29 @@ import org.bukkit.Particle;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class ParticleEffect {
|
public class ParticleEffect {
|
||||||
private final String type;
|
private final String type;
|
||||||
private double angle = 0;
|
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) {
|
public void update(Player player) {
|
||||||
Location loc = player.getLocation();
|
Location loc = player.getLocation();
|
||||||
switch (type.toLowerCase()) {
|
switch (this.type.toLowerCase()) {
|
||||||
case "hearts":
|
case "hearts":
|
||||||
player.getWorld().spawnParticle(Particle.HEART, loc.clone().add(0, 2.2, 0), 1, 0.3, 0.3, 0.3, 0);
|
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;
|
break;
|
||||||
case "flames":
|
case "flames":
|
||||||
double x = 0.6 * Math.cos(angle);
|
double x = 0.6 * Math.cos(this.angle);
|
||||||
double z = 0.6 * Math.sin(angle);
|
double z = 0.6 * Math.sin(this.angle);
|
||||||
player.getWorld().spawnParticle(Particle.FLAME, loc.clone().add(x, 0.1, z), 1, 0, 0, 0, 0);
|
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);
|
||||||
angle += 0.2;
|
this.angle += 0.2;
|
||||||
break;
|
break;
|
||||||
case "cloud":
|
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.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(0, 2.4, 0), 1, 0.1, 0, 0.1, 0);
|
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);
|
||||||
break;
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,138 +1,234 @@
|
|||||||
package de.nexuslobby.modules.gadgets;
|
package de.nexuslobby.modules.gadgets;
|
||||||
|
|
||||||
import de.nexuslobby.NexusLobby;
|
import de.nexuslobby.NexusLobby;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
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.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
|
import org.bukkit.entity.Fox;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.Tameable;
|
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.EventHandler;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent;
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
import org.bukkit.event.entity.EntityTargetEvent;
|
import org.bukkit.event.entity.EntityTargetEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
import org.bukkit.scoreboard.Scoreboard;
|
||||||
import java.util.HashMap;
|
import org.bukkit.scoreboard.Team;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class PetManager implements Listener {
|
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() {
|
public static void register() {
|
||||||
Bukkit.getPluginManager().registerEvents(this, NexusLobby.getInstance());
|
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;
|
public static void unregister() {
|
||||||
try {
|
if (instance != null) {
|
||||||
entityType = EntityType.valueOf(type);
|
HandlerList.unregisterAll(instance);
|
||||||
} catch (IllegalArgumentException e) {
|
instance = null;
|
||||||
player.sendMessage("§cFehler: Tier-Typ nicht gefunden.");
|
}
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Location loc = player.getLocation();
|
}
|
||||||
Entity pet = player.getWorld().spawnEntity(loc, entityType);
|
|
||||||
|
|
||||||
pet.setCustomName("§d" + player.getName() + "'s " + capitalize(type.toLowerCase()));
|
public static void spawnEntityPet(Player player, String type) {
|
||||||
pet.setCustomNameVisible(true);
|
spawnEntityPet(player, type, false);
|
||||||
pet.setInvulnerable(true);
|
}
|
||||||
pet.setPersistent(false);
|
|
||||||
|
|
||||||
if (pet instanceof LivingEntity) {
|
public static void spawnEntityPet(Player player, String type, boolean baby) {
|
||||||
LivingEntity le = (LivingEntity) pet;
|
spawnEntityPet(player, type, baby, (String)null);
|
||||||
le.setRemoveWhenFarAway(false);
|
}
|
||||||
|
|
||||||
// Verhindert, dass das Pet andere angreift
|
public static void spawnEntityPet(Player player, String type, boolean baby, String variantName) {
|
||||||
if (le instanceof Tameable) {
|
removePet(player);
|
||||||
((Tameable) le).setTamed(true);
|
|
||||||
((Tameable) le).setOwner(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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
if (le instanceof Fox && variantName != null && !variantName.isEmpty()) {
|
||||||
* Steuert das Folgen der Tiere. Wird vom GadgetModule-Timer aufgerufen.
|
try {
|
||||||
*/
|
((Fox)le).setFoxType(Type.valueOf(variantName));
|
||||||
public static void updatePets() {
|
} catch (IllegalArgumentException var11) {
|
||||||
for (Map.Entry<UUID, Entity> entry : activePets.entrySet()) {
|
}
|
||||||
Player owner = Bukkit.getPlayer(entry.getKey());
|
}
|
||||||
Entity pet = entry.getValue();
|
|
||||||
|
|
||||||
if (owner == null || !owner.isOnline() || pet.isDead()) {
|
if (le instanceof Tameable) {
|
||||||
continue;
|
((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
|
@EventHandler
|
||||||
if (pet.getLocation().distance(owner.getLocation()) > 3) {
|
public void onPetDamage(EntityDamageEvent event) {
|
||||||
Location target = owner.getLocation().clone().add(owner.getLocation().getDirection().multiply(-1.5));
|
if (activePets.containsValue(event.getEntity())) {
|
||||||
target.setY(owner.getLocation().getY());
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
// 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void removePet(Player player) {
|
}
|
||||||
if (activePets.containsKey(player.getUniqueId())) {
|
|
||||||
activePets.get(player.getUniqueId()).remove();
|
|
||||||
activePets.remove(player.getUniqueId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void clearAll() {
|
@EventHandler
|
||||||
for (Entity pet : activePets.values()) {
|
public void onPetTarget(EntityTargetEvent event) {
|
||||||
pet.remove();
|
if (activePets.containsValue(event.getEntity())) {
|
||||||
}
|
event.setCancelled(true);
|
||||||
activePets.clear();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
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 onQuit(PlayerQuitEvent event) {
|
||||||
@EventHandler
|
removePet(event.getPlayer());
|
||||||
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());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
package de.nexuslobby.modules.gadgets;
|
package de.nexuslobby.modules.gadgets;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
import org.bukkit.Particle;
|
import org.bukkit.Particle;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
@@ -7,26 +10,32 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
public class ShieldTask {
|
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) {
|
public static void handleShield(Player owner) {
|
||||||
// Erzeuge einen Partikel-Ring um den Spieler
|
for(double i = (double)0.0F; i < (Math.PI * 2D); i += (Math.PI / 8D)) {
|
||||||
for (double i = 0; i < Math.PI * 2; i += Math.PI / 8) {
|
double x = Math.cos(i) * 2.2;
|
||||||
double x = Math.cos(i) * 2.2;
|
double z = Math.sin(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);
|
||||||
owner.getWorld().spawnParticle(Particle.WITCH, owner.getLocation().add(x, 0.5, z), 1, 0, 0, 0, 0);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Stoße andere Spieler weg
|
long now = System.currentTimeMillis();
|
||||||
for (Entity entity : owner.getNearbyEntities(2.2, 2.0, 2.2)) {
|
|
||||||
if (entity instanceof Player && entity != owner) {
|
for(Entity entity : owner.getNearbyEntities(2.2, (double)2.0F, 2.2)) {
|
||||||
Player target = (Player) entity;
|
if (entity instanceof Player target) {
|
||||||
|
if (entity != owner && !GadgetShield.isProtected(target)) {
|
||||||
Vector direction = target.getLocation().toVector().subtract(owner.getLocation().toVector()).normalize();
|
long lastPush = (Long)pushCooldowns.getOrDefault(target.getUniqueId(), 0L);
|
||||||
direction.multiply(0.4).setY(0.2);
|
if (now - lastPush >= 3000L) {
|
||||||
|
pushCooldowns.put(target.getUniqueId(), now);
|
||||||
target.setVelocity(direction);
|
Vector direction = target.getLocation().toVector().subtract(owner.getLocation().toVector()).normalize();
|
||||||
target.playSound(target.getLocation(), Sound.ENTITY_CHICKEN_EGG, 0.5f, 0.5f);
|
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;
|
package de.nexuslobby.commands;
|
||||||
|
|
||||||
import de.nexuslobby.modules.hologram.HologramModule;
|
import de.nexuslobby.modules.hologram.HologramModule;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class HoloCommand implements CommandExecutor {
|
public class HoloCommand implements CommandExecutor {
|
||||||
|
|
||||||
private final HologramModule module;
|
private final HologramModule module;
|
||||||
|
|
||||||
public HoloCommand(HologramModule module) {
|
public HoloCommand(HologramModule module) {
|
||||||
this.module = module;
|
this.module = module;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
if (!(sender instanceof Player player)) return true;
|
if (!(sender instanceof Player player)) return true;
|
||||||
|
|
||||||
if (!player.hasPermission("nexuslobby.hologram")) {
|
if (!player.hasPermission("nexuslobby.hologram")) {
|
||||||
player.sendMessage("§8[§6Nexus§8] §cKeine Rechte.");
|
player.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§cKeine Rechte.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.length < 1) {
|
if (args.length < 1) {
|
||||||
sendHelp(player);
|
sendHelp(player);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args[0].equalsIgnoreCase("create")) {
|
if (args[0].equalsIgnoreCase("create")) {
|
||||||
// Wir brauchen id, typ und mindestens ein Wort Text
|
// Wir brauchen id, typ und mindestens ein Wort Text
|
||||||
if (args.length < 4) {
|
if (args.length < 4) {
|
||||||
player.sendMessage("§cNutze: /holo create <id> <NONE|FAST|SLOW> <text>");
|
player.sendMessage("§cNutze: /holo create <id> <NONE|FAST|SLOW> <text>");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
String id = args[1];
|
String id = args[1];
|
||||||
// Der Typ (args[2]) wird im neuen System ignoriert, da wir Seiten nutzen
|
// Der Typ (args[2]) wird im neuen System ignoriert, da wir Seiten nutzen
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
for (int i = 3; i < args.length; i++) {
|
for (int i = 3; i < args.length; i++) {
|
||||||
sb.append(args[i]).append(i == args.length - 1 ? "" : " ");
|
sb.append(args[i]).append(i == args.length - 1 ? "" : " ");
|
||||||
}
|
}
|
||||||
|
|
||||||
String fullText = sb.toString().trim();
|
String fullText = sb.toString().trim();
|
||||||
List<String> pages = new ArrayList<>();
|
List<String> pages = new ArrayList<>();
|
||||||
|
|
||||||
// Support für mehrere Seiten via ";"
|
// Support für mehrere Seiten via ";"
|
||||||
if (fullText.contains(";")) {
|
if (fullText.contains(";")) {
|
||||||
pages.addAll(Arrays.asList(fullText.split(";")));
|
pages.addAll(Arrays.asList(fullText.split(";")));
|
||||||
} else {
|
} else {
|
||||||
pages.add(fullText);
|
pages.add(fullText);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Aufruf der neuen Methode mit List<String>
|
// Aufruf der neuen Methode mit List<String>
|
||||||
module.createHologram(id, player.getLocation(), pages);
|
module.createHologram(id, player.getLocation(), pages);
|
||||||
player.sendMessage("§8[§6Nexus§8] §aHologramm §e" + id + " §aerstellt (" + pages.size() + " Seiten).");
|
player.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§aHologramm §e" + id + " §aerstellt (" + pages.size() + " Seiten).");
|
||||||
}
|
}
|
||||||
else if (args[0].equalsIgnoreCase("delete")) {
|
else if (args[0].equalsIgnoreCase("delete")) {
|
||||||
if (args.length < 2) {
|
if (args.length < 2) {
|
||||||
player.sendMessage("§cBitte gib eine ID an: /holo delete <id>");
|
player.sendMessage("§cBitte gib eine ID an: /holo delete <id>");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
module.removeHologram(args[1]);
|
module.removeHologram(args[1]);
|
||||||
player.sendMessage("§8[§6Nexus§8] §cHologramm §e" + args[1] + " §agelöscht.");
|
player.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§cHologramm §e" + args[1] + " §agelöscht.");
|
||||||
} else {
|
}
|
||||||
sendHelp(player);
|
else if (args[0].equalsIgnoreCase("reload")) {
|
||||||
}
|
module.reloadHolograms();
|
||||||
|
player.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§aHologramme neu geladen.");
|
||||||
return true;
|
} else {
|
||||||
}
|
sendHelp(player);
|
||||||
|
}
|
||||||
private void sendHelp(Player player) {
|
|
||||||
player.sendMessage("§8§m-----------§r §6Hologramme §8§m-----------");
|
return true;
|
||||||
player.sendMessage("§e/holo create <id> <NONE|FAST|SLOW> <text>");
|
}
|
||||||
player.sendMessage("§e/holo delete <id>");
|
|
||||||
player.sendMessage("§7Nutze §b; §7für neue Seiten.");
|
private void sendHelp(Player player) {
|
||||||
player.sendMessage("§7Nutze §b\\n §7für Zeilenumbruch.");
|
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;
|
package de.nexuslobby.modules.hologram;
|
||||||
|
|
||||||
import de.nexuslobby.NexusLobby;
|
import de.nexuslobby.NexusLobby;
|
||||||
import de.nexuslobby.api.Module;
|
import de.nexuslobby.api.Module;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Interaction;
|
import org.bukkit.entity.Interaction;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.TextDisplay;
|
import org.bukkit.entity.TextDisplay;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerChangedWorldEvent;
|
import org.bukkit.event.player.PlayerChangedWorldEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
public class HologramModule implements Module, Listener {
|
public class HologramModule implements Module, Listener {
|
||||||
|
|
||||||
private final Map<String, NexusHologram> holograms = new ConcurrentHashMap<>();
|
private final Map<String, NexusHologram> holograms = new ConcurrentHashMap<>();
|
||||||
private File file;
|
private File file;
|
||||||
private FileConfiguration config;
|
private FileConfiguration config;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() { return "Holograms"; }
|
public String getName() { return "Holograms"; }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
loadConfig();
|
loadConfig();
|
||||||
loadHolograms();
|
loadHolograms();
|
||||||
Bukkit.getPluginManager().registerEvents(this, NexusLobby.getInstance());
|
Bukkit.getPluginManager().registerEvents(this, NexusLobby.getInstance());
|
||||||
|
|
||||||
// Render-Task: Prüft alle 5 Ticks Sichtbarkeit und Placeholder-Updates
|
// Render-Task: Prüft alle 5 Ticks Sichtbarkeit und Placeholder-Updates
|
||||||
Bukkit.getScheduler().runTaskTimer(NexusLobby.getInstance(), () -> {
|
Bukkit.getScheduler().runTaskTimer(NexusLobby.getInstance(), () -> {
|
||||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
holograms.values().forEach(h -> h.renderForPlayer(player));
|
holograms.values().forEach(h -> h.renderForPlayer(player));
|
||||||
}
|
}
|
||||||
}, 20L, 5L);
|
}, 20L, 5L);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadConfig() {
|
private void loadConfig() {
|
||||||
file = new File(NexusLobby.getInstance().getDataFolder(), "holograms.yml");
|
file = new File(NexusLobby.getInstance().getDataFolder(), "holograms.yml");
|
||||||
config = YamlConfiguration.loadConfiguration(file);
|
config = YamlConfiguration.loadConfiguration(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadHolograms() {
|
private void loadHolograms() {
|
||||||
// Vorherige Instanzen säubern
|
// Vorherige Instanzen säubern
|
||||||
holograms.values().forEach(NexusHologram::removeAll);
|
holograms.values().forEach(NexusHologram::removeAll);
|
||||||
holograms.clear();
|
holograms.clear();
|
||||||
|
|
||||||
for (String id : config.getKeys(false)) {
|
for (String id : config.getKeys(false)) {
|
||||||
String worldName = config.getString(id + ".world");
|
String worldName = config.getString(id + ".world");
|
||||||
if (worldName == null) continue;
|
if (worldName == null) continue;
|
||||||
|
|
||||||
World world = Bukkit.getWorld(worldName);
|
World world = Bukkit.getWorld(worldName);
|
||||||
if (world == null) continue;
|
if (world == null) continue;
|
||||||
|
|
||||||
Location loc = new Location(world,
|
Location loc = new Location(world,
|
||||||
config.getDouble(id + ".x"),
|
config.getDouble(id + ".x"),
|
||||||
config.getDouble(id + ".y"),
|
config.getDouble(id + ".y"),
|
||||||
config.getDouble(id + ".z"));
|
config.getDouble(id + ".z"));
|
||||||
|
|
||||||
List<String> pages;
|
List<String> pages;
|
||||||
if (config.isList(id + ".text")) {
|
if (config.isList(id + ".text")) {
|
||||||
pages = config.getStringList(id + ".text");
|
pages = config.getStringList(id + ".text");
|
||||||
} else {
|
} else {
|
||||||
pages = new ArrayList<>();
|
pages = new ArrayList<>();
|
||||||
pages.add(config.getString(id + ".text", "No Text"));
|
pages.add(config.getString(id + ".text", "No Text"));
|
||||||
}
|
}
|
||||||
|
|
||||||
holograms.put(id, new NexusHologram(id, loc, pages));
|
holograms.put(id, new NexusHologram(id, loc, pages));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onInteract(PlayerInteractEntityEvent event) {
|
public void onInteract(PlayerInteractEntityEvent event) {
|
||||||
// Nur auf Interaction-Entities reagieren (Hologramm-Hitboxen)
|
// Nur auf Interaction-Entities reagieren (Hologramm-Hitboxen)
|
||||||
if (!(event.getRightClicked() instanceof Interaction)) return;
|
if (!(event.getRightClicked() instanceof Interaction)) return;
|
||||||
|
|
||||||
for (NexusHologram holo : holograms.values()) {
|
for (NexusHologram holo : holograms.values()) {
|
||||||
if (holo.isInteractionEntity(event.getRightClicked().getUniqueId())) {
|
if (holo.isInteractionEntity(event.getRightClicked().getUniqueId())) {
|
||||||
holo.nextPage(event.getPlayer());
|
holo.nextPage(event.getPlayer());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onQuit(PlayerQuitEvent event) {
|
public void onQuit(PlayerQuitEvent event) {
|
||||||
holograms.values().forEach(h -> h.removeForPlayer(event.getPlayer()));
|
holograms.values().forEach(h -> h.removeForPlayer(event.getPlayer()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onWorldChange(PlayerChangedWorldEvent event) {
|
public void onWorldChange(PlayerChangedWorldEvent event) {
|
||||||
holograms.values().forEach(h -> h.removeForPlayer(event.getPlayer()));
|
holograms.values().forEach(h -> h.removeForPlayer(event.getPlayer()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onJoin(PlayerJoinEvent event) {
|
public void onJoin(PlayerJoinEvent event) {
|
||||||
// Cleanup alter Entity-Reste, die eventuell noch in der Welt schweben
|
// Cleanup alter Entity-Reste, die eventuell noch in der Welt schweben
|
||||||
Bukkit.getScheduler().runTaskLater(NexusLobby.getInstance(), () -> {
|
Bukkit.getScheduler().runTaskLater(NexusLobby.getInstance(), () -> {
|
||||||
Player p = event.getPlayer();
|
Player p = event.getPlayer();
|
||||||
for (Entity entity : p.getWorld().getEntities()) {
|
for (Entity entity : p.getWorld().getEntities()) {
|
||||||
if (entity.getCustomName() != null && entity.getCustomName().startsWith("nexus_h_")) {
|
if (entity.getCustomName() != null && entity.getCustomName().startsWith("nexus_h_")) {
|
||||||
// Wenn das Hologramm nicht exakt für diesen Spieler benannt ist -> verstecken
|
// Wenn das Hologramm nicht exakt für diesen Spieler benannt ist -> verstecken
|
||||||
if (!entity.getCustomName().endsWith("_" + p.getName())) {
|
if (!entity.getCustomName().endsWith("_" + p.getName())) {
|
||||||
p.hideEntity(NexusLobby.getInstance(), entity);
|
p.hideEntity(NexusLobby.getInstance(), entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 10L);
|
}, 10L);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createHologram(String id, Location loc, List<String> pages) {
|
public void createHologram(String id, Location loc, List<String> pages) {
|
||||||
// Falls ID bereits existiert, altes Hologramm sauber entfernen
|
// Falls ID bereits existiert, altes Hologramm sauber entfernen
|
||||||
if (holograms.containsKey(id)) {
|
if (holograms.containsKey(id)) {
|
||||||
removeHologram(id);
|
removeHologram(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
config.set(id + ".world", loc.getWorld().getName());
|
config.set(id + ".world", loc.getWorld().getName());
|
||||||
config.set(id + ".x", loc.getX());
|
config.set(id + ".x", loc.getX());
|
||||||
config.set(id + ".y", loc.getY());
|
config.set(id + ".y", loc.getY());
|
||||||
config.set(id + ".z", loc.getZ());
|
config.set(id + ".z", loc.getZ());
|
||||||
config.set(id + ".text", pages);
|
config.set(id + ".text", pages);
|
||||||
saveHoloConfig();
|
saveHoloConfig();
|
||||||
|
|
||||||
NexusHologram holo = new NexusHologram(id, loc, pages);
|
NexusHologram holo = new NexusHologram(id, loc, pages);
|
||||||
holograms.put(id, holo);
|
holograms.put(id, holo);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeHologram(String id) {
|
public void removeHologram(String id) {
|
||||||
NexusHologram holo = holograms.remove(id);
|
NexusHologram holo = holograms.remove(id);
|
||||||
if (holo != null) {
|
if (holo != null) {
|
||||||
// Erst für alle Spieler visuell entfernen
|
// Erst für alle Spieler visuell entfernen
|
||||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
holo.removeForPlayer(player);
|
holo.removeForPlayer(player);
|
||||||
}
|
}
|
||||||
// Dann Entities serverseitig löschen
|
// Dann Entities serverseitig löschen
|
||||||
holo.removeAll();
|
holo.removeAll();
|
||||||
}
|
}
|
||||||
config.set(id, null);
|
config.set(id, null);
|
||||||
saveHoloConfig();
|
saveHoloConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveHoloConfig() {
|
/**
|
||||||
try {
|
* Lädt die holograms.yml neu und rendert alle Hologramme für Online-Spieler neu.
|
||||||
config.save(file);
|
* Wird von HoloCommand (/holo reload) aufgerufen.
|
||||||
} catch (IOException e) {
|
*/
|
||||||
NexusLobby.getInstance().getLogger().severe("Konnte holograms.yml nicht speichern!");
|
public void reloadHolograms() {
|
||||||
NexusLobby.getInstance().getLogger().severe("Fehler beim Speichern der Hologramme: " + e.getMessage());
|
// 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
|
||||||
* WICHTIG: Diese Methode wird vom LobbyTabCompleter benötigt!
|
loadConfig();
|
||||||
* @return Set aller registrierten Hologramm-IDs
|
loadHolograms();
|
||||||
*/
|
}
|
||||||
public Set<String> getHologramIds() {
|
|
||||||
return holograms.keySet();
|
private void saveHoloConfig() {
|
||||||
}
|
try {
|
||||||
|
// Sicherstellen, dass Placeholder-Strings (z.B. %bungeetotal%) korrekt
|
||||||
@Override
|
// gequotet gespeichert werden, damit SnakeYAML sie nicht als YAML-Direktive
|
||||||
public void onDisable() {
|
// missinterpretiert. Dazu speichern wir die text-Listen explizit als
|
||||||
holograms.values().forEach(NexusHologram::removeAll);
|
// String-Werte mit einfachen Anführungszeichen via eigener Serialisierung.
|
||||||
holograms.clear();
|
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;
|
package de.nexuslobby.modules.hologram;
|
||||||
|
|
||||||
import de.nexuslobby.NexusLobby;
|
import de.nexuslobby.NexusLobby;
|
||||||
import me.clip.placeholderapi.PlaceholderAPI;
|
import me.clip.placeholderapi.PlaceholderAPI;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Color;
|
import org.bukkit.Color;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Display;
|
import org.bukkit.entity.Display;
|
||||||
import org.bukkit.entity.Interaction;
|
import org.bukkit.entity.Interaction;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.TextDisplay;
|
import org.bukkit.entity.TextDisplay;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
public class NexusHologram {
|
public class NexusHologram {
|
||||||
|
|
||||||
private final String id;
|
private final String id;
|
||||||
private final Location location;
|
private final Location location;
|
||||||
private final List<String> pages;
|
private final List<String> pages;
|
||||||
|
|
||||||
private final Map<UUID, TextDisplay> playerEntities = new ConcurrentHashMap<>();
|
private final Map<UUID, TextDisplay> playerEntities = new ConcurrentHashMap<>();
|
||||||
private final Map<UUID, Interaction> playerInteractions = new ConcurrentHashMap<>();
|
private final Map<UUID, Interaction> playerInteractions = new ConcurrentHashMap<>();
|
||||||
private final Map<UUID, Integer> currentPage = new ConcurrentHashMap<>();
|
private final Map<UUID, Integer> currentPage = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
public NexusHologram(String id, Location location, List<String> pages) {
|
public NexusHologram(String id, Location location, List<String> pages) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.location = location;
|
this.location = location;
|
||||||
this.pages = pages;
|
this.pages = pages;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void nextPage(Player player) {
|
public void nextPage(Player player) {
|
||||||
if (pages.size() <= 1) return;
|
if (pages.size() <= 1) return;
|
||||||
int next = (currentPage.getOrDefault(player.getUniqueId(), 0) + 1) % pages.size();
|
int next = (currentPage.getOrDefault(player.getUniqueId(), 0) + 1) % pages.size();
|
||||||
currentPage.put(player.getUniqueId(), next);
|
currentPage.put(player.getUniqueId(), next);
|
||||||
renderForPlayer(player);
|
renderForPlayer(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void renderForPlayer(Player player) {
|
public void renderForPlayer(Player player) {
|
||||||
if (!player.getWorld().equals(location.getWorld()) || player.getLocation().distanceSquared(location) > 2304) {
|
if (!player.getWorld().equals(location.getWorld()) || player.getLocation().distanceSquared(location) > 2304) {
|
||||||
removeForPlayer(player);
|
removeForPlayer(player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int pageIdx = currentPage.getOrDefault(player.getUniqueId(), 0);
|
int pageIdx = currentPage.getOrDefault(player.getUniqueId(), 0);
|
||||||
if (pageIdx >= pages.size()) pageIdx = 0;
|
if (pageIdx >= pages.size()) pageIdx = 0;
|
||||||
|
|
||||||
String rawText = pages.get(pageIdx);
|
String rawText = pages.get(pageIdx);
|
||||||
if (Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI")) {
|
if (Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI")) {
|
||||||
rawText = PlaceholderAPI.setPlaceholders(player, rawText);
|
rawText = PlaceholderAPI.setPlaceholders(player, rawText);
|
||||||
}
|
}
|
||||||
final String finalText = rawText.replace("&", "§").replace("\\n", "\n");
|
final String finalText = rawText.replace("&", "§").replace("\\n", "\n");
|
||||||
|
|
||||||
TextDisplay display = playerEntities.get(player.getUniqueId());
|
TextDisplay display = playerEntities.get(player.getUniqueId());
|
||||||
|
|
||||||
if (display == null || !display.isValid()) {
|
if (display == null || !display.isValid()) {
|
||||||
// Text-Display erstellen (Hier lassen wir den Namen zur internen Identifikation,
|
// Text-Display erstellen (Hier lassen wir den Namen zur internen Identifikation,
|
||||||
// aber schalten ihn strikt unsichtbar)
|
// aber schalten ihn strikt unsichtbar)
|
||||||
display = location.getWorld().spawn(location, TextDisplay.class, entity -> {
|
display = location.getWorld().spawn(location, TextDisplay.class, entity -> {
|
||||||
entity.setCustomName("nexus_h_" + id + "_" + player.getName());
|
entity.setCustomName("nexus_h_" + id + "_" + player.getName());
|
||||||
entity.setCustomNameVisible(false);
|
entity.setCustomNameVisible(false);
|
||||||
entity.setPersistent(false);
|
entity.setPersistent(false);
|
||||||
entity.setBillboard(Display.Billboard.CENTER);
|
entity.setBillboard(Display.Billboard.CENTER);
|
||||||
entity.setBackgroundColor(Color.fromARGB(0, 0, 0, 0));
|
entity.setBackgroundColor(Color.fromARGB(0, 0, 0, 0));
|
||||||
entity.setText(finalText);
|
entity.setText(finalText);
|
||||||
entity.setInvulnerable(true);
|
entity.setInvulnerable(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Interaction Entity (Hitbox) erstellen
|
// Interaction Entity (Hitbox) erstellen
|
||||||
// FIX: WIR SETZEN KEINEN CUSTOM NAME MEHR.
|
// FIX: WIR SETZEN KEINEN CUSTOM NAME MEHR.
|
||||||
// Das verhindert zu 100%, dass Minecraft etwas anzeigt.
|
// Das verhindert zu 100%, dass Minecraft etwas anzeigt.
|
||||||
Interaction interact = location.getWorld().spawn(location, Interaction.class, entity -> {
|
Interaction interact = location.getWorld().spawn(location, Interaction.class, entity -> {
|
||||||
entity.setInteractionWidth(2.5f);
|
entity.setInteractionWidth(2.5f);
|
||||||
entity.setInteractionHeight(2.0f);
|
entity.setInteractionHeight(2.0f);
|
||||||
entity.setCustomNameVisible(false);
|
entity.setCustomNameVisible(false);
|
||||||
entity.setPersistent(false);
|
entity.setPersistent(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Nur für den Zielspieler sichtbar machen
|
// Nur für den Zielspieler sichtbar machen
|
||||||
for (Player other : Bukkit.getOnlinePlayers()) {
|
for (Player other : Bukkit.getOnlinePlayers()) {
|
||||||
if (!other.getUniqueId().equals(player.getUniqueId())) {
|
if (!other.getUniqueId().equals(player.getUniqueId())) {
|
||||||
other.hideEntity(NexusLobby.getInstance(), display);
|
other.hideEntity(NexusLobby.getInstance(), display);
|
||||||
other.hideEntity(NexusLobby.getInstance(), interact);
|
other.hideEntity(NexusLobby.getInstance(), interact);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
playerEntities.put(player.getUniqueId(), display);
|
playerEntities.put(player.getUniqueId(), display);
|
||||||
playerInteractions.put(player.getUniqueId(), interact);
|
playerInteractions.put(player.getUniqueId(), interact);
|
||||||
} else {
|
} else {
|
||||||
if (!display.getText().equals(finalText)) {
|
if (!display.getText().equals(finalText)) {
|
||||||
display.setText(finalText);
|
display.setText(finalText);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeForPlayer(Player player) {
|
public void removeForPlayer(Player player) {
|
||||||
TextDisplay display = playerEntities.remove(player.getUniqueId());
|
TextDisplay display = playerEntities.remove(player.getUniqueId());
|
||||||
if (display != null) display.remove();
|
if (display != null) display.remove();
|
||||||
|
|
||||||
Interaction interact = playerInteractions.remove(player.getUniqueId());
|
Interaction interact = playerInteractions.remove(player.getUniqueId());
|
||||||
if (interact != null) interact.remove();
|
if (interact != null) interact.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeAll() {
|
public void removeAll() {
|
||||||
playerEntities.values().forEach(TextDisplay::remove);
|
playerEntities.values().forEach(TextDisplay::remove);
|
||||||
playerInteractions.values().forEach(Interaction::remove);
|
playerInteractions.values().forEach(Interaction::remove);
|
||||||
playerEntities.clear();
|
playerEntities.clear();
|
||||||
playerInteractions.clear();
|
playerInteractions.clear();
|
||||||
currentPage.clear();
|
currentPage.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isInteractionEntity(UUID entityId) {
|
public boolean isInteractionEntity(UUID entityId) {
|
||||||
// Da wir keinen Namen mehr nutzen, verlassen wir uns rein auf die UUID in der Map
|
// 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));
|
return playerInteractions.values().stream().anyMatch(i -> i.getUniqueId().equals(entityId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,223 +1,365 @@
|
|||||||
package de.nexuslobby.modules.intro;
|
package de.nexuslobby.modules.intro;
|
||||||
|
|
||||||
import de.nexuslobby.NexusLobby;
|
import de.nexuslobby.NexusLobby;
|
||||||
import de.nexuslobby.api.Module;
|
import de.nexuslobby.api.Module;
|
||||||
import net.md_5.bungee.api.ChatMessageType;
|
import org.bukkit.Bukkit;
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.bukkit.event.player.PlayerToggleSneakEvent;
|
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import java.io.File;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import java.io.IOException;
|
||||||
|
import java.util.*;
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
public class IntroModule implements Module, Listener, CommandExecutor {
|
||||||
import java.util.*;
|
|
||||||
|
private final Set<UUID> activeIntro = new HashSet<>();
|
||||||
public class IntroModule implements Module, Listener, CommandExecutor {
|
|
||||||
|
private final List<Location> points = new ArrayList<>();
|
||||||
private final Set<UUID> activeIntro = new HashSet<>();
|
private final List<String> labels = new ArrayList<>();
|
||||||
private final List<Location> points = new ArrayList<>();
|
|
||||||
private File configFile;
|
// Abschluss-Titel (konfigurierbar)
|
||||||
private FileConfiguration config;
|
private String endTitle = "§a§lWillkommen!";
|
||||||
|
private String endSubtitle = "§7Viel Spaß auf NexusLobby";
|
||||||
// --- Einstellungen ---
|
|
||||||
private final int TICKS_FLUG = 70; // Dauer der Fahrt zwischen zwei Punkten (3.5 Sek)
|
private File configFile;
|
||||||
private final int TICKS_PAUSE = 30; // Standzeit an jedem Punkt (1.5 Sek)
|
private FileConfiguration config;
|
||||||
|
|
||||||
@Override
|
// --- Einstellungen ---
|
||||||
public String getName() { return "Intro"; }
|
private final int TICKS_FLUG = 70;
|
||||||
|
private final int TICKS_PAUSE = 30;
|
||||||
@Override
|
|
||||||
public void onEnable() {
|
private final int TITLE_FADE_IN = 10;
|
||||||
Bukkit.getPluginManager().registerEvents(this, NexusLobby.getInstance());
|
private final int TITLE_STAY = 50;
|
||||||
if (NexusLobby.getInstance().getCommand("intro") != null) {
|
private final int TITLE_FADE_OUT = 10;
|
||||||
NexusLobby.getInstance().getCommand("intro").setExecutor(this);
|
|
||||||
}
|
@Override
|
||||||
loadPoints();
|
public String getName() { return "Intro"; }
|
||||||
}
|
|
||||||
|
@Override
|
||||||
@Override
|
public void onEnable() {
|
||||||
public void onDisable() {
|
Bukkit.getPluginManager().registerEvents(this, NexusLobby.getInstance());
|
||||||
activeIntro.clear();
|
if (NexusLobby.getInstance().getCommand("intro") != null) {
|
||||||
}
|
NexusLobby.getInstance().getCommand("intro").setExecutor(this);
|
||||||
|
}
|
||||||
private void loadPoints() {
|
loadConfig();
|
||||||
points.clear();
|
}
|
||||||
configFile = new File(NexusLobby.getInstance().getDataFolder(), "intro.yml");
|
|
||||||
if (!configFile.exists()) {
|
@Override
|
||||||
try { configFile.createNewFile(); } catch (IOException ignored) {}
|
public void onDisable() {
|
||||||
}
|
org.bukkit.event.HandlerList.unregisterAll(this);
|
||||||
config = YamlConfiguration.loadConfiguration(configFile);
|
activeIntro.clear();
|
||||||
List<?> list = config.getList("points");
|
}
|
||||||
if (list != null) {
|
|
||||||
for (Object obj : list) {
|
// ─────────────────────────────────────────────────────────────────────────
|
||||||
if (obj instanceof Location loc) points.add(loc);
|
// Persistenz
|
||||||
}
|
// ─────────────────────────────────────────────────────────────────────────
|
||||||
}
|
|
||||||
}
|
private void loadConfig() {
|
||||||
|
points.clear();
|
||||||
private void savePoints() {
|
labels.clear();
|
||||||
config.set("points", points);
|
configFile = new File(NexusLobby.getInstance().getDataFolder(), "intro.yml");
|
||||||
try {
|
if (!configFile.exists()) {
|
||||||
config.save(configFile);
|
try { configFile.createNewFile(); } catch (IOException ignored) {}
|
||||||
} catch (IOException e) {
|
}
|
||||||
NexusLobby.getInstance().getLogger().severe("Fehler beim Speichern der Intro-Config: " + e.getMessage());
|
config = YamlConfiguration.loadConfiguration(configFile);
|
||||||
}
|
|
||||||
}
|
// Abschluss-Titel laden
|
||||||
|
endTitle = config.getString("end-title", "§a§lWillkommen!");
|
||||||
@EventHandler
|
endSubtitle = config.getString("end-subtitle", "§7Viel Spaß auf NexusLobby");
|
||||||
public void onJoin(PlayerJoinEvent event) {
|
|
||||||
if (!event.getPlayer().hasPlayedBefore() && points.size() >= 2) {
|
// Punkte laden
|
||||||
startIntro(event.getPlayer());
|
List<?> list = config.getList("intro-points");
|
||||||
}
|
if (list != null) {
|
||||||
}
|
for (Object obj : list) {
|
||||||
|
if (obj instanceof Map<?, ?> map) {
|
||||||
@EventHandler
|
Object locObj = map.get("location");
|
||||||
public void onSneak(PlayerToggleSneakEvent event) {
|
Object labelObj = map.get("label");
|
||||||
if (activeIntro.contains(event.getPlayer().getUniqueId()) && event.isSneaking()) {
|
if (locObj instanceof Location loc) {
|
||||||
stopIntro(event.getPlayer(), true);
|
points.add(loc);
|
||||||
}
|
labels.add(labelObj != null ? labelObj.toString() : "");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
@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;
|
// Rückwärts-Kompatibilität
|
||||||
|
if (points.isEmpty()) {
|
||||||
if (args.length == 0) {
|
List<?> oldList = config.getList("points");
|
||||||
p.sendMessage("§8§m------------------------------------");
|
if (oldList != null) {
|
||||||
p.sendMessage("§6§lNexus Intro System (Cinematic)");
|
for (Object obj : oldList) {
|
||||||
p.sendMessage("§e/intro add §7- Punkt hinzufügen");
|
if (obj instanceof Location loc) {
|
||||||
p.sendMessage("§e/intro clear §7- Alle Punkte löschen");
|
points.add(loc);
|
||||||
p.sendMessage("§e/intro start §7- Teste die Fahrt");
|
labels.add("");
|
||||||
p.sendMessage("§8§m------------------------------------");
|
}
|
||||||
return true;
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
switch (args[0].toLowerCase()) {
|
}
|
||||||
case "add" -> {
|
|
||||||
points.add(p.getLocation());
|
private void saveConfig() {
|
||||||
savePoints();
|
// Abschluss-Titel speichern
|
||||||
p.sendMessage("§8[§6Nexus§8] §aPunkt #" + points.size() + " wurde gesetzt!");
|
config.set("end-title", endTitle);
|
||||||
}
|
config.set("end-subtitle", endSubtitle);
|
||||||
case "clear" -> {
|
|
||||||
points.clear();
|
// Punkte speichern
|
||||||
savePoints();
|
List<Map<String, Object>> data = new ArrayList<>();
|
||||||
p.sendMessage("§8[§6Nexus§8] §cAlle Intro-Punkte wurden gelöscht.");
|
for (int i = 0; i < points.size(); i++) {
|
||||||
}
|
Map<String, Object> entry = new LinkedHashMap<>();
|
||||||
case "start" -> {
|
entry.put("location", points.get(i));
|
||||||
if (points.size() < 2) {
|
entry.put("label", labels.get(i));
|
||||||
p.sendMessage("§8[§6Nexus§8] §cDu brauchst mindestens 2 Punkte für eine Fahrt.");
|
data.add(entry);
|
||||||
} else {
|
}
|
||||||
startIntro(p);
|
config.set("intro-points", data);
|
||||||
}
|
config.set("points", null);
|
||||||
}
|
|
||||||
}
|
try {
|
||||||
return true;
|
config.save(configFile);
|
||||||
}
|
} catch (IOException e) {
|
||||||
|
NexusLobby.getInstance().getLogger().severe("Fehler beim Speichern der Intro-Config: " + e.getMessage());
|
||||||
public void startIntro(Player player) {
|
}
|
||||||
activeIntro.add(player.getUniqueId());
|
}
|
||||||
player.setGameMode(GameMode.SPECTATOR);
|
|
||||||
|
// ─────────────────────────────────────────────────────────────────────────
|
||||||
new BukkitRunnable() {
|
// Events
|
||||||
int currentSegment = 0;
|
// ─────────────────────────────────────────────────────────────────────────
|
||||||
int tickInSegment = 0;
|
|
||||||
boolean isPausing = true;
|
@EventHandler
|
||||||
|
public void onJoin(PlayerJoinEvent event) {
|
||||||
@Override
|
if (!event.getPlayer().hasPlayedBefore() && points.size() >= 2) {
|
||||||
public void run() {
|
startIntro(event.getPlayer());
|
||||||
try {
|
}
|
||||||
if (!player.isOnline() || !activeIntro.contains(player.getUniqueId())) {
|
}
|
||||||
this.cancel();
|
|
||||||
return;
|
// ─────────────────────────────────────────────────────────────────────────
|
||||||
}
|
// Befehle
|
||||||
|
// ─────────────────────────────────────────────────────────────────────────
|
||||||
if (currentSegment >= points.size() - 1) {
|
|
||||||
stopIntro(player, false);
|
@Override
|
||||||
this.cancel();
|
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||||
return;
|
if (!(sender instanceof Player p)) return true;
|
||||||
}
|
if (!p.hasPermission("nexuslobby.admin")) return true;
|
||||||
|
|
||||||
Location start = points.get(currentSegment);
|
if (args.length == 0) {
|
||||||
Location end = points.get(currentSegment + 1);
|
sendHelp(p);
|
||||||
|
return true;
|
||||||
if (isPausing) {
|
}
|
||||||
// Kamera steht am aktuellen Punkt
|
|
||||||
player.teleport(start);
|
switch (args[0].toLowerCase()) {
|
||||||
tickInSegment++;
|
|
||||||
if (tickInSegment >= TICKS_PAUSE) {
|
case "add" -> {
|
||||||
isPausing = false;
|
String pointLabel = args.length > 1
|
||||||
tickInSegment = 0;
|
? String.join(" ", Arrays.copyOfRange(args, 1, args.length))
|
||||||
}
|
: "";
|
||||||
} else {
|
points.add(p.getLocation());
|
||||||
// Kamera fliegt zum nächsten Punkt
|
labels.add(pointLabel);
|
||||||
double progress = (double) tickInSegment / (double) TICKS_FLUG;
|
saveConfig();
|
||||||
|
if (pointLabel.isEmpty()) {
|
||||||
// "Smooth Step" für flüssigeres Beschleunigen/Bremsen
|
p.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§aPunkt §e#" + points.size() + " §awurde gesetzt.");
|
||||||
double smoothT = progress * progress * (3 - 2 * progress);
|
} else {
|
||||||
|
p.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§aPunkt §e#" + points.size() + " §amit Text §e\"" + pointLabel + "\" §agesetzt.");
|
||||||
Location nextLoc = interpolate(start, end, smoothT);
|
}
|
||||||
player.teleport(nextLoc);
|
}
|
||||||
|
|
||||||
tickInSegment++;
|
case "clear" -> {
|
||||||
if (tickInSegment >= TICKS_FLUG) {
|
points.clear();
|
||||||
isPausing = true;
|
labels.clear();
|
||||||
tickInSegment = 0;
|
saveConfig();
|
||||||
currentSegment++;
|
p.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§cAlle Intro-Punkte wurden gelöscht.");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
case "list" -> {
|
||||||
player.spigot().sendMessage(ChatMessageType.ACTION_BAR,
|
if (points.isEmpty()) {
|
||||||
new TextComponent("§6§lINTRO-TOUR §8| §ePunkt " + (currentSegment + 1) + " §8| §7Sneak zum Abbrechen"));
|
p.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§cKeine Punkte vorhanden.");
|
||||||
|
return true;
|
||||||
} catch (Exception e) {
|
}
|
||||||
this.cancel();
|
p.sendMessage("§8§m------------------------------------");
|
||||||
stopIntro(player, true);
|
p.sendMessage("§6§lIntro-Punkte (" + points.size() + ")");
|
||||||
}
|
for (int i = 0; i < points.size(); i++) {
|
||||||
}
|
Location loc = points.get(i);
|
||||||
}.runTaskTimer(NexusLobby.getInstance(), 0L, 1L);
|
String lbl = labels.get(i).isEmpty() ? "§7(kein Text)" : "§e" + labels.get(i);
|
||||||
}
|
p.sendMessage("§8#" + (i + 1) + " §7"
|
||||||
|
+ String.format("%.1f", loc.getX()) + ", "
|
||||||
private Location interpolate(Location start, Location end, double t) {
|
+ String.format("%.1f", loc.getY()) + ", "
|
||||||
double x = start.getX() + (end.getX() - start.getX()) * t;
|
+ String.format("%.1f", loc.getZ())
|
||||||
double y = start.getY() + (end.getY() - start.getY()) * t;
|
+ " " + lbl);
|
||||||
double z = start.getZ() + (end.getZ() - start.getZ()) * t;
|
}
|
||||||
|
p.sendMessage("§8§m------------------------------------");
|
||||||
// Sanfte Drehung
|
}
|
||||||
float startYaw = start.getYaw();
|
|
||||||
float endYaw = end.getYaw();
|
case "start" -> {
|
||||||
// Verhindert ruckartige 360-Grad Dreher
|
if (points.size() < 2) {
|
||||||
float diff = (endYaw - startYaw) % 360;
|
p.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§cDu brauchst mindestens 2 Punkte für eine Fahrt.");
|
||||||
if (diff > 180) diff -= 360;
|
} else {
|
||||||
if (diff < -180) diff += 360;
|
startIntro(p);
|
||||||
float yaw = startYaw + diff * (float)t;
|
}
|
||||||
|
}
|
||||||
float pitch = (float) (start.getPitch() + (end.getPitch() - start.getPitch()) * t);
|
|
||||||
|
// /intro setendtitle <Text> — setzt den großen Abschluss-Titel
|
||||||
return new Location(start.getWorld(), x, y, z, yaw, pitch);
|
case "setendtitle" -> {
|
||||||
}
|
if (args.length < 2) {
|
||||||
|
p.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§cBenutzung: §e/intro setendtitle <Text>");
|
||||||
private void stopIntro(Player player, boolean canceled) {
|
p.sendMessage("§7Farbcodes mit §e& §7möglich. Beispiel: §e/intro setendtitle &a&lWillkommen!");
|
||||||
activeIntro.remove(player.getUniqueId());
|
return true;
|
||||||
player.setGameMode(GameMode.ADVENTURE);
|
}
|
||||||
player.teleport(player.getWorld().getSpawnLocation());
|
endTitle = colorize(String.join(" ", Arrays.copyOfRange(args, 1, args.length)));
|
||||||
|
saveConfig();
|
||||||
if (canceled) {
|
p.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§aAbschluss-Titel gesetzt: " + endTitle);
|
||||||
player.sendMessage("§8[§6Nexus§8] §cIntro abgebrochen.");
|
// Vorschau
|
||||||
} else {
|
p.sendTitle(endTitle, endSubtitle, TITLE_FADE_IN, TITLE_STAY, TITLE_FADE_OUT);
|
||||||
player.sendMessage("§8[§6Nexus§8] §aWillkommen auf dem Netzwerk!");
|
}
|
||||||
}
|
|
||||||
}
|
// /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;
|
package de.nexuslobby.modules.mapart;
|
||||||
|
|
||||||
import de.nexuslobby.NexusLobby;
|
import de.nexuslobby.NexusLobby;
|
||||||
import de.nexuslobby.api.Module;
|
import de.nexuslobby.api.Module;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.entity.ItemFrame;
|
import org.bukkit.entity.ItemFrame;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.MapMeta;
|
import org.bukkit.inventory.meta.MapMeta;
|
||||||
import org.bukkit.map.MapCanvas;
|
import org.bukkit.map.MapCanvas;
|
||||||
import org.bukkit.map.MapRenderer;
|
import org.bukkit.map.MapRenderer;
|
||||||
import org.bukkit.map.MapView;
|
import org.bukkit.map.MapView;
|
||||||
import org.bukkit.util.RayTraceResult;
|
import org.bukkit.util.RayTraceResult;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.Image;
|
import java.awt.Image;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.Map;
|
import java.util.Collections;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
public class MapArtModule implements Module, CommandExecutor {
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
private File storageFile;
|
public class MapArtModule implements Module, CommandExecutor {
|
||||||
private FileConfiguration storageConfig;
|
|
||||||
|
private File storageFile;
|
||||||
// RAM-Schutz: Cache für bereits geladene Bild-Kacheln
|
private FileConfiguration storageConfig;
|
||||||
private final Map<String, BufferedImage> tileCache = new ConcurrentHashMap<>();
|
|
||||||
// Hilfs-Set um parallele Downloads der gleichen URL zu verhindern
|
// FIX: Unbegrenzter Cache führt bei vielen verschiedenen Bild-URLs zu einem
|
||||||
private final Map<String, Boolean> loadingShield = new ConcurrentHashMap<>();
|
// OutOfMemoryError. Stattdessen nutzen wir einen LRU-Cache mit max. 50 Einträgen.
|
||||||
|
// Älteste Kacheln werden automatisch verdrängt.
|
||||||
@Override
|
private static final int MAX_CACHE_SIZE = 50;
|
||||||
public String getName() { return "MapArt"; }
|
private final Map<String, BufferedImage> tileCache = Collections.synchronizedMap(
|
||||||
|
new LinkedHashMap<String, BufferedImage>(MAX_CACHE_SIZE + 1, 0.75f, true) {
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
protected boolean removeEldestEntry(Map.Entry<String, BufferedImage> eldest) {
|
||||||
if (NexusLobby.getInstance().getCommand("mapart") != null) {
|
return size() > MAX_CACHE_SIZE;
|
||||||
NexusLobby.getInstance().getCommand("mapart").setExecutor(this);
|
}
|
||||||
}
|
}
|
||||||
initStorage();
|
);
|
||||||
reloadMaps();
|
// Hilfs-Set um parallele Downloads der gleichen URL zu verhindern
|
||||||
}
|
private final Map<String, Boolean> loadingShield = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public String getName() { return "MapArt"; }
|
||||||
saveStorage();
|
|
||||||
tileCache.clear();
|
@Override
|
||||||
}
|
public void onEnable() {
|
||||||
|
if (NexusLobby.getInstance().getCommand("mapart") != null) {
|
||||||
private void initStorage() {
|
NexusLobby.getInstance().getCommand("mapart").setExecutor(this);
|
||||||
storageFile = new File(NexusLobby.getInstance().getDataFolder(), "mapart.yml");
|
}
|
||||||
if (!storageFile.exists()) {
|
initStorage();
|
||||||
try {
|
reloadMaps();
|
||||||
storageFile.createNewFile();
|
}
|
||||||
} catch (IOException e) {
|
|
||||||
NexusLobby.getInstance().getLogger().severe("Fehler beim Erstellen der mapart.yml: " + e.getMessage());
|
@Override
|
||||||
}
|
public void onDisable() {
|
||||||
}
|
saveStorage();
|
||||||
storageConfig = YamlConfiguration.loadConfiguration(storageFile);
|
tileCache.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveStorage() {
|
private void initStorage() {
|
||||||
try {
|
storageFile = new File(NexusLobby.getInstance().getDataFolder(), "mapart.yml");
|
||||||
storageConfig.save(storageFile);
|
if (!storageFile.exists()) {
|
||||||
} catch (IOException e) {
|
try {
|
||||||
NexusLobby.getInstance().getLogger().severe("Fehler beim Speichern der mapart.yml: " + e.getMessage());
|
storageFile.createNewFile();
|
||||||
}
|
} catch (IOException e) {
|
||||||
}
|
NexusLobby.getInstance().getLogger().severe("Fehler beim Erstellen der mapart.yml: " + e.getMessage());
|
||||||
|
}
|
||||||
private void reloadMaps() {
|
}
|
||||||
ConfigurationSection section = storageConfig.getConfigurationSection("active_maps");
|
storageConfig = YamlConfiguration.loadConfiguration(storageFile);
|
||||||
if (section == null) return;
|
}
|
||||||
|
|
||||||
for (String idStr : section.getKeys(false)) {
|
private void saveStorage() {
|
||||||
try {
|
try {
|
||||||
int mapId = Integer.parseInt(idStr);
|
storageConfig.save(storageFile);
|
||||||
String url = section.getString(idStr + ".url");
|
} catch (IOException e) {
|
||||||
int x = section.getInt(idStr + ".x");
|
NexusLobby.getInstance().getLogger().severe("Fehler beim Speichern der mapart.yml: " + e.getMessage());
|
||||||
int y = section.getInt(idStr + ".y");
|
}
|
||||||
int totalW = section.getInt(idStr + ".totalW");
|
}
|
||||||
int totalH = section.getInt(idStr + ".totalH");
|
|
||||||
|
private void reloadMaps() {
|
||||||
@SuppressWarnings("deprecation")
|
ConfigurationSection section = storageConfig.getConfigurationSection("active_maps");
|
||||||
MapView view = Bukkit.getMap(mapId);
|
if (section == null) return;
|
||||||
if (view != null) {
|
|
||||||
applyRenderer(view, url, x, y, totalW, totalH);
|
for (String idStr : section.getKeys(false)) {
|
||||||
}
|
try {
|
||||||
} catch (Exception ignored) {}
|
int mapId = Integer.parseInt(idStr);
|
||||||
}
|
String url = section.getString(idStr + ".url");
|
||||||
}
|
int x = section.getInt(idStr + ".x");
|
||||||
|
int y = section.getInt(idStr + ".y");
|
||||||
@Override
|
int totalW = section.getInt(idStr + ".totalW");
|
||||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
int totalH = section.getInt(idStr + ".totalH");
|
||||||
if (!(sender instanceof Player player)) return true;
|
|
||||||
if (!player.hasPermission("nexuslobby.mapart")) {
|
@SuppressWarnings("deprecation")
|
||||||
player.sendMessage("§8[§6Nexus§8] §cKeine Rechte.");
|
MapView view = Bukkit.getMap(mapId);
|
||||||
return true;
|
if (view != null) {
|
||||||
}
|
applyRenderer(view, url, x, y, totalW, totalH);
|
||||||
|
}
|
||||||
if (args.length == 0) {
|
} catch (Exception ignored) {}
|
||||||
sendHelp(player);
|
}
|
||||||
return true;
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
if (args[0].equalsIgnoreCase("delete")) {
|
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||||
int radius = 3;
|
if (!(sender instanceof Player player)) return true;
|
||||||
if (args.length == 2) {
|
if (!player.hasPermission("nexuslobby.mapart")) {
|
||||||
try {
|
player.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§cKeine Rechte.");
|
||||||
radius = Integer.parseInt(args[1]);
|
return true;
|
||||||
} catch (NumberFormatException e) {
|
}
|
||||||
player.sendMessage("§8[§6Nexus§8] §cUngültiger Radius.");
|
|
||||||
return true;
|
if (args.length == 0) {
|
||||||
}
|
sendHelp(player);
|
||||||
}
|
return true;
|
||||||
deleteNearbyMaps(player, radius);
|
}
|
||||||
return true;
|
|
||||||
}
|
if (args[0].equalsIgnoreCase("delete")) {
|
||||||
|
int radius = 3;
|
||||||
if (args.length != 2) {
|
if (args.length == 2) {
|
||||||
sendHelp(player);
|
try {
|
||||||
return true;
|
radius = Integer.parseInt(args[1]);
|
||||||
}
|
} catch (NumberFormatException e) {
|
||||||
|
player.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§cUngültiger Radius.");
|
||||||
RayTraceResult rayTrace = player.rayTraceBlocks(5);
|
return true;
|
||||||
if (rayTrace == null || rayTrace.getHitBlock() == null || rayTrace.getHitBlockFace() == null) {
|
}
|
||||||
player.sendMessage("§8[§6Nexus§8] §cBitte schaue eine Wand direkt an.");
|
}
|
||||||
return true;
|
deleteNearbyMaps(player, radius);
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
Block targetBlock = rayTrace.getHitBlock();
|
|
||||||
BlockFace hitFace = rayTrace.getHitBlockFace();
|
if (args.length != 2) {
|
||||||
|
sendHelp(player);
|
||||||
if (hitFace == BlockFace.UP || hitFace == BlockFace.DOWN) {
|
return true;
|
||||||
player.sendMessage("§8[§6Nexus§8] §cAktuell nur an vertikalen Wänden möglich.");
|
}
|
||||||
return true;
|
|
||||||
}
|
RayTraceResult rayTrace = player.rayTraceBlocks(5);
|
||||||
|
if (rayTrace == null || rayTrace.getHitBlock() == null || rayTrace.getHitBlockFace() == null) {
|
||||||
String url = args[0];
|
player.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§cBitte schaue eine Wand direkt an.");
|
||||||
int width, height;
|
return true;
|
||||||
try {
|
}
|
||||||
String[] parts = args[1].toLowerCase().split("x");
|
|
||||||
width = Integer.parseInt(parts[0]);
|
Block targetBlock = rayTrace.getHitBlock();
|
||||||
height = Integer.parseInt(parts[1]);
|
BlockFace hitFace = rayTrace.getHitBlockFace();
|
||||||
} catch (Exception e) {
|
|
||||||
player.sendMessage("§8[§6Nexus§8] §cUngültiges Format (z.B. 6x4).");
|
if (hitFace == BlockFace.UP || hitFace == BlockFace.DOWN) {
|
||||||
return true;
|
player.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§cAktuell nur an vertikalen Wänden möglich.");
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
player.sendMessage("§8[§6Nexus§8] §7Bild wird verarbeitet...");
|
|
||||||
createRaster(player, targetBlock, hitFace, url, width, height);
|
String url = args[0];
|
||||||
|
int width, height;
|
||||||
return true;
|
try {
|
||||||
}
|
String[] parts = args[1].toLowerCase().split("x");
|
||||||
|
width = Integer.parseInt(parts[0]);
|
||||||
private void sendHelp(Player p) {
|
height = Integer.parseInt(parts[1]);
|
||||||
p.sendMessage("§8§m------------------------------------");
|
} catch (Exception e) {
|
||||||
p.sendMessage("§6§lNexus MapArt");
|
player.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§cUngültiges Format (z.B. 6x4).");
|
||||||
p.sendMessage("§e/mapart <URL> <BxH> §7- Bild erstellen");
|
return true;
|
||||||
p.sendMessage("§e/mapart delete [Radius] §7- Bilder in der Nähe löschen");
|
}
|
||||||
p.sendMessage("§8§m------------------------------------");
|
|
||||||
}
|
player.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§7Bild wird verarbeitet...");
|
||||||
|
createRaster(player, targetBlock, hitFace, url, width, height);
|
||||||
private void deleteNearbyMaps(Player player, int radius) {
|
|
||||||
AtomicInteger count = new AtomicInteger(0);
|
return true;
|
||||||
player.getNearbyEntities(radius, radius, radius).forEach(entity -> {
|
}
|
||||||
if (entity instanceof ItemFrame frame) {
|
|
||||||
ItemStack item = frame.getItem();
|
private void sendHelp(Player p) {
|
||||||
if (item != null && item.getType() == Material.FILLED_MAP && item.getItemMeta() instanceof MapMeta meta) {
|
p.sendMessage("§8§m------------------------------------");
|
||||||
if (meta.hasMapView()) {
|
p.sendMessage("§6§lNexus MapArt");
|
||||||
int id = meta.getMapView().getId();
|
p.sendMessage("§e/mapart <URL> <BxH> §7- Bild erstellen");
|
||||||
if (storageConfig.contains("active_maps." + id)) {
|
p.sendMessage("§e/mapart delete [Radius] §7- Bilder in der Nähe löschen");
|
||||||
storageConfig.set("active_maps." + id, null);
|
p.sendMessage("§8§m------------------------------------");
|
||||||
frame.remove();
|
}
|
||||||
count.incrementAndGet();
|
|
||||||
}
|
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();
|
||||||
saveStorage();
|
if (item != null && item.getType() == Material.FILLED_MAP && item.getItemMeta() instanceof MapMeta meta) {
|
||||||
player.sendMessage("§8[§6Nexus§8] §aErfolgreich §e" + count.get() + " §aKartenelemente gelöscht.");
|
if (meta.hasMapView()) {
|
||||||
}
|
int id = meta.getMapView().getId();
|
||||||
|
if (storageConfig.contains("active_maps." + id)) {
|
||||||
private void createRaster(Player player, Block startBlock, BlockFace face, String url, int gridW, int gridH) {
|
storageConfig.set("active_maps." + id, null);
|
||||||
BlockFace rightDirection;
|
frame.remove();
|
||||||
switch (face) {
|
count.incrementAndGet();
|
||||||
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;
|
});
|
||||||
}
|
saveStorage();
|
||||||
|
player.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§aErfolgreich §e" + count.get() + " §aKartenelemente gelöscht.");
|
||||||
Block origin = startBlock.getRelative(face);
|
}
|
||||||
|
|
||||||
for (int y = 0; y < gridH; y++) {
|
private void createRaster(Player player, Block startBlock, BlockFace face, String url, int gridW, int gridH) {
|
||||||
for (int x = 0; x < gridW; x++) {
|
BlockFace rightDirection;
|
||||||
Block currentPos = origin.getRelative(rightDirection, x).getRelative(BlockFace.DOWN, y);
|
switch (face) {
|
||||||
spawnPersistentFrame(player, currentPos, face, url, x, y, gridW, gridH);
|
case NORTH: rightDirection = BlockFace.WEST; break;
|
||||||
}
|
case SOUTH: rightDirection = BlockFace.EAST; break;
|
||||||
}
|
case EAST: rightDirection = BlockFace.NORTH; break;
|
||||||
player.sendMessage("§8[§6Nexus§8] §aBild-Raster wurde permanent platziert!");
|
case WEST: rightDirection = BlockFace.SOUTH; break;
|
||||||
}
|
default: rightDirection = BlockFace.EAST;
|
||||||
|
}
|
||||||
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());
|
Block origin = startBlock.getRelative(face);
|
||||||
applyRenderer(view, url, x, y, totalW, totalH);
|
|
||||||
|
for (int y = 0; y < gridH; y++) {
|
||||||
String path = "active_maps." + view.getId();
|
for (int x = 0; x < gridW; x++) {
|
||||||
storageConfig.set(path + ".url", url);
|
Block currentPos = origin.getRelative(rightDirection, x).getRelative(BlockFace.DOWN, y);
|
||||||
storageConfig.set(path + ".x", x);
|
spawnPersistentFrame(player, currentPos, face, url, x, y, gridW, gridH);
|
||||||
storageConfig.set(path + ".y", y);
|
}
|
||||||
storageConfig.set(path + ".totalW", totalW);
|
}
|
||||||
storageConfig.set(path + ".totalH", totalH);
|
player.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§aBild-Raster wurde permanent platziert!");
|
||||||
saveStorage();
|
}
|
||||||
|
|
||||||
ItemStack mapStack = new ItemStack(Material.FILLED_MAP);
|
private void spawnPersistentFrame(Player player, Block pos, BlockFace face, String url, int x, int y, int totalW, int totalH) {
|
||||||
MapMeta meta = (MapMeta) mapStack.getItemMeta();
|
MapView view = Bukkit.createMap(player.getWorld());
|
||||||
if (meta != null) {
|
applyRenderer(view, url, x, y, totalW, totalH);
|
||||||
meta.setMapView(view);
|
|
||||||
mapStack.setItemMeta(meta);
|
String path = "active_maps." + view.getId();
|
||||||
}
|
storageConfig.set(path + ".url", url);
|
||||||
|
storageConfig.set(path + ".x", x);
|
||||||
try {
|
storageConfig.set(path + ".y", y);
|
||||||
ItemFrame frame = player.getWorld().spawn(pos.getLocation(), ItemFrame.class);
|
storageConfig.set(path + ".totalW", totalW);
|
||||||
frame.setFacingDirection(face);
|
storageConfig.set(path + ".totalH", totalH);
|
||||||
frame.setItem(mapStack);
|
saveStorage();
|
||||||
frame.setVisible(false);
|
|
||||||
frame.setFixed(true);
|
ItemStack mapStack = new ItemStack(Material.FILLED_MAP);
|
||||||
} catch (Exception ignored) {}
|
MapMeta meta = (MapMeta) mapStack.getItemMeta();
|
||||||
}
|
if (meta != null) {
|
||||||
|
meta.setMapView(view);
|
||||||
private void applyRenderer(MapView view, String url, int tileX, int tileY, int totalW, int totalH) {
|
mapStack.setItemMeta(meta);
|
||||||
view.getRenderers().forEach(view::removeRenderer);
|
}
|
||||||
view.addRenderer(new MapRenderer() {
|
|
||||||
private final String cacheKey = url + "_" + totalW + "x" + totalH + "_" + tileX + "_" + tileY;
|
try {
|
||||||
private boolean errorLogged = false;
|
ItemFrame frame = player.getWorld().spawn(pos.getLocation(), ItemFrame.class);
|
||||||
|
frame.setFacingDirection(face);
|
||||||
@Override
|
frame.setItem(mapStack);
|
||||||
public void render(@NotNull MapView map, @NotNull MapCanvas canvas, @NotNull Player p) {
|
frame.setVisible(false);
|
||||||
// 1. Wenn Kachel im Cache, sofort zeichnen (extrem schnell)
|
frame.setFixed(true);
|
||||||
if (tileCache.containsKey(cacheKey)) {
|
} catch (Exception ignored) {}
|
||||||
canvas.drawImage(0, 0, tileCache.get(cacheKey));
|
}
|
||||||
return;
|
|
||||||
}
|
private void applyRenderer(MapView view, String url, int tileX, int tileY, int totalW, int totalH) {
|
||||||
|
view.getRenderers().forEach(view::removeRenderer);
|
||||||
// 2. Wenn bereits ein Thread für diese URL lädt, abbrechen (verhindert Spam)
|
view.addRenderer(new MapRenderer() {
|
||||||
if (loadingShield.containsKey(url)) return;
|
private final String cacheKey = url + "_" + totalW + "x" + totalH + "_" + tileX + "_" + tileY;
|
||||||
|
private boolean errorLogged = false;
|
||||||
// 3. Bild asynchron laden
|
|
||||||
loadingShield.put(url, true);
|
@Override
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(NexusLobby.getInstance(), () -> {
|
public void render(@NotNull MapView map, @NotNull MapCanvas canvas, @NotNull Player p) {
|
||||||
try {
|
// 1. Wenn Kachel im Cache, sofort zeichnen (extrem schnell)
|
||||||
BufferedImage original = ImageIO.read(new URL(url));
|
if (tileCache.containsKey(cacheKey)) {
|
||||||
if (original != null) {
|
canvas.drawImage(0, 0, tileCache.get(cacheKey));
|
||||||
int targetW = totalW * 128;
|
return;
|
||||||
int targetH = totalH * 128;
|
}
|
||||||
|
|
||||||
BufferedImage fullScaled = new BufferedImage(targetW, targetH, BufferedImage.TYPE_INT_ARGB);
|
// 2. Wenn bereits ein Thread für diese URL lädt, abbrechen (verhindert Spam)
|
||||||
Graphics2D g = fullScaled.createGraphics();
|
if (loadingShield.containsKey(url)) return;
|
||||||
g.drawImage(original.getScaledInstance(targetW, targetH, Image.SCALE_SMOOTH), 0, 0, null);
|
|
||||||
g.dispose();
|
// 3. Bild asynchron laden
|
||||||
|
loadingShield.put(url, true);
|
||||||
// Alle benötigten Kacheln für dieses Bild in den Cache legen
|
Bukkit.getScheduler().runTaskAsynchronously(NexusLobby.getInstance(), () -> {
|
||||||
for (int ty = 0; ty < totalH; ty++) {
|
try {
|
||||||
for (int tx = 0; tx < totalW; tx++) {
|
BufferedImage original = ImageIO.read(new URL(url));
|
||||||
String key = url + "_" + totalW + "x" + totalH + "_" + tx + "_" + ty;
|
if (original != null) {
|
||||||
tileCache.put(key, fullScaled.getSubimage(tx * 128, ty * 128, 128, 128));
|
int targetW = totalW * 128;
|
||||||
}
|
int targetH = totalH * 128;
|
||||||
}
|
|
||||||
}
|
BufferedImage fullScaled = new BufferedImage(targetW, targetH, BufferedImage.TYPE_INT_ARGB);
|
||||||
} catch (Exception e) {
|
Graphics2D g = fullScaled.createGraphics();
|
||||||
if (!errorLogged) {
|
g.drawImage(original.getScaledInstance(targetW, targetH, Image.SCALE_SMOOTH), 0, 0, null);
|
||||||
NexusLobby.getInstance().getLogger().warning("Fehler beim Laden von MapArt: " + url);
|
g.dispose();
|
||||||
errorLogged = true;
|
|
||||||
}
|
// Alle benötigten Kacheln für dieses Bild in den Cache legen
|
||||||
} finally {
|
for (int ty = 0; ty < totalH; ty++) {
|
||||||
loadingShield.remove(url);
|
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;
|
package de.nexuslobby.modules.parkour;
|
||||||
|
|
||||||
import de.nexuslobby.NexusLobby;
|
import de.nexuslobby.NexusLobby;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.entity.ArmorStand;
|
import org.bukkit.entity.ArmorStand;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
|
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
|
||||||
import org.bukkit.event.player.PlayerMoveEvent;
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class ParkourListener implements Listener {
|
public class ParkourListener implements Listener {
|
||||||
|
|
||||||
private final ParkourManager manager;
|
private final ParkourManager manager;
|
||||||
private final String NPC_TAG = "parkour_npc";
|
private final String NPC_TAG = "parkour_npc";
|
||||||
private final HashMap<UUID, Long> startCooldown = new HashMap<>();
|
private final HashMap<UUID, Long> startCooldown = new HashMap<>();
|
||||||
|
|
||||||
public ParkourListener(ParkourManager manager) {
|
public ParkourListener(ParkourManager manager) {
|
||||||
this.manager = manager;
|
this.manager = manager;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@EventHandler
|
||||||
* Startet den Parkour per Rechtsklick auf den ArmorStand
|
public void onInteract(PlayerInteractAtEntityEvent event) {
|
||||||
*/
|
if (!(event.getRightClicked() instanceof ArmorStand as)) return;
|
||||||
@EventHandler
|
if (!as.getScoreboardTags().contains(NPC_TAG)) return;
|
||||||
public void onInteract(PlayerInteractAtEntityEvent event) {
|
|
||||||
if (!(event.getRightClicked() instanceof ArmorStand as)) return;
|
Player player = event.getPlayer();
|
||||||
|
event.setCancelled(true);
|
||||||
// Prüfen, ob der ArmorStand den richtigen Tag hat
|
|
||||||
if (as.getScoreboardTags().contains(NPC_TAG)) {
|
if (manager.isIngame(player)) return;
|
||||||
Player player = event.getPlayer();
|
|
||||||
|
// Cooldown-Check (3 Sekunden)
|
||||||
// Abbrechen, wenn der Spieler schon im Parkour ist
|
if (startCooldown.containsKey(player.getUniqueId())) {
|
||||||
if (manager.isIngame(player)) return;
|
if (System.currentTimeMillis() - startCooldown.get(player.getUniqueId()) < 3000) {
|
||||||
|
player.sendMessage("§cBitte warte einen Moment, bevor du erneut startest.");
|
||||||
// Cooldown-Check (3 Sekunden)
|
return;
|
||||||
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) {
|
||||||
// Parkour starten
|
player.sendMessage("§8[§6Parkour§8] §eViel Erfolg auf §bStrecke " + track + "§e! Erreiche das Ziel so schnell wie möglich.");
|
||||||
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);
|
||||||
player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1f, 1f);
|
}
|
||||||
|
|
||||||
// Event abbrechen, damit man keine Ausrüstung vom ArmorStand klaut
|
@EventHandler
|
||||||
event.setCancelled(true);
|
public void onMove(PlayerMoveEvent event) {
|
||||||
}
|
// Performance: Nur bei Block-Wechsel berechnen
|
||||||
}
|
if (event.getFrom().getBlockX() == event.getTo().getBlockX() &&
|
||||||
|
event.getFrom().getBlockY() == event.getTo().getBlockY() &&
|
||||||
@EventHandler
|
event.getFrom().getBlockZ() == event.getTo().getBlockZ()) return;
|
||||||
public void onMove(PlayerMoveEvent event) {
|
|
||||||
// Performance: Nur berechnen, wenn ein voller Block gewechselt wurde
|
Player player = event.getPlayer();
|
||||||
if (event.getFrom().getBlockX() == event.getTo().getBlockX() &&
|
if (!manager.isIngame(player)) return;
|
||||||
event.getFrom().getBlockY() == event.getTo().getBlockY() &&
|
|
||||||
event.getFrom().getBlockZ() == event.getTo().getBlockZ()) return;
|
Location loc = player.getLocation();
|
||||||
|
|
||||||
Player player = event.getPlayer();
|
// --- 1. ABSTURZ-CHECK ---
|
||||||
if (!manager.isIngame(player)) return;
|
// 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);
|
||||||
Location loc = player.getLocation();
|
if (loc.getY() < fallY) {
|
||||||
|
Location lastCp = manager.getCheckpoint(player);
|
||||||
// --- 1. ABSTURZ-CHECK ---
|
if (lastCp != null) {
|
||||||
// Passe die Höhe '50' an deine Map an!
|
player.teleport(lastCp);
|
||||||
if (loc.getY() < 50) {
|
player.sendMessage("§8[§6Parkour§8] §cAbgestürzt! Zurück zum Checkpoint.");
|
||||||
Location lastCp = manager.getCheckpoint(player);
|
player.playSound(player.getLocation(), Sound.ENTITY_ENDERMAN_TELEPORT, 0.5f, 1.0f);
|
||||||
if (lastCp != null) {
|
}
|
||||||
player.teleport(lastCp);
|
return;
|
||||||
player.sendMessage("§8[§6Parkour§8] §cAbgestürzt! Zurück zum Checkpoint.");
|
}
|
||||||
player.playSound(player.getLocation(), Sound.ENTITY_ENDERMAN_TELEPORT, 0.5f, 1.0f);
|
|
||||||
}
|
// --- 2. CHECKPOINT-CHECK (Track-spezifisch) ---
|
||||||
return;
|
List<Location> cps = manager.getOrderedCheckpoints(player);
|
||||||
}
|
for (int i = 0; i < cps.size(); i++) {
|
||||||
|
if (isNearby(loc, cps.get(i))) {
|
||||||
// --- 2. CHECKPOINT-CHECK ---
|
manager.reachCheckpoint(player, i);
|
||||||
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 (Track-spezifisch) ---
|
||||||
}
|
Location finish = manager.getFinishLocation(player);
|
||||||
}
|
if (finish != null && isNearby(loc, finish)) {
|
||||||
|
manager.finishParkour(player);
|
||||||
// --- 3. ZIEL-CHECK ---
|
startCooldown.put(player.getUniqueId(), System.currentTimeMillis());
|
||||||
Location finish = manager.getFinishLocation();
|
}
|
||||||
if (finish != null && isNearby(loc, finish)) {
|
}
|
||||||
manager.finishParkour(player);
|
|
||||||
// Nach dem Ziel setzen wir einen Cooldown
|
private boolean isNearby(Location playerLoc, Location targetLoc) {
|
||||||
startCooldown.put(player.getUniqueId(), System.currentTimeMillis());
|
if (playerLoc.getWorld() == null || !playerLoc.getWorld().equals(targetLoc.getWorld())) return false;
|
||||||
}
|
return playerLoc.distanceSquared(targetLoc) <= 2.25; // ~1.5 Blöcke Radius
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isNearby(Location playerLoc, Location targetLoc) {
|
@EventHandler
|
||||||
if (playerLoc.getWorld() == null || !playerLoc.getWorld().equals(targetLoc.getWorld())) return false;
|
public void onQuit(PlayerQuitEvent event) {
|
||||||
// 2.25 entspricht einem Radius von ca. 1.5 Blöcken
|
UUID uuid = event.getPlayer().getUniqueId();
|
||||||
return playerLoc.distanceSquared(targetLoc) <= 2.25;
|
manager.stopParkour(event.getPlayer());
|
||||||
}
|
startCooldown.remove(uuid);
|
||||||
|
}
|
||||||
@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;
|
package de.nexuslobby.modules.parkour;
|
||||||
|
|
||||||
import de.nexuslobby.NexusLobby;
|
import de.nexuslobby.NexusLobby;
|
||||||
import net.md_5.bungee.api.ChatMessageType;
|
import net.md_5.bungee.api.ChatMessageType;
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Particle;
|
import org.bukkit.Particle;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class ParkourManager {
|
/**
|
||||||
|
* ParkourManager – unterstützt zwei Strecken (Track 1 & 2).
|
||||||
private final NexusLobby plugin;
|
*
|
||||||
private final File file;
|
* Config-Struktur (parkour.yml):
|
||||||
private FileConfiguration config;
|
* tracks:
|
||||||
|
* 1:
|
||||||
private final Map<UUID, Long> startTime = new HashMap<>();
|
* start: <Location>
|
||||||
private final Map<UUID, Location> lastCheckpointLoc = new HashMap<>();
|
* finish: <Location>
|
||||||
private final Map<UUID, Integer> nextCheckpointIndex = new HashMap<>();
|
* checkpoints:
|
||||||
|
* 1: <Location>
|
||||||
public ParkourManager(NexusLobby plugin) {
|
* 2: <Location>
|
||||||
this.plugin = plugin;
|
* ...
|
||||||
this.file = new File(plugin.getDataFolder(), "parkour.yml");
|
* 2:
|
||||||
loadConfig();
|
* start: <Location>
|
||||||
startParticleTask();
|
* finish: <Location>
|
||||||
}
|
* checkpoints:
|
||||||
|
* 1: <Location>
|
||||||
private void loadConfig() {
|
* ...
|
||||||
if (!file.exists()) {
|
* besttimes:
|
||||||
file.getParentFile().mkdirs();
|
* <uuid>: <seconds>
|
||||||
try {
|
* names:
|
||||||
file.createNewFile();
|
* <uuid>: <playerName>
|
||||||
} catch (IOException e) {
|
*
|
||||||
plugin.getLogger().severe("Fehler beim Erstellen der Parkour-Datei: " + e.getMessage());
|
* 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.
|
||||||
config = YamlConfiguration.loadConfiguration(file);
|
*/
|
||||||
}
|
public class ParkourManager {
|
||||||
|
|
||||||
public void setCheckpoint(Player player, Location loc) {
|
private final NexusLobby plugin;
|
||||||
int nextId = 1;
|
private final File file;
|
||||||
if (config.contains("locations.checkpoints") && config.getConfigurationSection("locations.checkpoints") != null) {
|
private FileConfiguration config;
|
||||||
nextId = config.getConfigurationSection("locations.checkpoints").getKeys(false).size() + 1;
|
|
||||||
}
|
// Aktive Läufe
|
||||||
|
private final Map<UUID, Long> startTime = new HashMap<>();
|
||||||
addCheckpointLocation(String.valueOf(nextId), loc);
|
private final Map<UUID, Location> lastCheckpointLoc = new HashMap<>();
|
||||||
player.sendMessage("§8[§6Parkour§8] §7Checkpoint §e#" + nextId + " §7an deiner Position gesetzt.");
|
private final Map<UUID, Integer> nextCheckpointIndex= new HashMap<>();
|
||||||
player.playSound(player.getLocation(), Sound.BLOCK_AMETHYST_BLOCK_CHIME, 1.0f, 1.5f);
|
/** 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();
|
||||||
* Löscht die gesamte Strecke (Checkpoints und Ziel) und bricht aktuelle Läufe ab.
|
|
||||||
*/
|
public ParkourManager(NexusLobby plugin) {
|
||||||
public void removeAllPoints() {
|
this.plugin = plugin;
|
||||||
config.set("locations.checkpoints", null);
|
this.file = new File(plugin.getDataFolder(), "parkour.yml");
|
||||||
config.set("locations.finish", null);
|
loadConfig();
|
||||||
save();
|
migrateLegacyBestTimes();
|
||||||
|
startParticleTask();
|
||||||
// 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) {
|
// Config I/O
|
||||||
stopParkour(p);
|
// ─────────────────────────────────────────────────────────────────────────
|
||||||
p.sendMessage("§8[§6Parkour§8] §cDie aktuelle Strecke wurde soeben gelöscht.");
|
|
||||||
}
|
private void loadConfig() {
|
||||||
}
|
if (!file.exists()) {
|
||||||
}
|
file.getParentFile().mkdirs();
|
||||||
|
try {
|
||||||
public void startParkour(Player player, Location startLoc) {
|
file.createNewFile();
|
||||||
if (startTime.containsKey(player.getUniqueId())) return;
|
} catch (IOException e) {
|
||||||
|
plugin.getLogger().severe("Fehler beim Erstellen der Parkour-Datei: " + e.getMessage());
|
||||||
startTime.put(player.getUniqueId(), System.currentTimeMillis());
|
}
|
||||||
lastCheckpointLoc.put(player.getUniqueId(), startLoc);
|
}
|
||||||
nextCheckpointIndex.put(player.getUniqueId(), 0);
|
config = YamlConfiguration.loadConfiguration(file);
|
||||||
|
}
|
||||||
player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_CHIME, 1.0f, 1.2f);
|
|
||||||
|
/**
|
||||||
new BukkitRunnable() {
|
* Migriert Bestzeiten vom alten Format (besttimes.<uuid>) ins neue Format
|
||||||
@Override
|
* (besttimes.<track>.<uuid>). Alte Zeiten werden Track 1 zugeordnet, da vor
|
||||||
public void run() {
|
* dieser Änderung nur ein Track existierte.
|
||||||
if (!isIngame(player) || !player.isOnline()) {
|
* Läuft einmalig beim Start; tut nichts wenn keine alten Daten vorhanden sind.
|
||||||
this.cancel();
|
*/
|
||||||
return;
|
private void migrateLegacyBestTimes() {
|
||||||
}
|
if (!config.contains("besttimes")) return;
|
||||||
long diff = System.currentTimeMillis() - startTime.get(player.getUniqueId());
|
|
||||||
double sec = diff / 1000.0;
|
// Prüfen ob es direkte UUID-Keys unter besttimes gibt (altes Format)
|
||||||
player.spigot().sendMessage(ChatMessageType.ACTION_BAR,
|
// Im neuen Format wären hier nur "1" und "2" als Keys
|
||||||
new TextComponent("§6⏱ Zeit: §e" + String.format("%.2f", sec) + "s §8| §bNächster Punkt: §7Partikel folgen"));
|
var section = config.getConfigurationSection("besttimes");
|
||||||
}
|
if (section == null) return;
|
||||||
}.runTaskTimer(plugin, 0L, 1L);
|
|
||||||
}
|
int migrated = 0;
|
||||||
|
for (String key : new java.util.HashSet<>(section.getKeys(false))) {
|
||||||
private void startParticleTask() {
|
// Neue Keys sind "1" oder "2" – alte Keys sind UUID-Strings (36 Zeichen, enthalten "-")
|
||||||
new BukkitRunnable() {
|
if (!key.equals("1") && !key.equals("2") && key.contains("-")) {
|
||||||
@Override
|
double time = config.getDouble("besttimes." + key);
|
||||||
public void run() {
|
// Nur migrieren wenn unter besttimes.1.<uuid> noch kein besserer Wert steht
|
||||||
for (UUID uuid : startTime.keySet()) {
|
String newPath = "besttimes.1." + key;
|
||||||
Player p = Bukkit.getPlayer(uuid);
|
double existingTime = config.getDouble(newPath, 99999.9);
|
||||||
if (p == null) continue;
|
if (time < existingTime) {
|
||||||
|
config.set(newPath, time);
|
||||||
int nextIdx = nextCheckpointIndex.getOrDefault(uuid, 0);
|
}
|
||||||
List<Location> cps = getOrderedCheckpoints();
|
// Alten Key entfernen
|
||||||
|
config.set("besttimes." + key, null);
|
||||||
if (nextIdx < cps.size()) {
|
migrated++;
|
||||||
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);
|
|
||||||
}
|
if (migrated > 0) {
|
||||||
} else {
|
save();
|
||||||
Location finish = getFinishLocation();
|
plugin.getLogger().info("[Parkour] Migration: " + migrated
|
||||||
if (finish != null && p.getWorld().equals(finish.getWorld())) {
|
+ " Bestzeit(en) von altem Format nach Strecke 1 übertragen.");
|
||||||
p.spawnParticle(Particle.HAPPY_VILLAGER, finish.clone().add(0, 0.5, 0), 8, 0.2, 0.5, 0.2, 0.02);
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
private void save() {
|
||||||
}
|
try {
|
||||||
}.runTaskTimer(plugin, 0L, 6L);
|
config.save(file);
|
||||||
}
|
} catch (IOException e) {
|
||||||
|
plugin.getLogger().severe("Fehler beim Speichern der Parkour-Config: " + e.getMessage());
|
||||||
public void reachCheckpoint(Player player, int reachedIndex) {
|
}
|
||||||
int currentNext = nextCheckpointIndex.getOrDefault(player.getUniqueId(), 0);
|
}
|
||||||
|
|
||||||
if (reachedIndex == currentNext) {
|
// ─────────────────────────────────────────────────────────────────────────
|
||||||
List<Location> cps = getOrderedCheckpoints();
|
// Setup-Befehle (Admin)
|
||||||
if (reachedIndex < cps.size()) {
|
// ─────────────────────────────────────────────────────────────────────────
|
||||||
lastCheckpointLoc.put(player.getUniqueId(), cps.get(reachedIndex));
|
|
||||||
nextCheckpointIndex.put(player.getUniqueId(), reachedIndex + 1);
|
public void setStartLocation(Player player, int track) {
|
||||||
|
config.set("tracks." + track + ".start", player.getLocation());
|
||||||
player.sendMessage("§8[§6Parkour§8] §bCheckpoint #" + (reachedIndex + 1) + " erreicht!");
|
save();
|
||||||
player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 0.8f, 1.5f);
|
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());
|
||||||
public void finishParkour(Player player) {
|
save();
|
||||||
if (!startTime.containsKey(player.getUniqueId())) return;
|
player.sendMessage("§8[§6Parkour§8] §7Ziel von §eStrecke " + track + " §7an deiner Position gesetzt.");
|
||||||
|
}
|
||||||
if (nextCheckpointIndex.getOrDefault(player.getUniqueId(), 0) < getOrderedCheckpoints().size()) {
|
|
||||||
player.sendMessage("§cDu hast Checkpoints übersprungen! Folge den Partikeln.");
|
public void setCheckpoint(Player player, int track) {
|
||||||
return;
|
String cpBase = "tracks." + track + ".checkpoints";
|
||||||
}
|
int nextId = 1;
|
||||||
|
if (config.contains(cpBase) && config.getConfigurationSection(cpBase) != null) {
|
||||||
long duration = System.currentTimeMillis() - startTime.get(player.getUniqueId());
|
nextId = config.getConfigurationSection(cpBase).getKeys(false).size() + 1;
|
||||||
double seconds = duration / 1000.0;
|
}
|
||||||
|
config.set(cpBase + "." + nextId, player.getLocation());
|
||||||
player.sendMessage("§8§m--------------------------------------");
|
save();
|
||||||
player.sendMessage("§8[§6Parkour§8] §a§lZiel erreicht!");
|
player.sendMessage("§8[§6Parkour§8] §7Checkpoint §e#" + nextId + " §7(Strecke " + track + ") §7gesetzt.");
|
||||||
player.sendMessage("§7Deine Zeit: §e" + String.format("%.2f", seconds) + "s");
|
player.playSound(player.getLocation(), Sound.BLOCK_AMETHYST_BLOCK_CHIME, 1.0f, 1.5f);
|
||||||
player.sendMessage("§8§m--------------------------------------");
|
}
|
||||||
|
|
||||||
player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1.0f, 1.0f);
|
/**
|
||||||
|
* Löscht alle Punkte beider Strecken und bricht laufende Runs ab.
|
||||||
saveBestTime(player, seconds);
|
*/
|
||||||
stopParkour(player);
|
public void removeAllPoints() {
|
||||||
}
|
config.set("tracks", null);
|
||||||
|
save();
|
||||||
public void stopParkour(Player player) {
|
for (UUID uuid : new HashSet<>(startTime.keySet())) {
|
||||||
startTime.remove(player.getUniqueId());
|
Player p = Bukkit.getPlayer(uuid);
|
||||||
lastCheckpointLoc.remove(player.getUniqueId());
|
if (p != null) {
|
||||||
nextCheckpointIndex.remove(player.getUniqueId());
|
stopParkour(p);
|
||||||
}
|
p.sendMessage("§8[§6Parkour§8] §cDie Strecken wurden soeben gelöscht.");
|
||||||
|
}
|
||||||
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"); }
|
// Getter (Track-spezifisch)
|
||||||
public Location getFinishLocation() { return config.getLocation("locations.finish"); }
|
// ─────────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
public List<Location> getOrderedCheckpoints() {
|
public Location getStartLocation(int track) {
|
||||||
if (!config.contains("locations.checkpoints") || config.getConfigurationSection("locations.checkpoints") == null)
|
return config.getLocation("tracks." + track + ".start");
|
||||||
return new ArrayList<>();
|
}
|
||||||
|
|
||||||
return config.getConfigurationSection("locations.checkpoints").getKeys(false).stream()
|
public Location getFinishLocation(int track) {
|
||||||
.sorted(Comparator.comparingInt(Integer::parseInt))
|
return config.getLocation("tracks." + track + ".finish");
|
||||||
.map(key -> config.getLocation("locations.checkpoints." + key))
|
}
|
||||||
.filter(Objects::nonNull)
|
|
||||||
.collect(Collectors.toList());
|
public List<Location> getOrderedCheckpoints(int track) {
|
||||||
}
|
String cpBase = "tracks." + track + ".checkpoints";
|
||||||
|
if (!config.contains(cpBase) || config.getConfigurationSection(cpBase) == null)
|
||||||
private void save() {
|
return new ArrayList<>();
|
||||||
try {
|
|
||||||
config.save(file);
|
return config.getConfigurationSection(cpBase).getKeys(false).stream()
|
||||||
} catch (IOException e) {
|
.sorted(Comparator.comparingInt(Integer::parseInt))
|
||||||
plugin.getLogger().severe("Fehler beim Speichern der Parkour-Config: " + e.getMessage());
|
.map(key -> config.getLocation(cpBase + "." + key))
|
||||||
}
|
.filter(Objects::nonNull)
|
||||||
}
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
public void clearStats() {
|
|
||||||
config.set("besttimes", null);
|
/**
|
||||||
config.set("names", null);
|
* Gibt die aktive Track-Nummer des Spielers zurück (1 oder 2), oder -1 wenn nicht aktiv.
|
||||||
save();
|
*/
|
||||||
}
|
public int getActiveTrack(Player player) {
|
||||||
|
return activeTrack.getOrDefault(player.getUniqueId(), -1);
|
||||||
public boolean isIngame(Player player) { return startTime.containsKey(player.getUniqueId()); }
|
}
|
||||||
public Location getCheckpoint(Player player) { return lastCheckpointLoc.get(player.getUniqueId()); }
|
|
||||||
|
// Convenience-Wrapper für ParkourListener (nutzt den aktiven Track des Spielers)
|
||||||
private void saveBestTime(Player player, double time) {
|
public List<Location> getOrderedCheckpoints(Player player) {
|
||||||
String path = "besttimes." + player.getUniqueId();
|
return getOrderedCheckpoints(getActiveTrack(player));
|
||||||
double currentTime = config.getDouble(path, 99999.9);
|
}
|
||||||
if (time < currentTime) {
|
|
||||||
config.set(path, time);
|
public Location getFinishLocation(Player player) {
|
||||||
config.set("names." + player.getUniqueId(), player.getName());
|
return getFinishLocation(getActiveTrack(player));
|
||||||
save();
|
}
|
||||||
player.sendMessage("§8[§6Parkour§8] §6§lNeuer Rekord! §7Du hast dich verbessert.");
|
|
||||||
}
|
// ─────────────────────────────────────────────────────────────────────────
|
||||||
}
|
// Parkour-Ablauf
|
||||||
|
// ─────────────────────────────────────────────────────────────────────────
|
||||||
public String getTopTen() {
|
|
||||||
if (!config.contains("besttimes") || config.getConfigurationSection("besttimes") == null)
|
/**
|
||||||
return "§6§l🏆 TOP 10 PARKOUR 🏆\n§7Noch keine Rekorde.";
|
* Startet den Parkour für den Spieler.
|
||||||
|
* Es wird zufällig eine der beiden Strecken gewählt, sofern beide vollständig
|
||||||
Map<String, Double> allTimes = new HashMap<>();
|
* konfiguriert sind (Start + Finish + mindestens gleiche Checkpoint-Anzahl).
|
||||||
for (String uuidStr : config.getConfigurationSection("besttimes").getKeys(false)) {
|
* Falls nur eine Strecke konfiguriert ist, wird diese gewählt.
|
||||||
allTimes.put(uuidStr, config.getDouble("besttimes." + uuidStr));
|
*/
|
||||||
}
|
public void startParkour(Player player, Location npcLocation) {
|
||||||
|
if (startTime.containsKey(player.getUniqueId())) return;
|
||||||
List<Map.Entry<String, Double>> sortedList = allTimes.entrySet().stream()
|
|
||||||
.sorted(Map.Entry.comparingByValue())
|
int chosenTrack = pickRandomTrack();
|
||||||
.limit(10)
|
if (chosenTrack == -1) {
|
||||||
.toList();
|
player.sendMessage("§8[§6Parkour§8] §cKeine Strecke konfiguriert. Bitte einen Admin kontaktieren.");
|
||||||
|
return;
|
||||||
StringBuilder builder = new StringBuilder("§6§l🏆 TOP 10 PARKOUR 🏆");
|
}
|
||||||
int rank = 1;
|
|
||||||
for (Map.Entry<String, Double> entry : sortedList) {
|
startTime.put(player.getUniqueId(), System.currentTimeMillis());
|
||||||
String name = config.getString("names." + entry.getKey(), "Unbekannt");
|
lastCheckpointLoc.put(player.getUniqueId(), npcLocation);
|
||||||
builder.append("\n§e#").append(rank).append(" §f").append(name).append(" §8» §a").append(String.format("%.2f", entry.getValue())).append("s");
|
nextCheckpointIndex.put(player.getUniqueId(), 0);
|
||||||
rank++;
|
activeTrack.put(player.getUniqueId(), chosenTrack);
|
||||||
}
|
|
||||||
return builder.toString();
|
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;
|
package de.nexuslobby.modules.player;
|
||||||
|
|
||||||
import de.nexuslobby.NexusLobby;
|
import de.nexuslobby.NexusLobby;
|
||||||
import de.nexuslobby.api.Module;
|
import de.nexuslobby.api.Module;
|
||||||
import me.clip.placeholderapi.PlaceholderAPI;
|
import me.clip.placeholderapi.PlaceholderAPI;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Statistic;
|
import org.bukkit.Statistic;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.bukkit.inventory.meta.SkullMeta;
|
import org.bukkit.inventory.meta.SkullMeta;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Modul zur Inspektion von Spielern in der Lobby.
|
* Modul zur Inspektion von Spielern in der Lobby.
|
||||||
* Zeigt detaillierte Statistiken in einer interaktiven GUI an.
|
* Zeigt detaillierte Statistiken in einer interaktiven GUI an.
|
||||||
*/
|
*/
|
||||||
public class PlayerInspectModule implements Module, Listener {
|
public class PlayerInspectModule implements Module, Listener {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "PlayerInspect";
|
return "PlayerInspect";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
Bukkit.getPluginManager().registerEvents(this, NexusLobby.getInstance());
|
Bukkit.getPluginManager().registerEvents(this, NexusLobby.getInstance());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {}
|
public void onDisable() {
|
||||||
|
org.bukkit.event.HandlerList.unregisterAll(this);
|
||||||
@EventHandler
|
}
|
||||||
public void onPlayerInteract(PlayerInteractEntityEvent event) {
|
|
||||||
// Prüfen, ob ein Spieler rechtsgeklickt wurde
|
@EventHandler
|
||||||
if (event.getRightClicked() instanceof Player target) {
|
public void onPlayerInteract(PlayerInteractEntityEvent event) {
|
||||||
Player viewer = event.getPlayer();
|
// Prüfen, ob ein Spieler rechtsgeklickt wurde
|
||||||
|
if (event.getRightClicked() instanceof Player target) {
|
||||||
// GUI nur öffnen, wenn die Hand leer ist (verhindert Konflikte mit Items)
|
Player viewer = event.getPlayer();
|
||||||
if (viewer.getInventory().getItemInMainHand().getType() == Material.AIR) {
|
|
||||||
openDetailedInspectGUI(viewer, target);
|
// 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
|
@EventHandler
|
||||||
if (event.getView().getTitle().contains("Statistiken")) {
|
public void onInventoryClick(InventoryClickEvent event) {
|
||||||
event.setCancelled(true); // Verhindert, dass Items herausgenommen werden
|
// Sicherstellen, dass es unser Statistik-Inventar ist anhand des Titels
|
||||||
|
if (event.getView().getTitle().contains("Statistiken")) {
|
||||||
ItemStack clickedItem = event.getCurrentItem();
|
event.setCancelled(true); // Verhindert, dass Items herausgenommen werden
|
||||||
if (clickedItem == null || clickedItem.getType() == Material.AIR) return;
|
|
||||||
|
ItemStack clickedItem = event.getCurrentItem();
|
||||||
// Logik für den Schließen-Button (Barriere)
|
if (clickedItem == null || clickedItem.getType() == Material.AIR) return;
|
||||||
if (clickedItem.getType() == Material.BARRIER) {
|
|
||||||
event.getWhoClicked().closeInventory();
|
// 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();
|
public void openDetailedInspectGUI(Player viewer, Player target) {
|
||||||
Inventory gui = Bukkit.createInventory(null, 45, title);
|
// Titel mit Farbcodes
|
||||||
|
String title = "§8» §3Statistiken: §b" + target.getName();
|
||||||
// --- Design: Hintergrund mit Glasscheiben füllen ---
|
Inventory gui = Bukkit.createInventory(null, 45, title);
|
||||||
ItemStack separator = createSimpleItem(Material.GRAY_STAINED_GLASS_PANE, " ");
|
|
||||||
int[] borderSlots = {
|
// --- Design: Hintergrund mit Glasscheiben füllen ---
|
||||||
0,1,2,3,4,5,6,7,8,
|
ItemStack separator = createSimpleItem(Material.GRAY_STAINED_GLASS_PANE, " ");
|
||||||
9,17,
|
int[] borderSlots = {
|
||||||
18,26,
|
0,1,2,3,4,5,6,7,8,
|
||||||
27,35,
|
9,17,
|
||||||
36,37,38,39,41,42,43,44
|
18,26,
|
||||||
};
|
27,35,
|
||||||
for (int slot : borderSlots) gui.setItem(slot, separator);
|
36,37,38,39,41,42,43,44
|
||||||
|
};
|
||||||
// --- Kopf des Spielers mit LuckPerms Prefix via PAPI ---
|
for (int slot : borderSlots) gui.setItem(slot, separator);
|
||||||
ItemStack head = new ItemStack(Material.PLAYER_HEAD);
|
|
||||||
SkullMeta headMeta = (SkullMeta) head.getItemMeta();
|
// --- Kopf des Spielers mit LuckPerms Prefix via PAPI ---
|
||||||
if (headMeta != null) {
|
ItemStack head = new ItemStack(Material.PLAYER_HEAD);
|
||||||
headMeta.setOwningPlayer(target);
|
SkullMeta headMeta = (SkullMeta) head.getItemMeta();
|
||||||
headMeta.setDisplayName("§e§l" + target.getName());
|
if (headMeta != null) {
|
||||||
|
headMeta.setOwningPlayer(target);
|
||||||
List<String> lore = new ArrayList<>();
|
headMeta.setDisplayName("§e§l" + target.getName());
|
||||||
lore.add("§8§m-----------------------");
|
|
||||||
|
List<String> lore = new ArrayList<>();
|
||||||
// LuckPerms Prefix über PlaceholderAPI auslesen (falls vorhanden)
|
lore.add("§8§m-----------------------");
|
||||||
String prefix = "%luckperms_prefix%";
|
|
||||||
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
|
// LuckPerms Prefix über PlaceholderAPI auslesen (falls vorhanden)
|
||||||
try {
|
String prefix = "%luckperms_prefix%";
|
||||||
prefix = PlaceholderAPI.setPlaceholders(target, prefix);
|
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
|
||||||
} catch (NoClassDefFoundError ignored) {
|
try {
|
||||||
// PlaceholderAPI fehlt zur Laufzeit
|
prefix = PlaceholderAPI.setPlaceholders(target, prefix);
|
||||||
}
|
} catch (NoClassDefFoundError ignored) {
|
||||||
}
|
// PlaceholderAPI fehlt zur Laufzeit
|
||||||
|
}
|
||||||
// KORREKTUR: Farbcodes (&) in echte Minecraft-Farben (§) umwandeln
|
}
|
||||||
prefix = ChatColor.translateAlternateColorCodes('&', prefix);
|
|
||||||
|
// KORREKTUR: Farbcodes (&) in echte Minecraft-Farben (§) umwandeln
|
||||||
lore.add("§7Rang: " + (prefix.isEmpty() ? "§fSpieler" : prefix));
|
prefix = ChatColor.translateAlternateColorCodes('&', prefix);
|
||||||
lore.add("§7Level: §a" + target.getLevel());
|
|
||||||
lore.add("§7Status: §aOnline");
|
lore.add("§7Rang: " + (prefix.isEmpty() ? "§fSpieler" : prefix));
|
||||||
lore.add("§8§m-----------------------");
|
lore.add("§7Level: §a" + target.getLevel());
|
||||||
|
lore.add("§7Status: §aOnline");
|
||||||
headMeta.setLore(lore);
|
lore.add("§8§m-----------------------");
|
||||||
head.setItemMeta(headMeta);
|
|
||||||
}
|
headMeta.setLore(lore);
|
||||||
gui.setItem(4, head);
|
head.setItemMeta(headMeta);
|
||||||
|
}
|
||||||
// --- Statistik Kategorie: KAMPF (Slot 19) ---
|
gui.setItem(4, head);
|
||||||
gui.setItem(19, createStatsItem(Material.DIAMOND_SWORD, "§c§lKampf-Statistiken",
|
|
||||||
"§8» §7Spieler-Kills: §f" + target.getStatistic(Statistic.PLAYER_KILLS),
|
// --- Statistik Kategorie: KAMPF (Slot 19) ---
|
||||||
"§8» §7Mob-Kills: §f" + target.getStatistic(Statistic.MOB_KILLS),
|
gui.setItem(19, createStatsItem(Material.DIAMOND_SWORD, "§c§lKampf-Statistiken",
|
||||||
"§8» §7Tode gesamt: §f" + target.getStatistic(Statistic.DEATHS),
|
"§8» §7Spieler-Kills: §f" + target.getStatistic(Statistic.PLAYER_KILLS),
|
||||||
"§8» §7Schaden verursacht: §f" + (target.getStatistic(Statistic.DAMAGE_DEALT) / 10) + " ❤"));
|
"§8» §7Mob-Kills: §f" + target.getStatistic(Statistic.MOB_KILLS),
|
||||||
|
"§8» §7Tode gesamt: §f" + target.getStatistic(Statistic.DEATHS),
|
||||||
// --- Statistik Kategorie: ARBEIT (Slot 21) ---
|
"§8» §7Schaden verursacht: §f" + (target.getStatistic(Statistic.DAMAGE_DEALT) / 10) + " ❤"));
|
||||||
// Optimierte Abfrage für wichtige Blöcke
|
|
||||||
int totalBlocks = target.getStatistic(Statistic.MINE_BLOCK, Material.STONE) +
|
// --- Statistik Kategorie: ARBEIT (Slot 21) ---
|
||||||
target.getStatistic(Statistic.MINE_BLOCK, Material.DIRT) +
|
// Optimierte Abfrage für wichtige Blöcke
|
||||||
target.getStatistic(Statistic.MINE_BLOCK, Material.COBBLESTONE);
|
int totalBlocks = target.getStatistic(Statistic.MINE_BLOCK, Material.STONE) +
|
||||||
|
target.getStatistic(Statistic.MINE_BLOCK, Material.DIRT) +
|
||||||
gui.setItem(21, createStatsItem(Material.IRON_PICKAXE, "§e§lHandwerk & Fleiß",
|
target.getStatistic(Statistic.MINE_BLOCK, Material.COBBLESTONE);
|
||||||
"§8» §7Blöcke (S/D/C): §f" + totalBlocks,
|
|
||||||
"§8» §7Items gedroppt: §f" + target.getStatistic(Statistic.DROP_COUNT),
|
gui.setItem(21, createStatsItem(Material.IRON_PICKAXE, "§e§lHandwerk & Fleiß",
|
||||||
"§8» §7Fische gefangen: §f" + target.getStatistic(Statistic.FISH_CAUGHT),
|
"§8» §7Blöcke (S/D/C): §f" + totalBlocks,
|
||||||
"§8» §7Glocken geläutet: §f" + target.getStatistic(Statistic.BELL_RING)));
|
"§8» §7Items gedroppt: §f" + target.getStatistic(Statistic.DROP_COUNT),
|
||||||
|
"§8» §7Fische gefangen: §f" + target.getStatistic(Statistic.FISH_CAUGHT),
|
||||||
// --- Statistik Kategorie: BEWEGUNG (Slot 23) ---
|
"§8» §7Glocken geläutet: §f" + target.getStatistic(Statistic.BELL_RING)));
|
||||||
double walkKm = target.getStatistic(Statistic.WALK_ONE_CM) / 100000.0;
|
|
||||||
double flyKm = target.getStatistic(Statistic.FLY_ONE_CM) / 100000.0;
|
// --- Statistik Kategorie: BEWEGUNG (Slot 23) ---
|
||||||
gui.setItem(23, createStatsItem(Material.GOLDEN_BOOTS, "§b§lReise-Statistiken",
|
double walkKm = target.getStatistic(Statistic.WALK_ONE_CM) / 100000.0;
|
||||||
"§8» §7Gelaufen: §f" + String.format("%.2f", walkKm) + " km",
|
double flyKm = target.getStatistic(Statistic.FLY_ONE_CM) / 100000.0;
|
||||||
"§8» §7Geflogen: §f" + String.format("%.2f", flyKm) + " km",
|
gui.setItem(23, createStatsItem(Material.GOLDEN_BOOTS, "§b§lReise-Statistiken",
|
||||||
"§8» §7Sprünge: §f" + target.getStatistic(Statistic.JUMP)));
|
"§8» §7Gelaufen: §f" + String.format("%.2f", walkKm) + " km",
|
||||||
|
"§8» §7Geflogen: §f" + String.format("%.2f", flyKm) + " km",
|
||||||
// --- Statistik Kategorie: ZEIT (Slot 25) ---
|
"§8» §7Sprünge: §f" + target.getStatistic(Statistic.JUMP)));
|
||||||
long ticks = target.getStatistic(Statistic.PLAY_ONE_MINUTE);
|
|
||||||
long hours = ticks / 72000;
|
// --- Statistik Kategorie: ZEIT (Slot 25) ---
|
||||||
long mins = (ticks % 72000) / 1200;
|
long ticks = target.getStatistic(Statistic.PLAY_ONE_MINUTE);
|
||||||
gui.setItem(25, createStatsItem(Material.CLOCK, "§a§lZeit-Statistiken",
|
long hours = ticks / 72000;
|
||||||
"§8» §7Spielzeit: §f" + hours + " Std. " + mins + " Min.",
|
long mins = (ticks % 72000) / 1200;
|
||||||
"§8» §7Letzter Tod vor: §f" + (target.getStatistic(Statistic.TIME_SINCE_DEATH) / 1200) + " Min.",
|
gui.setItem(25, createStatsItem(Material.CLOCK, "§a§lZeit-Statistiken",
|
||||||
"§8» §7Tage auf Server: §f" + (target.getStatistic(Statistic.PLAY_ONE_MINUTE) / 1728000)));
|
"§8» §7Spielzeit: §f" + hours + " Std. " + mins + " Min.",
|
||||||
|
"§8» §7Letzter Tod vor: §f" + (target.getStatistic(Statistic.TIME_SINCE_DEATH) / 1200) + " Min.",
|
||||||
// --- Schließen Button (Slot 40) ---
|
"§8» §7Tage auf Server: §f" + (target.getStatistic(Statistic.PLAY_ONE_MINUTE) / 1728000)));
|
||||||
gui.setItem(40, createSimpleItem(Material.BARRIER, "§c§lMenü schließen"));
|
|
||||||
|
// --- Schließen Button (Slot 40) ---
|
||||||
// Inventar für den Zuschauer öffnen
|
gui.setItem(40, createSimpleItem(Material.BARRIER, "§c§lMenü schließen"));
|
||||||
viewer.openInventory(gui);
|
|
||||||
}
|
// 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) {
|
* Erstellt ein ItemStack mit Name und Lore-Zeilen inklusive einer Leerzeile am Anfang.
|
||||||
ItemStack item = new ItemStack(material);
|
*/
|
||||||
ItemMeta meta = item.getItemMeta();
|
private ItemStack createStatsItem(Material material, String displayName, String... loreLines) {
|
||||||
if (meta != null) {
|
ItemStack item = new ItemStack(material);
|
||||||
meta.setDisplayName(displayName);
|
ItemMeta meta = item.getItemMeta();
|
||||||
List<String> lore = new ArrayList<>();
|
if (meta != null) {
|
||||||
lore.add(" "); // Leerzeile für sauberes Design
|
meta.setDisplayName(displayName);
|
||||||
for (String line : loreLines) {
|
List<String> lore = new ArrayList<>();
|
||||||
lore.add(line);
|
lore.add(" "); // Leerzeile für sauberes Design
|
||||||
}
|
for (String line : loreLines) {
|
||||||
meta.setLore(lore);
|
lore.add(line);
|
||||||
item.setItemMeta(meta);
|
}
|
||||||
}
|
meta.setLore(lore);
|
||||||
return item;
|
item.setItemMeta(meta);
|
||||||
}
|
}
|
||||||
|
return item;
|
||||||
/**
|
}
|
||||||
* Erstellt ein einfaches ItemStack ohne Lore für Designzwecke.
|
|
||||||
*/
|
/**
|
||||||
private ItemStack createSimpleItem(Material material, String displayName) {
|
* Erstellt ein einfaches ItemStack ohne Lore für Designzwecke.
|
||||||
ItemStack item = new ItemStack(material);
|
*/
|
||||||
ItemMeta meta = item.getItemMeta();
|
private ItemStack createSimpleItem(Material material, String displayName) {
|
||||||
if (meta != null) {
|
ItemStack item = new ItemStack(material);
|
||||||
meta.setDisplayName(displayName);
|
ItemMeta meta = item.getItemMeta();
|
||||||
item.setItemMeta(meta);
|
if (meta != null) {
|
||||||
}
|
meta.setDisplayName(displayName);
|
||||||
return item;
|
item.setItemMeta(meta);
|
||||||
}
|
}
|
||||||
|
return item;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -5,12 +5,15 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
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.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class PortalCommand implements CommandExecutor {
|
public class PortalCommand implements CommandExecutor, Listener {
|
||||||
|
|
||||||
private final PortalManager portalManager;
|
private final PortalManager portalManager;
|
||||||
|
|
||||||
@@ -20,6 +23,17 @@ public class PortalCommand implements CommandExecutor {
|
|||||||
|
|
||||||
public PortalCommand(PortalManager portalManager) {
|
public PortalCommand(PortalManager portalManager) {
|
||||||
this.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
|
// Statische Hilfsmethoden für andere Klassen
|
||||||
|
|||||||
@@ -31,7 +31,12 @@ import java.util.UUID;
|
|||||||
import java.util.Set;
|
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 {
|
public class PortalManager implements Module, Listener {
|
||||||
|
|
||||||
@@ -42,12 +47,6 @@ public class PortalManager implements Module, Listener {
|
|||||||
private final NamespacedKey wandKey;
|
private final NamespacedKey wandKey;
|
||||||
private BukkitTask particleTask;
|
private BukkitTask particleTask;
|
||||||
|
|
||||||
// Boundary Cache
|
|
||||||
private Location borderMin;
|
|
||||||
private Location borderMax;
|
|
||||||
private boolean borderEnabled = false;
|
|
||||||
private String borderType;
|
|
||||||
|
|
||||||
public PortalManager(NexusLobby plugin) {
|
public PortalManager(NexusLobby plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.wandKey = new NamespacedKey(plugin, "nexuslobby_portal_wand");
|
this.wandKey = new NamespacedKey(plugin, "nexuslobby_portal_wand");
|
||||||
@@ -61,7 +60,6 @@ public class PortalManager implements Module, Listener {
|
|||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
loadPortals();
|
loadPortals();
|
||||||
loadBorderSettings();
|
|
||||||
Bukkit.getPluginManager().registerEvents(this, plugin);
|
Bukkit.getPluginManager().registerEvents(this, plugin);
|
||||||
startParticleTask();
|
startParticleTask();
|
||||||
}
|
}
|
||||||
@@ -76,28 +74,6 @@ public class PortalManager implements Module, Listener {
|
|||||||
plugin.getLogger().info("PortalManager deaktiviert.");
|
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() {
|
public Set<String> getPortalNames() {
|
||||||
return portals.keySet();
|
return portals.keySet();
|
||||||
}
|
}
|
||||||
@@ -135,30 +111,30 @@ public class PortalManager implements Module, Listener {
|
|||||||
if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
|
if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
|
||||||
selectionMap.get(uuid)[0] = clickedLoc;
|
selectionMap.get(uuid)[0] = clickedLoc;
|
||||||
PortalCommand.setSelection1(p, clickedLoc);
|
PortalCommand.setSelection1(p, clickedLoc);
|
||||||
|
|
||||||
p.playSound(p.getLocation(), Sound.BLOCK_NOTE_BLOCK_PLING, 1.0f, 2.0f);
|
p.playSound(p.getLocation(), Sound.BLOCK_NOTE_BLOCK_PLING, 1.0f, 2.0f);
|
||||||
p.sendMessage("§aPosition 1 gesetzt: " + clickedLoc.getBlockX() + ", " + clickedLoc.getBlockY() + ", " + clickedLoc.getBlockZ());
|
p.sendMessage("§aPosition 1 gesetzt: " + clickedLoc.getBlockX() + ", " + clickedLoc.getBlockY() + ", " + clickedLoc.getBlockZ());
|
||||||
|
|
||||||
} else if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
} else if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||||
selectionMap.get(uuid)[1] = clickedLoc;
|
selectionMap.get(uuid)[1] = clickedLoc;
|
||||||
PortalCommand.setSelection2(p, clickedLoc);
|
PortalCommand.setSelection2(p, clickedLoc);
|
||||||
|
|
||||||
p.playSound(p.getLocation(), Sound.BLOCK_NOTE_BLOCK_PLING, 1.0f, 1.0f);
|
p.playSound(p.getLocation(), Sound.BLOCK_NOTE_BLOCK_PLING, 1.0f, 1.0f);
|
||||||
p.sendMessage("§bPosition 2 gesetzt: " + clickedLoc.getBlockX() + ", " + clickedLoc.getBlockY() + ", " + clickedLoc.getBlockZ());
|
p.sendMessage("§bPosition 2 gesetzt: " + clickedLoc.getBlockX() + ", " + clickedLoc.getBlockY() + ", " + clickedLoc.getBlockZ());
|
||||||
|
|
||||||
Location loc1 = selectionMap.get(uuid)[0];
|
Location loc1 = selectionMap.get(uuid)[0];
|
||||||
if (loc1 != null) {
|
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 height = Math.abs(loc1.getBlockY() - clickedLoc.getBlockY()) + 1;
|
||||||
int length = Math.abs(loc1.getBlockZ() - clickedLoc.getBlockZ()) + 1;
|
int length = Math.abs(loc1.getBlockZ() - clickedLoc.getBlockZ()) + 1;
|
||||||
long volume = (long) width * height * length;
|
long volume = (long) width * height * length;
|
||||||
|
|
||||||
p.sendMessage("§7§m----------------------------------");
|
p.sendMessage("§7§m----------------------------------");
|
||||||
if (volume < 500) {
|
if (volume < 500) {
|
||||||
p.sendMessage("§e[Nexus] Kleiner Bereich erkannt (Portal-Größe)");
|
p.sendMessage(de.nexuslobby.utils.LangManager.getPrefix() + "§eKleiner Bereich erkannt (Portal-Größe)");
|
||||||
p.sendMessage("§fBefehl: §b/portal create <Name> <server|world>");
|
p.sendMessage("§fBefehl: §b/portal create <n> <server|world>");
|
||||||
} else {
|
} 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("§fBefehl: §a/border square");
|
||||||
}
|
}
|
||||||
p.sendMessage("§7§m----------------------------------");
|
p.sendMessage("§7§m----------------------------------");
|
||||||
@@ -190,12 +166,9 @@ public class PortalManager implements Module, Listener {
|
|||||||
String type = portalConfig.getString("portals." + key + ".type", "WORLD");
|
String type = portalConfig.getString("portals." + key + ".type", "WORLD");
|
||||||
Portal portal = new Portal(key, type);
|
Portal portal = new Portal(key, type);
|
||||||
|
|
||||||
if (portalConfig.contains("portals." + key + ".pos1")) {
|
portal.setPos1(loadLocation(portalConfig, "portals." + key + ".pos1"));
|
||||||
portal.setPos1(portalConfig.getLocation("portals." + key + ".pos1"));
|
portal.setPos2(loadLocation(portalConfig, "portals." + key + ".pos2"));
|
||||||
}
|
portal.setReturnSpawn(loadLocation(portalConfig, "portals." + key + ".returnSpawn"));
|
||||||
if (portalConfig.contains("portals." + key + ".pos2")) {
|
|
||||||
portal.setPos2(portalConfig.getLocation("portals." + key + ".pos2"));
|
|
||||||
}
|
|
||||||
|
|
||||||
portal.setDestination(portalConfig.getString("portals." + key + ".destination", ""));
|
portal.setDestination(portalConfig.getString("portals." + key + ".destination", ""));
|
||||||
try {
|
try {
|
||||||
@@ -204,10 +177,6 @@ public class PortalManager implements Module, Listener {
|
|||||||
portal.setParticle(Particle.PORTAL);
|
portal.setParticle(Particle.PORTAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (portalConfig.contains("portals." + key + ".returnSpawn")) {
|
|
||||||
portal.setReturnSpawn(portalConfig.getLocation("portals." + key + ".returnSpawn"));
|
|
||||||
}
|
|
||||||
|
|
||||||
portals.put(key, portal);
|
portals.put(key, portal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -219,11 +188,11 @@ public class PortalManager implements Module, Listener {
|
|||||||
for (Portal portal : portals.values()) {
|
for (Portal portal : portals.values()) {
|
||||||
String path = "portals." + portal.getName() + ".";
|
String path = "portals." + portal.getName() + ".";
|
||||||
config.set(path + "type", portal.getType());
|
config.set(path + "type", portal.getType());
|
||||||
config.set(path + "pos1", portal.getPos1());
|
saveLocation(config, path + "pos1", portal.getPos1());
|
||||||
config.set(path + "pos2", portal.getPos2());
|
saveLocation(config, path + "pos2", portal.getPos2());
|
||||||
config.set(path + "destination", portal.getDestination());
|
config.set(path + "destination", portal.getDestination());
|
||||||
config.set(path + "particle", portal.getParticle() != null ? portal.getParticle().name() : "PORTAL");
|
config.set(path + "particle", portal.getParticle() != null ? portal.getParticle().name() : "PORTAL");
|
||||||
config.set(path + "returnSpawn", portal.getReturnSpawn());
|
saveLocation(config, path + "returnSpawn", portal.getReturnSpawn());
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
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 ---
|
// --- CRUD ---
|
||||||
public boolean createPortal(String name, String type, Player creator) {
|
public boolean createPortal(String name, String type, Player creator) {
|
||||||
Location[] sel = selectionMap.getOrDefault(creator.getUniqueId(), new Location[2]);
|
Location[] sel = selectionMap.getOrDefault(creator.getUniqueId(), new Location[2]);
|
||||||
@@ -295,7 +293,7 @@ public class PortalManager implements Module, Listener {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- Movement / Teleport / Boundary Logic ---
|
// --- Movement / Teleport Logic ---
|
||||||
@org.bukkit.event.EventHandler
|
@org.bukkit.event.EventHandler
|
||||||
public void onPlayerMove(PlayerMoveEvent event) {
|
public void onPlayerMove(PlayerMoveEvent event) {
|
||||||
if (event.getFrom().getX() == event.getTo().getX() &&
|
if (event.getFrom().getX() == event.getTo().getX() &&
|
||||||
@@ -307,20 +305,7 @@ public class PortalManager implements Module, Listener {
|
|||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
Location loc = event.getTo();
|
Location loc = event.getTo();
|
||||||
|
|
||||||
// 1. Grenzschutz (Boundary Protection)
|
// Portal-Logik
|
||||||
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
|
|
||||||
for (Portal portal : portals.values()) {
|
for (Portal portal : portals.values()) {
|
||||||
if (portal.getPos1() == null || portal.getPos2() == null) continue;
|
if (portal.getPos1() == null || portal.getPos2() == null) continue;
|
||||||
if (!isInArea(loc, portal.getPos1(), portal.getPos2())) 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) {
|
private void executeTeleport(Player player, Portal portal) {
|
||||||
if ("SERVER".equalsIgnoreCase(portal.getType())) {
|
if ("SERVER".equalsIgnoreCase(portal.getType())) {
|
||||||
String serverName = portal.getDestination();
|
String serverName = portal.getDestination();
|
||||||
@@ -352,17 +329,17 @@ public class PortalManager implements Module, Listener {
|
|||||||
Location loc = portal.getReturnSpawn();
|
Location loc = portal.getReturnSpawn();
|
||||||
if (loc == null) {
|
if (loc == null) {
|
||||||
Location pos2 = portal.getPos2();
|
Location pos2 = portal.getPos2();
|
||||||
loc = player.getLocation();
|
loc = player.getLocation().clone();
|
||||||
if (pos2 != null) {
|
if (pos2 != null) {
|
||||||
double dx = loc.getX() - pos2.getX();
|
double dx = loc.getX() - pos2.getX();
|
||||||
double dz = loc.getZ() - pos2.getZ();
|
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;
|
if (length == 0) length = 1;
|
||||||
dx = (dx / length) * 2;
|
dx = (dx / length) * 2;
|
||||||
dz = (dz / length) * 2;
|
dz = (dz / length) * 2;
|
||||||
loc.add(dx, 0, dz);
|
loc.add(dx, 0, dz);
|
||||||
} else {
|
} else {
|
||||||
loc.add(0,0,2);
|
loc.add(0, 0, 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
player.teleport(loc);
|
player.teleport(loc);
|
||||||
@@ -393,7 +370,7 @@ public class PortalManager implements Module, Listener {
|
|||||||
double x = Double.parseDouble(parts[1]);
|
double x = Double.parseDouble(parts[1]);
|
||||||
double y = Double.parseDouble(parts[2]);
|
double y = Double.parseDouble(parts[2]);
|
||||||
double z = Double.parseDouble(parts[3]);
|
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;
|
float pitch = parts.length >= 6 ? Float.parseFloat(parts[5]) : 0f;
|
||||||
player.teleport(new Location(world, x, y, z, yaw, pitch));
|
player.teleport(new Location(world, x, y, z, yaw, pitch));
|
||||||
player.sendMessage("§aDu wurdest teleportiert!");
|
player.sendMessage("§aDu wurdest teleportiert!");
|
||||||
@@ -418,11 +395,11 @@ public class PortalManager implements Module, Listener {
|
|||||||
if (worldName != null) {
|
if (worldName != null) {
|
||||||
World w = Bukkit.getWorld(worldName);
|
World w = Bukkit.getWorld(worldName);
|
||||||
if (w != null) {
|
if (w != null) {
|
||||||
return new Location(w,
|
return new Location(w,
|
||||||
plugin.getConfig().getDouble("spawn.x"),
|
plugin.getConfig().getDouble("spawn.x"),
|
||||||
plugin.getConfig().getDouble("spawn.y"),
|
plugin.getConfig().getDouble("spawn.y"),
|
||||||
plugin.getConfig().getDouble("spawn.z"),
|
plugin.getConfig().getDouble("spawn.z"),
|
||||||
(float) plugin.getConfig().getDouble("spawn.yaw"),
|
(float) plugin.getConfig().getDouble("spawn.yaw"),
|
||||||
(float) plugin.getConfig().getDouble("spawn.pitch"));
|
(float) plugin.getConfig().getDouble("spawn.pitch"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -461,6 +438,7 @@ public class PortalManager implements Module, Listener {
|
|||||||
Location min = getMinLocation(portal.getPos1(), portal.getPos2());
|
Location min = getMinLocation(portal.getPos1(), portal.getPos2());
|
||||||
Location max = getMaxLocation(portal.getPos1(), portal.getPos2());
|
Location max = getMaxLocation(portal.getPos1(), portal.getPos2());
|
||||||
World world = portal.getPos1().getWorld();
|
World world = portal.getPos1().getWorld();
|
||||||
|
if (world == null) return;
|
||||||
for (int i = 0; i < 15; i++) {
|
for (int i = 0; i < 15; i++) {
|
||||||
double x = min.getX() + Math.random() * (max.getX() - min.getX() + 1);
|
double x = min.getX() + Math.random() * (max.getX() - min.getX() + 1);
|
||||||
double y = min.getY() + Math.random() * (max.getY() - min.getY() + 1);
|
double y = min.getY() + Math.random() * (max.getY() - min.getY() + 1);
|
||||||
|
|||||||
@@ -115,5 +115,7 @@ public class SecurityModule implements Module, Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {}
|
public void onDisable() {
|
||||||
|
org.bukkit.event.HandlerList.unregisterAll(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,135 +1,135 @@
|
|||||||
package de.nexuslobby.modules.servers;
|
package de.nexuslobby.modules.servers;
|
||||||
|
|
||||||
import de.nexuslobby.NexusLobby;
|
import de.nexuslobby.NexusLobby;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.ArmorStand;
|
import org.bukkit.entity.ArmorStand;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
public class ServerChecker {
|
public class ServerChecker {
|
||||||
|
|
||||||
private static BukkitTask globalCheckerTask = null;
|
private static BukkitTask globalCheckerTask = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prüft asynchron, ob ein Server unter der angegebenen IP und Port erreichbar ist.
|
* Prüft asynchron, ob ein Server unter der angegebenen IP und Port erreichbar ist.
|
||||||
*/
|
*/
|
||||||
public static CompletableFuture<Boolean> isOnline(String ip, int port) {
|
public static CompletableFuture<Boolean> isOnline(String ip, int port) {
|
||||||
return CompletableFuture.supplyAsync(() -> {
|
return CompletableFuture.supplyAsync(() -> {
|
||||||
try (Socket socket = new Socket()) {
|
try (Socket socket = new Socket()) {
|
||||||
// 500ms Timeout für stabilere Erkennung
|
// 500ms Timeout für stabilere Erkennung
|
||||||
socket.connect(new InetSocketAddress(ip, port), 500);
|
socket.connect(new InetSocketAddress(ip, port), 500);
|
||||||
return true;
|
return true;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Startet den Scheduler, der alle ArmorStands in allen Welten regelmäßig prüft.
|
* Startet den Scheduler, der alle ArmorStands in allen Welten regelmäßig prüft.
|
||||||
*/
|
*/
|
||||||
public static void startGlobalChecker() {
|
public static void startGlobalChecker() {
|
||||||
// Cancel alten Task falls vorhanden
|
// Cancel alten Task falls vorhanden
|
||||||
stopGlobalChecker();
|
stopGlobalChecker();
|
||||||
|
|
||||||
// WICHTIG: runTaskTimer (synchron), um den Main-Thread für getEntitiesByClass zu nutzen
|
// WICHTIG: runTaskTimer (synchron), um den Main-Thread für getEntitiesByClass zu nutzen
|
||||||
globalCheckerTask = Bukkit.getScheduler().runTaskTimer(NexusLobby.getInstance(), () -> {
|
globalCheckerTask = Bukkit.getScheduler().runTaskTimer(NexusLobby.getInstance(), () -> {
|
||||||
for (World world : Bukkit.getWorlds()) {
|
for (World world : Bukkit.getWorlds()) {
|
||||||
// Das Abrufen der Entities muss auf dem Main-Thread passieren
|
// Das Abrufen der Entities muss auf dem Main-Thread passieren
|
||||||
for (ArmorStand as : world.getEntitiesByClass(ArmorStand.class)) {
|
for (ArmorStand as : world.getEntitiesByClass(ArmorStand.class)) {
|
||||||
checkAndUpdateArmorStand(as);
|
checkAndUpdateArmorStand(as);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 100L, 200L);
|
}, 100L, 200L);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stoppt den Server-Checker Task
|
* Stoppt den Server-Checker Task
|
||||||
*/
|
*/
|
||||||
public static void stopGlobalChecker() {
|
public static void stopGlobalChecker() {
|
||||||
if (globalCheckerTask != null && !globalCheckerTask.isCancelled()) {
|
if (globalCheckerTask != null && !globalCheckerTask.isCancelled()) {
|
||||||
globalCheckerTask.cancel();
|
globalCheckerTask.cancel();
|
||||||
globalCheckerTask = null;
|
globalCheckerTask = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Analysiert die Tags eines ArmorStands und aktualisiert den Namen basierend auf dem Serverstatus.
|
* Analysiert die Tags eines ArmorStands und aktualisiert den Namen basierend auf dem Serverstatus.
|
||||||
*/
|
*/
|
||||||
private static void checkAndUpdateArmorStand(ArmorStand as) {
|
private static void checkAndUpdateArmorStand(ArmorStand as) {
|
||||||
for (String tag : as.getScoreboardTags()) {
|
for (String tag : as.getScoreboardTags()) {
|
||||||
// Erwartetes Format: ascmd:slot1:slot2:type:command
|
// Erwartetes Format: ascmd:slot1:slot2:type:command
|
||||||
if (tag.startsWith("ascmd:")) {
|
if (tag.startsWith("ascmd:")) {
|
||||||
String[] parts = tag.split(":");
|
String[] parts = tag.split(":");
|
||||||
if (parts.length < 5) continue;
|
if (parts.length < 5) continue;
|
||||||
|
|
||||||
String type = parts[3].toLowerCase();
|
String type = parts[3].toLowerCase();
|
||||||
if (!type.equals("bungee")) continue;
|
if (!type.equals("bungee")) continue;
|
||||||
|
|
||||||
String serverName = parts[4];
|
String serverName = parts[4];
|
||||||
|
|
||||||
// Suche den passenden Key in der Config
|
// Suche den passenden Key in der Config
|
||||||
String configKey = null;
|
String configKey = null;
|
||||||
if (NexusLobby.getInstance().getConfig().getConfigurationSection("servers") != null) {
|
if (NexusLobby.getInstance().getConfig().getConfigurationSection("servers") != null) {
|
||||||
for (String key : NexusLobby.getInstance().getConfig().getConfigurationSection("servers").getKeys(false)) {
|
for (String key : NexusLobby.getInstance().getConfig().getConfigurationSection("servers").getKeys(false)) {
|
||||||
if (key.equalsIgnoreCase(serverName)) {
|
if (key.equalsIgnoreCase(serverName)) {
|
||||||
configKey = key;
|
configKey = key;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (configKey == null) continue;
|
if (configKey == null) continue;
|
||||||
|
|
||||||
String ip = NexusLobby.getInstance().getConfig().getString("servers." + configKey + ".ip");
|
String ip = NexusLobby.getInstance().getConfig().getString("servers." + configKey + ".ip");
|
||||||
int port = NexusLobby.getInstance().getConfig().getInt("servers." + configKey + ".port");
|
int port = NexusLobby.getInstance().getConfig().getInt("servers." + configKey + ".port");
|
||||||
|
|
||||||
if (ip == null) continue;
|
if (ip == null) continue;
|
||||||
|
|
||||||
// Der Ping selbst läuft asynchron weg vom Main-Thread
|
// Der Ping selbst läuft asynchron weg vom Main-Thread
|
||||||
isOnline(ip, port).thenAccept(online -> {
|
isOnline(ip, port).thenAccept(online -> {
|
||||||
// Zurück zum Main-Thread für die Änderung des ArmorStands
|
// Zurück zum Main-Thread für die Änderung des ArmorStands
|
||||||
Bukkit.getScheduler().runTask(NexusLobby.getInstance(), () -> {
|
Bukkit.getScheduler().runTask(NexusLobby.getInstance(), () -> {
|
||||||
if (!as.isValid()) return; // Sicherheitscheck falls AS gelöscht wurde
|
if (!as.isValid()) return; // Sicherheitscheck falls AS gelöscht wurde
|
||||||
|
|
||||||
if (online) {
|
if (online) {
|
||||||
restoreName(as);
|
restoreName(as);
|
||||||
} else {
|
} else {
|
||||||
String offlineText = "§c● §lOFFLINE §c●";
|
String offlineText = "§c● §lOFFLINE §c●";
|
||||||
if (!offlineText.equals(as.getCustomName())) {
|
if (!offlineText.equals(as.getCustomName())) {
|
||||||
as.setCustomName(offlineText);
|
as.setCustomName(offlineText);
|
||||||
as.setCustomNameVisible(true);
|
as.setCustomNameVisible(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stellt den ursprünglichen Namen des ArmorStands wieder her.
|
* Stellt den ursprünglichen Namen des ArmorStands wieder her.
|
||||||
* Nutzt den Tag "asname:NAME" als Backup.
|
* Nutzt den Tag "asname:NAME" als Backup.
|
||||||
*/
|
*/
|
||||||
private static void restoreName(ArmorStand as) {
|
private static void restoreName(ArmorStand as) {
|
||||||
for (String t : as.getScoreboardTags()) {
|
for (String t : as.getScoreboardTags()) {
|
||||||
if (t.startsWith("asname:")) {
|
if (t.startsWith("asname:")) {
|
||||||
String originalName = t.substring(7);
|
String originalName = t.substring(7);
|
||||||
String translatedName = ChatColor.translateAlternateColorCodes('&', originalName);
|
String translatedName = ChatColor.translateAlternateColorCodes('&', originalName);
|
||||||
|
|
||||||
if (!translatedName.equals(as.getCustomName())) {
|
if (!translatedName.equals(as.getCustomName())) {
|
||||||
as.setCustomName(translatedName);
|
as.setCustomName(translatedName);
|
||||||
as.setCustomNameVisible(true);
|
as.setCustomNameVisible(true);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -146,20 +146,50 @@ public class ServerSwitcherListener implements Listener, CommandExecutor {
|
|||||||
int clickedSlot = e.getSlot();
|
int clickedSlot = e.getSlot();
|
||||||
ConfigurationSection serversSection = NexusLobby.getInstance().getConfig().getConfigurationSection("compass.servers");
|
ConfigurationSection serversSection = NexusLobby.getInstance().getConfig().getConfigurationSection("compass.servers");
|
||||||
|
|
||||||
if (serversSection != null) {
|
if (serversSection == null) return;
|
||||||
for (String serverId : serversSection.getKeys(false)) {
|
|
||||||
String path = "compass.servers." + serverId;
|
|
||||||
int configSlot = NexusLobby.getInstance().getConfig().getInt(path + ".slot", -1);
|
|
||||||
|
|
||||||
if (configSlot == clickedSlot) {
|
for (String serverId : serversSection.getKeys(false)) {
|
||||||
String command = NexusLobby.getInstance().getConfig().getString(path + ".command");
|
String path = "compass.servers." + serverId;
|
||||||
if (command != null && !command.isEmpty()) {
|
int configSlot = NexusLobby.getInstance().getConfig().getInt(path + ".slot", -1);
|
||||||
p.closeInventory();
|
|
||||||
p.chat("/" + command);
|
if (configSlot != clickedSlot) continue;
|
||||||
return;
|
|
||||||
}
|
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
|
@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
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
|
org.bukkit.event.HandlerList.unregisterAll(this);
|
||||||
plugin.getServer().getMessenger().unregisterIncomingPluginChannel(plugin, CHANNEL_CONTROL);
|
plugin.getServer().getMessenger().unregisterIncomingPluginChannel(plugin, CHANNEL_CONTROL);
|
||||||
plugin.getServer().getMessenger().unregisterIncomingPluginChannel(plugin, CHANNEL_CHAT);
|
plugin.getServer().getMessenger().unregisterIncomingPluginChannel(plugin, CHANNEL_CHAT);
|
||||||
plugin.getServer().getMessenger().unregisterOutgoingPluginChannel(plugin, CHANNEL_CONTROL);
|
plugin.getServer().getMessenger().unregisterOutgoingPluginChannel(plugin, CHANNEL_CONTROL);
|
||||||
@@ -105,4 +106,4 @@ public class GlobalChatSuppressor implements Module, PluginMessageListener, List
|
|||||||
SuppressManager.unsuppress(uuid);
|
SuppressManager.unsuppress(uuid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,155 +1,156 @@
|
|||||||
package de.nexuslobby.utils;
|
package de.nexuslobby.utils;
|
||||||
|
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validiert Config-Werte und setzt Default-Werte wenn nötig
|
* Validiert Config-Werte und setzt Default-Werte wenn nötig
|
||||||
*/
|
*/
|
||||||
public class ConfigValidator {
|
public class ConfigValidator {
|
||||||
|
|
||||||
private final JavaPlugin plugin;
|
private final JavaPlugin plugin;
|
||||||
private final FileConfiguration config;
|
private final FileConfiguration config;
|
||||||
private final List<String> warnings = new ArrayList<>();
|
private final List<String> warnings = new ArrayList<>();
|
||||||
private boolean modified = false;
|
private boolean modified = false;
|
||||||
|
|
||||||
public ConfigValidator(JavaPlugin plugin, FileConfiguration config) {
|
public ConfigValidator(JavaPlugin plugin, FileConfiguration config) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.config = config;
|
this.config = config;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validiert alle Config-Werte und gibt Warnings aus
|
* Validiert alle Config-Werte und gibt Warnings aus
|
||||||
*/
|
*/
|
||||||
public void validate() {
|
public void validate() {
|
||||||
validateSpawn();
|
ensureDefault("prefix", "&8[&6Nexus&8] ");
|
||||||
validateLobbySettings();
|
validateSpawn();
|
||||||
validateTablist();
|
validateLobbySettings();
|
||||||
validateBall();
|
validateTablist();
|
||||||
validateModules();
|
validateBall();
|
||||||
|
validateModules();
|
||||||
// Warnings ausgeben
|
|
||||||
if (!warnings.isEmpty()) {
|
// Warnings ausgeben
|
||||||
plugin.getLogger().warning("=== Config-Validierung ===");
|
if (!warnings.isEmpty()) {
|
||||||
warnings.forEach(msg -> plugin.getLogger().warning(" " + msg));
|
plugin.getLogger().warning("=== Config-Validierung ===");
|
||||||
plugin.getLogger().warning("=========================");
|
warnings.forEach(msg -> plugin.getLogger().warning(" " + msg));
|
||||||
}
|
plugin.getLogger().warning("=========================");
|
||||||
|
}
|
||||||
// Config speichern wenn Änderungen vorgenommen wurden
|
|
||||||
if (modified) {
|
// Config speichern wenn Änderungen vorgenommen wurden
|
||||||
plugin.saveConfig();
|
if (modified) {
|
||||||
plugin.getLogger().info("Config wurde mit Default-Werten aktualisiert.");
|
plugin.saveConfig();
|
||||||
}
|
plugin.getLogger().info("Config wurde mit Default-Werten aktualisiert.");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
private void validateSpawn() {
|
|
||||||
ensureDefault("spawn.world", "world");
|
private void validateSpawn() {
|
||||||
ensureDefault("spawn.x", 0.5);
|
ensureDefault("spawn.world", "world");
|
||||||
ensureDefault("spawn.y", 64.0);
|
ensureDefault("spawn.x", 0.5);
|
||||||
ensureDefault("spawn.z", 0.5);
|
ensureDefault("spawn.y", 64.0);
|
||||||
ensureDefault("spawn.yaw", 0.0);
|
ensureDefault("spawn.z", 0.5);
|
||||||
ensureDefault("spawn.pitch", 0.0);
|
ensureDefault("spawn.yaw", 0.0);
|
||||||
|
ensureDefault("spawn.pitch", 0.0);
|
||||||
// Validiere Y-Koordinate
|
|
||||||
double y = config.getDouble("spawn.y", 64.0);
|
// Validiere Y-Koordinate
|
||||||
if (y < -64 || y > 320) {
|
double y = config.getDouble("spawn.y", 64.0);
|
||||||
warnings.add("spawn.y (" + y + ") außerhalb des gültigen Bereichs (-64 bis 320)");
|
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);
|
private void validateLobbySettings() {
|
||||||
ensureDefault("lobby.pvp-enabled", false);
|
ensureDefault("lobby.allow-fly", false);
|
||||||
ensureDefault("lobby.build-enabled", false);
|
ensureDefault("lobby.pvp-enabled", false);
|
||||||
ensureDefault("lobby.default-gamemode", "Adventure");
|
ensureDefault("lobby.build-enabled", false);
|
||||||
ensureDefault("lobby.clear-inventory-on-join", true);
|
ensureDefault("lobby.default-gamemode", "Adventure");
|
||||||
|
ensureDefault("lobby.clear-inventory-on-join", true);
|
||||||
// Validiere GameMode
|
|
||||||
String gamemode = config.getString("lobby.default-gamemode", "Adventure");
|
// Validiere GameMode
|
||||||
if (!isValidGameMode(gamemode)) {
|
String gamemode = config.getString("lobby.default-gamemode", "Adventure");
|
||||||
warnings.add("lobby.default-gamemode '" + gamemode + "' ist ungültig. Nutze: Survival, Creative, Adventure oder Spectator");
|
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);
|
private void validateTablist() {
|
||||||
ensureDefault("tablist.header", "&6Willkommen auf &eNexusLobby");
|
ensureDefault("tablist.enabled", true);
|
||||||
ensureDefault("tablist.footer", "&7Viel Spaß!");
|
ensureDefault("tablist.header", "&6Willkommen auf &eNexusLobby");
|
||||||
ensureDefault("tablist.refresh-interval", 40);
|
ensureDefault("tablist.footer", "&7Viel Spaß!");
|
||||||
|
ensureDefault("tablist.refresh-interval", 40);
|
||||||
// Validiere Refresh-Interval
|
|
||||||
int interval = config.getInt("tablist.refresh-interval", 40);
|
// Validiere Refresh-Interval
|
||||||
if (interval < 1) {
|
int interval = config.getInt("tablist.refresh-interval", 40);
|
||||||
warnings.add("tablist.refresh-interval (" + interval + ") ist zu klein. Minimum ist 1 Tick.");
|
if (interval < 1) {
|
||||||
config.set("tablist.refresh-interval", 1);
|
warnings.add("tablist.refresh-interval (" + interval + ") ist zu klein. Minimum ist 1 Tick.");
|
||||||
modified = true;
|
config.set("tablist.refresh-interval", 1);
|
||||||
} else if (interval > 200) {
|
modified = true;
|
||||||
warnings.add("tablist.refresh-interval (" + interval + ") ist sehr hoch. Empfohlen: 20-100 Ticks.");
|
} 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);
|
private void validateBall() {
|
||||||
|
ensureDefault("ball.respawn_delay", 60);
|
||||||
// Validiere Respawn-Delay
|
|
||||||
long delay = config.getLong("ball.respawn_delay", 60);
|
// Validiere Respawn-Delay
|
||||||
if (delay < 5) {
|
long delay = config.getLong("ball.respawn_delay", 60);
|
||||||
warnings.add("ball.respawn_delay (" + delay + "s) ist zu kurz. Minimum empfohlen: 5 Sekunden.");
|
if (delay < 5) {
|
||||||
} else if (delay > 600) {
|
warnings.add("ball.respawn_delay (" + delay + "s) ist zu kurz. Minimum empfohlen: 5 Sekunden.");
|
||||||
warnings.add("ball.respawn_delay (" + delay + "s) ist sehr lang. Empfohlen: 30-120 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")) {
|
// Prüfe ob Spawn gesetzt ist
|
||||||
warnings.add("ball.spawn nicht gesetzt. Nutze /nexuslobby ball setspawn");
|
if (!config.contains("ball.spawn")) {
|
||||||
}
|
warnings.add("ball.spawn nicht gesetzt. Nutze /nexuslobby ball setspawn");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
private void validateModules() {
|
|
||||||
// Worldborder
|
private void validateModules() {
|
||||||
if (config.contains("worldborder.enabled")) {
|
// Worldborder
|
||||||
ensureDefault("worldborder.type", "SQUARE");
|
if (config.contains("worldborder.enabled")) {
|
||||||
ensureDefault("worldborder.radius", 50.0);
|
ensureDefault("worldborder.type", "SQUARE");
|
||||||
|
ensureDefault("worldborder.radius", 50.0);
|
||||||
double radius = config.getDouble("worldborder.radius", 50.0);
|
|
||||||
if (radius < 10) {
|
double radius = config.getDouble("worldborder.radius", 50.0);
|
||||||
warnings.add("worldborder.radius (" + radius + ") ist sehr klein. Minimum empfohlen: 10 Blöcke.");
|
if (radius < 10) {
|
||||||
} else if (radius > 10000) {
|
warnings.add("worldborder.radius (" + radius + ") ist sehr klein. Minimum empfohlen: 10 Blöcke.");
|
||||||
warnings.add("worldborder.radius (" + radius + ") ist extrem groß. Performance-Warnung!");
|
} 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")) {
|
String type = config.getString("worldborder.type", "SQUARE");
|
||||||
warnings.add("worldborder.type '" + type + "' ist ungültig. Nutze: SQUARE oder CIRCLE");
|
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")) {
|
// Items Modul
|
||||||
// Prüfe ob Slot-Nummern gültig sind (0-8)
|
if (config.contains("items.lobby-tools")) {
|
||||||
for (String toolKey : config.getConfigurationSection("items.lobby-tools").getKeys(false)) {
|
// Prüfe ob Slot-Nummern gültig sind (0-8)
|
||||||
int slot = config.getInt("items.lobby-tools." + toolKey + ".slot", -1);
|
for (String toolKey : config.getConfigurationSection("items.lobby-tools").getKeys(false)) {
|
||||||
if (slot < 0 || slot > 8) {
|
int slot = config.getInt("items.lobby-tools." + toolKey + ".slot", -1);
|
||||||
warnings.add("items.lobby-tools." + toolKey + ".slot (" + slot + ") ist ungültig (0-8)");
|
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)) {
|
private void ensureDefault(String path, Object defaultValue) {
|
||||||
config.set(path, defaultValue);
|
if (!config.contains(path)) {
|
||||||
modified = true;
|
config.set(path, defaultValue);
|
||||||
}
|
modified = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
private boolean isValidGameMode(String mode) {
|
|
||||||
return mode.equalsIgnoreCase("Survival") ||
|
private boolean isValidGameMode(String mode) {
|
||||||
mode.equalsIgnoreCase("Creative") ||
|
return mode.equalsIgnoreCase("Survival") ||
|
||||||
mode.equalsIgnoreCase("Adventure") ||
|
mode.equalsIgnoreCase("Creative") ||
|
||||||
mode.equalsIgnoreCase("Spectator");
|
mode.equalsIgnoreCase("Adventure") ||
|
||||||
}
|
mode.equalsIgnoreCase("Spectator");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public class DoubleJump implements Listener {
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void onMove(PlayerMoveEvent event) {
|
public void onMove(PlayerMoveEvent event) {
|
||||||
Player player = event.getPlayer();
|
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)) {
|
if (NexusLobby.getInstance().getConfig().getBoolean("doublejump.enabled", true)) {
|
||||||
player.setAllowFlight(true);
|
player.setAllowFlight(true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,32 +1,43 @@
|
|||||||
package de.nexuslobby.utils;
|
package de.nexuslobby.utils;
|
||||||
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import de.nexuslobby.NexusLobby;
|
||||||
import org.yaml.snakeyaml.Yaml;
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import java.io.InputStream;
|
import org.yaml.snakeyaml.Yaml;
|
||||||
import java.util.Map;
|
|
||||||
|
import java.io.InputStream;
|
||||||
public class LangManager {
|
import java.util.Map;
|
||||||
private static Map<String, Map<String, String>> langMap;
|
|
||||||
private static String currentLang = "de";
|
public class LangManager {
|
||||||
|
private static Map<String, Map<String, String>> langMap;
|
||||||
public static void load(JavaPlugin plugin) {
|
private static String currentLang = "de";
|
||||||
Yaml yaml = new Yaml();
|
|
||||||
try (InputStream in = plugin.getResource("lang.yml")) {
|
public static void load(JavaPlugin plugin) {
|
||||||
langMap = yaml.load(in);
|
Yaml yaml = new Yaml();
|
||||||
} catch (Exception e) {
|
try (InputStream in = plugin.getResource("lang.yml")) {
|
||||||
e.printStackTrace();
|
langMap = yaml.load(in);
|
||||||
}
|
} catch (Exception e) {
|
||||||
}
|
e.printStackTrace();
|
||||||
|
}
|
||||||
public static void setLanguage(String lang) {
|
}
|
||||||
currentLang = lang;
|
|
||||||
}
|
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);
|
public static String get(String key) {
|
||||||
if (translations == null) return key;
|
if (langMap == null) return key;
|
||||||
return translations.getOrDefault(currentLang, 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.block.Action;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
@@ -84,4 +85,9 @@ public class PlayerHider implements Listener {
|
|||||||
private String colorize(String s) {
|
private String colorize(String s) {
|
||||||
return s == null ? "" : s.replace("&", "§");
|
return s == null ? "" : s.replace("&", "§");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onQuit(PlayerQuitEvent event) {
|
||||||
|
hidden.remove(event.getPlayer().getUniqueId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,85 +1,36 @@
|
|||||||
package de.nexuslobby.utils;
|
package de.nexuslobby.utils;
|
||||||
|
|
||||||
import com.google.gson.JsonObject;
|
import de.nexuslobby.NexusLobby;
|
||||||
import com.google.gson.JsonParser;
|
import org.bukkit.Bukkit;
|
||||||
import com.google.gson.JsonSyntaxException;
|
|
||||||
import de.nexuslobby.NexusLobby;
|
import java.io.IOException;
|
||||||
import org.bukkit.Bukkit;
|
import java.io.InputStream;
|
||||||
|
import java.net.URL;
|
||||||
import java.io.BufferedReader;
|
import java.util.Scanner;
|
||||||
import java.io.IOException;
|
import java.util.function.Consumer;
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.net.HttpURLConnection;
|
public class UpdateChecker {
|
||||||
import java.net.URL;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
private final NexusLobby plugin;
|
||||||
import java.util.function.Consumer;
|
private static final int RESOURCE_ID = 132388;
|
||||||
|
|
||||||
public class UpdateChecker {
|
public UpdateChecker(NexusLobby plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
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 void getVersion(final Consumer<String> consumer) {
|
||||||
|
Bukkit.getScheduler().runTaskAsynchronously(this.plugin, () -> {
|
||||||
public UpdateChecker(NexusLobby plugin) {
|
try (InputStream is = new URL(
|
||||||
this.plugin = plugin;
|
"https://api.spigotmc.org/legacy/update.php?resource=" + RESOURCE_ID + "/~").openStream();
|
||||||
}
|
Scanner scanner = new Scanner(is)) {
|
||||||
|
|
||||||
public void getVersion(final Consumer<String> consumer) {
|
if (scanner.hasNext()) {
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(this.plugin, () -> {
|
consumer.accept(scanner.next());
|
||||||
HttpURLConnection connection = null;
|
}
|
||||||
try {
|
|
||||||
URL url = new URL(API_URL);
|
} catch (IOException e) {
|
||||||
connection = (HttpURLConnection) url.openConnection();
|
plugin.getLogger().warning("Update-Check fehlgeschlagen: " + e.getMessage());
|
||||||
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());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -3,6 +3,8 @@ package de.nexuslobby.utils;
|
|||||||
import de.nexuslobby.NexusLobby;
|
import de.nexuslobby.NexusLobby;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
@@ -17,7 +19,21 @@ public class VoidProtection implements Listener {
|
|||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
if (player.getLocation().getY() < 0) {
|
if (player.getLocation().getY() < 0) {
|
||||||
if (NexusLobby.getInstance().getConfig().getBoolean("void_protection.teleport_to_spawn", true)) {
|
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);
|
player.teleport(spawn);
|
||||||
String msg = de.nexuslobby.utils.LangManager.get("void_protection_message");
|
String msg = de.nexuslobby.utils.LangManager.get("void_protection_message");
|
||||||
if (msg != null && !msg.isEmpty()) {
|
if (msg != null && !msg.isEmpty()) {
|
||||||
|
|||||||
@@ -20,6 +20,9 @@
|
|||||||
# Verfügbare Optionen: de (Deutsch), en (Englisch), fr (Französisch)
|
# Verfügbare Optionen: de (Deutsch), en (Englisch), fr (Französisch)
|
||||||
language: de
|
language: de
|
||||||
|
|
||||||
|
# Prefix vor Plugin-Nachrichten im Chat (&-Farbcodes sind erlaubt)
|
||||||
|
prefix: "&8[&6Nexus&8] "
|
||||||
|
|
||||||
# ══════════════════════════════════════════════════════════════════════════════
|
# ══════════════════════════════════════════════════════════════════════════════
|
||||||
# SPAWN EINSTELLUNGEN
|
# SPAWN EINSTELLUNGEN
|
||||||
# ══════════════════════════════════════════════════════════════════════════════
|
# ══════════════════════════════════════════════════════════════════════════════
|
||||||
@@ -65,12 +68,12 @@ worldborder:
|
|||||||
|
|
||||||
# Zentrum der Weltgrenze (optional, kann leer bleiben)
|
# Zentrum der Weltgrenze (optional, kann leer bleiben)
|
||||||
# Wenn nicht gesetzt, wird der Spawn-Punkt als Zentrum verwendet
|
# 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)
|
# Alternative: Definiere Eckpunkte (für rechteckige Border)
|
||||||
# Format: x,y,z
|
# Format: x,y,z
|
||||||
pos1:
|
# pos1 wird automatisch über /border square gesetzt
|
||||||
pos2:
|
# pos2 wird automatisch über /border square gesetzt
|
||||||
|
|
||||||
# ══════════════════════════════════════════════════════════════════════════════
|
# ══════════════════════════════════════════════════════════════════════════════
|
||||||
# LOBBY EINSTELLUNGEN
|
# LOBBY EINSTELLUNGEN
|
||||||
@@ -162,7 +165,7 @@ items:
|
|||||||
# Kompass (Server-Auswahl / Teleporter)
|
# Kompass (Server-Auswahl / Teleporter)
|
||||||
compass:
|
compass:
|
||||||
# Aktiviert das Kompass-Item (true = an, false = aus)
|
# Aktiviert das Kompass-Item (true = an, false = aus)
|
||||||
enabled: true
|
enabled: false
|
||||||
|
|
||||||
# Anzeigename des Items (unterstützt Farbcodes)
|
# Anzeigename des Items (unterstützt Farbcodes)
|
||||||
displayname: "&eTeleporter"
|
displayname: "&eTeleporter"
|
||||||
@@ -184,7 +187,7 @@ items:
|
|||||||
# Gadget-Menü (Spezialeffekte und Extras)
|
# Gadget-Menü (Spezialeffekte und Extras)
|
||||||
gadget:
|
gadget:
|
||||||
# Aktiviert das Gadget-Item (true = an, false = aus)
|
# Aktiviert das Gadget-Item (true = an, false = aus)
|
||||||
enabled: false
|
enabled: true
|
||||||
|
|
||||||
# Anzeigename des Items (unterstützt Farbcodes)
|
# Anzeigename des Items (unterstützt Farbcodes)
|
||||||
displayname: "&bGadgets"
|
displayname: "&bGadgets"
|
||||||
@@ -283,7 +286,7 @@ player_inspect:
|
|||||||
# Join/Quit-Nachrichten Unterdrückung und BungeeCord-Messaging
|
# Join/Quit-Nachrichten Unterdrückung und BungeeCord-Messaging
|
||||||
suppressor:
|
suppressor:
|
||||||
# Aktiviert das Suppressor-System (true = an, false = aus)
|
# Aktiviert das Suppressor-System (true = an, false = aus)
|
||||||
enabled: true
|
enabled: false
|
||||||
|
|
||||||
# Unterdrückt Join- und Quit-Nachrichten für neue Spieler temporär
|
# Unterdrückt Join- und Quit-Nachrichten für neue Spieler temporär
|
||||||
# true = Nachrichten werden unterdrückt, false = normale Anzeige
|
# true = Nachrichten werden unterdrückt, false = normale Anzeige
|
||||||
@@ -402,7 +405,7 @@ ball:
|
|||||||
enabled: true
|
enabled: true
|
||||||
|
|
||||||
# Spawn-Position des Balls
|
# 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:
|
spawn:
|
||||||
# Name der Welt in der der Ball spawnt
|
# Name der Welt in der der Ball spawnt
|
||||||
world: "world"
|
world: "world"
|
||||||
@@ -425,12 +428,62 @@ ball:
|
|||||||
# 0 = Kein automatischer Respawn
|
# 0 = Kein automatischer Respawn
|
||||||
respawn_delay: 60
|
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
|
# Links
|
||||||
# ══════════════════════════════════════════════════════════════════════════════
|
# ══════════════════════════════════════════════════════════════════════════════
|
||||||
#
|
#
|
||||||
# Benötigst du Hilfe oder Support?
|
# Benötigst du Hilfe oder Support?
|
||||||
# - Webseite: https://m-viper.de
|
# - Webseite: https://m-viper.de
|
||||||
# - Dokumentation: https://git.viper.ipv64.net/M_Viper/NexusLobby/wiki
|
# - Dokumentation: https://viper-network.de/wiki/NexusLobby/
|
||||||
# - Discord: https://discord.com/invite/FdRs4BRd8D
|
# - Discord: https://discord.com/invite/FdRs4BRd8D
|
||||||
# - GitHub: https://git.viper.ipv64.net/M_Viper/NexusLobby
|
|
||||||
+203
-203
@@ -1,203 +1,203 @@
|
|||||||
# _ __ __ __ __
|
# _ __ __ __ __
|
||||||
# / | / /__ _ ____ _______/ / ____ / /_ / /_ __ __
|
# / | / /__ _ ____ _______/ / ____ / /_ / /_ __ __
|
||||||
# / |/ / _ \| |/_/ / / / ___/ / / __ \/ __ \/ __ \/ / / /
|
# / |/ / _ \| |/_/ / / / ___/ / / __ \/ __ \/ __ \/ / / /
|
||||||
# / /| / __/> </ /_/ (__ ) /___/ /_/ / /_/ / /_/ / /_/ /
|
# / /| / __/> </ /_/ (__ ) /___/ /_/ / /_/ / /_/ / /_/ /
|
||||||
# /_/ |_/\___/_/|_|\__,_/____/_____/\____/_.___/_.___/\__, /
|
# /_/ |_/\___/_/|_|\__,_/____/_____/\____/_.___/_.___/\__, /
|
||||||
# /____/
|
# /____/
|
||||||
#
|
#
|
||||||
# =====================================================
|
# =====================================================
|
||||||
# DEFAULT Language
|
# DEFAULT Language
|
||||||
# =====================================================
|
# =====================================================
|
||||||
|
|
||||||
soccer_module_not_loaded:
|
soccer_module_not_loaded:
|
||||||
de: "§cDas Fußball-Modul ist nicht geladen."
|
de: "§cDas Fußball-Modul ist nicht geladen."
|
||||||
en: "§cThe soccer module is not loaded."
|
en: "§cThe soccer module is not loaded."
|
||||||
parkour_usage:
|
parkour_usage:
|
||||||
de: "§8[§6Nexus§8] §7Nutze: §e/nexus parkour <setstart|setfinish|setcheckpoint|reset|clear|removeall>"
|
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>"
|
en: "§8[§6Nexus§8] §7Usage: §e/nexus parkour <setstart|setfinish|setcheckpoint|reset|clear|removeall>"
|
||||||
parkour_run_aborted:
|
parkour_run_aborted:
|
||||||
de: "§8[§6Nexus§8] §7Dein aktueller Lauf wurde abgebrochen."
|
de: "§8[§6Nexus§8] §7Dein aktueller Lauf wurde abgebrochen."
|
||||||
en: "§8[§6Nexus§8] §7Your current run was aborted."
|
en: "§8[§6Nexus§8] §7Your current run was aborted."
|
||||||
parkour_besttimes_cleared:
|
parkour_besttimes_cleared:
|
||||||
de: "§8[§6Nexus§8] §aAlle Parkour-Bestzeiten wurden gelöscht!"
|
de: "§8[§6Nexus§8] §aAlle Parkour-Bestzeiten wurden gelöscht!"
|
||||||
en: "§8[§6Nexus§8] §aAll parkour best times have been cleared!"
|
en: "§8[§6Nexus§8] §aAll parkour best times have been cleared!"
|
||||||
parkour_track_removed:
|
parkour_track_removed:
|
||||||
de: "§8[§6Nexus§8] §cDie gesamte Strecke (Checkpoints & Ziel) wurde gelöscht!"
|
de: "§8[§6Nexus§8] §cDie gesamte Strecke (Checkpoints & Ziel) wurde gelöscht!"
|
||||||
en: "§8[§6Nexus§8] §cThe entire track (checkpoints & finish) has been removed!"
|
en: "§8[§6Nexus§8] §cThe entire track (checkpoints & finish) has been removed!"
|
||||||
unknown_subcommand:
|
unknown_subcommand:
|
||||||
de: "§cUnbekannter Unterbefehl."
|
de: "§cUnbekannter Unterbefehl."
|
||||||
en: "§cUnknown subcommand."
|
en: "§cUnknown subcommand."
|
||||||
parkour_npc_marked:
|
parkour_npc_marked:
|
||||||
de: "§8[§6Nexus§8] §aArmorStand als Parkour-NPC markiert!"
|
de: "§8[§6Nexus§8] §aArmorStand als Parkour-NPC markiert!"
|
||||||
en: "§8[§6Nexus§8] §aArmorStand marked as parkour NPC!"
|
en: "§8[§6Nexus§8] §aArmorStand marked as parkour NPC!"
|
||||||
parkour_start_set:
|
parkour_start_set:
|
||||||
de: "§8[§6Nexus§8] §aParkour-Startpunkt an deiner Position gesetzt!"
|
de: "§8[§6Nexus§8] §aParkour-Startpunkt an deiner Position gesetzt!"
|
||||||
en: "§8[§6Nexus§8] §aParkour start set at your position!"
|
en: "§8[§6Nexus§8] §aParkour start set at your position!"
|
||||||
scoreboard_usage:
|
scoreboard_usage:
|
||||||
de: "§cBenutzung: /nexus sb <on|off|admin|spieler>"
|
de: "§cBenutzung: /nexus sb <on|off|admin|spieler>"
|
||||||
en: "§cUsage: /nexus sb <on|off|admin|player>"
|
en: "§cUsage: /nexus sb <on|off|admin|player>"
|
||||||
scoreboard_module_disabled:
|
scoreboard_module_disabled:
|
||||||
de: "§cScoreboard-Modul ist deaktiviert."
|
de: "§cScoreboard-Modul ist deaktiviert."
|
||||||
en: "§cScoreboard module is disabled."
|
en: "§cScoreboard module is disabled."
|
||||||
info_header:
|
info_header:
|
||||||
de: "§8§m--------------------------------------"
|
de: "§8§m--------------------------------------"
|
||||||
en: "§8§m--------------------------------------"
|
en: "§8§m--------------------------------------"
|
||||||
info_title:
|
info_title:
|
||||||
de: "§6§lNexusLobby §7- Informationen"
|
de: "§6§lNexusLobby §7- Informationen"
|
||||||
en: "§6§lNexusLobby §7- Information"
|
en: "§6§lNexusLobby §7- Information"
|
||||||
info_spawn:
|
info_spawn:
|
||||||
de: "§f/spawn §7- Zum Spawn"
|
de: "§f/spawn §7- Zum Spawn"
|
||||||
en: "§f/spawn §7- To spawn"
|
en: "§f/spawn §7- To spawn"
|
||||||
info_parkour:
|
info_parkour:
|
||||||
de: "§f/setstart §8| §f/setcheckpoint §8| §f/setfinish"
|
de: "§f/setstart §8| §f/setcheckpoint §8| §f/setfinish"
|
||||||
en: "§f/setstart §8| §f/setcheckpoint §8| §f/setfinish"
|
en: "§f/setstart §8| §f/setcheckpoint §8| §f/setfinish"
|
||||||
info_removeall:
|
info_removeall:
|
||||||
de: "§f/nexus parkour removeall §7- Strecke löschen"
|
de: "§f/nexus parkour removeall §7- Strecke löschen"
|
||||||
en: "§f/nexus parkour removeall §7- Remove track"
|
en: "§f/nexus parkour removeall §7- Remove track"
|
||||||
info_ball:
|
info_ball:
|
||||||
de: "§f/nexus ball setspawn §7- Fußball Spawn setzen"
|
de: "§f/nexus ball setspawn §7- Fußball Spawn setzen"
|
||||||
en: "§f/nexus ball setspawn §7- Set soccer spawn"
|
en: "§f/nexus ball setspawn §7- Set soccer spawn"
|
||||||
info_setspawn:
|
info_setspawn:
|
||||||
de: "§f/nexus setspawn §7- Spawn setzen"
|
de: "§f/nexus setspawn §7- Spawn setzen"
|
||||||
en: "§f/nexus setspawn §7- Set spawn"
|
en: "§f/nexus setspawn §7- Set spawn"
|
||||||
info_scoreboard:
|
info_scoreboard:
|
||||||
de: "§f/nexus sb <on|off> §7- Scoreboard"
|
de: "§f/nexus sb <on|off> §7- Scoreboard"
|
||||||
en: "§f/nexus sb <on|off> §7- Scoreboard"
|
en: "§f/nexus sb <on|off> §7- Scoreboard"
|
||||||
info_reload:
|
info_reload:
|
||||||
de: "§f/nexus reload §7- Config laden"
|
de: "§f/nexus reload §7- Config laden"
|
||||||
en: "§f/nexus reload §7- Reload config"
|
en: "§f/nexus reload §7- Reload config"
|
||||||
info_footer:
|
info_footer:
|
||||||
de: "§8§m--------------------------------------"
|
de: "§8§m--------------------------------------"
|
||||||
en: "§8§m--------------------------------------"
|
en: "§8§m--------------------------------------"
|
||||||
parkour_trainer_greeting:
|
parkour_trainer_greeting:
|
||||||
de: "§6§lTrainer §8» §aViel Erfolg beim Parkour! Gib dein Bestes!"
|
de: "§6§lTrainer §8» §aViel Erfolg beim Parkour! Gib dein Bestes!"
|
||||||
en: "§6§lTrainer §8» §aGood luck with the parkour! Give it your best!"
|
en: "§6§lTrainer §8» §aGood luck with the parkour! Give it your best!"
|
||||||
update_available:
|
update_available:
|
||||||
de: "§8[§6Nexus§8] §aEin neues §6Update §afür §eNexusLobby §aist verfügbar!"
|
de: "§8[§6Nexus§8] §aEin neues §6Update §afür §eNexusLobby §aist verfügbar!"
|
||||||
en: "§8[§6Nexus§8] §aA new §6update §afor §eNexusLobby §ais available!"
|
en: "§8[§6Nexus§8] §aA new §6update §afor §eNexusLobby §ais available!"
|
||||||
update_version:
|
update_version:
|
||||||
de: "§8» §7Version: §c{old} §8-> §a{new}"
|
de: "§8» §7Version: §c{old} §8-> §a{new}"
|
||||||
en: "§8» §7Version: §c{old} §8-> §a{new}"
|
en: "§8» §7Version: §c{old} §8-> §a{new}"
|
||||||
update_download_link:
|
update_download_link:
|
||||||
de: "§8» §6Klicke §e§l[HIER] §6zum Herunterladen."
|
de: "§8» §6Klicke §e§l[HIER] §6zum Herunterladen."
|
||||||
en: "§8» §6Click §e§l[HERE] §6to download."
|
en: "§8» §6Click §e§l[HERE] §6to download."
|
||||||
update_download_hover:
|
update_download_hover:
|
||||||
de: "§7Öffnet die Release-Seite"
|
de: "§7Öffnet die Release-Seite"
|
||||||
en: "§7Opens the release page"
|
en: "§7Opens the release page"
|
||||||
hider_all:
|
hider_all:
|
||||||
de: "§aAlle Spieler"
|
de: "§aAlle Spieler"
|
||||||
en: "§aAll players"
|
en: "§aAll players"
|
||||||
hider_none:
|
hider_none:
|
||||||
de: "§cKeine Spieler"
|
de: "§cKeine Spieler"
|
||||||
en: "§cNo players"
|
en: "§cNo players"
|
||||||
void_protection_message:
|
void_protection_message:
|
||||||
de: "§cDu wurdest vor dem Void gerettet!"
|
de: "§cDu wurdest vor dem Void gerettet!"
|
||||||
en: "§cYou were saved from the void!"
|
en: "§cYou were saved from the void!"
|
||||||
proxy_not_registered:
|
proxy_not_registered:
|
||||||
de: "§cProxy-Verbindung nicht möglich (BungeeCord Kanal nicht registriert)."
|
de: "§cProxy-Verbindung nicht möglich (BungeeCord Kanal nicht registriert)."
|
||||||
en: "§cProxy connection not possible (BungeeCord channel not registered)."
|
en: "§cProxy connection not possible (BungeeCord channel not registered)."
|
||||||
connecting_to_server:
|
connecting_to_server:
|
||||||
de: "§eVerbinde zu: §f{server}"
|
de: "§eVerbinde zu: §f{server}"
|
||||||
en: "§eConnecting to: §f{server}"
|
en: "§eConnecting to: §f{server}"
|
||||||
server_connect_error:
|
server_connect_error:
|
||||||
de: "§cFehler beim Verbinden zum Server."
|
de: "§cFehler beim Verbinden zum Server."
|
||||||
en: "§cError connecting to server."
|
en: "§cError connecting to server."
|
||||||
proxy_connect_error:
|
proxy_connect_error:
|
||||||
de: "§cProxy-Verbindung nicht möglich."
|
de: "§cProxy-Verbindung nicht möglich."
|
||||||
en: "§cProxy connection not possible."
|
en: "§cProxy connection not possible."
|
||||||
armorstand_lookat_required:
|
armorstand_lookat_required:
|
||||||
de: "§cDu musst einen ArmorStand direkt anschauen (Fadenkreuz)!"
|
de: "§cDu musst einen ArmorStand direkt anschauen (Fadenkreuz)!"
|
||||||
en: "§cYou must look directly at an ArmorStand (crosshair)!"
|
en: "§cYou must look directly at an ArmorStand (crosshair)!"
|
||||||
conv_link_usage:
|
conv_link_usage:
|
||||||
de: "§cNutze: /nexuscmd conv link <Dialog-ID>"
|
de: "§cNutze: /nexuscmd conv link <Dialog-ID>"
|
||||||
en: "§cUsage: /nexuscmd conv link <Dialog-ID>"
|
en: "§cUsage: /nexuscmd conv link <Dialog-ID>"
|
||||||
conv_mark_npcs:
|
conv_mark_npcs:
|
||||||
de: "§cBitte markiere mindestens die ersten beiden NPCs (select1 & select2)!"
|
de: "§cBitte markiere mindestens die ersten beiden NPCs (select1 & select2)!"
|
||||||
en: "§cPlease mark at least the first two NPCs (select1 & select2)!"
|
en: "§cPlease mark at least the first two NPCs (select1 & select2)!"
|
||||||
conv_link_created:
|
conv_link_created:
|
||||||
de: "§a§lDauerhafte Verknüpfung erstellt!"
|
de: "§a§lDauerhafte Verknüpfung erstellt!"
|
||||||
en: "§a§lPermanent link created!"
|
en: "§a§lPermanent link created!"
|
||||||
conv_link_npcs:
|
conv_link_npcs:
|
||||||
de: "§7Beteiligte NPCs: §e{count}"
|
de: "§7Beteiligte NPCs: §e{count}"
|
||||||
en: "§7Linked NPCs: §e{count}"
|
en: "§7Linked NPCs: §e{count}"
|
||||||
conv_speaker_not_found:
|
conv_speaker_not_found:
|
||||||
de: "§cFehler: Sprecher 1 nicht gefunden."
|
de: "§cFehler: Sprecher 1 nicht gefunden."
|
||||||
en: "§cError: Speaker 1 not found."
|
en: "§cError: Speaker 1 not found."
|
||||||
conv_unlink_lookat:
|
conv_unlink_lookat:
|
||||||
de: "§cSchau den NPC an, dessen Verknüpfung du lösen willst!"
|
de: "§cSchau den NPC an, dessen Verknüpfung du lösen willst!"
|
||||||
en: "§cLook at the NPC you want to unlink!"
|
en: "§cLook at the NPC you want to unlink!"
|
||||||
conv_unlinked:
|
conv_unlinked:
|
||||||
de: "§eNPC-Verknüpfung wurde aufgehoben."
|
de: "§eNPC-Verknüpfung wurde aufgehoben."
|
||||||
en: "§eNPC link has been removed."
|
en: "§eNPC link has been removed."
|
||||||
conv_start_usage:
|
conv_start_usage:
|
||||||
de: "§cNutze: /nexuscmd conv start <ID>"
|
de: "§cNutze: /nexuscmd conv start <ID>"
|
||||||
en: "§cUsage: /nexuscmd conv start <ID>"
|
en: "§cUsage: /nexuscmd conv start <ID>"
|
||||||
conv_mark_two_npcs:
|
conv_mark_two_npcs:
|
||||||
de: "§cBitte markiere mindestens zwei NPCs!"
|
de: "§cBitte markiere mindestens zwei NPCs!"
|
||||||
en: "§cPlease mark at least two NPCs!"
|
en: "§cPlease mark at least two NPCs!"
|
||||||
npc_bubble_sent:
|
npc_bubble_sent:
|
||||||
de: "§aNPC-Sprechblase gesendet."
|
de: "§aNPC-Sprechblase gesendet."
|
||||||
en: "§aNPC speech bubble sent."
|
en: "§aNPC speech bubble sent."
|
||||||
lookat_off:
|
lookat_off:
|
||||||
de: "§cBlickkontakt aus."
|
de: "§cBlickkontakt aus."
|
||||||
en: "§cLook-at disabled."
|
en: "§cLook-at disabled."
|
||||||
lookat_on:
|
lookat_on:
|
||||||
de: "§aBlickkontakt an."
|
de: "§aBlickkontakt an."
|
||||||
en: "§aLook-at enabled."
|
en: "§aLook-at enabled."
|
||||||
name_removed:
|
name_removed:
|
||||||
de: "§eName entfernt."
|
de: "§eName entfernt."
|
||||||
en: "§eName removed."
|
en: "§eName removed."
|
||||||
name_set:
|
name_set:
|
||||||
de: "§7Name gesetzt: {name}"
|
de: "§7Name gesetzt: {name}"
|
||||||
en: "§7Name set: {name}"
|
en: "§7Name set: {name}"
|
||||||
status_backup_saved:
|
status_backup_saved:
|
||||||
de: "§8(Status-Backup wurde gespeichert)"
|
de: "§8(Status-Backup wurde gespeichert)"
|
||||||
en: "§8(Status backup saved)"
|
en: "§8(Status backup saved)"
|
||||||
command_bound:
|
command_bound:
|
||||||
de: "§aBefehl gebunden."
|
de: "§aBefehl gebunden."
|
||||||
en: "§aCommand bound."
|
en: "§aCommand bound."
|
||||||
no_target:
|
no_target:
|
||||||
de: "§cKein Ziel!"
|
de: "§cKein Ziel!"
|
||||||
en: "§cNo target!"
|
en: "§cNo target!"
|
||||||
commands_and_tags:
|
commands_and_tags:
|
||||||
de: "§6§lBefehle & Tags:"
|
de: "§6§lBefehle & Tags:"
|
||||||
en: "§6§lCommands & Tags:"
|
en: "§6§lCommands & Tags:"
|
||||||
commands_removed:
|
commands_removed:
|
||||||
de: "§eAlle Befehle gelöscht."
|
de: "§eAlle Befehle gelöscht."
|
||||||
en: "§eAll commands removed."
|
en: "§eAll commands removed."
|
||||||
welcome:
|
welcome:
|
||||||
de: "Willkommen auf dem Server!"
|
de: "Willkommen auf dem Server!"
|
||||||
en: "Welcome to the server!"
|
en: "Welcome to the server!"
|
||||||
no_permission:
|
no_permission:
|
||||||
de: "§cKeine Berechtigung."
|
de: "§cKeine Berechtigung."
|
||||||
en: "§cNo permission."
|
en: "§cNo permission."
|
||||||
only_player:
|
only_player:
|
||||||
de: "§cDieser Befehl ist nur für Spieler!"
|
de: "§cDieser Befehl ist nur für Spieler!"
|
||||||
en: "§cThis command is for players only!"
|
en: "§cThis command is for players only!"
|
||||||
parkour_checkpoint_set:
|
parkour_checkpoint_set:
|
||||||
de: "§8[§6Nexus§8] §aParkour-Checkpoint gesetzt!"
|
de: "§8[§6Nexus§8] §aParkour-Checkpoint gesetzt!"
|
||||||
en: "§8[§6Nexus§8] §aParkour checkpoint set!"
|
en: "§8[§6Nexus§8] §aParkour checkpoint set!"
|
||||||
parkour_finish_set:
|
parkour_finish_set:
|
||||||
de: "§8[§6Nexus§8] §aParkour-Zielpunkt gesetzt!"
|
de: "§8[§6Nexus§8] §aParkour-Zielpunkt gesetzt!"
|
||||||
en: "§8[§6Nexus§8] §aParkour finish set!"
|
en: "§8[§6Nexus§8] §aParkour finish set!"
|
||||||
teleport_spawn:
|
teleport_spawn:
|
||||||
de: "§8[§6Nexus§8] §aDu wurdest zum Spawn teleportiert."
|
de: "§8[§6Nexus§8] §aDu wurdest zum Spawn teleportiert."
|
||||||
en: "§8[§6Nexus§8] §aYou have been teleported to spawn."
|
en: "§8[§6Nexus§8] §aYou have been teleported to spawn."
|
||||||
spawn_world_missing:
|
spawn_world_missing:
|
||||||
de: "§cFehler: Die Spawn-Welt existiert nicht."
|
de: "§cFehler: Die Spawn-Welt existiert nicht."
|
||||||
en: "§cError: The spawn world does not exist."
|
en: "§cError: The spawn world does not exist."
|
||||||
spawn_not_set:
|
spawn_not_set:
|
||||||
de: "§cEs wurde noch kein Spawn gesetzt."
|
de: "§cEs wurde noch kein Spawn gesetzt."
|
||||||
en: "§cNo spawn has been set yet."
|
en: "§cNo spawn has been set yet."
|
||||||
plugin_reloaded:
|
plugin_reloaded:
|
||||||
de: "§8[§6Nexus§8] §aPlugin erfolgreich neu geladen!"
|
de: "§8[§6Nexus§8] §aPlugin erfolgreich neu geladen!"
|
||||||
en: "§8[§6Nexus§8] §aPlugin successfully reloaded!"
|
en: "§8[§6Nexus§8] §aPlugin successfully reloaded!"
|
||||||
spawn_set:
|
spawn_set:
|
||||||
de: "§8[§6Nexus§8] §aLobby-Spawn erfolgreich gesetzt!"
|
de: "§8[§6Nexus§8] §aLobby-Spawn erfolgreich gesetzt!"
|
||||||
en: "§8[§6Nexus§8] §aLobby spawn set successfully!"
|
en: "§8[§6Nexus§8] §aLobby spawn set successfully!"
|
||||||
silentjoin_on:
|
silentjoin_on:
|
||||||
de: "§8[§6Nexus§8] §7Silent Join: §aAktiviert"
|
de: "§8[§6Nexus§8] §7Silent Join: §aAktiviert"
|
||||||
en: "§8[§6Nexus§8] §7Silent Join: §aEnabled"
|
en: "§8[§6Nexus§8] §7Silent Join: §aEnabled"
|
||||||
silentjoin_off:
|
silentjoin_off:
|
||||||
de: "§8[§6Nexus§8] §7Silent Join: §cDeaktiviert"
|
de: "§8[§6Nexus§8] §7Silent Join: §cDeaktiviert"
|
||||||
en: "§8[§6Nexus§8] §7Silent Join: §cDisabled"
|
en: "§8[§6Nexus§8] §7Silent Join: §cDisabled"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
name: NexusLobby
|
name: NexusLobby
|
||||||
main: de.nexuslobby.NexusLobby
|
main: de.nexuslobby.NexusLobby
|
||||||
version: "1.1.1"
|
version: "2.0"
|
||||||
api-version: "1.21"
|
api-version: "1.21"
|
||||||
author: M_Viper
|
author: M_Viper
|
||||||
description: Modular Lobby Plugin with an invisible Particle-Parkour system.
|
description: Modular Lobby Plugin with an invisible Particle-Parkour system.
|
||||||
|
|||||||
Reference in New Issue
Block a user