Update from Git Manager GUI
This commit is contained in:
@@ -18,15 +18,12 @@ public class NexusLobbyCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
if (!(sender instanceof Player player)) {
|
||||
sender.sendMessage("§cDieser Befehl ist nur für Spieler!");
|
||||
return true;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
|
||||
// ==========================================
|
||||
// LOGIK FÜR /spawn
|
||||
// ==========================================
|
||||
// --- SPAWN BEFEHL ---
|
||||
if (command.getName().equalsIgnoreCase("spawn")) {
|
||||
FileConfiguration config = NexusLobby.getInstance().getConfig();
|
||||
if (config.contains("spawn.world")) {
|
||||
@@ -44,75 +41,94 @@ public class NexusLobbyCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
// ==========================================
|
||||
// LOGIK FÜR /nexus (Hauptbefehl)
|
||||
// ==========================================
|
||||
|
||||
// Sub-Befehl: /nexus setspawn
|
||||
if (args.length == 1 && args[0].equalsIgnoreCase("setspawn")) {
|
||||
if (!player.hasPermission("nexuslobby.admin")) {
|
||||
player.sendMessage("§cDu hast keine Berechtigung, den Spawn zu setzen.");
|
||||
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!");
|
||||
player.sendMessage("§7X: §f" + String.format("%.2f", loc.getX()) + " §7Y: §f" + String.format("%.2f", loc.getY()) + " §7Z: §f" + String.format("%.2f", loc.getZ()));
|
||||
// --- HAUPTBEFEHL ARGUMENTE ---
|
||||
if (args.length == 0) {
|
||||
sendInfo(player);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Sub-Befehl: /nexus sb <on|off|admin|spieler>
|
||||
if (args.length >= 2 && args[0].equalsIgnoreCase("sb")) {
|
||||
ScoreboardModule sbModule = (ScoreboardModule) NexusLobby.getInstance().getModuleManager().getModule(ScoreboardModule.class);
|
||||
if (sbModule == null) {
|
||||
player.sendMessage("§cScoreboard-Modul ist deaktiviert.");
|
||||
return true;
|
||||
}
|
||||
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;
|
||||
|
||||
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;
|
||||
default: player.sendMessage("§cBenutzung: /nexus sb <on|off|admin|spieler>"); break;
|
||||
}
|
||||
return true;
|
||||
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;
|
||||
}
|
||||
|
||||
// Sub-Befehl: /nexus reload
|
||||
if (args.length == 1 && args[0].equalsIgnoreCase("reload")) {
|
||||
if (!player.hasPermission("nexuslobby.admin")) {
|
||||
player.sendMessage("§cKeine Rechte.");
|
||||
return true;
|
||||
}
|
||||
NexusLobby.getInstance().reloadPlugin();
|
||||
player.sendMessage("§7[§6NexusLobby§7] §aPlugin erfolgreich neu geladen!");
|
||||
return true;
|
||||
}
|
||||
|
||||
// Info-Screen
|
||||
sendInfo(player);
|
||||
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;
|
||||
@@ -122,14 +138,14 @@ public class NexusLobbyCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
private void sendInfo(Player player) {
|
||||
String version = NexusLobby.getInstance().getDescription().getVersion();
|
||||
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 reload §7- Konfiguration laden");
|
||||
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--------------------------------------");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user