SHARE
TWEET

dsad

lohcKamlaX May 19th, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package pl.szymeko.command;
  2.  
  3. import java.io.File;
  4. import java.io.IOException;
  5. import java.util.ArrayList;
  6. import java.util.List;
  7. import java.util.logging.Logger;
  8.  
  9. import org.bukkit.command.CommandSender;
  10. import org.bukkit.configuration.file.YamlConfiguration;
  11. import org.bukkit.entity.Player;
  12.  
  13. import pl.szymeko.command.CommandUtil.Command;
  14. import pl.szymeko.command.main.Main;
  15. import pl.szymeko.command.managers.FileManager;
  16.  
  17. public class SetSpawnCommand extends Command {
  18.  
  19.     public SetSpawnCommand() {
  20.         super("setspawn", "ustawia spawna", "/setspawn", "lohc.setspawn", new ArrayList<String>());
  21.         // TODO Auto-generated constructor stub
  22.     }
  23.  
  24.     @Override
  25.     public boolean komenda(CommandSender sender, String[] args) {
  26.  
  27.                 File f;
  28.                 if (FileManager.plik("warps.yml") == null) {
  29.                     f = new File(Main.getInst().getDataFolder(), "warps.yml");
  30.                     try {
  31.                         f.createNewFile();
  32.                     }
  33.                     catch (IOException e) {
  34.                         e.printStackTrace();
  35.                     }
  36.                     Logger.getLogger("[ACommands] Plik warps.yml nie istnial wiec zostal stworzony");
  37.                 }
  38.                 else {
  39.                     f = FileManager.plik("warps.yml");
  40.                 }
  41.                 final YamlConfiguration warps = YamlConfiguration.loadConfiguration(f);
  42.                 if (sender instanceof Player) {
  43.                     final Player p = (Player)sender;
  44.                     warps.set("spawn.x", (Object)p.getLocation().getX());
  45.                     warps.set("spawn.y", (Object)p.getLocation().getY());
  46.                     warps.set("spawn.z", (Object)p.getLocation().getZ());
  47.                     warps.set("spawn.world", (Object)p.getLocation().getWorld().getName().toString());
  48.                     try {
  49.                         warps.save(f);
  50.                     }
  51.                     catch (IOException e2) {
  52.                         e2.printStackTrace();
  53.                     }
  54.                     p.sendMessage("§c§lSETSPAWN §8» §7Ustawiono miejsce §cSPAWNA");
  55.                 }
  56.            
  57.         return false;
  58.     }
  59.  
  60. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top