Advertisement
Guest User

Untitled

a guest
Feb 2nd, 2021
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.16 KB | None | 0 0
  1. package de.universxlgenie.classserver.commands;
  2.  
  3. import org.bukkit.Bukkit;
  4. import org.bukkit.Location;
  5. import org.bukkit.World;
  6. import org.bukkit.command.Command;
  7. import org.bukkit.command.CommandExecutor;
  8. import org.bukkit.command.CommandSender;
  9. import org.bukkit.configuration.file.FileConfiguration;
  10. import org.bukkit.configuration.file.YamlConfiguration;
  11. import org.bukkit.entity.Player;
  12.  
  13. import java.io.File;
  14.  
  15. public class HomeCommand implements CommandExecutor {
  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(configuration.contains(player.getUniqueId().toString() + " . " + args[0] + " . " + "Home.World" )){
  25.                 World world = Bukkit.getWorld(player.getUniqueId().toString() + " . " + args[0] + " . " + "Home.World");
  26.                 double x = configuration.getDouble(player.getUniqueId().toString() + " . " + args[0] + " . " + "Home.X");
  27.                 double y = configuration.getDouble(player.getUniqueId().toString() + " . " + args[0] + " . " + "Home.Y");
  28.                 double z = configuration.getDouble(player.getUniqueId().toString() + " . " + args[0] + " . " + "Home.Z");
  29.                 float yaw = (float) configuration.getDouble(player.getUniqueId().toString() + " . " + args[0] + " . " + "Home.Yaw");
  30.                 float pitch = (float) configuration.getDouble(player.getUniqueId().toString() + " . " + args[0] + " . " + "Home.Pitch");
  31.                 Location loc = new Location(world, x, y, z, yaw, pitch);
  32.                 player.teleport(loc);
  33.                 player.sendMessage("§aDu wurdest zu deinem Home " + args[0] + " §ateleportiert.");
  34.             } else{
  35.                 player.sendMessage("§cDas Home gibt es nicht");
  36.             }
  37.         } else{
  38.             commandSender.sendMessage("Du musst ein Spieler sein um diesen Command ausführen zu können.");
  39.         }
  40.         return false;
  41.     }
  42. }
  43.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement