Advertisement
Guest User

Untitled

a guest
Feb 16th, 2015
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.46 KB | None | 0 0
  1. public class SetSpawn implements CommandExecutor {
  2.  
  3.     @Override
  4.     public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
  5.         if (!(sender instanceof Player)) {
  6.             sender.sendMessage(API.c.getConfig().getString("Comando_Console").replaceAll("&", "§"));
  7.             return true;
  8.            
  9.         }
  10.        
  11.         Player p = (Player)sender;
  12.         if (cmd.getName().equalsIgnoreCase("SetSpawn")) {
  13.             File spawn = new File("plugins/dEssentials/spawn.yml");
  14.             FileConfiguration fc = YamlConfiguration.loadConfiguration(spawn);
  15.             if (sender.hasPermission(API.c.getConfig().getString("SetSpawn_Permissao"))) {
  16.                 fc.set("spawn.world", p.getWorld().getName());
  17.                 fc.set("spawn.x", p.getLocation().getX());
  18.                 fc.set("spawn.y", p.getLocation().getY());
  19.                 fc.set("spawn.z", p.getLocation().getZ());
  20.                 fc.set("spawn.yaw", p.getLocation().getYaw());
  21.                 fc.set("spawn.pitch", p.getLocation().getPitch());
  22.                 p.sendMessage(API.c.getConfig().getString("Spawn_Definido").replaceAll("&", "§"));
  23.                 try {
  24.                     fc.save(spawn);
  25.                 } catch (IOException e) {
  26.                     e.printStackTrace();
  27.                 }
  28.                
  29.             }else {
  30.                 p.sendMessage(API.c.getConfig().getString("Sem_Permissao").replaceAll("&", "§"));
  31.             }
  32.         }
  33.        
  34.         return false;
  35.     }
  36.    
  37. }
  38.  
  39. //No outro:
  40.  
  41. public class Spawn implements CommandExecutor {
  42.  
  43.     @Override
  44.     public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
  45.         if (!(sender instanceof Player)) {
  46.             sender.sendMessage(API.c.getConfig().getString("Comando_Console").replaceAll("&", "§"));
  47.             return true;
  48.         }
  49.        
  50.         Player p = (Player)sender;
  51.         if (cmd.getName().equalsIgnoreCase("Spawn")) {
  52.             File spawn = new File("plugins/dEssentials/spawn.yml");
  53.             FileConfiguration fc = YamlConfiguration.loadConfiguration(spawn);
  54.             if (p.hasPermission(API.c.getConfig().getString("Spawn_Permissao"))) {
  55.                
  56.                 World world = Bukkit.getServer().getWorld(fc.getString("spawn.world"));
  57.                 double x = fc.getDouble("spawn.x");
  58.                 double y = fc.getDouble("spawn.y");
  59.                 double z = fc.getDouble("spawn.z");
  60.                 float yaw = (float)fc.getDouble("spawn.yaw");
  61.                 float pitch = (float)fc.getDouble("spawn.pitch");
  62.                 p.sendMessage(API.c.getConfig().getString("Spawn").replaceAll("&", "§"));
  63.                 Location l = new Location(world, x, y, z);
  64.                 l.setYaw(yaw);
  65.                 l.setPitch(pitch);
  66.                 p.teleport(l);
  67.                
  68.             }else {
  69.                 p.sendMessage(API.c.getConfig().getString("Sem_Permissao").replaceAll("&", "§"));
  70.             }
  71.         }
  72.         return false;
  73.     }
  74.  
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement