Advertisement
Guest User

Untitled

a guest
Feb 2nd, 2021
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.64 KB | None | 0 0
  1. package de.universxlgenie.classserver.commands;
  2.  
  3. import org.bukkit.command.Command;
  4. import org.bukkit.command.CommandExecutor;
  5. import org.bukkit.command.CommandSender;
  6. import org.bukkit.configuration.file.FileConfiguration;
  7. import org.bukkit.configuration.file.YamlConfiguration;
  8. import org.bukkit.entity.Player;
  9.  
  10. import java.io.File;
  11. import java.io.IOException;
  12.  
  13. public class SetHomeCommand implements CommandExecutor {
  14.  
  15.     int anzahl = 0;
  16.  
  17.     File file = new File("plugins/Info", "homes.yml");
  18.     FileConfiguration configuration = YamlConfiguration.loadConfiguration(file);
  19.  
  20.     @Override
  21.     public boolean onCommand(CommandSender commandSender, Command command, String label, String[] args) {
  22.         if (commandSender instanceof Player) {
  23.             Player player = (Player) commandSender;
  24.             if(args.length == 1){
  25.                 if(anzahl <= 3){
  26.                     if(player.getWorld().getName().equals("world")) {
  27.                         configuration.set(player.getUniqueId().toString() + " . " + args[0] + " . " + "Home.World" , player.getWorld().getName());
  28.                         configuration.set(player.getUniqueId().toString() + " . " + args[0] + " . " + "Home.X", player.getLocation().getX());
  29.                         configuration.set(player.getUniqueId().toString() + " . " + args[0] + " . " + "Home.Y", player.getLocation().getY());
  30.                         configuration.set(player.getUniqueId().toString() + " . " + args[0] + " . " + "Home.Z", player.getLocation().getZ());
  31.                         configuration.set(player.getUniqueId().toString() + " . " + args[0] + " . " + "Home.Yaw", player.getLocation().getYaw());
  32.                         configuration.set(player.getUniqueId().toString() + " . " + args[0] + " . " + "Home.Pitch", player.getLocation().getPitch());
  33.                         try {
  34.                             configuration.save(file);
  35.                         } catch (IOException e) {
  36.                             e.printStackTrace();
  37.                         }
  38.                         player.sendMessage("§aDu hast ein Home gesetzt");
  39.                     } else{
  40.                         player.sendMessage("§cDu kannst dein Home nur in der Oberwelt setzen.");
  41.                     }
  42.                 } else{
  43.                     player.sendMessage("§cDu hast schon die maximale Anzahl deiner Homes gesetzt.");
  44.                 }
  45.             }else{
  46.                 player.sendMessage("§cBitte benutze /home <home>");
  47.             }
  48.  
  49.         } else {
  50.             commandSender.sendMessage("Du musst ein Spieler sein um diesen Command ausführen zu können.");
  51.         }
  52.         return false;
  53.     }
  54. }
  55.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement