Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 250bf2fea6 | |||
| 64a03b539e | |||
| 1db87e81f0 | |||
| 4c847401a0 | |||
| aac2482511 | |||
| 8ea8ab50f3 | |||
| addab7245d |
198
README.md
198
README.md
@@ -4,7 +4,7 @@
|
||||
<img src="https://m-viper.de/img/NexusLobby.png" width="500" alt="NexusLobby">
|
||||
</p>
|
||||
|
||||
Ein umfassendes Lobby-Plugin fur Minecraft Server (Paper/Spigot 1.21+) mit modularem Aufbau, umfangreichen Sicherheitsfunktionen und voller Konfigurierbarkeit.
|
||||
Ein umfassendes Lobby-Plugin für Minecraft Server (Paper/Spigot 1.21+) mit modularem Aufbau, High-End NPC-System, umfangreichen Sicherheitsfunktionen und voller Konfigurierbarkeit.
|
||||
|
||||

|
||||

|
||||
@@ -16,62 +16,43 @@ Ein umfassendes Lobby-Plugin fur Minecraft Server (Paper/Spigot 1.21+) mit modul
|
||||
|
||||
**ALLE RECHTE VORBEHALTEN**
|
||||
|
||||
Dieses Plugin ist urheberrechtlich geschutzt. Es gelten folgende Bedingungen:
|
||||
Dieses Plugin ist urheberrechtlich geschützt. Es gelten folgende Bedingungen:
|
||||
|
||||
- Die Nutzung ist ausschliesslich fur den persönlichen Gebrauch gestattet
|
||||
- Die Weitergabe, Verbreitung oder Veröffentlichung des Plugins ist **strengstens untersagt**
|
||||
- Jegliche Anderung, 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
|
||||
- Die Nutzung ist ausschließlich für den persönlichen Gebrauch gestattet.
|
||||
- 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 Verstoss gegen diese Bedingungen behalten wir uns rechtliche Schritte vor.
|
||||
Bei Verstoß gegen diese Bedingungen behalten wir uns rechtliche Schritte vor.
|
||||
|
||||
---
|
||||
|
||||
## Features
|
||||
|
||||
### Lobby-Management
|
||||
- **Spawn-System** - Automatischer Teleport zum Spawn bei Join/Respawn
|
||||
- **Void-Schutz** - Automatischer Teleport bei Fall ins Void
|
||||
- **Doppelsprung** - Konfigurierbarer Double-Jump mit Cooldown
|
||||
- **Build-Modus** - Schnelles Umschalten zwischen Bau- und Spielmodus
|
||||
### 🤖 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.
|
||||
|
||||
### Visuelle Elemente
|
||||
- **Scoreboard** - Anpassbares Sidebar-Scoreboard mit Animationen
|
||||
- **Tablist** - Header und Footer mit PlaceholderAPI-Support
|
||||
- **BossBar** - Animierte Boss-Bar mit wechselnden Nachrichten
|
||||
- **ActionBar** - Permanente ActionBar-Nachrichten
|
||||
### 🌍 Lobby-Management
|
||||
- **Spawn-System** - Automatischer Teleport zum Spawn bei Join/Respawn.
|
||||
- **Portal-System** - BungeeCord-Portale für nahtlose Server-Wechsel.
|
||||
- **Build-Modus** - Schnelles Umschalten zwischen Bau- und Spielmodus.
|
||||
- **Double-Jump** - Konfigurierbarer Doppelsprung mit Cooldown und Partikeln.
|
||||
|
||||
### Sicherheit
|
||||
- **VPN-Blocker** - Blockiert VPN/Proxy-Verbindungen (proxycheck.io API)
|
||||
- **Country-Blocker** - Erlaubt nur bestimmte Lander (Whitelist/Blacklist)
|
||||
- **Wartungsmodus** - Sperrt den Server für nicht-berechtigte Spieler
|
||||
- **Lobby-Schutz** - Verhindert Griefing und unerwünschte Aktionen
|
||||
### 🛡️ Sicherheit & Protection
|
||||
- **VPN-Blocker** - Blockiert VPN/Proxy-Verbindungen via proxycheck.io API.
|
||||
- **Country-Blocker** - Geo-IP Filter (Whitelist/Blacklist für Länder).
|
||||
- **Maintenance** - Vollständiger Wartungsmodus mit Whitelist-Funktion.
|
||||
- **World-Protection** - Schutz vor Griefing, Hunger, Fallschaden und PvP.
|
||||
|
||||
### Zusatzliche Module
|
||||
- **Portal-System** - Erstelle Portale fur Server-Wechsel (BungeeCord)
|
||||
- **ArmorStand-Tools** - Bearbeite ArmorStands mit GUI und Command-Binding
|
||||
- **Server-Switcher** - GUI-basierter Server-Wechsel
|
||||
- **Spieler verstecken** - Toggle fur Spieler-Sichtbarkeit
|
||||
- **Chat-Suppressor** - Unterdrückung fur globalen Chat
|
||||
|
||||
---
|
||||
|
||||
## Installation
|
||||
|
||||
### Voraussetzungen
|
||||
- Paper/Spigot Server 1.21 oder höher
|
||||
- Java 21 oder hoher
|
||||
|
||||
### Optionale Abhangigkeiten
|
||||
- [PlaceholderAPI](https://www.spigotmc.org/resources/placeholderapi.6245/) - Für Platzhalter-Support
|
||||
- [LuckPerms](https://luckperms.net/) - Für Berechtigungsverwaltung
|
||||
|
||||
### Schritte
|
||||
1. Lade `NexusLobby.jar` herunter
|
||||
2. Kopiere die JAR in den `plugins/` Ordner deines Servers
|
||||
3. Starte den Server neu
|
||||
4. Konfiguriere das Plugin in `plugins/NexusLobby/`
|
||||
### 📊 Visuelle Elemente
|
||||
- **Scoreboard & Tablist** - Vollständig animiert mit PlaceholderAPI-Support.
|
||||
- **BossBar & ActionBar** - Rotierende Nachrichten und permanente Status-Anzeigen.
|
||||
- **Hologramme** - Einfache Erstellung von Text-Displays in der Lobby.
|
||||
|
||||
---
|
||||
|
||||
@@ -79,73 +60,31 @@ Bei Verstoss gegen diese Bedingungen behalten wir uns rechtliche Schritte vor.
|
||||
|
||||
| Befehl | Beschreibung | Berechtigung |
|
||||
|--------|--------------|--------------|
|
||||
| `/nexuslobby` | Hauptbefehl mit Hilfe | `nexuslobby.use` |
|
||||
| `/nexuslobby reload` | Konfiguration neu laden | `nexuslobby.reload` |
|
||||
| `/nexuslobby setspawn` | Spawn-Punkt setzen | `nexuslobby.setspawn` |
|
||||
| `/build` | Build-Modus umschalten | `nexuslobby.build` |
|
||||
| `/maintenance` | Wartungsmodus verwalten | `nexuslobby.maintenance` |
|
||||
| `/portal` | Portal-System verwalten | `nexuslobby.portal` |
|
||||
| `/armorstand` | ArmorStand-Editor | `nexuslobby.armorstand` |
|
||||
| `/lobbysettings` | Spieler-Einstellungen | `nexuslobby.settings` |
|
||||
| `/nexuslobby` | Hauptbefehl (reload, setspawn, silentjoin) | `nexuslobby.admin` |
|
||||
| `/nexuscmd` | NPC Command/Dialog Verwaltung (aliases: `ncmd`, `conv`) | `nexuslobby.armorstand.cmd` |
|
||||
| `/nexustools` | NPC Editor GUI (Rotation, KI, Sichtbarkeit) | `nexuslobby.armorstand.use` |
|
||||
| `/build` | Aktiviert/Deaktiviert den Baumodus | `nexuslobby.build` |
|
||||
| `/maintenance` | Schaltet den Wartungsmodus (on/off) | `nexuslobby.maintenance` |
|
||||
| `/portal` | Verwaltung der Server-Portale | `nexuslobby.portal` |
|
||||
| `/holo` | Erstellt oder löscht Text-Hologramme | `nexuslobby.hologram` |
|
||||
| `/mapart` | Erstellt Bilder aus URLs auf Karten-Rahmen | `nexuslobby.mapart` |
|
||||
|
||||
---
|
||||
|
||||
## Konfiguration
|
||||
## Konfiguration (Auszug)
|
||||
|
||||
### config.yml
|
||||
### conversations.yml
|
||||
```yaml
|
||||
prefix: "&8[&6NexusLobby&8] "
|
||||
conversations:
|
||||
willkommen:
|
||||
dialogue:
|
||||
- "&eWächter: &7Willkommen auf dem Server!"
|
||||
- "&aBürger: &7Schön, dass du da bist!"
|
||||
|
||||
spawn:
|
||||
teleport_on_join: true
|
||||
teleport_on_respawn: true
|
||||
world: "world"
|
||||
x: 0.5
|
||||
y: 100.0
|
||||
z: 0.5
|
||||
|
||||
double_jump:
|
||||
enabled: true
|
||||
cooldown: 3
|
||||
velocity_y: 1.0
|
||||
velocity_multiplier: 1.5
|
||||
```
|
||||
|
||||
### settings.yml
|
||||
```yaml
|
||||
player_visibility: true
|
||||
double_jump: true
|
||||
flight: false
|
||||
|
||||
gamerules:
|
||||
block_break: false
|
||||
block_place: false
|
||||
pvp: false
|
||||
hunger: false
|
||||
fall_damage: false
|
||||
```
|
||||
|
||||
### visuals.yml
|
||||
```yaml
|
||||
scoreboard:
|
||||
enabled: true
|
||||
title: "&6&lNEXUS LOBBY"
|
||||
lines:
|
||||
- "&7"
|
||||
- "&fSpieler: &a%online%"
|
||||
- "&fRang: &e%luckperms_primary_group_name%"
|
||||
|
||||
tablist:
|
||||
enabled: true
|
||||
header:
|
||||
- "&6&lNEXUS NETWORK"
|
||||
footer:
|
||||
- "&7Spieler online: &a%online%"
|
||||
|
||||
bossbar:
|
||||
enabled: true
|
||||
messages:
|
||||
- "&6Willkommen auf NexusNetwork!"
|
||||
links:
|
||||
UUID-NPC1:
|
||||
partner: UUID-NPC2
|
||||
dialog: willkommen
|
||||
```
|
||||
|
||||
---
|
||||
@@ -154,47 +93,28 @@ bossbar:
|
||||
|
||||
| Berechtigung | Beschreibung |
|
||||
|--------------|--------------|
|
||||
| `nexuslobby.*` | Alle Berechtigungen |
|
||||
| `nexuslobby.use` | Grundlegende Nutzung |
|
||||
| `nexuslobby.reload` | Konfiguration neu laden |
|
||||
| `nexuslobby.setspawn` | Spawn setzen |
|
||||
| `nexuslobby.build` | Build-Modus nutzen |
|
||||
| `nexuslobby.maintenance` | Wartungsmodus verwalten |
|
||||
| `nexuslobby.portal` | Portale verwalten |
|
||||
| `nexuslobby.armorstand` | ArmorStand-Editor nutzen |
|
||||
| `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 |
|
||||
|
||||
### Bypass-Berechtigungen
|
||||
|
||||
| Berechtigung | Beschreibung |
|
||||
|--------------|--------------|
|
||||
| `nexuslobby.bypass.protection` | Lobby-Schutz umgehen |
|
||||
| `nexuslobby.bypass.maintenance` | Wartungsmodus umgehen |
|
||||
| `nexuslobby.bypass.vpn` | VPN-Blocker umgehen |
|
||||
| `nexuslobby.bypass.country` | Country-Blocker umgehen |
|
||||
| `nexuslobby.bypass.maintenance` | Server trotz Wartungsmodus betreten |
|
||||
| `nexuslobby.bypass.vpn` | VPN-Check überspringen |
|
||||
|
||||
---
|
||||
|
||||
## PlaceholderAPI
|
||||
## Support & Kontakt
|
||||
|
||||
Das Plugin registriert eigene Platzhalter unter der Expansion `nexuslobby`:
|
||||
|
||||
| Platzhalter | Beschreibung |
|
||||
|-------------|--------------|
|
||||
| `%nexuslobby_online%` | Spieler online |
|
||||
| `%nexuslobby_max_players%` | Maximale Spieler |
|
||||
| `%nexuslobby_maintenance%` | Wartungsmodus Status |
|
||||
| `%nexuslobby_build_mode%` | Build-Modus Status |
|
||||
| `%nexuslobby_double_jump%` | Double-Jump Status |
|
||||
- **Wiki:** Ausführliche Dokumentation der Module im [Wiki](../../../wiki).
|
||||
- **Bug-Reports:** Erstelle ein [Issue](../../../issues) bei technischen Problemen.
|
||||
|
||||
---
|
||||
|
||||
## Support
|
||||
**Copyright (c) 2026 - M_Viper - Alle Rechte vorbehalten**
|
||||
|
||||
- [Wiki](../../../wiki) - Ausführliche Dokumentation
|
||||
- [Issues](../../../issues) - Bug-Reports und Feature-Requests
|
||||
|
||||
---
|
||||
|
||||
**Copyright (c) 2025 - Alle Rechte vorbehalten**
|
||||
|
||||
Die unbefugte Vervielfältigung, Verbreitung oder Weitergabe dieses Plugins ist strafbar und wird rechtlich verfolgt.
|
||||
Die unbefugte Vervielfältigung, Verbreitung oder Weitergabe dieses Plugins ist strafbar und wird rechtlich verfolgt.
|
||||
2
pom.xml
2
pom.xml
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>de.nexuslobby</groupId>
|
||||
<artifactId>NexusLobby</artifactId>
|
||||
<version>1.0.4</version>
|
||||
<version>1.0.5</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>NexusLobby</name>
|
||||
|
||||
@@ -13,11 +13,13 @@ import de.nexuslobby.modules.settings.LobbySettingsModule;
|
||||
import de.nexuslobby.modules.portal.PortalManager;
|
||||
import de.nexuslobby.modules.portal.PortalCommand;
|
||||
import de.nexuslobby.modules.servers.ServerSwitcherListener;
|
||||
import de.nexuslobby.modules.servers.ServerChecker; // Hinzugefügt
|
||||
import de.nexuslobby.modules.armorstandtools.*;
|
||||
import de.nexuslobby.modules.gadgets.GadgetModule;
|
||||
import de.nexuslobby.modules.hologram.HologramModule;
|
||||
import de.nexuslobby.modules.mapart.MapArtModule; // Neu
|
||||
import de.nexuslobby.modules.intro.IntroModule; // Neu
|
||||
import de.nexuslobby.modules.mapart.MapArtModule;
|
||||
import de.nexuslobby.modules.intro.IntroModule;
|
||||
import de.nexuslobby.modules.border.BorderModule;
|
||||
import de.nexuslobby.utils.*;
|
||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
@@ -26,18 +28,25 @@ import net.md_5.bungee.api.chat.HoverEvent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public class NexusLobby extends JavaPlugin implements Listener {
|
||||
|
||||
@@ -50,19 +59,32 @@ public class NexusLobby extends JavaPlugin implements Listener {
|
||||
private GadgetModule gadgetModule;
|
||||
private HologramModule hologramModule;
|
||||
private DynamicArmorStandModule dynamicArmorStandModule;
|
||||
private MapArtModule mapArtModule; // Neu
|
||||
private IntroModule introModule; // Neu
|
||||
private MapArtModule mapArtModule;
|
||||
private IntroModule introModule;
|
||||
private BorderModule borderModule;
|
||||
|
||||
private ConversationManager conversationManager;
|
||||
|
||||
private File visualsFile;
|
||||
private FileConfiguration visualsConfig;
|
||||
|
||||
private boolean updateAvailable = false;
|
||||
private String latestVersion = "";
|
||||
|
||||
private final Set<UUID> silentPlayers = new HashSet<>();
|
||||
|
||||
public static NexusLobby getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public Set<UUID> getSilentPlayers() {
|
||||
return silentPlayers;
|
||||
}
|
||||
|
||||
public ConversationManager getConversationManager() {
|
||||
return conversationManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
instance = this;
|
||||
@@ -72,12 +94,21 @@ public class NexusLobby extends JavaPlugin implements Listener {
|
||||
getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
|
||||
moduleManager = new ModuleManager(this);
|
||||
|
||||
this.conversationManager = new ConversationManager(this);
|
||||
|
||||
ArmorStandGUI.init();
|
||||
|
||||
registerModules();
|
||||
moduleManager.enableAll();
|
||||
registerListeners();
|
||||
|
||||
// --- STATUS CHECKER START ---
|
||||
ServerChecker.startGlobalChecker();
|
||||
|
||||
new ArmorStandLookAtModule();
|
||||
|
||||
startAutoConversationTimer();
|
||||
|
||||
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
|
||||
new NexusLobbyExpansion().register();
|
||||
getLogger().info("NexusLobby PAPI Expansion registriert.");
|
||||
@@ -86,7 +117,86 @@ public class NexusLobby extends JavaPlugin implements Listener {
|
||||
registerCommands();
|
||||
checkUpdates();
|
||||
|
||||
getLogger().info("NexusLobby wurde erfolgreich gestartet.");
|
||||
getLogger().info("NexusLobby v" + getDescription().getVersion() + " wurde erfolgreich gestartet.");
|
||||
}
|
||||
|
||||
private void startAutoConversationTimer() {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (conversationManager == null) return;
|
||||
|
||||
for (World world : Bukkit.getWorlds()) {
|
||||
for (ArmorStand as : world.getEntitiesByClass(ArmorStand.class)) {
|
||||
if (as.getScoreboardTags().stream().anyMatch(tag -> tag.startsWith("conv_id:"))) {
|
||||
boolean playerNearby = false;
|
||||
for (Entity nearby : as.getNearbyEntities(30, 30, 30)) {
|
||||
if (nearby instanceof Player) {
|
||||
playerNearby = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (playerNearby) {
|
||||
String dialogId = null;
|
||||
String partnerUUID = null;
|
||||
|
||||
for (String tag : as.getScoreboardTags()) {
|
||||
if (tag.startsWith("conv_id:")) dialogId = tag.split(":")[1];
|
||||
if (tag.startsWith("conv_partner:")) partnerUUID = tag.split(":")[1];
|
||||
}
|
||||
|
||||
if (dialogId != null && partnerUUID != null) {
|
||||
try {
|
||||
UUID partnerId = UUID.fromString(partnerUUID);
|
||||
conversationManager.playConversation(as.getUniqueId(), partnerId, dialogId);
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}.runTaskTimer(this, 20L * 30, 20L * 90);
|
||||
}
|
||||
|
||||
public void reloadPlugin() {
|
||||
getLogger().info("Plugin Reload wird gestartet...");
|
||||
|
||||
Bukkit.getScheduler().cancelTasks(this);
|
||||
|
||||
if (moduleManager != null) {
|
||||
moduleManager.disableAll();
|
||||
}
|
||||
|
||||
reloadConfig();
|
||||
visualsConfig = null;
|
||||
reloadVisualsConfig();
|
||||
Config.load();
|
||||
|
||||
if (conversationManager != null) {
|
||||
conversationManager.setupFile();
|
||||
}
|
||||
|
||||
if (borderModule != null) {
|
||||
borderModule.reloadConfig();
|
||||
}
|
||||
|
||||
if (portalManager != null) {
|
||||
portalManager.loadPortals();
|
||||
}
|
||||
|
||||
ArmorStandGUI.init();
|
||||
|
||||
if (moduleManager != null) {
|
||||
moduleManager.enableAll();
|
||||
}
|
||||
|
||||
ServerChecker.startGlobalChecker();
|
||||
new ArmorStandLookAtModule();
|
||||
startAutoConversationTimer();
|
||||
|
||||
getLogger().info("Plugin Reload abgeschlossen. Änderungen wurden übernommen.");
|
||||
}
|
||||
|
||||
private void checkUpdates() {
|
||||
@@ -96,7 +206,6 @@ public class NexusLobby extends JavaPlugin implements Listener {
|
||||
this.latestVersion = version;
|
||||
getLogger().warning("====================================================");
|
||||
getLogger().warning("Update gefunden! v" + getDescription().getVersion() + " -> v" + version);
|
||||
getLogger().warning("Autor: M_Viper");
|
||||
getLogger().warning("====================================================");
|
||||
} else {
|
||||
getLogger().info("NexusLobby ist aktuell (v" + version + ").");
|
||||
@@ -104,30 +213,6 @@ public class NexusLobby extends JavaPlugin implements Listener {
|
||||
});
|
||||
}
|
||||
|
||||
public void reloadPlugin() {
|
||||
getLogger().info("Plugin Reload wird gestartet...");
|
||||
|
||||
if (moduleManager != null) {
|
||||
moduleManager.disableAll();
|
||||
}
|
||||
|
||||
reloadConfig();
|
||||
visualsConfig = null;
|
||||
reloadVisualsConfig();
|
||||
Config.load();
|
||||
|
||||
if (portalManager != null) {
|
||||
portalManager.loadPortals();
|
||||
}
|
||||
ArmorStandGUI.init();
|
||||
|
||||
if (moduleManager != null) {
|
||||
moduleManager.enableAll();
|
||||
}
|
||||
|
||||
getLogger().info("Plugin Reload abgeschlossen. Änderungen wurden übernommen.");
|
||||
}
|
||||
|
||||
private void registerModules() {
|
||||
moduleManager.registerModule(new ProtectionModule());
|
||||
moduleManager.registerModule(new ScoreboardModule());
|
||||
@@ -141,28 +226,31 @@ public class NexusLobby extends JavaPlugin implements Listener {
|
||||
this.hologramModule = new HologramModule();
|
||||
moduleManager.registerModule(this.hologramModule);
|
||||
|
||||
// Dynamic ArmorStand Module
|
||||
this.dynamicArmorStandModule = new DynamicArmorStandModule();
|
||||
moduleManager.registerModule(this.dynamicArmorStandModule);
|
||||
|
||||
// MapArt & Intro Module
|
||||
moduleManager.registerModule(new ArmorStandStatusModule());
|
||||
|
||||
this.mapArtModule = new MapArtModule();
|
||||
moduleManager.registerModule(this.mapArtModule);
|
||||
|
||||
this.introModule = new IntroModule();
|
||||
moduleManager.registerModule(this.introModule);
|
||||
|
||||
this.borderModule = new BorderModule();
|
||||
moduleManager.registerModule(this.borderModule);
|
||||
|
||||
moduleManager.registerModule(new SecurityModule());
|
||||
moduleManager.registerModule(new BossBarModule());
|
||||
moduleManager.registerModule(new ActionBarModule());
|
||||
|
||||
lobbySettingsModule = new LobbySettingsModule();
|
||||
this.lobbySettingsModule = new LobbySettingsModule();
|
||||
moduleManager.registerModule(lobbySettingsModule);
|
||||
|
||||
tablistModule = new TablistModule();
|
||||
this.tablistModule = new TablistModule();
|
||||
moduleManager.registerModule(tablistModule);
|
||||
|
||||
portalManager = new PortalManager(this);
|
||||
this.portalManager = new PortalManager(this);
|
||||
moduleManager.registerModule(portalManager);
|
||||
}
|
||||
|
||||
@@ -181,6 +269,8 @@ public class NexusLobby extends JavaPlugin implements Listener {
|
||||
Player player = event.getPlayer();
|
||||
event.setJoinMessage(null);
|
||||
|
||||
teleportToSpawn(player);
|
||||
|
||||
player.getInventory().clear();
|
||||
player.getInventory().setArmorContents(null);
|
||||
|
||||
@@ -201,51 +291,57 @@ public class NexusLobby extends JavaPlugin implements Listener {
|
||||
TextComponent link = new TextComponent("§8» §6Klicke §e§l[HIER] §6zum Herunterladen.");
|
||||
link.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://git.viper.ipv64.net/M_Viper/NexusLobby/releases"));
|
||||
link.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT,
|
||||
new ComponentBuilder("§7Öffnet die Gitea Release-Seite").create()));
|
||||
new ComponentBuilder("§7Öffnet die Release-Seite").create()));
|
||||
|
||||
player.spigot().sendMessage(link);
|
||||
player.sendMessage(" ");
|
||||
}
|
||||
}
|
||||
|
||||
private void initCustomConfigs() {
|
||||
if (!getDataFolder().exists()) {
|
||||
getDataFolder().mkdirs();
|
||||
private void teleportToSpawn(Player player) {
|
||||
FileConfiguration config = getConfig();
|
||||
if (config.contains("spawn.world")) {
|
||||
String worldName = config.getString("spawn.world");
|
||||
World world = Bukkit.getWorld(worldName);
|
||||
if (world != null) {
|
||||
Location spawnLoc = 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")
|
||||
);
|
||||
player.teleport(spawnLoc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void initCustomConfigs() {
|
||||
if (!getDataFolder().exists()) getDataFolder().mkdirs();
|
||||
|
||||
File configFile = new File(getDataFolder(), "config.yml");
|
||||
if (!configFile.exists()) {
|
||||
saveResource("config.yml", false);
|
||||
}
|
||||
if (!configFile.exists()) saveResource("config.yml", false);
|
||||
|
||||
reloadConfig();
|
||||
|
||||
File settingsFile = new File(getDataFolder(), "settings.yml");
|
||||
if (!settingsFile.exists()) {
|
||||
saveResource("settings.yml", false);
|
||||
}
|
||||
if (!settingsFile.exists()) saveResource("settings.yml", false);
|
||||
|
||||
visualsFile = new File(getDataFolder(), "visuals.yml");
|
||||
if (!visualsFile.exists()) {
|
||||
saveResource("visuals.yml", false);
|
||||
}
|
||||
if (!visualsFile.exists()) saveResource("visuals.yml", false);
|
||||
|
||||
reloadVisualsConfig();
|
||||
Config.load();
|
||||
}
|
||||
|
||||
public void reloadVisualsConfig() {
|
||||
if (visualsFile == null) {
|
||||
visualsFile = new File(getDataFolder(), "visuals.yml");
|
||||
}
|
||||
if (visualsFile == null) visualsFile = new File(getDataFolder(), "visuals.yml");
|
||||
visualsConfig = YamlConfiguration.loadConfiguration(visualsFile);
|
||||
getLogger().info("visuals.yml erfolgreich vom Speicher geladen.");
|
||||
}
|
||||
|
||||
public FileConfiguration getVisualsConfig() {
|
||||
if (visualsConfig == null) {
|
||||
reloadVisualsConfig();
|
||||
}
|
||||
if (visualsConfig == null) reloadVisualsConfig();
|
||||
return visualsConfig;
|
||||
}
|
||||
|
||||
@@ -253,28 +349,26 @@ public class NexusLobby extends JavaPlugin implements Listener {
|
||||
public void onDisable() {
|
||||
getServer().getMessenger().unregisterOutgoingPluginChannel(this, "BungeeCord");
|
||||
if (moduleManager != null) moduleManager.disableAll();
|
||||
getLogger().info("NexusLobby disabled");
|
||||
getLogger().info("NexusLobby deaktiviert.");
|
||||
}
|
||||
|
||||
private void registerCommands() {
|
||||
LobbyTabCompleter tabCompleter = new LobbyTabCompleter(portalManager, hologramModule);
|
||||
NexusLobbyCommand nexusCommand = new NexusLobbyCommand();
|
||||
|
||||
PluginCommand portalCmd = this.getCommand("portal");
|
||||
if (portalCmd != null) {
|
||||
portalCmd.setExecutor(new PortalCommand(portalManager));
|
||||
portalCmd.setTabCompleter(tabCompleter);
|
||||
if (getCommand("portal") != null) {
|
||||
getCommand("portal").setExecutor(new PortalCommand(portalManager));
|
||||
getCommand("portal").setTabCompleter(tabCompleter);
|
||||
}
|
||||
|
||||
PluginCommand holoCmd = this.getCommand("holo");
|
||||
if (holoCmd != null) {
|
||||
holoCmd.setExecutor(new HoloCommand(hologramModule));
|
||||
holoCmd.setTabCompleter(tabCompleter);
|
||||
if (getCommand("holo") != null) {
|
||||
getCommand("holo").setExecutor(new HoloCommand(hologramModule));
|
||||
getCommand("holo").setTabCompleter(tabCompleter);
|
||||
}
|
||||
|
||||
PluginCommand maintenanceCmd = this.getCommand("maintenance");
|
||||
if (maintenanceCmd != null) {
|
||||
maintenanceCmd.setExecutor(new MaintenanceCommand());
|
||||
maintenanceCmd.setTabCompleter(tabCompleter);
|
||||
if (getCommand("maintenance") != null) {
|
||||
getCommand("maintenance").setExecutor(new MaintenanceCommand());
|
||||
getCommand("maintenance").setTabCompleter(tabCompleter);
|
||||
}
|
||||
|
||||
if (getCommand("giveportalwand") != null) getCommand("giveportalwand").setExecutor(new GivePortalToolCommand(this));
|
||||
@@ -291,20 +385,28 @@ public class NexusLobby extends JavaPlugin implements Listener {
|
||||
getCommand("nexuscmd").setTabCompleter(tabCompleter);
|
||||
}
|
||||
|
||||
PluginCommand nexusCmd = this.getCommand("nexuslobby");
|
||||
if (nexusCmd != null) {
|
||||
nexusCmd.setExecutor(new NexusLobbyCommand());
|
||||
nexusCmd.setTabCompleter(tabCompleter);
|
||||
if (getCommand("nexuslobby") != null) {
|
||||
getCommand("nexuslobby").setExecutor(nexusCommand);
|
||||
getCommand("nexuslobby").setTabCompleter(tabCompleter);
|
||||
}
|
||||
|
||||
if (getCommand("spawn") != null) {
|
||||
getCommand("spawn").setExecutor(nexusCommand);
|
||||
getCommand("spawn").setTabCompleter(tabCompleter);
|
||||
}
|
||||
|
||||
// Neue Commands im TabCompleter registrieren
|
||||
if (getCommand("mapart") != null) getCommand("mapart").setTabCompleter(tabCompleter);
|
||||
if (getCommand("introtest") != null) getCommand("introtest").setTabCompleter(tabCompleter);
|
||||
if (getCommand("intro") != null) getCommand("intro").setTabCompleter(tabCompleter);
|
||||
|
||||
if (getCommand("border") != null) {
|
||||
getCommand("border").setExecutor(new BorderCommand());
|
||||
getCommand("border").setTabCompleter(tabCompleter);
|
||||
}
|
||||
}
|
||||
|
||||
public class NexusLobbyExpansion extends PlaceholderExpansion {
|
||||
@Override public @NotNull String getIdentifier() { return "nexuslobby"; }
|
||||
@Override public @NotNull String getAuthor() { return String.join(", ", NexusLobby.this.getDescription().getAuthors()); }
|
||||
@Override public @NotNull String getAuthor() { return "M_Viper"; }
|
||||
@Override public @NotNull String getVersion() { return NexusLobby.this.getDescription().getVersion(); }
|
||||
@Override public boolean persist() { return true; }
|
||||
|
||||
@@ -314,15 +416,18 @@ public class NexusLobby extends JavaPlugin implements Listener {
|
||||
if (params.equalsIgnoreCase("maintenance_status")) return MaintenanceListener.isMaintenance() ? "§cAktiv" : "§aDeaktiviert";
|
||||
if (params.equalsIgnoreCase("version")) return NexusLobby.this.getDescription().getVersion();
|
||||
if (params.equalsIgnoreCase("build_mode")) return BuildCommand.isInBuildMode(player) ? "§aAktiv" : "§cInaktiv";
|
||||
if (params.equalsIgnoreCase("silent_join")) return silentPlayers.contains(player.getUniqueId()) ? "§aEin" : "§cAus";
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public ModuleManager getModuleManager() { return moduleManager; }
|
||||
public PortalManager getPortalManager() { return portalManager; } // Hinzugefügt/Wiederhergestellt
|
||||
public TablistModule getTablistModule() { return tablistModule; }
|
||||
public LobbySettingsModule getLobbySettingsModule() { return lobbySettingsModule; }
|
||||
public ItemsModule getItemsModule() { return itemsModule; }
|
||||
public GadgetModule getGadgetModule() { return gadgetModule; }
|
||||
public HologramModule getHologramModule() { return hologramModule; }
|
||||
public DynamicArmorStandModule getDynamicArmorStandModule() { return dynamicArmorStandModule; }
|
||||
public MapArtModule getMapArtModule() { return mapArtModule; } // Wiederhergestellt
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package de.nexuslobby.commands;
|
||||
|
||||
import de.nexuslobby.NexusLobby;
|
||||
import de.nexuslobby.modules.portal.PortalManager;
|
||||
import de.nexuslobby.modules.hologram.HologramModule;
|
||||
import org.bukkit.command.Command;
|
||||
@@ -25,100 +26,133 @@ public class LobbyTabCompleter implements TabCompleter {
|
||||
@Override
|
||||
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) {
|
||||
List<String> suggestions = new ArrayList<>();
|
||||
String cmdName = command.getName().toLowerCase();
|
||||
|
||||
// --- NexusLobby Hauptbefehl ---
|
||||
if (command.getName().equalsIgnoreCase("nexuslobby") || command.getName().equalsIgnoreCase("nexus")) {
|
||||
// --- NexusLobby Hauptbefehl (/nexus) ---
|
||||
if (cmdName.equals("nexuslobby") || cmdName.equals("nexus")) {
|
||||
if (args.length == 1) {
|
||||
if (sender.hasPermission("nexuslobby.admin")) suggestions.add("reload");
|
||||
if (sender.hasPermission("nexuslobby.admin")) {
|
||||
suggestions.addAll(Arrays.asList("reload", "setspawn", "silentjoin"));
|
||||
}
|
||||
suggestions.add("sb");
|
||||
} else if (args.length == 2 && args[0].equalsIgnoreCase("sb")) {
|
||||
suggestions.add("on");
|
||||
suggestions.add("off");
|
||||
if (sender.hasPermission("nexuslobby.scoreboard.admin")) {
|
||||
suggestions.add("admin");
|
||||
suggestions.add("spieler");
|
||||
} else if (args.length == 2) {
|
||||
if (args[0].equalsIgnoreCase("sb")) {
|
||||
suggestions.addAll(Arrays.asList("on", "off"));
|
||||
if (sender.hasPermission("nexuslobby.scoreboard.admin")) {
|
||||
suggestions.addAll(Arrays.asList("admin", "spieler"));
|
||||
}
|
||||
} else if (args[0].equalsIgnoreCase("silentjoin")) {
|
||||
suggestions.addAll(Arrays.asList("on", "off"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --- Hologram Befehl ---
|
||||
else if (command.getName().equalsIgnoreCase("holo")) {
|
||||
else if (cmdName.equals("holo")) {
|
||||
if (args.length == 1) {
|
||||
suggestions.add("create");
|
||||
suggestions.add("delete");
|
||||
suggestions.addAll(Arrays.asList("create", "delete"));
|
||||
} else if (args.length == 2 && args[0].equalsIgnoreCase("delete")) {
|
||||
suggestions.addAll(hologramModule.getHologramIds());
|
||||
if (hologramModule != null) {
|
||||
suggestions.addAll(hologramModule.getHologramIds());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --- Wartungsmodus ---
|
||||
else if (command.getName().equalsIgnoreCase("maintenance")) {
|
||||
else if (cmdName.equals("maintenance")) {
|
||||
if (args.length == 1) {
|
||||
suggestions.add("on");
|
||||
suggestions.add("off");
|
||||
suggestions.addAll(Arrays.asList("on", "off"));
|
||||
}
|
||||
}
|
||||
|
||||
// --- Portalsystem ---
|
||||
else if (command.getName().equalsIgnoreCase("portal")) {
|
||||
else if (cmdName.equals("portal")) {
|
||||
if (args.length == 1) {
|
||||
suggestions.add("create");
|
||||
suggestions.add("delete");
|
||||
suggestions.add("list");
|
||||
suggestions.addAll(Arrays.asList("create", "delete", "list"));
|
||||
} else if (args.length == 2 && args[0].equalsIgnoreCase("delete")) {
|
||||
suggestions.addAll(portalManager.getPortalNames());
|
||||
if (portalManager != null) {
|
||||
suggestions.addAll(portalManager.getPortalNames());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --- MapArt ---
|
||||
else if (command.getName().equalsIgnoreCase("mapart")) {
|
||||
else if (cmdName.equals("mapart")) {
|
||||
if (args.length == 1) {
|
||||
suggestions.add("https://");
|
||||
} else if (args.length == 2) {
|
||||
suggestions.add("1x1");
|
||||
suggestions.add("3x2");
|
||||
suggestions.add("6x4");
|
||||
suggestions.addAll(Arrays.asList("1x1", "3x2", "6x4", "8x5"));
|
||||
}
|
||||
}
|
||||
|
||||
// --- Intro System ---
|
||||
else if (command.getName().equalsIgnoreCase("intro")) {
|
||||
else if (cmdName.equals("intro")) {
|
||||
if (args.length == 1) {
|
||||
suggestions.add("add");
|
||||
suggestions.add("clear");
|
||||
suggestions.add("start");
|
||||
}
|
||||
}
|
||||
|
||||
// --- NexusTools ---
|
||||
else if (command.getName().equalsIgnoreCase("nexustools") || command.getName().equalsIgnoreCase("astools") || command.getName().equalsIgnoreCase("nt")) {
|
||||
if (args.length == 1) {
|
||||
suggestions.add("reload");
|
||||
suggestions.add("dynamic");
|
||||
}
|
||||
}
|
||||
|
||||
// --- NexusCmd ---
|
||||
else if (command.getName().equalsIgnoreCase("nexuscmd") || command.getName().equalsIgnoreCase("ascmd") || command.getName().equalsIgnoreCase("ncmd")) {
|
||||
if (args.length == 1) {
|
||||
suggestions.add("name");
|
||||
suggestions.add("list");
|
||||
suggestions.add("add");
|
||||
suggestions.add("remove");
|
||||
}
|
||||
else if (args.length == 2 && args[0].equalsIgnoreCase("name")) {
|
||||
suggestions.add("none");
|
||||
}
|
||||
else if (args.length == 2 && args[0].equalsIgnoreCase("add")) {
|
||||
suggestions.add("0");
|
||||
}
|
||||
else if (args.length == 4 && args[0].equalsIgnoreCase("add")) {
|
||||
suggestions.add("player");
|
||||
suggestions.add("console");
|
||||
suggestions.add("bungee");
|
||||
suggestions.addAll(Arrays.asList("add", "clear", "start"));
|
||||
}
|
||||
}
|
||||
|
||||
// --- WorldBorder ---
|
||||
else if (cmdName.equals("border")) {
|
||||
if (args.length == 1) {
|
||||
suggestions.addAll(Arrays.asList("circle", "square", "disable"));
|
||||
} else if (args.length == 2 && args[0].equalsIgnoreCase("circle")) {
|
||||
suggestions.addAll(Arrays.asList("10", "25", "50", "100", "250"));
|
||||
}
|
||||
}
|
||||
|
||||
// --- NexusCmd (ArmorStand Commands & Dialoge) ---
|
||||
else if (cmdName.equals("nexuscmd") || cmdName.equals("ncmd") || cmdName.equals("ascmd")) {
|
||||
if (args.length == 1) {
|
||||
suggestions.addAll(Arrays.asList("add", "remove", "list", "name", "lookat", "conv"));
|
||||
}
|
||||
else if (args.length == 2) {
|
||||
if (args[0].equalsIgnoreCase("add")) {
|
||||
suggestions.addAll(Arrays.asList("0", "1", "2", "3", "4", "5", "6", "7", "8", "9"));
|
||||
} else if (args[0].equalsIgnoreCase("name")) {
|
||||
suggestions.addAll(Arrays.asList("<Anzeigename>", "none"));
|
||||
} else if (args[0].equalsIgnoreCase("conv")) {
|
||||
// NEU: unlink hinzugefügt
|
||||
suggestions.addAll(Arrays.asList("select1", "select2", "link", "unlink", "start"));
|
||||
} else if (args[0].equalsIgnoreCase("remove")) {
|
||||
suggestions.add("all");
|
||||
}
|
||||
}
|
||||
else if (args.length == 3) {
|
||||
if (args[0].equalsIgnoreCase("add")) {
|
||||
suggestions.addAll(Arrays.asList("0", "1", "2", "3", "4", "5", "6", "7", "8", "9"));
|
||||
} else if (args[0].equalsIgnoreCase("conv")) {
|
||||
if (args[1].equalsIgnoreCase("start") || args[1].equalsIgnoreCase("link")) {
|
||||
if (NexusLobby.getInstance().getConversationManager() != null) {
|
||||
suggestions.addAll(NexusLobby.getInstance().getConversationManager().getConversationIds());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (args.length == 4 && args[0].equalsIgnoreCase("add")) {
|
||||
suggestions.addAll(Arrays.asList("bungee", "console", "player"));
|
||||
}
|
||||
else if (args.length == 5 && args[0].equalsIgnoreCase("add") && args[3].equalsIgnoreCase("bungee")) {
|
||||
if (NexusLobby.getInstance().getConfig().getConfigurationSection("servers") != null) {
|
||||
suggestions.addAll(NexusLobby.getInstance().getConfig().getConfigurationSection("servers").getKeys(false));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --- ArmorStandTools (/astools) ---
|
||||
else if (cmdName.equals("astools") || cmdName.equals("nt") || cmdName.equals("ntools")) {
|
||||
if (args.length == 1) {
|
||||
suggestions.addAll(Arrays.asList("dynamic", "lookat", "addplayer", "addconsole", "remove", "reload"));
|
||||
}
|
||||
else if (args.length == 2 && (args[0].equalsIgnoreCase("addplayer") || args[0].equalsIgnoreCase("addconsole"))) {
|
||||
suggestions.addAll(Arrays.asList("0", "1", "2", "3", "4", "5", "6", "7", "8", "9"));
|
||||
}
|
||||
else if (args.length == 3 && (args[0].equalsIgnoreCase("addplayer") || args[0].equalsIgnoreCase("addconsole"))) {
|
||||
suggestions.addAll(Arrays.asList("0", "1", "2", "3", "4", "5", "6", "7", "8", "9"));
|
||||
}
|
||||
}
|
||||
|
||||
// Filtert die Liste basierend auf der bisherigen Eingabe (für Case-Insensitivity und Teilübereinstimmung)
|
||||
return suggestions.stream()
|
||||
.filter(s -> s.toLowerCase().startsWith(args[args.length - 1].toLowerCase()))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
@@ -2,89 +2,150 @@ package de.nexuslobby.commands;
|
||||
|
||||
import de.nexuslobby.NexusLobby;
|
||||
import de.nexuslobby.modules.ScoreboardModule;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class NexusLobbyCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
|
||||
// Sub-Befehl: /nexus sb <on|off|admin|spieler>
|
||||
if (args.length >= 2 && args[0].equalsIgnoreCase("sb")) {
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage("§cDieser Befehl ist nur für Spieler!");
|
||||
return true;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
ScoreboardModule sbModule = (ScoreboardModule) NexusLobby.getInstance().getModuleManager().getModule(ScoreboardModule.class);
|
||||
if (!(sender instanceof Player player)) {
|
||||
sender.sendMessage("§cDieser Befehl ist nur für Spieler!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (sbModule == null) {
|
||||
player.sendMessage("§cDas Scoreboard-Modul ist aktuell deaktiviert.");
|
||||
return true;
|
||||
}
|
||||
|
||||
String sub = args[1].toLowerCase();
|
||||
switch (sub) {
|
||||
case "on":
|
||||
sbModule.setVisibility(player, true);
|
||||
break;
|
||||
case "off":
|
||||
sbModule.setVisibility(player, false);
|
||||
break;
|
||||
case "admin":
|
||||
if (!player.hasPermission("nexuslobby.scoreboard.admin")) {
|
||||
player.sendMessage("§cKeine Rechte für den Admin-Modus.");
|
||||
return true;
|
||||
}
|
||||
sbModule.setAdminMode(player, true);
|
||||
break;
|
||||
case "spieler":
|
||||
if (!player.hasPermission("nexuslobby.scoreboard.admin")) {
|
||||
player.sendMessage("§cKeine Rechte für den Admin-Modus.");
|
||||
return true;
|
||||
}
|
||||
sbModule.setAdminMode(player, false);
|
||||
break;
|
||||
default:
|
||||
player.sendMessage("§cBenutzung: /nexus sb <on|off|admin|spieler>");
|
||||
break;
|
||||
// --- SPAWN BEFEHL ---
|
||||
if (command.getName().equalsIgnoreCase("spawn")) {
|
||||
FileConfiguration config = NexusLobby.getInstance().getConfig();
|
||||
if (config.contains("spawn.world")) {
|
||||
Location loc = getSpawnFromConfig(config);
|
||||
if (loc != null) {
|
||||
player.teleport(loc);
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_ENDERMAN_TELEPORT, 1.0f, 1.2f);
|
||||
player.sendMessage("§8[§6Nexus§8] §aDu wurdest zum Spawn teleportiert.");
|
||||
} else {
|
||||
player.sendMessage("§cFehler: Die Spawn-Welt existiert nicht.");
|
||||
}
|
||||
} else {
|
||||
player.sendMessage("§cEs wurde noch kein Spawn gesetzt.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Sub-Befehl: /nexus reload
|
||||
if (args.length == 1 && args[0].equalsIgnoreCase("reload")) {
|
||||
if (!sender.hasPermission("nexuslobby.admin")) {
|
||||
sender.sendMessage("§cDu hast keine Berechtigung für diesen Befehl.");
|
||||
return true;
|
||||
}
|
||||
|
||||
sender.sendMessage("§7[§6NexusLobby§7] §eKonfigurationen und Module werden neu geladen...");
|
||||
NexusLobby.getInstance().reloadPlugin();
|
||||
sender.sendMessage("§7[§6NexusLobby§7] §aDas Plugin wurde erfolgreich neu geladen!");
|
||||
// --- HAUPTBEFEHL ARGUMENTE ---
|
||||
if (args.length == 0) {
|
||||
sendInfo(player);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Standard-Info
|
||||
String version = NexusLobby.getInstance().getDescription().getVersion();
|
||||
sender.sendMessage("§8§m--------------------------------------");
|
||||
sender.sendMessage("§6§lNexusLobby §7- Informationen");
|
||||
sender.sendMessage("");
|
||||
sender.sendMessage("§ePlugin Name: §fNexusLobby");
|
||||
sender.sendMessage("§eVersion: §f" + version);
|
||||
sender.sendMessage("§eAutor: §fM_Viper");
|
||||
sender.sendMessage("");
|
||||
sender.sendMessage("§6Befehle:");
|
||||
sender.sendMessage("§f/nexus reload §7- Plugin neu laden");
|
||||
sender.sendMessage("§f/nexus sb <on|off> §7- Scoreboard schalten");
|
||||
if (sender.hasPermission("nexuslobby.scoreboard.admin")) {
|
||||
sender.sendMessage("§f/nexus sb <admin|spieler> §7- Modus wechseln");
|
||||
switch (args[0].toLowerCase()) {
|
||||
case "reload":
|
||||
if (!player.hasPermission("nexuslobby.admin")) {
|
||||
player.sendMessage("§cKeine Berechtigung.");
|
||||
return true;
|
||||
}
|
||||
|
||||
// Aufruf der Reload-Methode in der Hauptklasse
|
||||
NexusLobby.getInstance().reloadPlugin();
|
||||
|
||||
player.sendMessage("§8[§6Nexus§8] §aPlugin erfolgreich neu geladen!");
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1f, 1.5f);
|
||||
break;
|
||||
|
||||
case "setspawn":
|
||||
if (!player.hasPermission("nexuslobby.admin")) {
|
||||
player.sendMessage("§cKeine Berechtigung.");
|
||||
return true;
|
||||
}
|
||||
Location loc = player.getLocation();
|
||||
FileConfiguration config = NexusLobby.getInstance().getConfig();
|
||||
config.set("spawn.world", loc.getWorld().getName());
|
||||
config.set("spawn.x", loc.getX());
|
||||
config.set("spawn.y", loc.getY());
|
||||
config.set("spawn.z", loc.getZ());
|
||||
config.set("spawn.yaw", (double) loc.getYaw());
|
||||
config.set("spawn.pitch", (double) loc.getPitch());
|
||||
NexusLobby.getInstance().saveConfig();
|
||||
player.sendMessage("§8[§6Nexus§8] §aLobby-Spawn erfolgreich gesetzt!");
|
||||
break;
|
||||
|
||||
case "silentjoin":
|
||||
if (!player.hasPermission("nexuslobby.silentjoin")) {
|
||||
player.sendMessage("§cKeine Berechtigung.");
|
||||
return true;
|
||||
}
|
||||
if (NexusLobby.getInstance().getSilentPlayers().contains(player.getUniqueId())) {
|
||||
NexusLobby.getInstance().getSilentPlayers().remove(player.getUniqueId());
|
||||
player.sendMessage("§8[§6Nexus§8] §7Silent Join: §cDeaktiviert");
|
||||
} else {
|
||||
NexusLobby.getInstance().getSilentPlayers().add(player.getUniqueId());
|
||||
player.sendMessage("§8[§6Nexus§8] §7Silent Join: §aAktiviert");
|
||||
}
|
||||
break;
|
||||
|
||||
case "sb":
|
||||
handleScoreboard(player, args);
|
||||
break;
|
||||
|
||||
default:
|
||||
sendInfo(player);
|
||||
break;
|
||||
}
|
||||
sender.sendMessage("§8§m--------------------------------------");
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void handleScoreboard(Player player, String[] args) {
|
||||
if (args.length < 2) {
|
||||
player.sendMessage("§cBenutzung: /nexus sb <on|off|admin|spieler>");
|
||||
return;
|
||||
}
|
||||
ScoreboardModule sbModule = (ScoreboardModule) NexusLobby.getInstance().getModuleManager().getModule(ScoreboardModule.class);
|
||||
if (sbModule == null) {
|
||||
player.sendMessage("§cScoreboard-Modul ist deaktiviert.");
|
||||
return;
|
||||
}
|
||||
String sub = args[1].toLowerCase();
|
||||
switch (sub) {
|
||||
case "on": sbModule.setVisibility(player, true); break;
|
||||
case "off": sbModule.setVisibility(player, false); break;
|
||||
case "admin":
|
||||
if (player.hasPermission("nexuslobby.scoreboard.admin")) sbModule.setAdminMode(player, true);
|
||||
else player.sendMessage("§cKeine Rechte.");
|
||||
break;
|
||||
case "spieler":
|
||||
if (player.hasPermission("nexuslobby.scoreboard.admin")) sbModule.setAdminMode(player, false);
|
||||
else player.sendMessage("§cKeine Rechte.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private Location getSpawnFromConfig(FileConfiguration config) {
|
||||
World world = Bukkit.getWorld(config.getString("spawn.world", "world"));
|
||||
if (world == null) return null;
|
||||
return 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"));
|
||||
}
|
||||
|
||||
private void sendInfo(Player player) {
|
||||
player.sendMessage("§8§m--------------------------------------");
|
||||
player.sendMessage("§6§lNexusLobby §7- Informationen");
|
||||
player.sendMessage("");
|
||||
player.sendMessage("§f/spawn §7- Zum Spawn teleportieren");
|
||||
player.sendMessage("§f/nexus setspawn §7- Spawn setzen");
|
||||
player.sendMessage("§f/nexus silentjoin §7- Join-Nachricht umschalten");
|
||||
player.sendMessage("§f/nexus sb <on|off> §7- Scoreboard");
|
||||
player.sendMessage("§f/nexus reload §7- Konfiguration laden");
|
||||
player.sendMessage("§8§m--------------------------------------");
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
package de.nexuslobby.modules.armorstandtools;
|
||||
|
||||
import de.nexuslobby.NexusLobby;
|
||||
import com.google.common.io.ByteArrayDataOutput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import de.nexuslobby.NexusLobby;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
@@ -14,8 +14,7 @@ import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.Set;
|
||||
import org.bukkit.util.EulerAngle;
|
||||
|
||||
public class ASTListener implements Listener {
|
||||
|
||||
@@ -26,7 +25,7 @@ public class ASTListener implements Listener {
|
||||
|
||||
Player p = event.getPlayer();
|
||||
|
||||
// Sneak-Rechtsklick zum Bearbeiten
|
||||
// --- 1. FALL: SNEAKING -> Editor öffnen ---
|
||||
if (p.isSneaking()) {
|
||||
if (p.hasPermission("nexuslobby.armorstand.use")) {
|
||||
event.setCancelled(true);
|
||||
@@ -36,62 +35,116 @@ public class ASTListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
// Normale Interaktion (Befehl ausführen)
|
||||
Set<String> tags = as.getScoreboardTags();
|
||||
for (String tag : tags) {
|
||||
// --- 2. FALL: NORMALER KLICK -> Befehle ausführen (Bungee, etc.) ---
|
||||
for (String tag : as.getScoreboardTags()) {
|
||||
if (tag.startsWith("ascmd:")) {
|
||||
event.setCancelled(true);
|
||||
executeNexusCommand(p, tag);
|
||||
break;
|
||||
String[] parts = tag.split(":");
|
||||
if (parts.length < 5) continue;
|
||||
|
||||
String type = parts[3].toLowerCase();
|
||||
String command = parts[4];
|
||||
|
||||
event.setCancelled(true); // Verhindert z.B. dass man Items klaut
|
||||
|
||||
switch (type) {
|
||||
case "bungee":
|
||||
connectToServer(p, command);
|
||||
break;
|
||||
case "player":
|
||||
p.performCommand(command);
|
||||
break;
|
||||
case "console":
|
||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command.replace("%player%", p.getName()));
|
||||
break;
|
||||
}
|
||||
break; // Nur den ersten gefundenen Befehl ausführen
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sendet den Spieler per Plugin-Message an BungeeCord
|
||||
*/
|
||||
private void connectToServer(Player player, String server) {
|
||||
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
||||
out.writeUTF("Connect");
|
||||
out.writeUTF(server);
|
||||
player.sendPluginMessage(NexusLobby.getInstance(), "BungeeCord", out.toByteArray());
|
||||
player.sendMessage("§8[§6Nexus§8] §7Du wirst mit §e" + server + " §7verbunden...");
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onInventoryClick(InventoryClickEvent event) {
|
||||
if (!event.getView().getTitle().equals("Nexus ArmorStand Editor")) return;
|
||||
String title = event.getView().getTitle();
|
||||
|
||||
if (!title.equals("Nexus ArmorStand Editor") &&
|
||||
!title.equals("Pose: Körperteil wählen") &&
|
||||
!title.startsWith("Achsen:")) return;
|
||||
|
||||
event.setCancelled(true);
|
||||
if (!(event.getWhoClicked() instanceof Player p)) return;
|
||||
|
||||
ItemStack item = event.getCurrentItem();
|
||||
if (item == null || item.getType() == Material.AIR) return;
|
||||
|
||||
ArmorStand as = AST.selectedArmorStand.get(p.getUniqueId());
|
||||
if (as == null || !as.isValid()) {
|
||||
p.closeInventory();
|
||||
return;
|
||||
}
|
||||
|
||||
ArmorStandTool tool = ArmorStandTool.get(item);
|
||||
if (tool != null) {
|
||||
tool.execute(as, p);
|
||||
// GUI aktualisieren, falls noch offen (SET_NAME schließt es z.B.)
|
||||
if (p.getOpenInventory().getTitle().equals("Nexus ArmorStand Editor")) {
|
||||
ItemStack item = event.getCurrentItem();
|
||||
if (item == null || item.getType() == Material.AIR) return;
|
||||
|
||||
if (title.equals("Nexus ArmorStand Editor")) {
|
||||
ArmorStandTool tool = ArmorStandTool.get(item);
|
||||
if (tool != null) {
|
||||
tool.execute(as, p);
|
||||
if (p.getOpenInventory().getTitle().equals(title)) {
|
||||
new ArmorStandGUI(as, p);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (title.equals("Pose: Körperteil wählen")) {
|
||||
if (item.getType() == Material.BARRIER) {
|
||||
new ArmorStandGUI(as, p);
|
||||
return;
|
||||
}
|
||||
|
||||
String targetPart = null;
|
||||
switch (item.getType()) {
|
||||
case PLAYER_HEAD -> targetPart = "HEAD_ROT";
|
||||
case IRON_CHESTPLATE -> targetPart = "BODY_ROT";
|
||||
case STICK -> targetPart = (event.getSlot() == 14) ? "L_ARM_ROT" : "R_ARM_ROT";
|
||||
case LEATHER_BOOTS -> targetPart = (event.getSlot() == 28) ? "L_LEG_ROT" : "R_LEG_ROT";
|
||||
}
|
||||
|
||||
if (targetPart != null) {
|
||||
ArmorStandPoseGUI.openAxisDetailMenu(p, as, targetPart);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void executeNexusCommand(Player p, String tag) {
|
||||
try {
|
||||
String[] parts = tag.split(":", 3);
|
||||
if (parts.length < 3) return;
|
||||
String type = parts[1].toLowerCase();
|
||||
String finalizedCommand = parts[2].replace("%player%", p.getName());
|
||||
|
||||
switch (type) {
|
||||
case "player" -> p.performCommand(finalizedCommand);
|
||||
case "console" -> Bukkit.dispatchCommand(Bukkit.getConsoleSender(), finalizedCommand);
|
||||
case "bungee" -> sendToBungee(p, finalizedCommand);
|
||||
else if (title.startsWith("Achsen:")) {
|
||||
if (item.getType() == Material.ARROW) {
|
||||
ArmorStandPoseGUI.openPartSelectionMenu(p, as);
|
||||
return;
|
||||
}
|
||||
} catch (Exception e) { e.printStackTrace(); }
|
||||
}
|
||||
|
||||
String partName = title.split(": ")[1];
|
||||
ArmorStandTool tool = ArmorStandTool.valueOf(partName);
|
||||
|
||||
double change = event.isShiftClick() ? Math.toRadians(1) : Math.toRadians(15);
|
||||
if (event.isRightClick()) change *= -1;
|
||||
|
||||
private void sendToBungee(Player p, String server) {
|
||||
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
||||
out.writeUTF("Connect");
|
||||
out.writeUTF(server);
|
||||
p.sendPluginMessage(NexusLobby.getInstance(), "BungeeCord", out.toByteArray());
|
||||
EulerAngle oldPose = ArmorStandPoseGUI.getAngleForPart(as, tool);
|
||||
EulerAngle newPose = oldPose;
|
||||
|
||||
if (item.getType() == Material.RED_DYE) {
|
||||
newPose = oldPose.setX(oldPose.getX() + change);
|
||||
} else if (item.getType() == Material.GREEN_DYE) {
|
||||
newPose = oldPose.setY(oldPose.getY() + change);
|
||||
} else if (item.getType() == Material.BLUE_DYE) {
|
||||
newPose = oldPose.setZ(oldPose.getZ() + change);
|
||||
}
|
||||
|
||||
ArmorStandPoseGUI.setAngleForPart(as, tool, newPose);
|
||||
ArmorStandPoseGUI.openAxisDetailMenu(p, as, partName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,26 @@
|
||||
package de.nexuslobby.modules.armorstandtools;
|
||||
|
||||
import de.nexuslobby.NexusLobby;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
import org.bukkit.util.EulerAngle;
|
||||
import org.bukkit.util.RayTraceResult;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* ArmorStandCmdExecutor - Erweiterte Steuerung für ArmorStand-Interaktionen.
|
||||
* Nutzt Raytracing für präzise Auswahl und permanentes Dialog-Linking sowie Status-Backup.
|
||||
*/
|
||||
public class ArmorStandCmdExecutor implements CommandExecutor {
|
||||
|
||||
private final String prefix = "§8[§6Nexus§8] ";
|
||||
@@ -25,74 +34,175 @@ public class ArmorStandCmdExecutor implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
// 1. Priorität: Name setzen (verwendet den in der Map gespeicherten AS aus der GUI)
|
||||
if (args.length >= 2 && args[0].equalsIgnoreCase("name")) {
|
||||
ArmorStand target = AST.selectedArmorStand.get(p.getUniqueId());
|
||||
if (target == null || !target.isValid()) {
|
||||
p.sendMessage(prefix + "§cBitte wähle zuerst einen ArmorStand im GUI (Sneak-Rechtsklick) aus!");
|
||||
return true;
|
||||
if (args.length == 0) return sendHelp(p);
|
||||
|
||||
// --- CONVERSATION BEFEHLE ---
|
||||
if (args[0].equalsIgnoreCase("conv")) {
|
||||
if (args.length < 2) {
|
||||
return sendConvHelp(p);
|
||||
}
|
||||
|
||||
|
||||
switch (args[1].toLowerCase()) {
|
||||
case "select1":
|
||||
case "select2":
|
||||
ArmorStand target = getTargetArmorStand(p);
|
||||
if (target == null) {
|
||||
p.sendMessage(prefix + "§cDu musst einen ArmorStand direkt anschauen (Fadenkreuz)!");
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean isFirst = args[1].equalsIgnoreCase("select1");
|
||||
String metaKey = isFirst ? "conv_npc1" : "conv_npc2";
|
||||
UUID targetUUID = target.getUniqueId();
|
||||
|
||||
p.setMetadata(metaKey, new FixedMetadataValue(NexusLobby.getInstance(), targetUUID.toString()));
|
||||
p.sendMessage(prefix + "§aNPC §e" + (isFirst ? "1" : "2") + " §amarkiert (§7" + targetUUID.toString().substring(0, 8) + "...§a)");
|
||||
p.spawnParticle(Particle.WITCH, target.getLocation().add(0, 1.0, 0), 15, 0.2, 0.2, 0.2, 0.05);
|
||||
break;
|
||||
|
||||
case "link":
|
||||
if (args.length < 3) {
|
||||
p.sendMessage(prefix + "§cNutze: /nexuscmd conv link <Dialog-ID>");
|
||||
return true;
|
||||
}
|
||||
if (!p.hasMetadata("conv_npc1") || !p.hasMetadata("conv_npc2")) {
|
||||
p.sendMessage(prefix + "§cBitte markiere erst beide NPCs (select1 & select2)!");
|
||||
return true;
|
||||
}
|
||||
|
||||
UUID id1 = UUID.fromString(p.getMetadata("conv_npc1").get(0).asString());
|
||||
UUID id2 = UUID.fromString(p.getMetadata("conv_npc2").get(0).asString());
|
||||
String dialogId = args[2];
|
||||
|
||||
Entity entity1 = Bukkit.getEntity(id1);
|
||||
if (entity1 instanceof ArmorStand as1) {
|
||||
as1.getScoreboardTags().removeIf(tag -> tag.startsWith("conv_partner:") || tag.startsWith("conv_id:"));
|
||||
as1.addScoreboardTag("conv_partner:" + id2.toString());
|
||||
as1.addScoreboardTag("conv_id:" + dialogId);
|
||||
|
||||
NexusLobby.getInstance().getConversationManager().saveLink(id1, id2, dialogId);
|
||||
|
||||
p.sendMessage(prefix + "§a§lDauerhafte Verknüpfung erstellt!");
|
||||
p.spawnParticle(Particle.HAPPY_VILLAGER, as1.getLocation().add(0, 1.5, 0), 20, 0.4, 0.4, 0.4, 0.1);
|
||||
} else {
|
||||
p.sendMessage(prefix + "§cFehler: Sprecher 1 nicht gefunden.");
|
||||
}
|
||||
break;
|
||||
|
||||
case "unlink":
|
||||
ArmorStand targetUnlink = getTargetArmorStand(p);
|
||||
if (targetUnlink == null) {
|
||||
p.sendMessage(prefix + "§cSchau den NPC an, dessen Verknüpfung du lösen willst!");
|
||||
return true;
|
||||
}
|
||||
|
||||
// Ingame Tags entfernen
|
||||
targetUnlink.getScoreboardTags().removeIf(tag -> tag.startsWith("conv_partner:") || tag.startsWith("conv_id:"));
|
||||
|
||||
// Aus Konfiguration löschen
|
||||
NexusLobby.getInstance().getConversationManager().removeLink(targetUnlink.getUniqueId());
|
||||
|
||||
p.sendMessage(prefix + "§eNPC-Verknüpfung wurde aufgehoben.");
|
||||
p.spawnParticle(Particle.SMOKE, targetUnlink.getLocation().add(0, 1.0, 0), 20, 0.2, 0.2, 0.2, 0.02);
|
||||
break;
|
||||
|
||||
case "start":
|
||||
if (args.length < 3) {
|
||||
p.sendMessage(prefix + "§cNutze: /nexuscmd conv start <ID>");
|
||||
return true;
|
||||
}
|
||||
if (!p.hasMetadata("conv_npc1") || !p.hasMetadata("conv_npc2")) {
|
||||
p.sendMessage(prefix + "§cBitte markiere erst beide NPCs!");
|
||||
return true;
|
||||
}
|
||||
UUID s1 = UUID.fromString(p.getMetadata("conv_npc1").get(0).asString());
|
||||
UUID s2 = UUID.fromString(p.getMetadata("conv_npc2").get(0).asString());
|
||||
NexusLobby.getInstance().getConversationManager().playConversation(s1, s2, args[2]);
|
||||
break;
|
||||
|
||||
default:
|
||||
return sendConvHelp(p);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// --- STANDARD TOOLS (LOOKAT / NAME / ADD) ---
|
||||
ArmorStand target = getTargetArmorStand(p);
|
||||
|
||||
if (args[0].equalsIgnoreCase("lookat")) {
|
||||
if (target == null) { p.sendMessage(prefix + "§cSchau einen ArmorStand an!"); return true; }
|
||||
if (target.getScoreboardTags().contains("as_lookat")) {
|
||||
target.removeScoreboardTag("as_lookat");
|
||||
target.setHeadPose(new EulerAngle(0, 0, 0));
|
||||
p.sendMessage(prefix + "§cBlickkontakt aus.");
|
||||
} else {
|
||||
target.addScoreboardTag("as_lookat");
|
||||
p.sendMessage(prefix + "§aBlickkontakt an.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("name") && args.length >= 2) {
|
||||
if (target == null) { p.sendMessage(prefix + "§cSchau einen ArmorStand an!"); return true; }
|
||||
String nameInput = buildString(args, 1);
|
||||
|
||||
if (nameInput.equalsIgnoreCase("none")) {
|
||||
target.setCustomName("");
|
||||
target.setCustomNameVisible(false);
|
||||
target.getScoreboardTags().removeIf(tag -> tag.startsWith("asname:"));
|
||||
p.sendMessage(prefix + "§eName entfernt.");
|
||||
} else {
|
||||
String colored = ChatColor.translateAlternateColorCodes('&', nameInput);
|
||||
target.setCustomName(colored);
|
||||
target.setCustomNameVisible(true);
|
||||
|
||||
target.getScoreboardTags().removeIf(tag -> tag.startsWith("asname:"));
|
||||
target.addScoreboardTag("asname:" + nameInput);
|
||||
|
||||
p.sendMessage(prefix + "§7Name gesetzt: " + colored);
|
||||
p.sendMessage(prefix + "§8(Status-Backup wurde gespeichert)");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// 2. Priorität: Action-Commands (verwendet Nearby-Suche für /nexuscmd add...)
|
||||
ArmorStand target = getNearbyArmorStand(p);
|
||||
if (target == null) {
|
||||
p.sendMessage(prefix + "§cKein ArmorStand in der Nähe (4 Blöcke) gefunden!");
|
||||
if (args[0].equalsIgnoreCase("add") && args.length >= 5) {
|
||||
if (target == null) { p.sendMessage(prefix + "§cSchau einen ArmorStand an!"); return true; }
|
||||
String slot1 = args[1], slot2 = args[2], type = args[3].toLowerCase();
|
||||
String cmdStr = buildString(args, 4);
|
||||
|
||||
target.addScoreboardTag("ascmd:" + slot1 + ":" + slot2 + ":" + type + ":" + cmdStr);
|
||||
p.sendMessage(prefix + "§aBefehl gebunden.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length >= 5 && args[0].equalsIgnoreCase("add")) {
|
||||
String type = args[3].toLowerCase();
|
||||
String cmd = buildString(args, 4);
|
||||
|
||||
if (!type.equals("player") && !type.equals("console") && !type.equals("bungee")) {
|
||||
p.sendMessage(prefix + "§cTypen: §eplayer, console, bungee");
|
||||
return true;
|
||||
}
|
||||
|
||||
target.addScoreboardTag("ascmd:" + type + ":" + cmd);
|
||||
p.sendMessage(prefix + "§aBefehl an ArmorStand gebunden!");
|
||||
if (args[0].equalsIgnoreCase("list")) {
|
||||
if (target == null) { p.sendMessage(prefix + "§cKein Ziel!"); return true; }
|
||||
p.sendMessage("§6§lBefehle & Tags:");
|
||||
target.getScoreboardTags().forEach(t -> p.sendMessage(" §8» §e" + t));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length >= 1 && args[0].equalsIgnoreCase("list")) {
|
||||
p.sendMessage("§6§lBefehle auf diesem ArmorStand:");
|
||||
for (String tag : target.getScoreboardTags()) {
|
||||
if (tag.startsWith("ascmd:")) {
|
||||
p.sendMessage(" §8» §e" + tag.replace("ascmd:", ""));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length >= 1 && args[0].equalsIgnoreCase("remove")) {
|
||||
Set<String> tags = target.getScoreboardTags();
|
||||
for (String tag : new ArrayList<>(tags)) {
|
||||
if (tag.startsWith("ascmd:")) target.removeScoreboardTag(tag);
|
||||
}
|
||||
p.sendMessage(prefix + "§eAlle Befehle entfernt.");
|
||||
if (args[0].equalsIgnoreCase("remove")) {
|
||||
if (target == null) { p.sendMessage(prefix + "§cKein Ziel!"); return true; }
|
||||
target.getScoreboardTags().removeIf(tag -> tag.startsWith("ascmd:"));
|
||||
p.sendMessage(prefix + "§eAlle Befehle gelöscht.");
|
||||
return true;
|
||||
}
|
||||
|
||||
return sendHelp(p);
|
||||
}
|
||||
|
||||
private ArmorStand getNearbyArmorStand(Player p) {
|
||||
for (Entity e : p.getNearbyEntities(4, 4, 4)) {
|
||||
if (e instanceof ArmorStand as) return as;
|
||||
private ArmorStand getTargetArmorStand(Player p) {
|
||||
RayTraceResult result = p.getWorld().rayTraceEntities(
|
||||
p.getEyeLocation(),
|
||||
p.getLocation().getDirection(),
|
||||
8,
|
||||
0.3,
|
||||
entity -> entity instanceof ArmorStand
|
||||
);
|
||||
|
||||
if (result != null && result.getHitEntity() instanceof ArmorStand as) {
|
||||
return as;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -105,12 +215,26 @@ public class ArmorStandCmdExecutor implements CommandExecutor {
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private boolean sendConvHelp(Player p) {
|
||||
p.sendMessage(" ");
|
||||
p.sendMessage("§6§lConversation Setup:");
|
||||
p.sendMessage("§e/nexuscmd conv select1 §7- Sprecher 1");
|
||||
p.sendMessage("§e/nexuscmd conv select2 §7- Sprecher 2");
|
||||
p.sendMessage("§e/nexuscmd conv link <ID> §7- Speichern");
|
||||
p.sendMessage("§e/nexuscmd conv unlink §7- Verknüpfung lösen");
|
||||
p.sendMessage("§e/nexuscmd conv start <ID> §7- Testen");
|
||||
p.sendMessage(" ");
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean sendHelp(Player p) {
|
||||
p.sendMessage("§6§lNexus Command-Binder Hilfe:");
|
||||
p.sendMessage("§e/nexuscmd name <Text> §7- Namen setzen (AS vorher anklicken)");
|
||||
p.sendMessage("§e/nexuscmd add 0 0 <type> <cmd> §7- Befehl binden");
|
||||
p.sendMessage("§e/nexuscmd list §7- Befehle anzeigen");
|
||||
p.sendMessage("§e/nexuscmd remove §7- Befehle löschen");
|
||||
p.sendMessage("§6§lNexus Tools Hilfe:");
|
||||
p.sendMessage("§e/nexuscmd name <Text> §7- Setzt Namen & Status-Backup");
|
||||
p.sendMessage("§e/nexuscmd lookat §7- Blickkontakt umschalten");
|
||||
p.sendMessage("§e/nexuscmd add <s1> <s2> bungee <Server> §7- Bungee-Bindung");
|
||||
p.sendMessage("§e/nexuscmd conv §7- Gesprächs-Menü");
|
||||
p.sendMessage("§e/nexuscmd list §7- Zeigt alle Tags");
|
||||
p.sendMessage("§e/nexuscmd remove §7- Löscht Befehle");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -9,16 +9,39 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.EulerAngle;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* ArmorStandCommand - Vollständige Steuerung für ArmorStands.
|
||||
* Inklusive Dynamic-Modus Erkennung und visueller Rückmeldung.
|
||||
* Inklusive Dynamic-Modus, Look-At Funktion, Befehls-Slots und Conversation-Sprecher.
|
||||
*/
|
||||
public class ArmorStandCommand implements CommandExecutor {
|
||||
|
||||
// Statische Variablen für die aktuell markierten Sprecher
|
||||
private static UUID speaker1;
|
||||
private static UUID speaker2;
|
||||
|
||||
// Getter-Methoden für die NexusLobby Hauptklasse
|
||||
public static UUID getSpeaker1() {
|
||||
return speaker1;
|
||||
}
|
||||
|
||||
public static UUID getSpeaker2() {
|
||||
return speaker2;
|
||||
}
|
||||
|
||||
// Setter-Methoden (werden vom ASTListener oder der GUI aufgerufen)
|
||||
public static void setSpeaker1(UUID id) {
|
||||
speaker1 = id;
|
||||
}
|
||||
|
||||
public static void setSpeaker2(UUID id) {
|
||||
speaker2 = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (!(sender instanceof Player p)) {
|
||||
@@ -72,36 +95,56 @@ public class ArmorStandCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
if (NexusLobby.getInstance().getDynamicArmorStandModule() != null) {
|
||||
// Toggle Logik
|
||||
if (target.getScoreboardTags().contains("as_dynamic")) {
|
||||
target.removeScoreboardTag("as_dynamic");
|
||||
p.sendMessage(prefix + "§c§l[-] §7Dynamic-Modus §cdeaktiviert§7.");
|
||||
p.spawnParticle(Particle.SMOKE, target.getLocation().add(0, 1, 0), 15, 0.3, 0.3, 0.3, 0.05);
|
||||
} else {
|
||||
target.addScoreboardTag("as_dynamic");
|
||||
p.sendMessage(prefix + "§a§l[+] §7Dynamic-Modus §aaktiviert§7 (Wetter/Zeit).");
|
||||
// Visueller Erfolgseffekt (Grüne Sternchen)
|
||||
p.sendMessage(prefix + "§a§l[+] §7Dynamic-Modus §aaktiviert§7.");
|
||||
p.spawnParticle(Particle.HAPPY_VILLAGER, target.getLocation().add(0, 1, 0), 25, 0.5, 0.5, 0.5, 0.1);
|
||||
}
|
||||
// Internes Update sofort triggern
|
||||
NexusLobby.getInstance().getDynamicArmorStandModule().toggleDynamicStatus(target);
|
||||
} else {
|
||||
p.sendMessage(prefix + "§cFehler: Dynamic-Modul ist nicht aktiv!");
|
||||
}
|
||||
break;
|
||||
|
||||
case "lookat":
|
||||
if (!p.hasPermission("nexuslobby.armorstand.lookat")) {
|
||||
p.sendMessage(prefix + ChatColor.RED + "Keine Rechte für Look-At!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (target.getScoreboardTags().contains("as_lookat")) {
|
||||
target.removeScoreboardTag("as_lookat");
|
||||
// Kopf-Pose zurücksetzen für sauberen Übergang
|
||||
target.setHeadPose(new EulerAngle(0, 0, 0));
|
||||
p.sendMessage(prefix + "§c§l[-] §7Blickkontakt §cdeaktiviert§7.");
|
||||
p.spawnParticle(Particle.SMOKE, target.getLocation().add(0, 1, 0), 10, 0.2, 0.2, 0.2, 0.02);
|
||||
} else {
|
||||
target.addScoreboardTag("as_lookat");
|
||||
p.sendMessage(prefix + "§a§l[+] §7Blickkontakt §aaktiviert§7.");
|
||||
p.spawnParticle(Particle.HAPPY_VILLAGER, target.getLocation().add(0, 1, 0), 15, 0.4, 0.4, 0.4, 0.05);
|
||||
}
|
||||
break;
|
||||
|
||||
case "addplayer":
|
||||
if (args.length < 2) return sendHelp(p, prefix);
|
||||
String pCmd = buildString(args, 1);
|
||||
target.addScoreboardTag("ascmd:player:" + pCmd);
|
||||
p.sendMessage(prefix + "§aBefehl (Player) gespeichert: §e/" + pCmd);
|
||||
if (args.length < 4) return sendHelp(p, prefix);
|
||||
String s1P = args[1];
|
||||
String s2P = args[2];
|
||||
String pCmd = buildString(args, 3);
|
||||
target.addScoreboardTag("ascmd:" + s1P + ":" + s2P + ":player:" + pCmd);
|
||||
p.sendMessage(prefix + "§aBefehl (Player) auf Slot " + s1P + "/" + s2P + " gespeichert.");
|
||||
break;
|
||||
|
||||
case "addconsole":
|
||||
if (args.length < 2) return sendHelp(p, prefix);
|
||||
String cCmd = buildString(args, 1);
|
||||
target.addScoreboardTag("ascmd:console:" + cCmd);
|
||||
p.sendMessage(prefix + "§aBefehl (Konsole) gespeichert: §e" + cCmd);
|
||||
if (args.length < 4) return sendHelp(p, prefix);
|
||||
String s1C = args[1];
|
||||
String s2C = args[2];
|
||||
String cCmd = buildString(args, 3);
|
||||
target.addScoreboardTag("ascmd:" + s1C + ":" + s2C + ":console:" + cCmd);
|
||||
p.sendMessage(prefix + "§aBefehl (Konsole) auf Slot " + s1C + "/" + s2C + " gespeichert.");
|
||||
break;
|
||||
|
||||
case "remove":
|
||||
@@ -117,18 +160,12 @@ public class ArmorStandCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sucht den am besten passenden ArmorStand.
|
||||
* Priorität 1: Der ArmorStand, den der Spieler direkt ansieht.
|
||||
* Priorität 2: Der absolut nächste ArmorStand im Umkreis.
|
||||
*/
|
||||
private ArmorStand getBestTargetArmorStand(Player p) {
|
||||
ArmorStand best = null;
|
||||
double bestDot = 0.95; // Schwellenwert für das "Anschauen"
|
||||
double bestDot = 0.95;
|
||||
|
||||
for (Entity e : p.getNearbyEntities(8, 8, 8)) {
|
||||
if (e instanceof ArmorStand as) {
|
||||
// Berechne, ob der Spieler in Richtung des ArmorStands schaut
|
||||
double dot = p.getLocation().getDirection().dot(
|
||||
as.getLocation().toVector().subtract(p.getLocation().toVector()).normalize()
|
||||
);
|
||||
@@ -140,7 +177,6 @@ public class ArmorStandCommand implements CommandExecutor {
|
||||
}
|
||||
}
|
||||
|
||||
// Falls nichts aktiv angeschaut wird, nimm einfach den nächsten im 4-Block-Radius
|
||||
if (best == null) {
|
||||
for (Entity e : p.getNearbyEntities(4, 4, 4)) {
|
||||
if (e instanceof ArmorStand as) {
|
||||
@@ -163,12 +199,12 @@ public class ArmorStandCommand implements CommandExecutor {
|
||||
private boolean sendHelp(Player p, String prefix) {
|
||||
p.sendMessage(" ");
|
||||
p.sendMessage("§8§m-----------§r " + prefix + "§8§m-----------");
|
||||
p.sendMessage("§e/astools §7- Editor öffnen");
|
||||
p.sendMessage("§b/astools dynamic §7- Wetter/Zeit Logik umschalten");
|
||||
p.sendMessage("§e/astools addplayer <cmd> §7- Befehl als Spieler");
|
||||
p.sendMessage("§e/astools addconsole <cmd> §7- Befehl via Konsole");
|
||||
p.sendMessage("§e/astools §7- Editor GUI öffnen");
|
||||
p.sendMessage("§b/astools dynamic §7- Näherung/Zeit Logik");
|
||||
p.sendMessage("§b/astools lookat §7- Blickkontakt umschalten");
|
||||
p.sendMessage("§e/astools addplayer <S1> <S2> <cmd> §7- Befehl (Spieler)");
|
||||
p.sendMessage("§e/astools addconsole <S1> <S2> <cmd> §7- Befehl (Konsole)");
|
||||
p.sendMessage("§e/astools remove §7- Befehle löschen");
|
||||
p.sendMessage("§e/astools reload §7- Konfig neu laden");
|
||||
p.sendMessage("§8§m---------------------------------------");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
package de.nexuslobby.modules.armorstandtools;
|
||||
|
||||
import de.nexuslobby.NexusLobby;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.util.EulerAngle;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class ArmorStandLookAtModule {
|
||||
|
||||
public ArmorStandLookAtModule() {
|
||||
startRotationTask();
|
||||
}
|
||||
|
||||
private void startRotationTask() {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// Wir gehen alle Welten durch, um markierte ArmorStands zu finden
|
||||
for (World world : Bukkit.getWorlds()) {
|
||||
for (ArmorStand as : world.getEntitiesByClass(ArmorStand.class)) {
|
||||
|
||||
// Nur ArmorStands mit dem Tag "as_lookat"
|
||||
if (as.getScoreboardTags().contains("as_lookat")) {
|
||||
|
||||
// Suche den nächsten Spieler im Umkreis von 7 Blöcken
|
||||
Player nearest = getNearestPlayer(as, 7.0);
|
||||
|
||||
if (nearest != null) {
|
||||
// Spieler gefunden -> Kopf zum Spieler drehen
|
||||
updateLookAt(as, nearest);
|
||||
} else {
|
||||
// Kein Spieler da -> Kopf sanft auf 0,0,0 zurücksetzen
|
||||
resetHeadPose(as);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}.runTaskTimer(NexusLobby.getInstance(), 0L, 1L);
|
||||
}
|
||||
|
||||
private void updateLookAt(ArmorStand as, Player player) {
|
||||
Location asLoc = as.getEyeLocation();
|
||||
Location target = player.getEyeLocation();
|
||||
|
||||
Vector direction = target.toVector().subtract(asLoc.toVector()).normalize();
|
||||
|
||||
// Ziel-Winkel aus Vektor berechnen
|
||||
double targetYaw = Math.toDegrees(Math.atan2(-direction.getX(), direction.getZ()));
|
||||
double targetPitch = Math.toDegrees(Math.asin(direction.getY()));
|
||||
|
||||
// Relativer Yaw zum Körper-Yaw
|
||||
double relativeYaw = targetYaw - as.getLocation().getYaw();
|
||||
relativeYaw = ((relativeYaw + 180) % 360 + 360) % 360 - 180;
|
||||
|
||||
double yawRad = Math.toRadians(relativeYaw);
|
||||
double pitchRad = Math.toRadians(-targetPitch);
|
||||
|
||||
// Begrenzung (Nacken-Schutz)
|
||||
if (yawRad > 1.2) yawRad = 1.2;
|
||||
if (yawRad < -1.2) yawRad = -1.2;
|
||||
if (pitchRad > 0.8) pitchRad = 0.8;
|
||||
if (pitchRad < -0.8) pitchRad = -0.8;
|
||||
|
||||
applySmoothPose(as, pitchRad, yawRad);
|
||||
}
|
||||
|
||||
private void resetHeadPose(ArmorStand as) {
|
||||
EulerAngle current = as.getHeadPose();
|
||||
// Wenn der Kopf schon (fast) gerade ist, nichts tun
|
||||
if (Math.abs(current.getX()) < 0.01 && Math.abs(current.getY()) < 0.01) {
|
||||
if (current.getX() != 0 || current.getY() != 0) {
|
||||
as.setHeadPose(new EulerAngle(0, 0, 0));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Ziel: 0, 0, 0 (Geradeaus schauen)
|
||||
applySmoothPose(as, 0, 0);
|
||||
}
|
||||
|
||||
private void applySmoothPose(ArmorStand as, double pitchRad, double yawRad) {
|
||||
EulerAngle current = as.getHeadPose();
|
||||
double lerp = 0.15; // Geschmeidigkeit
|
||||
|
||||
double finalPitch = current.getX() + (pitchRad - current.getX()) * lerp;
|
||||
double finalYaw = current.getY() + (yawRad - current.getY()) * lerp;
|
||||
|
||||
as.setHeadPose(new EulerAngle(finalPitch, finalYaw, 0));
|
||||
}
|
||||
|
||||
private Player getNearestPlayer(ArmorStand as, double range) {
|
||||
Player nearest = null;
|
||||
double dSquared = range * range;
|
||||
|
||||
for (Player p : as.getWorld().getPlayers()) {
|
||||
// Falls Spieler im Vanish/Spectator ist, ignorieren (optional)
|
||||
if (p.getGameMode().name().equals("SPECTATOR")) continue;
|
||||
|
||||
double dist = p.getLocation().distanceSquared(as.getLocation());
|
||||
if (dist < dSquared) {
|
||||
dSquared = dist;
|
||||
nearest = p;
|
||||
}
|
||||
}
|
||||
return nearest;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
package de.nexuslobby.modules.armorstandtools;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.util.EulerAngle;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class ArmorStandPoseGUI {
|
||||
|
||||
// Schritt 1: Auswahl welches Körperteil (Die "letzte Reihe" ist jetzt hier)
|
||||
public static void openPartSelectionMenu(Player p, ArmorStand as) {
|
||||
Inventory inv = Bukkit.createInventory(null, 45, "Pose: Körperteil wählen");
|
||||
ItemStack filler = new ItemStack(Material.BLACK_STAINED_GLASS_PANE);
|
||||
for (int i = 0; i < 45; i++) inv.setItem(i, filler);
|
||||
|
||||
inv.setItem(10, createPartIcon(Material.PLAYER_HEAD, "§eKopf", as.getHeadPose()));
|
||||
inv.setItem(12, createPartIcon(Material.IRON_CHESTPLATE, "§eTorso", as.getBodyPose()));
|
||||
inv.setItem(14, createPartIcon(Material.STICK, "§eLinker Arm", as.getLeftArmPose()));
|
||||
inv.setItem(16, createPartIcon(Material.STICK, "§eRechter Arm", as.getRightArmPose()));
|
||||
inv.setItem(28, createPartIcon(Material.LEATHER_BOOTS, "§eLinkes Bein", as.getLeftLegPose()));
|
||||
inv.setItem(30, createPartIcon(Material.LEATHER_BOOTS, "§eRechtes Bein", as.getRightLegPose()));
|
||||
|
||||
inv.setItem(40, createNamedItem(Material.BARRIER, "§cZurück zum Hauptmenü"));
|
||||
p.openInventory(inv);
|
||||
}
|
||||
|
||||
// Schritt 2: Detail-Einstellung der Achsen (X, Y, Z)
|
||||
public static void openAxisDetailMenu(Player p, ArmorStand as, String partName) {
|
||||
Inventory inv = Bukkit.createInventory(null, 27, "Achsen: " + partName);
|
||||
ItemStack filler = new ItemStack(Material.GRAY_STAINED_GLASS_PANE);
|
||||
for (int i = 0; i < 27; i++) inv.setItem(i, filler);
|
||||
|
||||
ArmorStandTool tool = ArmorStandTool.valueOf(partName);
|
||||
EulerAngle angle = getAngleForPart(as, tool);
|
||||
|
||||
inv.setItem(11, createAxisItem(Material.RED_DYE, "§c§lX-Achse (Pitch)", angle.getX()));
|
||||
inv.setItem(13, createAxisItem(Material.GREEN_DYE, "§a§lY-Achse (Yaw)", angle.getY()));
|
||||
inv.setItem(15, createAxisItem(Material.BLUE_DYE, "§b§lZ-Achse (Roll)", angle.getZ()));
|
||||
|
||||
inv.setItem(22, createNamedItem(Material.ARROW, "§7Zurück zur Auswahl"));
|
||||
p.openInventory(inv);
|
||||
}
|
||||
|
||||
private static ItemStack createPartIcon(Material mat, String name, EulerAngle angle) {
|
||||
ItemStack item = new ItemStack(mat);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName(name);
|
||||
meta.setLore(Arrays.asList(
|
||||
"§8Rotation:",
|
||||
"§7X: §f" + Math.round(Math.toDegrees(angle.getX())) + "°",
|
||||
"§7Y: §f" + Math.round(Math.toDegrees(angle.getY())) + "°",
|
||||
"§7Z: §f" + Math.round(Math.toDegrees(angle.getZ())) + "°",
|
||||
"", "§6Klicken zum Justieren"
|
||||
));
|
||||
item.setItemMeta(meta);
|
||||
return item;
|
||||
}
|
||||
|
||||
private static ItemStack createAxisItem(Material mat, String name, double angleRad) {
|
||||
ItemStack item = new ItemStack(mat);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName(name);
|
||||
meta.setLore(Arrays.asList(
|
||||
"§7Aktueller Winkel: §f" + Math.round(Math.toDegrees(angleRad)) + "°",
|
||||
"",
|
||||
"§eLinksklick: §f+15° §8| §eRechtsklick: §f-15°",
|
||||
"§6Shift-Klick: §f+1° §8| §6Shift-Rechts: §f-1°"
|
||||
));
|
||||
item.setItemMeta(meta);
|
||||
return item;
|
||||
}
|
||||
|
||||
private static ItemStack createNamedItem(Material mat, String name) {
|
||||
ItemStack item = new ItemStack(mat);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName(name);
|
||||
item.setItemMeta(meta);
|
||||
return item;
|
||||
}
|
||||
|
||||
public static EulerAngle getAngleForPart(ArmorStand as, ArmorStandTool part) {
|
||||
return switch (part) {
|
||||
case HEAD_ROT -> as.getHeadPose();
|
||||
case BODY_ROT -> as.getBodyPose();
|
||||
case L_ARM_ROT -> as.getLeftArmPose();
|
||||
case R_ARM_ROT -> as.getRightArmPose();
|
||||
case L_LEG_ROT -> as.getLeftLegPose();
|
||||
case R_LEG_ROT -> as.getRightLegPose();
|
||||
default -> EulerAngle.ZERO;
|
||||
};
|
||||
}
|
||||
|
||||
public static void setAngleForPart(ArmorStand as, ArmorStandTool part, EulerAngle angle) {
|
||||
switch (part) {
|
||||
case HEAD_ROT -> as.setHeadPose(angle);
|
||||
case BODY_ROT -> as.setBodyPose(angle);
|
||||
case L_ARM_ROT -> as.setLeftArmPose(angle);
|
||||
case R_ARM_ROT -> as.setRightArmPose(angle);
|
||||
case L_LEG_ROT -> as.setLeftLegPose(angle);
|
||||
case R_LEG_ROT -> as.setRightLegPose(angle);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package de.nexuslobby.modules.armorstandtools;
|
||||
|
||||
import de.nexuslobby.NexusLobby;
|
||||
import de.nexuslobby.api.Module;
|
||||
import de.nexuslobby.modules.servers.ServerChecker;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.World;
|
||||
|
||||
public class ArmorStandStatusModule implements Module {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "ArmorStandStatus";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
// Alle 10 Sekunden prüfen
|
||||
Bukkit.getScheduler().runTaskTimer(NexusLobby.getInstance(), this::updateAllServerArmorStands, 100L, 200L);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {}
|
||||
|
||||
private void updateAllServerArmorStands() {
|
||||
for (World world : Bukkit.getWorlds()) {
|
||||
for (Entity entity : world.getEntitiesByClass(ArmorStand.class)) {
|
||||
if (entity instanceof ArmorStand as) {
|
||||
checkAndRefreshStatus(as);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void checkAndRefreshStatus(ArmorStand as) {
|
||||
String bungeeTag = null;
|
||||
for (String tag : as.getScoreboardTags()) {
|
||||
if (tag.startsWith("ascmd:bungee:")) {
|
||||
bungeeTag = tag.replace("ascmd:bungee:", "");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (bungeeTag == null) return;
|
||||
|
||||
String serverName = bungeeTag.toLowerCase();
|
||||
String ip = NexusLobby.getInstance().getConfig().getString("servers." + serverName + ".ip", "127.0.0.1");
|
||||
int port = NexusLobby.getInstance().getConfig().getInt("servers." + serverName + ".port", 25565);
|
||||
|
||||
ServerChecker.isOnline(ip, port).thenAccept(isOnline -> {
|
||||
Bukkit.getScheduler().runTask(NexusLobby.getInstance(), () -> {
|
||||
String originalDisplayName = getOriginalName(as);
|
||||
if (originalDisplayName == null) return;
|
||||
|
||||
String translatedName = ChatColor.translateAlternateColorCodes('&', originalDisplayName);
|
||||
|
||||
if (isOnline) {
|
||||
// Zeigt nur den normalen Namen an, wenn online
|
||||
as.setCustomName(translatedName);
|
||||
} else {
|
||||
// Zeigt den Namen an und darunter (getrennt durch Leerzeichen/Format) den Status
|
||||
// Da Minecraft Namen meist einzeilig sind, nutzen wir eine klare farbliche Trennung
|
||||
as.setCustomName(translatedName + " §7- §cOffline");
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private String getOriginalName(ArmorStand as) {
|
||||
for (String tag : as.getScoreboardTags()) {
|
||||
if (tag.startsWith("as_displayname:")) {
|
||||
return tag.replace("as_displayname:", "").replace("§§", ":");
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -6,84 +6,33 @@ import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
import de.nexuslobby.NexusLobby;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public enum ArmorStandTool {
|
||||
// Sichtbarkeit & Basis-Attribute
|
||||
INVIS(Material.GLASS_PANE, 10) {
|
||||
@Override public void execute(ArmorStand as, Player p) { as.setVisible(!as.isVisible()); }
|
||||
},
|
||||
ARMS(Material.STICK, 11) {
|
||||
@Override public void execute(ArmorStand as, Player p) { as.setArms(!as.hasArms()); }
|
||||
},
|
||||
BASE(Material.STONE_SLAB, 12) {
|
||||
@Override public void execute(ArmorStand as, Player p) { as.setBasePlate(!as.hasBasePlate()); }
|
||||
},
|
||||
SIZE(Material.PUMPKIN_SEEDS, 13) {
|
||||
@Override public void execute(ArmorStand as, Player p) { as.setSmall(!as.isSmall()); }
|
||||
},
|
||||
GRAV(Material.ANVIL, 14) {
|
||||
@Override public void execute(ArmorStand as, Player p) { as.setGravity(!as.hasGravity()); }
|
||||
},
|
||||
INVUL(Material.BEDROCK, 15) {
|
||||
@Override public void execute(ArmorStand as, Player p) { as.setInvulnerable(!as.isInvulnerable()); }
|
||||
},
|
||||
INVIS(Material.GLASS_PANE, 10),
|
||||
ARMS(Material.STICK, 11),
|
||||
BASE(Material.STONE_SLAB, 12),
|
||||
SIZE(Material.PUMPKIN_SEEDS, 13),
|
||||
GRAV(Material.ANVIL, 14),
|
||||
INVUL(Material.BEDROCK, 15),
|
||||
SET_NAME(Material.NAME_TAG, 16),
|
||||
|
||||
// Hologramm / Name setzen
|
||||
SET_NAME(Material.NAME_TAG, 16) {
|
||||
@Override public void execute(ArmorStand as, Player p) {
|
||||
p.closeInventory();
|
||||
p.sendMessage(" ");
|
||||
p.sendMessage("§8§m--------------------------------------");
|
||||
p.sendMessage("§6§lHologramm-Editor");
|
||||
p.sendMessage("§7Nutze: §e/nexuscmd name <Text> §7um den Namen zu setzen.");
|
||||
p.sendMessage("§7Nutze: §e/nexuscmd name none §7um den Namen zu entfernen.");
|
||||
p.sendMessage("§7Farbcodes mit §6& §7werden unterstützt.");
|
||||
p.sendMessage("§8§m--------------------------------------");
|
||||
AST.selectedArmorStand.put(p.getUniqueId(), as);
|
||||
}
|
||||
},
|
||||
// Neuer Button für Gespräche
|
||||
CONV_SETUP(Material.WRITABLE_BOOK, 17),
|
||||
|
||||
// KÖRPERGESTALTUNG (Rotationen)
|
||||
HEAD_ROT(Material.PLAYER_HEAD, 28) {
|
||||
@Override public void execute(ArmorStand as, Player p) {
|
||||
as.setHeadPose(as.getHeadPose().add(Math.toRadians(15), 0, 0));
|
||||
}
|
||||
},
|
||||
BODY_ROT(Material.IRON_CHESTPLATE, 29) {
|
||||
@Override public void execute(ArmorStand as, Player p) {
|
||||
as.setBodyPose(as.getBodyPose().add(0, Math.toRadians(15), 0));
|
||||
}
|
||||
},
|
||||
L_ARM_ROT(Material.STICK, 30) {
|
||||
@Override public void execute(ArmorStand as, Player p) {
|
||||
as.setLeftArmPose(as.getLeftArmPose().add(Math.toRadians(15), 0, 0));
|
||||
}
|
||||
},
|
||||
R_ARM_ROT(Material.STICK, 31) {
|
||||
@Override public void execute(ArmorStand as, Player p) {
|
||||
as.setRightArmPose(as.getRightArmPose().add(Math.toRadians(15), 0, 0));
|
||||
}
|
||||
},
|
||||
L_LEG_ROT(Material.LEATHER_BOOTS, 32) {
|
||||
@Override public void execute(ArmorStand as, Player p) {
|
||||
as.setLeftLegPose(as.getLeftLegPose().add(Math.toRadians(15), 0, 0));
|
||||
}
|
||||
},
|
||||
R_LEG_ROT(Material.LEATHER_BOOTS, 33) {
|
||||
@Override public void execute(ArmorStand as, Player p) {
|
||||
as.setRightLegPose(as.getRightLegPose().add(Math.toRadians(15), 0, 0));
|
||||
}
|
||||
},
|
||||
OPEN_POSE_EDITOR(Material.ARMOR_STAND, 31),
|
||||
|
||||
REMOVE(Material.BARRIER, 40) {
|
||||
@Override public void execute(ArmorStand as, Player p) {
|
||||
as.remove();
|
||||
p.closeInventory();
|
||||
p.sendMessage("§cNexus ArmorStand entfernt.");
|
||||
}
|
||||
};
|
||||
HEAD_ROT(Material.PLAYER_HEAD, -1),
|
||||
BODY_ROT(Material.IRON_CHESTPLATE, -1),
|
||||
L_ARM_ROT(Material.STICK, -1),
|
||||
R_ARM_ROT(Material.STICK, -1),
|
||||
L_LEG_ROT(Material.LEATHER_BOOTS, -1),
|
||||
R_LEG_ROT(Material.LEATHER_BOOTS, -1),
|
||||
|
||||
REMOVE(Material.BARRIER, 40);
|
||||
|
||||
private final Material material;
|
||||
private final int slot;
|
||||
@@ -93,20 +42,56 @@ public enum ArmorStandTool {
|
||||
this.slot = slot;
|
||||
}
|
||||
|
||||
public abstract void execute(ArmorStand as, Player p);
|
||||
|
||||
public void execute(ArmorStand as, Player p) {
|
||||
switch (this) {
|
||||
case INVIS -> as.setVisible(!as.isVisible());
|
||||
case ARMS -> as.setArms(!as.hasArms());
|
||||
case BASE -> as.setBasePlate(!as.hasBasePlate());
|
||||
case SIZE -> as.setSmall(!as.isSmall());
|
||||
case GRAV -> as.setGravity(!as.hasGravity());
|
||||
case INVUL -> as.setInvulnerable(!as.isInvulnerable());
|
||||
case SET_NAME -> {
|
||||
p.closeInventory();
|
||||
p.sendMessage("§8[§6Nexus§8] §7Nutze §e/nexuscmd name <Text>");
|
||||
AST.selectedArmorStand.put(p.getUniqueId(), as);
|
||||
}
|
||||
case CONV_SETUP -> {
|
||||
// Automatisches Markieren via GUI
|
||||
if (!p.hasMetadata("conv_npc1")) {
|
||||
p.setMetadata("conv_npc1", new FixedMetadataValue(NexusLobby.getInstance(), as.getUniqueId().toString()));
|
||||
p.sendMessage("§8[§6Nexus§8] §aNPC als Sprecher 1 markiert.");
|
||||
} else {
|
||||
p.setMetadata("conv_npc2", new FixedMetadataValue(NexusLobby.getInstance(), as.getUniqueId().toString()));
|
||||
p.sendMessage("§8[§6Nexus§8] §aNPC als Sprecher 2 markiert.");
|
||||
p.sendMessage("§8[§6Nexus§8] §7Nutze nun §e/nexuscmd conv start <ID>");
|
||||
}
|
||||
p.closeInventory();
|
||||
}
|
||||
case REMOVE -> {
|
||||
as.remove();
|
||||
p.closeInventory();
|
||||
p.sendMessage("§cNexus ArmorStand entfernt.");
|
||||
}
|
||||
case OPEN_POSE_EDITOR -> ArmorStandPoseGUI.openPartSelectionMenu(p, as);
|
||||
default -> {}
|
||||
}
|
||||
}
|
||||
|
||||
public int getSlot() { return slot; }
|
||||
|
||||
// Diese Methode hat im letzten Code gefehlt:
|
||||
public boolean isForGui() { return true; }
|
||||
public boolean isForGui() { return slot != -1; }
|
||||
|
||||
public ItemStack updateLore(ArmorStand as) {
|
||||
ItemStack item = new ItemStack(material);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
if (meta != null) {
|
||||
meta.setDisplayName("§6" + this.name().replace("_", " "));
|
||||
String displayName = switch (this) {
|
||||
case OPEN_POSE_EDITOR -> "§a§lPose Editor öffnen";
|
||||
case CONV_SETUP -> "§d§lGesprächs-Setup";
|
||||
default -> "§6" + this.name().replace("_", " ");
|
||||
};
|
||||
meta.setDisplayName(displayName);
|
||||
List<String> lore = new ArrayList<>();
|
||||
lore.add("§7Klicken zum Bearbeiten");
|
||||
lore.add("§7Klicken zum Verwalten");
|
||||
meta.setLore(lore);
|
||||
item.setItemMeta(meta);
|
||||
}
|
||||
@@ -116,6 +101,8 @@ public enum ArmorStandTool {
|
||||
public static ArmorStandTool get(ItemStack item) {
|
||||
if (item == null || !item.hasItemMeta() || !item.getItemMeta().hasDisplayName()) return null;
|
||||
String name = ChatColor.stripColor(item.getItemMeta().getDisplayName()).replace(" ", "_");
|
||||
if (name.equals("Pose_Editor_öffnen")) return OPEN_POSE_EDITOR;
|
||||
if (name.equals("Gesprächs-Setup")) return CONV_SETUP;
|
||||
try { return valueOf(name); } catch (Exception e) { return null; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
package de.nexuslobby.modules.armorstandtools;
|
||||
|
||||
import de.nexuslobby.NexusLobby;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class ConversationManager {
|
||||
|
||||
private final NexusLobby plugin;
|
||||
private File file;
|
||||
private FileConfiguration config;
|
||||
|
||||
public ConversationManager(NexusLobby plugin) {
|
||||
this.plugin = plugin;
|
||||
setupFile();
|
||||
}
|
||||
|
||||
public void setupFile() {
|
||||
this.file = new File(plugin.getDataFolder(), "conversations.yml");
|
||||
|
||||
if (!file.exists()) {
|
||||
try {
|
||||
if (!plugin.getDataFolder().exists()) {
|
||||
plugin.getDataFolder().mkdirs();
|
||||
}
|
||||
plugin.saveResource("conversations.yml", false);
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
file.createNewFile();
|
||||
YamlConfiguration defaultConfig = YamlConfiguration.loadConfiguration(file);
|
||||
defaultConfig.set("conversations.test.dialogue", Arrays.asList(
|
||||
"&eNPC 1: &7Hallo!",
|
||||
"&aNPC 2: &7Hi, wie geht es dir?",
|
||||
"&eNPC 1: &7Bestens, danke!"
|
||||
));
|
||||
defaultConfig.save(file);
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
this.config = YamlConfiguration.loadConfiguration(file);
|
||||
}
|
||||
|
||||
public void saveLink(UUID id1, UUID id2, String dialogId) {
|
||||
config.set("links." + id1.toString() + ".partner", id2.toString());
|
||||
config.set("links." + id1.toString() + ".dialog", dialogId); // WICHTIG: ".dialog"
|
||||
saveConfig();
|
||||
}
|
||||
|
||||
public void removeLink(UUID id) {
|
||||
if (config.contains("links." + id.toString())) {
|
||||
config.set("links." + id.toString(), null);
|
||||
saveConfig();
|
||||
}
|
||||
}
|
||||
|
||||
public void startAllAutomatedConversations() {
|
||||
if (config.getConfigurationSection("links") == null) return;
|
||||
|
||||
for (String npc1String : config.getConfigurationSection("links").getKeys(false)) {
|
||||
try {
|
||||
UUID id1 = UUID.fromString(npc1String);
|
||||
UUID id2 = UUID.fromString(config.getString("links." + npc1String + ".partner"));
|
||||
String dialogId = config.getString("links." + npc1String + ".dialog"); // WICHTIG: ".dialog"
|
||||
|
||||
Entity e1 = Bukkit.getEntity(id1);
|
||||
Entity e2 = Bukkit.getEntity(id2);
|
||||
|
||||
if (e1 instanceof ArmorStand as1 && e2 instanceof ArmorStand as2) {
|
||||
if (as1.getNearbyEntities(15, 15, 15).stream().anyMatch(e -> e instanceof Player)) {
|
||||
playConversation(id1, id2, dialogId);
|
||||
}
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
}
|
||||
|
||||
public List<String> getConversationIds() {
|
||||
if (config == null || !config.contains("conversations")) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return new ArrayList<>(config.getConfigurationSection("conversations").getKeys(false));
|
||||
}
|
||||
|
||||
public void playConversation(UUID id1, UUID id2, String key) {
|
||||
// Sicherstellen, dass wir auf "conversations.KEY.dialogue" prüfen
|
||||
if (config == null || !config.contains("conversations." + key)) {
|
||||
Bukkit.getLogger().warning("[NexusLobby] Dialog-ID '" + key + "' nicht in conversations.yml gefunden!");
|
||||
return;
|
||||
}
|
||||
|
||||
List<String> lines = config.getStringList("conversations." + key + ".dialogue");
|
||||
if (lines == null || lines.isEmpty()) return;
|
||||
|
||||
new BukkitRunnable() {
|
||||
int step = 0;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (step >= lines.size()) {
|
||||
this.cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
UUID speakerUUID = (step % 2 == 0) ? id1 : id2;
|
||||
Entity entity = Bukkit.getEntity(speakerUUID);
|
||||
|
||||
if (entity instanceof ArmorStand as) {
|
||||
as.getWorld().playSound(as.getLocation(), Sound.ENTITY_CHICKEN_EGG, 0.5f, 1.5f);
|
||||
showBubble(as, lines.get(step));
|
||||
} else {
|
||||
this.cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
step++;
|
||||
}
|
||||
}.runTaskTimer(plugin, 0L, 70L);
|
||||
}
|
||||
|
||||
private void showBubble(ArmorStand as, String text) {
|
||||
Location loc = as.getEyeLocation().add(0, 0.6, 0);
|
||||
|
||||
ArmorStand bubble = as.getWorld().spawn(loc, ArmorStand.class, s -> {
|
||||
s.setMarker(true);
|
||||
s.setVisible(false);
|
||||
s.setGravity(false);
|
||||
s.setCustomName(ChatColorTranslate(text));
|
||||
s.setCustomNameVisible(true);
|
||||
s.setInvulnerable(true);
|
||||
});
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(plugin, bubble::remove, 60L);
|
||||
}
|
||||
|
||||
private String ChatColorTranslate(String text) {
|
||||
return text.replace("&", "§");
|
||||
}
|
||||
|
||||
private void saveConfig() {
|
||||
try {
|
||||
config.save(file);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void reload() {
|
||||
this.config = YamlConfiguration.loadConfiguration(file);
|
||||
}
|
||||
}
|
||||
@@ -3,25 +3,20 @@ package de.nexuslobby.modules.armorstandtools;
|
||||
import de.nexuslobby.NexusLobby;
|
||||
import de.nexuslobby.api.Module;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
import org.bukkit.util.EulerAngle;
|
||||
|
||||
import java.time.LocalTime;
|
||||
|
||||
/**
|
||||
* DynamicArmorStandModule
|
||||
* Reagiert auf Uhrzeit und Wetter.
|
||||
* Nutzt PersistentData, damit die Einstellung auch nach einem Server-Neustart bleibt.
|
||||
*/
|
||||
public class DynamicArmorStandModule implements Module {
|
||||
|
||||
// Der Key muss mit dem Command übereinstimmen oder das Modul nutzt Tags.
|
||||
// Wir nutzen hier PersistentData, da es sicherer ist als Tags.
|
||||
private final NamespacedKey npcKey = new NamespacedKey(NexusLobby.getInstance(), "dynamic_npc");
|
||||
|
||||
@Override
|
||||
@@ -32,88 +27,106 @@ public class DynamicArmorStandModule implements Module {
|
||||
@Override
|
||||
public void onEnable() {
|
||||
startUpdateTask();
|
||||
Bukkit.getLogger().info("[NexusLobby] DynamicArmorStandModule wurde aktiviert.");
|
||||
Bukkit.getLogger().info("§a[NexusLobby] DynamicArmorStandModule aktiv: Ingame-Zeit & Sternen-Effekt geladen.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Startet einen Timer, der alle 5 Sekunden (100 Ticks) prüft.
|
||||
*/
|
||||
private void startUpdateTask() {
|
||||
Bukkit.getScheduler().runTaskTimer(NexusLobby.getInstance(), () -> {
|
||||
updateAllArmorStands();
|
||||
}, 100L, 100L); // Alle 5 Sekunden statt 2 Minuten
|
||||
// Alle 5 Ticks (0.25s) für flüssige Partikel
|
||||
Bukkit.getScheduler().runTaskTimer(NexusLobby.getInstance(), this::updateAllArmorStands, 20L, 5L);
|
||||
}
|
||||
|
||||
public void updateAllArmorStands() {
|
||||
int hour = LocalTime.now().getHour();
|
||||
|
||||
for (World world : Bukkit.getWorlds()) {
|
||||
boolean isRaining = world.hasStorm();
|
||||
long time = world.getTime();
|
||||
boolean isIngameNight = (time >= 13000 && time <= 23000);
|
||||
|
||||
for (Entity entity : world.getEntities()) {
|
||||
if (entity instanceof ArmorStand armorStand) {
|
||||
// PRÜFUNG: Entweder PersistentData ODER Scoreboard-Tag "as_dynamic"
|
||||
if (armorStand.getPersistentDataContainer().has(npcKey, PersistentDataType.BYTE) ||
|
||||
armorStand.getScoreboardTags().contains("as_dynamic")) {
|
||||
if (entity instanceof ArmorStand as) {
|
||||
if (as.getPersistentDataContainer().has(npcKey, PersistentDataType.BYTE) ||
|
||||
as.getScoreboardTags().contains("as_dynamic")) {
|
||||
|
||||
applyDynamicChanges(armorStand, hour, isRaining);
|
||||
applyDynamicChanges(as, isIngameNight);
|
||||
|
||||
if (isIngameNight && as.getEquipment().getItemInOffHand().getType() == Material.TORCH) {
|
||||
spawnStarParticles(as);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void applyDynamicChanges(ArmorStand as, int hour, boolean isRaining) {
|
||||
// --- ZEIT-LOGIK (Nacht: 20:00 - 06:00) ---
|
||||
if (hour >= 20 || hour <= 6) {
|
||||
private void applyDynamicChanges(ArmorStand as, boolean isNight) {
|
||||
if (!as.hasArms()) as.setArms(true);
|
||||
|
||||
// --- SPIELER-NÄHE ---
|
||||
boolean playerNearby = false;
|
||||
for (Entity nearby : as.getNearbyEntities(2.0, 2.0, 2.0)) {
|
||||
if (nearby instanceof Player) { playerNearby = true; break; }
|
||||
}
|
||||
|
||||
if (playerNearby) {
|
||||
if (as.getEquipment().getItemInMainHand().getType() != Material.STONE_SWORD) {
|
||||
as.getEquipment().setItemInMainHand(new ItemStack(Material.STONE_SWORD));
|
||||
as.setRightArmPose(new EulerAngle(Math.toRadians(-80), Math.toRadians(-10), 0));
|
||||
}
|
||||
} else {
|
||||
if (as.getEquipment().getItemInMainHand().getType() == Material.STONE_SWORD) {
|
||||
as.getEquipment().setItemInMainHand(null);
|
||||
as.setRightArmPose(EulerAngle.ZERO);
|
||||
}
|
||||
}
|
||||
|
||||
// --- INGAME-ZEIT ---
|
||||
if (isNight) {
|
||||
if (as.getEquipment().getItemInOffHand().getType() != Material.TORCH) {
|
||||
as.getEquipment().setItemInOffHand(new ItemStack(Material.TORCH));
|
||||
as.setLeftArmPose(new EulerAngle(Math.toRadians(-50), Math.toRadians(15), 0));
|
||||
}
|
||||
} else {
|
||||
if (as.getEquipment().getItemInOffHand().getType() == Material.TORCH) {
|
||||
as.getEquipment().setItemInOffHand(null);
|
||||
}
|
||||
}
|
||||
|
||||
// --- WETTER-LOGIK (Regen) ---
|
||||
if (isRaining) {
|
||||
if (as.getEquipment().getHelmet() == null || as.getEquipment().getHelmet().getType() != Material.LEATHER_HELMET) {
|
||||
as.getEquipment().setHelmet(new ItemStack(Material.LEATHER_HELMET));
|
||||
}
|
||||
} else {
|
||||
// Nur ausziehen, wenn es hellwach ist und nicht regnet
|
||||
if (hour < 20 && hour > 6) {
|
||||
if (as.getEquipment().getHelmet() != null && as.getEquipment().getHelmet().getType() == Material.LEATHER_HELMET) {
|
||||
as.getEquipment().setHelmet(null);
|
||||
}
|
||||
as.setLeftArmPose(EulerAngle.ZERO);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Schaltet den Status um. Wird vom ArmorStandCommand aufgerufen.
|
||||
*/
|
||||
private void spawnStarParticles(ArmorStand as) {
|
||||
Location loc = as.getLocation();
|
||||
double yawRad = Math.toRadians(loc.getYaw());
|
||||
|
||||
// Vektoren für Blickrichtung und Seite
|
||||
double dirX = -Math.sin(yawRad);
|
||||
double dirZ = Math.cos(yawRad);
|
||||
double sideX = Math.cos(yawRad);
|
||||
double sideZ = Math.sin(yawRad);
|
||||
|
||||
// Position: Vorne (0.4), Links (0.5), Oben (1.45)
|
||||
double finalX = loc.getX() + (dirX * 0.8) + (sideX * 0.2);
|
||||
double finalY = loc.getY() + 1.45;
|
||||
double finalZ = loc.getZ() + (dirZ * 0.8) + (sideZ * 0.2);
|
||||
|
||||
Location particleLoc = new Location(as.getWorld(), finalX, finalY, finalZ);
|
||||
as.getWorld().spawnParticle(Particle.WAX_OFF, particleLoc, 2, 0.05, 0.05, 0.05, 0.01);
|
||||
}
|
||||
|
||||
public void toggleDynamicStatus(ArmorStand as) {
|
||||
if (as.getPersistentDataContainer().has(npcKey, PersistentDataType.BYTE)) {
|
||||
// Deaktivieren
|
||||
as.getPersistentDataContainer().remove(npcKey);
|
||||
as.removeScoreboardTag("as_dynamic"); // Zur Sicherheit beides entfernen
|
||||
as.removeScoreboardTag("as_dynamic");
|
||||
as.getEquipment().setItemInMainHand(null);
|
||||
as.getEquipment().setItemInOffHand(null);
|
||||
as.getEquipment().setHelmet(null);
|
||||
as.setRightArmPose(EulerAngle.ZERO);
|
||||
as.setLeftArmPose(EulerAngle.ZERO);
|
||||
} else {
|
||||
// Aktivieren
|
||||
as.getPersistentDataContainer().set(npcKey, PersistentDataType.BYTE, (byte) 1);
|
||||
as.addScoreboardTag("as_dynamic");
|
||||
|
||||
// Sofortige visuelle Rückmeldung
|
||||
int hour = LocalTime.now().getHour();
|
||||
boolean isRaining = as.getWorld().hasStorm();
|
||||
applyDynamicChanges(as, hour, isRaining);
|
||||
applyDynamicChanges(as, (as.getWorld().getTime() >= 13000 && as.getWorld().getTime() <= 23000));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
// Nichts zu tun
|
||||
// Bereinigung falls nötig
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package de.nexuslobby.commands;
|
||||
|
||||
import de.nexuslobby.NexusLobby;
|
||||
import de.nexuslobby.modules.portal.PortalCommand;
|
||||
import de.nexuslobby.modules.border.BorderModule;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class BorderCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (!(sender instanceof Player p)) return true;
|
||||
if (!p.hasPermission("nexuslobby.admin")) {
|
||||
p.sendMessage("§8[§6Nexus§8] §cKeine Rechte.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length == 0) {
|
||||
p.sendMessage("§8§m------------------------------------");
|
||||
p.sendMessage("§6§lNexus WorldBorder Setup");
|
||||
p.sendMessage("§e/border circle <Radius> §7- Kreis um dich herum");
|
||||
p.sendMessage("§e/border square §7- Nutzt Axt-Markierung (Viereck)");
|
||||
p.sendMessage("§e/border disable §7- Grenze deaktivieren");
|
||||
p.sendMessage("§8§m------------------------------------");
|
||||
return true;
|
||||
}
|
||||
|
||||
var config = NexusLobby.getInstance().getConfig();
|
||||
|
||||
switch (args[0].toLowerCase()) {
|
||||
case "circle" -> {
|
||||
if (args.length < 2) {
|
||||
p.sendMessage("§cBitte gib einen Radius an.");
|
||||
return true;
|
||||
}
|
||||
try {
|
||||
double radius = Double.parseDouble(args[1]);
|
||||
config.set("worldborder.type", "CIRCLE");
|
||||
config.set("worldborder.center", p.getLocation());
|
||||
config.set("worldborder.radius", radius);
|
||||
config.set("worldborder.enabled", true);
|
||||
p.sendMessage("§8[§6Nexus§8] §aKreis-Grenze (Radius: " + radius + ") gesetzt.");
|
||||
} catch (NumberFormatException e) {
|
||||
p.sendMessage("§cUngültige Zahl.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
case "square" -> {
|
||||
Location l1 = PortalCommand.getSelection1(p);
|
||||
Location l2 = PortalCommand.getSelection2(p);
|
||||
if (l1 == null || l2 == null) {
|
||||
p.sendMessage("§8[§6Nexus§8] §cBitte markiere erst 2 Punkte mit der Portalwand!");
|
||||
return true;
|
||||
}
|
||||
config.set("worldborder.type", "SQUARE");
|
||||
config.set("worldborder.pos1", l1);
|
||||
config.set("worldborder.pos2", l2);
|
||||
config.set("worldborder.enabled", true);
|
||||
p.sendMessage("§8[§6Nexus§8] §aViereckige Grenze erfolgreich gesetzt.");
|
||||
}
|
||||
case "disable" -> {
|
||||
config.set("worldborder.enabled", false);
|
||||
p.sendMessage("§8[§6Nexus§8] §cGrenze wurde deaktiviert.");
|
||||
}
|
||||
default -> {
|
||||
p.sendMessage("§cUnbekannter Unterbefehl.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
NexusLobby.getInstance().saveConfig();
|
||||
|
||||
// Update das Modul direkt im RAM
|
||||
BorderModule module = NexusLobby.getInstance().getModuleManager().getModule(BorderModule.class);
|
||||
if (module != null) {
|
||||
module.reloadConfig();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
132
src/main/java/de/nexuslobby/modules/border/BorderModule.java
Normal file
132
src/main/java/de/nexuslobby/modules/border/BorderModule.java
Normal file
@@ -0,0 +1,132 @@
|
||||
package de.nexuslobby.modules.border;
|
||||
|
||||
import de.nexuslobby.NexusLobby;
|
||||
import de.nexuslobby.api.Module;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
/**
|
||||
* Verwaltet die Lobby-Begrenzung (Kreis oder Rechteck).
|
||||
* Speichert Daten in der Haupt-config.yml unter 'worldborder'.
|
||||
*/
|
||||
public class BorderModule implements Module, Listener {
|
||||
|
||||
private String type;
|
||||
private Location pos1, pos2, center;
|
||||
private double radius;
|
||||
private boolean enabled;
|
||||
|
||||
@Override
|
||||
public String getName() { return "WorldBorder"; }
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
reloadConfig();
|
||||
Bukkit.getPluginManager().registerEvents(this, NexusLobby.getInstance());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
// Aufräumarbeiten falls nötig
|
||||
}
|
||||
|
||||
/**
|
||||
* Lädt die Border-Einstellungen aus der config.yml.
|
||||
* Wird auch von NexusLobby.reloadPlugin() aufgerufen.
|
||||
*/
|
||||
public void reloadConfig() {
|
||||
FileConfiguration config = NexusLobby.getInstance().getConfig();
|
||||
|
||||
// Pfad in der config.yml: worldborder.enabled etc.
|
||||
this.enabled = config.getBoolean("worldborder.enabled", false);
|
||||
this.type = config.getString("worldborder.type", "CIRCLE");
|
||||
this.radius = config.getDouble("worldborder.radius", 50.0);
|
||||
|
||||
// Locations laden
|
||||
this.center = config.getLocation("worldborder.center");
|
||||
this.pos1 = config.getLocation("worldborder.pos1");
|
||||
this.pos2 = config.getLocation("worldborder.pos2");
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onMove(PlayerMoveEvent event) {
|
||||
if (!enabled || event.getTo() == null) return;
|
||||
|
||||
// Performance: Nur prüfen, wenn sich die Block-Koordinaten ändern
|
||||
if (event.getFrom().getBlockX() == event.getTo().getBlockX() &&
|
||||
event.getFrom().getBlockZ() == event.getTo().getBlockZ() &&
|
||||
event.getFrom().getBlockY() == event.getTo().getBlockY()) return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
// Admins und Spectators ignorieren
|
||||
if (player.hasPermission("nexuslobby.admin") || player.getGameMode().name().equals("SPECTATOR")) return;
|
||||
|
||||
Location to = event.getTo();
|
||||
boolean outside = false;
|
||||
|
||||
// --- Prüfung: Kreis-Border ---
|
||||
if (type.equalsIgnoreCase("CIRCLE") && center != null) {
|
||||
if (to.getWorld().equals(center.getWorld())) {
|
||||
double distSq = Math.pow(to.getX() - center.getX(), 2) + Math.pow(to.getZ() - center.getZ(), 2);
|
||||
if (distSq > Math.pow(radius, 2)) outside = true;
|
||||
}
|
||||
}
|
||||
// --- Prüfung: Rechteck-Border (Square) ---
|
||||
else if (type.equalsIgnoreCase("SQUARE") && pos1 != null && pos2 != null) {
|
||||
if (to.getWorld().equals(pos1.getWorld())) {
|
||||
double minX = Math.min(pos1.getX(), pos2.getX());
|
||||
double maxX = Math.max(pos1.getX(), pos2.getX());
|
||||
double minZ = Math.min(pos1.getZ(), pos2.getZ());
|
||||
double maxZ = Math.max(pos1.getZ(), pos2.getZ());
|
||||
|
||||
if (to.getX() < minX || to.getX() > maxX || to.getZ() < minZ || to.getZ() > maxZ) {
|
||||
outside = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --- Aktion wenn außerhalb ---
|
||||
if (outside) {
|
||||
Location spawnLocation = getMainSpawnLocation();
|
||||
|
||||
if (spawnLocation != null) {
|
||||
// Sofortiger Teleport zum definierten Spawn
|
||||
player.teleport(spawnLocation);
|
||||
|
||||
// Feedback an den Spieler
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_ENDERMAN_TELEPORT, 1.0f, 0.5f);
|
||||
player.sendMessage("§8[§6Nexus§8] §cDu hast den Lobby-Bereich verlassen!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Holt den zentralen Spawnpunkt aus der Config (Pfad: spawn.world, spawn.x, etc.)
|
||||
*/
|
||||
private Location getMainSpawnLocation() {
|
||||
FileConfiguration config = NexusLobby.getInstance().getConfig();
|
||||
String worldName = config.getString("spawn.world");
|
||||
|
||||
if (worldName != null) {
|
||||
World w = Bukkit.getWorld(worldName);
|
||||
if (w != null) {
|
||||
return new Location(w,
|
||||
config.getDouble("spawn.x"),
|
||||
config.getDouble("spawn.y"),
|
||||
config.getDouble("spawn.z"),
|
||||
(float) config.getDouble("spawn.yaw"),
|
||||
(float) config.getDouble("spawn.pitch"));
|
||||
}
|
||||
}
|
||||
// Fallback falls kein Spawn gesetzt ist
|
||||
return Bukkit.getWorlds().isEmpty() ? null : Bukkit.getWorlds().get(0).getSpawnLocation();
|
||||
}
|
||||
}
|
||||
@@ -67,7 +67,7 @@ public class HoloCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
module.removeHologram(args[1]);
|
||||
player.sendMessage("§8[§6Nexus§8] §cHologramm §e" + args[1] + " §ageloescht.");
|
||||
player.sendMessage("§8[§6Nexus§8] §cHologramm §e" + args[1] + " §agelöscht.");
|
||||
} else {
|
||||
sendHelp(player);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,10 @@ import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Interaction;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.TextDisplay;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerChangedWorldEvent;
|
||||
@@ -38,6 +41,7 @@ public class HologramModule implements Module, Listener {
|
||||
loadHolograms();
|
||||
Bukkit.getPluginManager().registerEvents(this, NexusLobby.getInstance());
|
||||
|
||||
// Render-Task: Prüft alle 5 Ticks Sichtbarkeit und Placeholder-Updates
|
||||
Bukkit.getScheduler().runTaskTimer(NexusLobby.getInstance(), () -> {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
holograms.values().forEach(h -> h.renderForPlayer(player));
|
||||
@@ -51,12 +55,21 @@ public class HologramModule implements Module, Listener {
|
||||
}
|
||||
|
||||
private void loadHolograms() {
|
||||
// Vorherige Instanzen säubern
|
||||
holograms.values().forEach(NexusHologram::removeAll);
|
||||
holograms.clear();
|
||||
|
||||
for (String id : config.getKeys(false)) {
|
||||
World world = Bukkit.getWorld(config.getString(id + ".world", "world"));
|
||||
String worldName = config.getString(id + ".world");
|
||||
if (worldName == null) continue;
|
||||
|
||||
World world = Bukkit.getWorld(worldName);
|
||||
if (world == null) continue;
|
||||
Location loc = new Location(world, config.getDouble(id + ".x"), config.getDouble(id + ".y"), config.getDouble(id + ".z"));
|
||||
|
||||
Location loc = new Location(world,
|
||||
config.getDouble(id + ".x"),
|
||||
config.getDouble(id + ".y"),
|
||||
config.getDouble(id + ".z"));
|
||||
|
||||
List<String> pages;
|
||||
if (config.isList(id + ".text")) {
|
||||
@@ -72,7 +85,9 @@ public class HologramModule implements Module, Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onInteract(PlayerInteractEntityEvent event) {
|
||||
// Wir prüfen, ob auf ein Interaction-Entity geklickt wurde
|
||||
// Nur auf Interaction-Entities reagieren (Hologramm-Hitboxen)
|
||||
if (!(event.getRightClicked() instanceof Interaction)) return;
|
||||
|
||||
for (NexusHologram holo : holograms.values()) {
|
||||
if (holo.isInteractionEntity(event.getRightClicked().getUniqueId())) {
|
||||
holo.nextPage(event.getPlayer());
|
||||
@@ -93,25 +108,32 @@ public class HologramModule implements Module, Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onJoin(PlayerJoinEvent event) {
|
||||
// Cleanup alter Entities für den Joiner
|
||||
// Cleanup alter Entity-Reste, die eventuell noch in der Welt schweben
|
||||
Bukkit.getScheduler().runTaskLater(NexusLobby.getInstance(), () -> {
|
||||
event.getPlayer().getWorld().getEntities().forEach(entity -> {
|
||||
Player p = event.getPlayer();
|
||||
for (Entity entity : p.getWorld().getEntities()) {
|
||||
if (entity.getCustomName() != null && entity.getCustomName().startsWith("nexus_h_")) {
|
||||
if (!entity.getCustomName().endsWith("_" + event.getPlayer().getName())) {
|
||||
event.getPlayer().hideEntity(NexusLobby.getInstance(), entity);
|
||||
// Wenn das Hologramm nicht exakt für diesen Spieler benannt ist -> verstecken
|
||||
if (!entity.getCustomName().endsWith("_" + p.getName())) {
|
||||
p.hideEntity(NexusLobby.getInstance(), entity);
|
||||
}
|
||||
}
|
||||
});
|
||||
}, 5L);
|
||||
}
|
||||
}, 10L);
|
||||
}
|
||||
|
||||
public void createHologram(String id, Location loc, List<String> pages) {
|
||||
// Falls ID bereits existiert, altes Hologramm sauber entfernen
|
||||
if (holograms.containsKey(id)) {
|
||||
removeHologram(id);
|
||||
}
|
||||
|
||||
config.set(id + ".world", loc.getWorld().getName());
|
||||
config.set(id + ".x", loc.getX());
|
||||
config.set(id + ".y", loc.getY());
|
||||
config.set(id + ".z", loc.getZ());
|
||||
config.set(id + ".text", pages);
|
||||
try { config.save(file); } catch (IOException e) { e.printStackTrace(); }
|
||||
saveHoloConfig();
|
||||
|
||||
NexusHologram holo = new NexusHologram(id, loc, pages);
|
||||
holograms.put(id, holo);
|
||||
@@ -119,12 +141,34 @@ public class HologramModule implements Module, Listener {
|
||||
|
||||
public void removeHologram(String id) {
|
||||
NexusHologram holo = holograms.remove(id);
|
||||
if (holo != null) holo.removeAll();
|
||||
if (holo != null) {
|
||||
// Erst für alle Spieler visuell entfernen
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
holo.removeForPlayer(player);
|
||||
}
|
||||
// Dann Entities serverseitig löschen
|
||||
holo.removeAll();
|
||||
}
|
||||
config.set(id, null);
|
||||
try { config.save(file); } catch (IOException e) { e.printStackTrace(); }
|
||||
saveHoloConfig();
|
||||
}
|
||||
|
||||
public Set<String> getHologramIds() { return config.getKeys(false); }
|
||||
private void saveHoloConfig() {
|
||||
try {
|
||||
config.save(file);
|
||||
} catch (IOException e) {
|
||||
NexusLobby.getInstance().getLogger().severe("Konnte holograms.yml nicht speichern!");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
|
||||
@@ -45,8 +45,9 @@ public class NexusHologram {
|
||||
}
|
||||
|
||||
int pageIdx = currentPage.getOrDefault(player.getUniqueId(), 0);
|
||||
String rawText = pages.get(pageIdx);
|
||||
if (pageIdx >= pages.size()) pageIdx = 0;
|
||||
|
||||
String rawText = pages.get(pageIdx);
|
||||
if (Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI")) {
|
||||
rawText = PlaceholderAPI.setPlaceholders(player, rawText);
|
||||
}
|
||||
@@ -55,7 +56,8 @@ public class NexusHologram {
|
||||
TextDisplay display = playerEntities.get(player.getUniqueId());
|
||||
|
||||
if (display == null || !display.isValid()) {
|
||||
// Text erstellen
|
||||
// Text-Display erstellen (Hier lassen wir den Namen zur internen Identifikation,
|
||||
// aber schalten ihn strikt unsichtbar)
|
||||
display = location.getWorld().spawn(location, TextDisplay.class, entity -> {
|
||||
entity.setCustomName("nexus_h_" + id + "_" + player.getName());
|
||||
entity.setCustomNameVisible(false);
|
||||
@@ -66,20 +68,21 @@ public class NexusHologram {
|
||||
entity.setInvulnerable(true);
|
||||
});
|
||||
|
||||
// Interaction Entity für Klick-Erkennung (Hitbox)
|
||||
// Interaction Entity (Hitbox) erstellen
|
||||
// FIX: WIR SETZEN KEINEN CUSTOM NAME MEHR.
|
||||
// Das verhindert zu 100%, dass Minecraft etwas anzeigt.
|
||||
Interaction interact = location.getWorld().spawn(location, Interaction.class, entity -> {
|
||||
entity.setInteractionWidth(2.0f);
|
||||
entity.setInteractionWidth(2.5f);
|
||||
entity.setInteractionHeight(2.0f);
|
||||
entity.setCustomNameVisible(false);
|
||||
entity.setPersistent(false);
|
||||
});
|
||||
|
||||
final TextDisplay finalDisplay = display;
|
||||
final Interaction finalInteract = interact;
|
||||
|
||||
// Nur für den Zielspieler sichtbar machen
|
||||
for (Player other : Bukkit.getOnlinePlayers()) {
|
||||
if (!other.equals(player)) {
|
||||
other.hideEntity(NexusLobby.getInstance(), finalDisplay);
|
||||
other.hideEntity(NexusLobby.getInstance(), finalInteract);
|
||||
if (!other.getUniqueId().equals(player.getUniqueId())) {
|
||||
other.hideEntity(NexusLobby.getInstance(), display);
|
||||
other.hideEntity(NexusLobby.getInstance(), interact);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,11 +108,11 @@ public class NexusHologram {
|
||||
playerInteractions.values().forEach(Interaction::remove);
|
||||
playerEntities.clear();
|
||||
playerInteractions.clear();
|
||||
currentPage.clear();
|
||||
}
|
||||
|
||||
public boolean isInteractionEntity(UUID entityId) {
|
||||
// Da wir keinen Namen mehr nutzen, verlassen wir uns rein auf die UUID in der Map
|
||||
return playerInteractions.values().stream().anyMatch(i -> i.getUniqueId().equals(entityId));
|
||||
}
|
||||
|
||||
public String getId() { return id; }
|
||||
}
|
||||
@@ -6,14 +6,40 @@ import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class PortalCommand implements CommandExecutor {
|
||||
|
||||
private final PortalManager portalManager;
|
||||
|
||||
// Statische Maps, damit wir von überall (z.B. BorderCommand) auf die Auswahl zugreifen können
|
||||
private static final Map<UUID, Location> selection1 = new HashMap<>();
|
||||
private static final Map<UUID, Location> selection2 = new HashMap<>();
|
||||
|
||||
public PortalCommand(PortalManager portalManager) {
|
||||
this.portalManager = portalManager;
|
||||
}
|
||||
|
||||
// Statische Hilfsmethoden für andere Klassen
|
||||
public static Location getSelection1(Player player) {
|
||||
return selection1.get(player.getUniqueId());
|
||||
}
|
||||
|
||||
public static Location getSelection2(Player player) {
|
||||
return selection2.get(player.getUniqueId());
|
||||
}
|
||||
|
||||
// Methoden zum Setzen (für deinen Wand-Listener oder Befehle)
|
||||
public static void setSelection1(Player player, Location loc) {
|
||||
selection1.put(player.getUniqueId(), loc);
|
||||
}
|
||||
|
||||
public static void setSelection2(Player player, Location loc) {
|
||||
selection2.put(player.getUniqueId(), loc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
@@ -23,13 +49,11 @@ public class PortalCommand implements CommandExecutor {
|
||||
|
||||
Player p = (Player) sender;
|
||||
|
||||
// Wenn keine Argumente da sind, Hilfe zeigen
|
||||
if (args.length == 0) {
|
||||
sendHelp(p);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Switch case für die Unterbefehle
|
||||
switch (args[0].toLowerCase()) {
|
||||
case "create":
|
||||
if (args.length < 3) {
|
||||
@@ -46,7 +70,9 @@ public class PortalCommand implements CommandExecutor {
|
||||
|
||||
case "setpos1":
|
||||
if (args.length < 2) { p.sendMessage("§cBenutzung: /portal setpos1 <Name>"); return true; }
|
||||
if (portalManager.setPortalPos(args[1], 1, p.getLocation())) {
|
||||
Location loc1 = p.getLocation();
|
||||
if (portalManager.setPortalPos(args[1], 1, loc1)) {
|
||||
setSelection1(p, loc1); // Speichert es auch in der statischen Map für die Border
|
||||
p.sendMessage("§aPosition 1 gesetzt für " + args[1]);
|
||||
} else {
|
||||
p.sendMessage("§cPortal nicht gefunden.");
|
||||
@@ -55,7 +81,9 @@ public class PortalCommand implements CommandExecutor {
|
||||
|
||||
case "setpos2":
|
||||
if (args.length < 2) { p.sendMessage("§cBenutzung: /portal setpos2 <Name>"); return true; }
|
||||
if (portalManager.setPortalPos(args[1], 2, p.getLocation())) {
|
||||
Location loc2 = p.getLocation();
|
||||
if (portalManager.setPortalPos(args[1], 2, loc2)) {
|
||||
setSelection2(p, loc2); // Speichert es auch in der statischen Map für die Border
|
||||
p.sendMessage("§aPosition 2 gesetzt für " + args[1]);
|
||||
} else {
|
||||
p.sendMessage("§cPortal nicht gefunden.");
|
||||
@@ -65,12 +93,9 @@ public class PortalCommand implements CommandExecutor {
|
||||
case "setdest":
|
||||
if (args.length < 3) {
|
||||
p.sendMessage("§cBenutzung: /portal setdest <Name> <Ziel>");
|
||||
p.sendMessage("§7Server: ServerName");
|
||||
p.sendMessage("§7Welt: Weltname;X;Y;Z;Yaw;Pitch");
|
||||
return true;
|
||||
}
|
||||
String dest = args[2];
|
||||
// Falls Koordinaten getrennt mit Leerzeichen gegeben werden (z.B. /portal setdest name world 100 64 100)
|
||||
if (args.length > 3) dest += ";" + args[3];
|
||||
if (args.length > 4) dest += ";" + args[4];
|
||||
if (args.length > 5) dest += ";" + args[5];
|
||||
@@ -96,20 +121,16 @@ public class PortalCommand implements CommandExecutor {
|
||||
break;
|
||||
|
||||
case "setspawn":
|
||||
// Neuer Befehl: /portal setspawn <Name>
|
||||
if (args.length < 2) {
|
||||
p.sendMessage("§cBenutzung: /portal setspawn <Name>");
|
||||
return true;
|
||||
}
|
||||
// Optional: Berechtigungscheck (anpassbar)
|
||||
if (!p.hasPermission("nexuslobby.portal")) {
|
||||
p.sendMessage("§cKeine Rechte!");
|
||||
return true;
|
||||
}
|
||||
|
||||
// Wir speichern die aktuelle Position leicht versetzt (2 Blöcke), damit Spieler nicht direkt wieder im Portal landen.
|
||||
Location spawnLoc = p.getLocation().clone();
|
||||
spawnLoc.add(0, 0, 2); // einfacher Offset als default
|
||||
spawnLoc.add(0, 0, 2);
|
||||
|
||||
if (portalManager.setPortalReturnSpawn(args[1], spawnLoc)) {
|
||||
p.sendMessage("§aPortal-Spawnpunkt für '" + args[1] + "' gesetzt!");
|
||||
@@ -151,4 +172,4 @@ public class PortalCommand implements CommandExecutor {
|
||||
p.sendMessage("§e/portal delete <Name>");
|
||||
p.sendMessage("§e/portal list");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,7 @@ import java.util.UUID;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* PortalManager - verwaltet Portale, lädt/speichert sie, spawnt Partikel und teleporiert Spieler.
|
||||
* PortalManager - Verwaltet Portale, Markierungen und den globalen Grenzschutz.
|
||||
*/
|
||||
public class PortalManager implements Module, Listener {
|
||||
|
||||
@@ -42,6 +42,11 @@ public class PortalManager implements Module, Listener {
|
||||
private final NamespacedKey wandKey;
|
||||
private BukkitTask particleTask;
|
||||
|
||||
// Boundary Cache
|
||||
private Location borderMin;
|
||||
private Location borderMax;
|
||||
private boolean borderEnabled = false;
|
||||
|
||||
public PortalManager(NexusLobby plugin) {
|
||||
this.plugin = plugin;
|
||||
this.wandKey = new NamespacedKey(plugin, "nexuslobby_portal_wand");
|
||||
@@ -55,9 +60,10 @@ public class PortalManager implements Module, Listener {
|
||||
@Override
|
||||
public void onEnable() {
|
||||
loadPortals();
|
||||
loadBorderSettings();
|
||||
Bukkit.getPluginManager().registerEvents(this, plugin);
|
||||
startParticleTask();
|
||||
plugin.getLogger().info("PortalManager geladen.");
|
||||
plugin.getLogger().info("PortalManager vollständig geladen.");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -70,15 +76,25 @@ public class PortalManager implements Module, Listener {
|
||||
plugin.getLogger().info("PortalManager deaktiviert.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gibt alle Namen der aktuell geladenen Portale zurück.
|
||||
* Wird vom LobbyTabCompleter genutzt.
|
||||
*/
|
||||
public void loadBorderSettings() {
|
||||
if (plugin.getConfig().contains("border.pos1") && plugin.getConfig().contains("border.pos2")) {
|
||||
Location p1 = plugin.getConfig().getLocation("border.pos1");
|
||||
Location p2 = plugin.getConfig().getLocation("border.pos2");
|
||||
if (p1 != null && p2 != null) {
|
||||
this.borderMin = getMinLocation(p1, p2);
|
||||
this.borderMax = getMaxLocation(p1, p2);
|
||||
this.borderEnabled = true;
|
||||
}
|
||||
} else {
|
||||
this.borderEnabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
public Set<String> getPortalNames() {
|
||||
return portals.keySet();
|
||||
}
|
||||
|
||||
// --- Wand / Selection ---
|
||||
// --- Wand / Selection Logic ---
|
||||
@org.bukkit.event.EventHandler
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
if (event.getAction() == Action.PHYSICAL) return;
|
||||
@@ -87,9 +103,7 @@ public class PortalManager implements Module, Listener {
|
||||
if (item == null || !item.hasItemMeta()) return;
|
||||
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
if (meta == null) return;
|
||||
|
||||
if (!meta.getPersistentDataContainer().has(wandKey, PersistentDataType.BYTE)) return;
|
||||
if (meta == null || !meta.getPersistentDataContainer().has(wandKey, PersistentDataType.BYTE)) return;
|
||||
|
||||
Player p = event.getPlayer();
|
||||
if (!p.hasPermission("nexuslobby.portal")) {
|
||||
@@ -98,7 +112,6 @@ public class PortalManager implements Module, Listener {
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
|
||||
if (!event.hasBlock()) {
|
||||
p.sendMessage("§cDu musst auf einen Block klicken!");
|
||||
return;
|
||||
@@ -113,15 +126,34 @@ public class PortalManager implements Module, Listener {
|
||||
|
||||
if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
|
||||
selectionMap.get(uuid)[0] = clickedLoc;
|
||||
PortalCommand.setSelection1(p, clickedLoc);
|
||||
|
||||
p.playSound(p.getLocation(), Sound.BLOCK_NOTE_BLOCK_PLING, 1.0f, 2.0f);
|
||||
p.sendMessage("§aPosition 1 gesetzt: " + clickedLoc.getBlockX() + ", " + clickedLoc.getBlockY() + ", " + clickedLoc.getBlockZ());
|
||||
|
||||
} else if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||
selectionMap.get(uuid)[1] = clickedLoc;
|
||||
PortalCommand.setSelection2(p, clickedLoc);
|
||||
|
||||
p.playSound(p.getLocation(), Sound.BLOCK_NOTE_BLOCK_PLING, 1.0f, 1.0f);
|
||||
p.sendMessage("§bPosition 2 gesetzt: " + clickedLoc.getBlockX() + ", " + clickedLoc.getBlockY() + ", " + clickedLoc.getBlockZ());
|
||||
|
||||
if (selectionMap.get(uuid)[0] != null) {
|
||||
p.sendMessage("§eBenutze jetzt: /portal create <Name> <server|world>");
|
||||
Location loc1 = selectionMap.get(uuid)[0];
|
||||
if (loc1 != null) {
|
||||
int width = Math.abs(loc1.getBlockX() - clickedLoc.getBlockX()) + 1;
|
||||
int height = Math.abs(loc1.getBlockY() - clickedLoc.getBlockY()) + 1;
|
||||
int length = Math.abs(loc1.getBlockZ() - clickedLoc.getBlockZ()) + 1;
|
||||
long volume = (long) width * height * length;
|
||||
|
||||
p.sendMessage("§7§m----------------------------------");
|
||||
if (volume < 500) {
|
||||
p.sendMessage("§e[Nexus] Kleiner Bereich erkannt (Portal-Größe)");
|
||||
p.sendMessage("§fBefehl: §b/portal create <Name> <server|world>");
|
||||
} else {
|
||||
p.sendMessage("§6[Nexus] Großer Bereich erkannt (WorldBorder-Größe)");
|
||||
p.sendMessage("§fBefehl: §a/border square");
|
||||
}
|
||||
p.sendMessage("§7§m----------------------------------");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -140,14 +172,8 @@ public class PortalManager implements Module, Listener {
|
||||
return YamlConfiguration.loadConfiguration(file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Lädt alle Portale aus der Konfiguration.
|
||||
* PUBLIC für den Zugriff durch NexusLobby.java beim Reload.
|
||||
*/
|
||||
public void loadPortals() {
|
||||
// Liste leeren, um Duplikate beim Reload zu vermeiden
|
||||
portals.clear();
|
||||
|
||||
YamlConfiguration portalConfig = loadPortalConfig();
|
||||
ConfigurationSection section = portalConfig.getConfigurationSection("portals");
|
||||
if (section == null) return;
|
||||
@@ -262,31 +288,7 @@ public class PortalManager implements Module, Listener {
|
||||
return true;
|
||||
}
|
||||
|
||||
// --- Particles ---
|
||||
private void startParticleTask() {
|
||||
particleTask = Bukkit.getScheduler().runTaskTimer(plugin, () -> {
|
||||
for (Portal portal : portals.values()) {
|
||||
if (portal.getPos1() == null || portal.getPos2() == null) continue;
|
||||
spawnParticles(portal);
|
||||
}
|
||||
}, 0L, 5L);
|
||||
}
|
||||
|
||||
private void spawnParticles(Portal portal) {
|
||||
Location min = getMinLocation(portal.getPos1(), portal.getPos2());
|
||||
Location max = getMaxLocation(portal.getPos1(), portal.getPos2());
|
||||
World world = portal.getPos1().getWorld();
|
||||
if (world == null) return;
|
||||
|
||||
for (int i = 0; i < 30; i++) {
|
||||
double x = min.getX() + 0.5 + (Math.random() * (max.getX() - min.getX()));
|
||||
double y = min.getY() + 0.5 + (Math.random() * (max.getY() - min.getY()));
|
||||
double z = min.getZ() + 0.5 + (Math.random() * (max.getZ() - min.getZ()));
|
||||
world.spawnParticle(portal.getParticle(), new Location(world, x, y, z), 3, 0.1, 0.1, 0.1, 0);
|
||||
}
|
||||
}
|
||||
|
||||
// --- Teleport / Movement ---
|
||||
// --- Movement / Teleport / Boundary Logic ---
|
||||
@org.bukkit.event.EventHandler
|
||||
public void onPlayerMove(PlayerMoveEvent event) {
|
||||
if (event.getFrom().getX() == event.getTo().getX() &&
|
||||
@@ -296,8 +298,22 @@ public class PortalManager implements Module, Listener {
|
||||
}
|
||||
|
||||
Player player = event.getPlayer();
|
||||
Location loc = player.getLocation();
|
||||
Location loc = event.getTo();
|
||||
|
||||
// 1. Grenzschutz (Boundary Protection)
|
||||
if (borderEnabled && !player.hasPermission("nexuslobby.border.bypass")) {
|
||||
if (!isWithinBorder(loc)) {
|
||||
Location spawn = getMainSpawnLocation();
|
||||
if (spawn != null) {
|
||||
player.teleport(spawn);
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_ENDERMAN_TELEPORT, 1.0f, 0.5f);
|
||||
player.sendMessage("§c§lHEY! §7Du hast den erlaubten Bereich verlassen.");
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// 2. Portal Logik
|
||||
for (Portal portal : portals.values()) {
|
||||
if (portal.getPos1() == null || portal.getPos2() == null) continue;
|
||||
if (!isInArea(loc, portal.getPos1(), portal.getPos2())) continue;
|
||||
@@ -313,11 +329,18 @@ public class PortalManager implements Module, Listener {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isWithinBorder(Location loc) {
|
||||
if (borderMin == null || borderMax == null) return true;
|
||||
if (!loc.getWorld().equals(borderMin.getWorld())) return true;
|
||||
return loc.getX() >= borderMin.getX() && loc.getX() <= borderMax.getX() &&
|
||||
loc.getY() >= borderMin.getY() && loc.getY() <= borderMax.getY() &&
|
||||
loc.getZ() >= borderMin.getZ() && loc.getZ() <= borderMax.getZ();
|
||||
}
|
||||
|
||||
private void executeTeleport(Player player, Portal portal) {
|
||||
if ("SERVER".equalsIgnoreCase(portal.getType())) {
|
||||
String serverName = portal.getDestination();
|
||||
player.sendMessage("§eVerbinde zum Server: " + serverName);
|
||||
plugin.getLogger().info("Verbinde " + player.getName() + " -> " + serverName);
|
||||
|
||||
Location loc = portal.getReturnSpawn();
|
||||
if (loc == null) {
|
||||
@@ -335,7 +358,6 @@ public class PortalManager implements Module, Listener {
|
||||
loc.add(0,0,2);
|
||||
}
|
||||
}
|
||||
|
||||
player.teleport(loc);
|
||||
connectToServer(player, serverName);
|
||||
return;
|
||||
@@ -352,8 +374,6 @@ public class PortalManager implements Module, Listener {
|
||||
if (spawnLoc != null) {
|
||||
player.teleport(spawnLoc);
|
||||
player.sendMessage("§aDu wurdest zum Spawn teleportiert!");
|
||||
} else {
|
||||
player.sendMessage("§cSpawn konnte nicht gefunden werden.");
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -361,99 +381,84 @@ public class PortalManager implements Module, Listener {
|
||||
String[] parts = dest.split(";");
|
||||
if (parts.length >= 4) {
|
||||
World world = Bukkit.getWorld(parts[0]);
|
||||
if (world == null) {
|
||||
player.sendMessage("§cZielwelt nicht gefunden: " + parts[0]);
|
||||
return;
|
||||
}
|
||||
if (world == null) return;
|
||||
try {
|
||||
double x = Double.parseDouble(parts[1]);
|
||||
double y = Double.parseDouble(parts[2]);
|
||||
double z = Double.parseDouble(parts[3]);
|
||||
float yaw = 0f, pitch = 0f;
|
||||
if (parts.length >= 6) {
|
||||
yaw = Float.parseFloat(parts[4]);
|
||||
pitch = Float.parseFloat(parts[5]);
|
||||
}
|
||||
Location target = new Location(world, x, y, z, yaw, pitch);
|
||||
player.teleport(target);
|
||||
float yaw = parts.length >= 6 ? Float.parseFloat(parts[4]) : 0f;
|
||||
float pitch = parts.length >= 6 ? Float.parseFloat(parts[5]) : 0f;
|
||||
player.teleport(new Location(world, x, y, z, yaw, pitch));
|
||||
player.sendMessage("§aDu wurdest teleportiert!");
|
||||
} catch (NumberFormatException e) {
|
||||
player.sendMessage("§cUngültige Koordinaten im Portalziel!");
|
||||
}
|
||||
} else {
|
||||
player.sendMessage("§cUngültiges Portalzielformat!");
|
||||
} catch (NumberFormatException ignored) {}
|
||||
}
|
||||
}
|
||||
|
||||
private void connectToServer(Player player, String serverName) {
|
||||
try {
|
||||
if (!Bukkit.getMessenger().isOutgoingChannelRegistered(plugin, "BungeeCord")) {
|
||||
plugin.getLogger().warning("BungeeCord outgoing channel not registered; cannot send plugin message.");
|
||||
player.sendMessage("§cProxy-Verbindung nicht möglich: BungeeCord-Kanal nicht registriert.");
|
||||
return;
|
||||
}
|
||||
|
||||
ByteArrayOutputStream b = new ByteArrayOutputStream();
|
||||
DataOutputStream out = new DataOutputStream(b);
|
||||
out.writeUTF("Connect");
|
||||
out.writeUTF(serverName);
|
||||
player.sendPluginMessage(plugin, "BungeeCord", b.toByteArray());
|
||||
} catch (IOException e) {
|
||||
plugin.getLogger().severe("Fehler beim Senden der BungeeCord-Message: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
player.sendMessage("§cFehler beim Verbinden zum Proxy.");
|
||||
} catch (RuntimeException e) {
|
||||
plugin.getLogger().warning("Konnte Plugin-Message nicht senden: " + e.getMessage());
|
||||
player.sendMessage("§cProxy-Verbindung nicht möglich.");
|
||||
}
|
||||
}
|
||||
|
||||
// --- Hilfsfunktionen ---
|
||||
private Location getMainSpawnLocation() {
|
||||
String worldName = plugin.getConfig().getString("spawn.world", null);
|
||||
if (worldName != null) {
|
||||
World w = Bukkit.getWorld(worldName);
|
||||
if (w != null) {
|
||||
double x = plugin.getConfig().getDouble("spawn.x", w.getSpawnLocation().getX());
|
||||
double y = plugin.getConfig().getDouble("spawn.y", w.getSpawnLocation().getY());
|
||||
double z = plugin.getConfig().getDouble("spawn.z", w.getSpawnLocation().getZ());
|
||||
float yaw = (float) plugin.getConfig().getDouble("spawn.yaw", w.getSpawnLocation().getYaw());
|
||||
float pitch = (float) plugin.getConfig().getDouble("spawn.pitch", w.getSpawnLocation().getPitch());
|
||||
return new Location(w, x, y, z, yaw, pitch);
|
||||
return new Location(w,
|
||||
plugin.getConfig().getDouble("spawn.x"),
|
||||
plugin.getConfig().getDouble("spawn.y"),
|
||||
plugin.getConfig().getDouble("spawn.z"),
|
||||
(float) plugin.getConfig().getDouble("spawn.yaw"),
|
||||
(float) plugin.getConfig().getDouble("spawn.pitch"));
|
||||
}
|
||||
}
|
||||
if (!Bukkit.getWorlds().isEmpty()) {
|
||||
return Bukkit.getWorlds().get(0).getSpawnLocation();
|
||||
}
|
||||
return null;
|
||||
return !Bukkit.getWorlds().isEmpty() ? Bukkit.getWorlds().get(0).getSpawnLocation() : null;
|
||||
}
|
||||
|
||||
// --- Utils & Particles ---
|
||||
private boolean isInArea(Location loc, Location loc1, Location loc2) {
|
||||
if (loc == null || loc1 == null || loc2 == null) return false;
|
||||
if (!loc.getWorld().equals(loc1.getWorld())) return false;
|
||||
|
||||
int x = loc.getBlockX();
|
||||
int y = loc.getBlockY();
|
||||
int z = loc.getBlockZ();
|
||||
int headY = y + 1;
|
||||
|
||||
Location min = getMinLocation(loc1, loc2);
|
||||
Location max = getMaxLocation(loc1, loc2);
|
||||
|
||||
boolean xMatch = (x >= min.getBlockX()) && (x <= max.getBlockX());
|
||||
boolean zMatch = (z >= min.getBlockZ()) && (z <= max.getBlockZ());
|
||||
boolean yMatch = (y >= min.getBlockY()) && (headY <= max.getBlockY());
|
||||
|
||||
return xMatch && yMatch && zMatch;
|
||||
return (loc.getX() >= min.getX() && loc.getX() <= max.getX() + 1) &&
|
||||
(loc.getY() >= min.getY() && loc.getY() <= max.getY() + 1) &&
|
||||
(loc.getZ() >= min.getZ() && loc.getZ() <= max.getZ() + 1);
|
||||
}
|
||||
|
||||
private Location getMinLocation(Location a, Location b) {
|
||||
return new Location(a.getWorld(), Math.min(a.getX(), b.getX()),
|
||||
Math.min(a.getY(), b.getY()), Math.min(a.getZ(), b.getZ()));
|
||||
return new Location(a.getWorld(), Math.min(a.getX(), b.getX()), Math.min(a.getY(), b.getY()), Math.min(a.getZ(), b.getZ()));
|
||||
}
|
||||
|
||||
private Location getMaxLocation(Location a, Location b) {
|
||||
return new Location(a.getWorld(), Math.max(a.getX(), b.getX()),
|
||||
Math.max(a.getY(), b.getY()), Math.max(a.getZ(), b.getZ()));
|
||||
return new Location(a.getWorld(), Math.max(a.getX(), b.getX()), Math.max(a.getY(), b.getY()), Math.max(a.getZ(), b.getZ()));
|
||||
}
|
||||
|
||||
private void startParticleTask() {
|
||||
particleTask = Bukkit.getScheduler().runTaskTimer(plugin, () -> {
|
||||
for (Portal portal : portals.values()) {
|
||||
if (portal.getPos1() != null && portal.getPos2() != null) {
|
||||
spawnParticles(portal);
|
||||
}
|
||||
}
|
||||
}, 0L, 5L);
|
||||
}
|
||||
|
||||
private void spawnParticles(Portal portal) {
|
||||
Location min = getMinLocation(portal.getPos1(), portal.getPos2());
|
||||
Location max = getMaxLocation(portal.getPos1(), portal.getPos2());
|
||||
World world = portal.getPos1().getWorld();
|
||||
for (int i = 0; i < 15; i++) {
|
||||
double x = min.getX() + Math.random() * (max.getX() - min.getX() + 1);
|
||||
double y = min.getY() + Math.random() * (max.getY() - min.getY() + 1);
|
||||
double z = min.getZ() + Math.random() * (max.getZ() - min.getZ() + 1);
|
||||
world.spawnParticle(portal.getParticle(), x, y, z, 1, 0.1, 0.1, 0.1, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
119
src/main/java/de/nexuslobby/modules/servers/ServerChecker.java
Normal file
119
src/main/java/de/nexuslobby/modules/servers/ServerChecker.java
Normal file
@@ -0,0 +1,119 @@
|
||||
package de.nexuslobby.modules.servers;
|
||||
|
||||
import de.nexuslobby.NexusLobby;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Socket;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class ServerChecker {
|
||||
|
||||
/**
|
||||
* Prüft asynchron, ob ein Server unter der angegebenen IP und Port erreichbar ist.
|
||||
*/
|
||||
public static CompletableFuture<Boolean> isOnline(String ip, int port) {
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
try (Socket socket = new Socket()) {
|
||||
// 500ms Timeout für stabilere Erkennung
|
||||
socket.connect(new InetSocketAddress(ip, port), 500);
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Startet den Scheduler, der alle ArmorStands in allen Welten regelmäßig prüft.
|
||||
*/
|
||||
public static void startGlobalChecker() {
|
||||
// WICHTIG: runTaskTimer (synchron), um den Main-Thread für getEntitiesByClass zu nutzen
|
||||
Bukkit.getScheduler().runTaskTimer(NexusLobby.getInstance(), () -> {
|
||||
for (World world : Bukkit.getWorlds()) {
|
||||
// Das Abrufen der Entities muss auf dem Main-Thread passieren
|
||||
for (ArmorStand as : world.getEntitiesByClass(ArmorStand.class)) {
|
||||
checkAndUpdateArmorStand(as);
|
||||
}
|
||||
}
|
||||
}, 100L, 200L);
|
||||
}
|
||||
|
||||
/**
|
||||
* Analysiert die Tags eines ArmorStands und aktualisiert den Namen basierend auf dem Serverstatus.
|
||||
*/
|
||||
private static void checkAndUpdateArmorStand(ArmorStand as) {
|
||||
for (String tag : as.getScoreboardTags()) {
|
||||
// Erwartetes Format: ascmd:slot1:slot2:type:command
|
||||
if (tag.startsWith("ascmd:")) {
|
||||
String[] parts = tag.split(":");
|
||||
if (parts.length < 5) continue;
|
||||
|
||||
String type = parts[3].toLowerCase();
|
||||
if (!type.equals("bungee")) continue;
|
||||
|
||||
String serverName = parts[4];
|
||||
|
||||
// Suche den passenden Key in der Config
|
||||
String configKey = null;
|
||||
if (NexusLobby.getInstance().getConfig().getConfigurationSection("servers") != null) {
|
||||
for (String key : NexusLobby.getInstance().getConfig().getConfigurationSection("servers").getKeys(false)) {
|
||||
if (key.equalsIgnoreCase(serverName)) {
|
||||
configKey = key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (configKey == null) continue;
|
||||
|
||||
String ip = NexusLobby.getInstance().getConfig().getString("servers." + configKey + ".ip");
|
||||
int port = NexusLobby.getInstance().getConfig().getInt("servers." + configKey + ".port");
|
||||
|
||||
if (ip == null) continue;
|
||||
|
||||
// Der Ping selbst läuft asynchron weg vom Main-Thread
|
||||
isOnline(ip, port).thenAccept(online -> {
|
||||
// Zurück zum Main-Thread für die Änderung des ArmorStands
|
||||
Bukkit.getScheduler().runTask(NexusLobby.getInstance(), () -> {
|
||||
if (!as.isValid()) return; // Sicherheitscheck falls AS gelöscht wurde
|
||||
|
||||
if (online) {
|
||||
restoreName(as);
|
||||
} else {
|
||||
String offlineText = "§c● §lOFFLINE §c●";
|
||||
if (!offlineText.equals(as.getCustomName())) {
|
||||
as.setCustomName(offlineText);
|
||||
as.setCustomNameVisible(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stellt den ursprünglichen Namen des ArmorStands wieder her.
|
||||
* Nutzt den Tag "asname:NAME" als Backup.
|
||||
*/
|
||||
private static void restoreName(ArmorStand as) {
|
||||
for (String t : as.getScoreboardTags()) {
|
||||
if (t.startsWith("asname:")) {
|
||||
String originalName = t.substring(7);
|
||||
String translatedName = ChatColor.translateAlternateColorCodes('&', originalName);
|
||||
|
||||
if (!translatedName.equals(as.getCustomName())) {
|
||||
as.setCustomName(translatedName);
|
||||
as.setCustomNameVisible(true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,14 @@ spawn:
|
||||
yaw: 0.0 # Blickrichtung
|
||||
pitch: 0.0 # Blickrichtung
|
||||
|
||||
worldborder:
|
||||
enabled: true
|
||||
type: "SQUARE" # oder "CIRCLE"
|
||||
radius: 50.0
|
||||
center:
|
||||
pos1:
|
||||
pos2:
|
||||
|
||||
# --- Lobby Einstellungen ---
|
||||
lobby:
|
||||
allow-fly: false # Spieler dürfen fliegen
|
||||
@@ -19,6 +27,16 @@ lobby:
|
||||
default-gamemode: Adventure
|
||||
clear-inventory-on-join: true
|
||||
|
||||
# Mapping für den Server-Status-Ping der ArmorStands
|
||||
# Der Name (z.B. survival) muss exakt dem Bungee-Servernamen entsprechen
|
||||
servers:
|
||||
survival:
|
||||
ip: "127.0.0.1"
|
||||
port: 25566
|
||||
skyblock:
|
||||
ip: "127.0.0.1"
|
||||
port: 25567
|
||||
|
||||
# --- Tablist Einstellungen ---
|
||||
tablist:
|
||||
enabled: true
|
||||
@@ -46,7 +64,7 @@ items:
|
||||
portals:
|
||||
default-particle: "PORTAL"
|
||||
portal-cooldown: 40 # Ticks, 2 Sekunden
|
||||
save-file: "portals.yml" # Datei im Plugin-Ordner
|
||||
save-file: "portals.yml"
|
||||
|
||||
# -----------------------------------------------------
|
||||
# COMPASS MENU
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
name: NexusLobby
|
||||
main: de.nexuslobby.NexusLobby
|
||||
version: "1.0.4"
|
||||
version: "1.0.5"
|
||||
api-version: "1.21"
|
||||
author: M_Viper
|
||||
description: Modular Lobby Plugin
|
||||
@@ -39,14 +39,17 @@ commands:
|
||||
permission-message: "§cDu hast keine Rechte!"
|
||||
nexuslobby:
|
||||
description: Zeigt Informationen über das Plugin an oder lädt es neu
|
||||
usage: /nexuslobby [reload]
|
||||
aliases: [nexus]
|
||||
usage: /nexuslobby [reload|setspawn]
|
||||
aliases: [nexus, lobby]
|
||||
nexustools:
|
||||
description: Nexus ArmorStand Editor
|
||||
description: Nexus ArmorStand Editor (LookAt, Dynamic, etc.)
|
||||
aliases: [nt, ntools, astools]
|
||||
nexuscmd:
|
||||
description: Nexus Command Binder
|
||||
aliases: [ncmd, ascmd]
|
||||
description: Nexus Command Binder (Slots 0-9) und Gesprächs-System
|
||||
usage: /nexuscmd <args>
|
||||
permission: nexuslobby.armorstand.cmd
|
||||
permission-message: "§cDu hast keine Rechte!"
|
||||
aliases: [ncmd, ascmd, conv]
|
||||
holo:
|
||||
description: Verwalte Lobby Hologramme (Text-Displays)
|
||||
usage: /holo <create|delete> <id> [text]
|
||||
@@ -59,6 +62,14 @@ commands:
|
||||
description: Verwalte und teste die Cinematic Intro Tour
|
||||
usage: /intro <add|clear|start>
|
||||
permission: nexuslobby.admin
|
||||
border:
|
||||
description: Verwalte die unsichtbare Lobby-Begrenzung
|
||||
usage: /border <circle|square|disable>
|
||||
permission: nexuslobby.admin
|
||||
spawn:
|
||||
description: Teleportiert dich zum Lobby-Spawnpunkt
|
||||
usage: /spawn
|
||||
aliases: [l, hub]
|
||||
|
||||
permissions:
|
||||
nexuslobby.portal:
|
||||
@@ -74,7 +85,7 @@ permissions:
|
||||
description: Zugriff auf den Server Switcher
|
||||
default: true
|
||||
nexuslobby.admin:
|
||||
description: Voller Zugriff auf Lobby-Gamerules, Einstellungen, Intro und Reload
|
||||
description: Voller Zugriff auf Lobby-Gamerules, Einstellungen, Intro, Border und Reload
|
||||
default: op
|
||||
nexuslobby.build:
|
||||
description: Erlaubt das Umgehen des Lobby-Schutzes zum Bauen
|
||||
@@ -83,11 +94,14 @@ permissions:
|
||||
description: Erlaubt die Nutzung der NexusTools GUI
|
||||
default: op
|
||||
nexuslobby.armorstand.cmd:
|
||||
description: Erlaubt das Binden von Commands via NexusCmd
|
||||
description: Erlaubt das Binden von Commands und das Verwalten von Conversations
|
||||
default: op
|
||||
nexuslobby.armorstand.dynamic:
|
||||
description: Erlaubt das Markieren von dynamischen NPCs
|
||||
default: op
|
||||
nexuslobby.armorstand.lookat:
|
||||
description: Erlaubt das Aktivieren des Blickkontakts bei NPCs
|
||||
default: op
|
||||
nexuslobby.hologram:
|
||||
description: Erlaubt das Erstellen von Text-Display Hologrammen
|
||||
default: op
|
||||
|
||||
Reference in New Issue
Block a user