42 lines
1.4 KiB
Java
42 lines
1.4 KiB
Java
package de.viper.survivalplus.commands;
|
|
|
|
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 de.viper.survivalplus.SurvivalPlus;
|
|
|
|
public class SetSpawnCommand implements CommandExecutor {
|
|
private final SurvivalPlus plugin;
|
|
|
|
public SetSpawnCommand(SurvivalPlus plugin) {
|
|
this.plugin = plugin;
|
|
}
|
|
|
|
@Override
|
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
|
if (!(sender instanceof Player player)) {
|
|
sender.sendMessage("Nur Spieler können diesen Befehl verwenden!");
|
|
return true;
|
|
}
|
|
|
|
if (!player.hasPermission("survivalplus.setspawn")) {
|
|
player.sendMessage("§cDu hast keine Rechte für diesen Befehl.");
|
|
return true;
|
|
}
|
|
|
|
Location loc = player.getLocation();
|
|
plugin.getConfig().set("spawn.world", loc.getWorld().getName());
|
|
plugin.getConfig().set("spawn.x", loc.getX());
|
|
plugin.getConfig().set("spawn.y", loc.getY());
|
|
plugin.getConfig().set("spawn.z", loc.getZ());
|
|
plugin.getConfig().set("spawn.yaw", loc.getYaw());
|
|
plugin.getConfig().set("spawn.pitch", loc.getPitch());
|
|
plugin.saveConfig();
|
|
|
|
player.sendMessage("§aSpawnpunkt erfolgreich gesetzt!");
|
|
return true;
|
|
}
|
|
}
|