Advertisement
Guest User

Untitled

a guest
Aug 28th, 2014
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package Files;
  2.  
  3. import java.io.File;
  4.  
  5. import org.bukkit.Bukkit;
  6. import org.bukkit.Location;
  7. import org.bukkit.command.Command;
  8. import org.bukkit.command.CommandExecutor;
  9. import org.bukkit.command.CommandSender;
  10. import org.bukkit.configuration.file.YamlConfiguration;
  11. import org.bukkit.entity.Player;
  12.  
  13. import Main.hauptklasse;
  14.  
  15. public class Home implements CommandExecutor {
  16.  
  17.     public Home(hauptklasse hauptklasse) {
  18.     }
  19.  
  20.     String path = "plugins//Core//User//Home//";
  21.     public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
  22.        
  23.         if(!(sender instanceof Player)){
  24.             Bukkit.getConsoleSender().sendMessage("§4Der Befehl §eHOME §4geht nur im Spiel!");
  25.             return true;
  26.         }
  27.        
  28.         if (cmd.getName().equalsIgnoreCase("home")) {
  29.         Player plr =(Player) sender;
  30.  
  31.  
  32.                 if(args.length == 0) {
  33.             //Spieler hat folgendes eingegeben: /home
  34.             return true;
  35.         }
  36.  
  37.  
  38.         if (args[0].equalsIgnoreCase(":")) {
  39.            
  40.             plr.sendMessage("xD");
  41.             return true;
  42.         } else if (! args[0].equalsIgnoreCase(":")) {
  43.        
  44.        
  45.        
  46.         File file = new File(path+plr.getUniqueId()+".yml");
  47.             if (file.length() == 0) {
  48.                 plr.sendMessage("§c§lHome §8| §7Du hast keinen §cHome §7Point.");
  49.                 return true;
  50.             }
  51.            
  52.         YamlConfiguration cfg = YamlConfiguration.loadConfiguration(file); 
  53.         double x = cfg.getDouble("x");
  54.         double y = cfg.getDouble("y");
  55.         double z = cfg.getDouble("z");
  56.         double yaw = cfg.getDouble("yaw");
  57.         double pitch = cfg.getDouble("pitch");
  58.         String worldname = cfg.getString("world");
  59.    
  60.         Location loc = new Location(Bukkit.getWorld(worldname), x, y, z);
  61.         loc.setYaw((float) yaw);
  62.         loc.setPitch((float) pitch);
  63.         plr.teleport(loc);
  64.         plr.sendMessage("§c§lHome §8| §7Du wurdest zu deinem §cHome §7teleportiert.");
  65.             }
  66.         }
  67.         return true;
  68.     }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement