Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package de.universxlgenie.classserver.commands;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandExecutor;
- import org.bukkit.command.CommandSender;
- import org.bukkit.configuration.file.FileConfiguration;
- import org.bukkit.configuration.file.YamlConfiguration;
- import org.bukkit.entity.Player;
- import java.io.File;
- import java.io.IOException;
- public class SetHomeCommand implements CommandExecutor {
- int anzahl = 0;
- File file = new File("plugins/Info", "homes.yml");
- FileConfiguration configuration = YamlConfiguration.loadConfiguration(file);
- @Override
- public boolean onCommand(CommandSender commandSender, Command command, String label, String[] args) {
- if (commandSender instanceof Player) {
- Player player = (Player) commandSender;
- if(args.length == 1){
- if(anzahl <= 3){
- if(player.getWorld().getName().equals("world")) {
- configuration.set(player.getUniqueId().toString() + " . " + args[0] + " . " + "Home.World" , player.getWorld().getName());
- configuration.set(player.getUniqueId().toString() + " . " + args[0] + " . " + "Home.X", player.getLocation().getX());
- configuration.set(player.getUniqueId().toString() + " . " + args[0] + " . " + "Home.Y", player.getLocation().getY());
- configuration.set(player.getUniqueId().toString() + " . " + args[0] + " . " + "Home.Z", player.getLocation().getZ());
- configuration.set(player.getUniqueId().toString() + " . " + args[0] + " . " + "Home.Yaw", player.getLocation().getYaw());
- configuration.set(player.getUniqueId().toString() + " . " + args[0] + " . " + "Home.Pitch", player.getLocation().getPitch());
- try {
- configuration.save(file);
- } catch (IOException e) {
- e.printStackTrace();
- }
- player.sendMessage("§aDu hast ein Home gesetzt");
- } else{
- player.sendMessage("§cDu kannst dein Home nur in der Oberwelt setzen.");
- }
- } else{
- player.sendMessage("§cDu hast schon die maximale Anzahl deiner Homes gesetzt.");
- }
- }else{
- player.sendMessage("§cBitte benutze /home <home>");
- }
- } else {
- commandSender.sendMessage("Du musst ein Spieler sein um diesen Command ausführen zu können.");
- }
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement