Advertisement
Guest User

LocationPort

a guest
Nov 24th, 2014
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.18 KB | None | 0 0
  1. package me.xkev320x.info;
  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.FileConfiguration;
  11. import org.bukkit.configuration.file.YamlConfiguration;
  12. import org.bukkit.entity.Player;
  13.  
  14. public class LocationPort implements CommandExecutor {
  15.  
  16.     @SuppressWarnings("unused")
  17.     private Info plugin;
  18.     File file = new File("plugins/Info", "homes.yml");  //File wird geladen,er existiert ja schon...
  19.     FileConfiguration cfg  = YamlConfiguration.loadConfiguration(file);
  20.  
  21.     public LocationPort(Info info) {
  22.         this.plugin = info;
  23.     }
  24.  
  25.     @Override
  26.     public boolean onCommand(CommandSender sender, Command cmd, String cmdlabel, String[] args) {
  27.         if(!(sender instanceof Player)){
  28.             sender.sendMessage("§cDu musst ein Spieler sein!");
  29.         } else {
  30.             Player p = (Player) sender;
  31.             if(args.length == 1){
  32.                 if(cfg.contains(args[0])){      //falls das Home existiert...
  33.                
  34.                 String world = cfg.getString(p.getName() + "." + args[0] + ".world");   //String world wird als der Weltname definiert in der Datei..
  35.                 double x = cfg.getDouble(p.getName() + "." + args[0] + ".x");   //...
  36.                 double y = cfg.getDouble(p.getName() + "." + args[0] + ".y");
  37.                 double z = cfg.getDouble(p.getName() + "." + args[0] + ".z");
  38.                 double yaw = cfg.getDouble(p.getName() + "." + args[0] + ".yaw");
  39.                 double pitch = cfg.getDouble(p.getName() + "." + args[0] + ".pitch");
  40.                
  41.                 Location loc = new Location(Bukkit.getWorld(world), x, y, z);   //Die Location loc wird erstellt und die Koordinaten sind die aus der Datei...
  42.                 loc.setPitch((float) pitch);    //Der pitch wird zur loc hinzugefügt
  43.                 loc.setYaw((float) yaw);        //Der yaw wird zur loc hinzugefügt
  44.                 p.teleport(loc);        //Player wird zu dieser loc geportet...
  45.                 p.sendMessage("§2Du wurdest zu deinem Home §6" + args[0] + " §2geportet");
  46.                 } else if(!(cfg.contains(args[0]))){
  47.                     p.sendMessage("§cDieses Home existiert nicht!");
  48.                 }
  49.                
  50.             } else {
  51.                 p.sendMessage("§4Nutze bitte /location <name>");
  52.             }
  53.            
  54.            
  55.            
  56.         }
  57.        
  58.         return true;
  59.     }
  60.  
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement