Update from Git Manager GUI
This commit is contained in:
@@ -2,89 +2,134 @@ 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!");
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage("§cDieser Befehl ist nur für Spieler!");
|
||||
return true;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
|
||||
// ==========================================
|
||||
// LOGIK FÜR /spawn
|
||||
// ==========================================
|
||||
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;
|
||||
}
|
||||
|
||||
// ==========================================
|
||||
// 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;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
ScoreboardModule sbModule = (ScoreboardModule) NexusLobby.getInstance().getModuleManager().getModule(ScoreboardModule.class);
|
||||
|
||||
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()));
|
||||
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("§cDas Scoreboard-Modul ist aktuell deaktiviert.");
|
||||
player.sendMessage("§cScoreboard-Modul ist 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 "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);
|
||||
if (player.hasPermission("nexuslobby.scoreboard.admin")) sbModule.setAdminMode(player, true);
|
||||
else player.sendMessage("§cKeine Rechte.");
|
||||
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>");
|
||||
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;
|
||||
}
|
||||
|
||||
// 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.");
|
||||
if (!player.hasPermission("nexuslobby.admin")) {
|
||||
player.sendMessage("§cKeine Rechte.");
|
||||
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!");
|
||||
player.sendMessage("§7[§6NexusLobby§7] §aPlugin erfolgreich neu geladen!");
|
||||
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");
|
||||
}
|
||||
sender.sendMessage("§8§m--------------------------------------");
|
||||
|
||||
// Info-Screen
|
||||
sendInfo(player);
|
||||
return true;
|
||||
}
|
||||
|
||||
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) {
|
||||
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 sb <on|off> §7- Scoreboard");
|
||||
player.sendMessage("§8§m--------------------------------------");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user