Dateien nach "src/main/java/de/nexuslobby/commands" hochladen
This commit is contained in:
61
src/main/java/de/nexuslobby/commands/BuildCommand.java
Normal file
61
src/main/java/de/nexuslobby/commands/BuildCommand.java
Normal file
@@ -0,0 +1,61 @@
|
||||
package de.nexuslobby.commands;
|
||||
|
||||
import de.nexuslobby.NexusLobby;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.UUID;
|
||||
|
||||
public class BuildCommand implements CommandExecutor {
|
||||
|
||||
// Liste der Spieler im Baumodus
|
||||
private static final ArrayList<UUID> buildModePlayers = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!(sender instanceof Player)) return true;
|
||||
Player player = (Player) sender;
|
||||
|
||||
if (!player.hasPermission("nexuslobby.build")) {
|
||||
player.sendMessage("§cKeine Rechte.");
|
||||
return true;
|
||||
}
|
||||
|
||||
UUID uuid = player.getUniqueId();
|
||||
if (buildModePlayers.contains(uuid)) {
|
||||
// BAUMODUS DEAKTIVIEREN
|
||||
buildModePlayers.remove(uuid);
|
||||
|
||||
// Gamemode zurücksetzen (aus Config)
|
||||
String defaultGmName = NexusLobby.getInstance().getConfig().getString("default-gamemode", "ADVENTURE");
|
||||
try {
|
||||
GameMode gm = GameMode.valueOf(defaultGmName.toUpperCase());
|
||||
player.setGameMode(gm);
|
||||
} catch (IllegalArgumentException e) {
|
||||
player.setGameMode(GameMode.ADVENTURE);
|
||||
}
|
||||
|
||||
player.sendMessage("§8» §6§lBuild §8| §7Baumodus §cdeaktiviert§7.");
|
||||
} else {
|
||||
// BAUMODUS AKTIVIEREN
|
||||
buildModePlayers.add(uuid);
|
||||
player.setGameMode(GameMode.CREATIVE);
|
||||
|
||||
player.sendMessage("§8» §6§lBuild §8| §7Baumodus §aaktiviert§7.");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean isInBuildMode(Player player) {
|
||||
return buildModePlayers.contains(player.getUniqueId());
|
||||
}
|
||||
|
||||
public static void removePlayerFromBuildMode(Player player) {
|
||||
buildModePlayers.remove(player.getUniqueId());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user