Vinetos

Bukkit Dev' | #6 - La Téléportation Définis

Oct 15th, 2014
724
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. import java.io.File;
  2.  
  3. import org.bukkit.Bukkit;
  4. import org.bukkit.Location;
  5. import org.bukkit.command.Command;
  6. import org.bukkit.command.CommandSender;
  7. import org.bukkit.entity.Player;
  8. import org.bukkit.plugin.java.JavaPlugin;
  9.  
  10.  
  11. public class Main extends JavaPlugin {
  12.  
  13. public void onEnable()
  14. {
  15. File f = new File("plugins/EP6", "config.yml");
  16. if(f.exists())
  17. {
  18. System.out.println("Fichier de configuration existant!");
  19. }else{
  20. getConfig().options().copyDefaults(false);
  21. getConfig().createSection("Spawn");
  22. getConfig().createSection("Spawn.x");
  23. getConfig().createSection("Spawn.y");
  24. getConfig().createSection("Spawn.z");
  25.  
  26. saveConfig();
  27. }
  28. }
  29.  
  30. public boolean onCommand(CommandSender sender, Command cmd, String label, String[]args)
  31. {
  32. Player player = (Player) sender;
  33.  
  34. if(cmd.getName().equalsIgnoreCase("setspawn"))
  35. {
  36. Location loc = player.getLocation();
  37.  
  38. getConfig().set("Spawn.x", loc.getX());
  39. getConfig().set("Spawn.y", loc.getY());
  40. getConfig().set("Spawn.z", loc.getZ());
  41.  
  42. saveConfig();
  43. player.sendMessage("§2>> Point de spawn defini acec succes!");
  44.  
  45. }else if(cmd.getName().equalsIgnoreCase("spawn"))
  46. {
  47. Location TPSpawn = new Location(Bukkit.getWorld("world"), getConfig().getDouble("Spawn.x"), getConfig().getDouble("Spawn.y"), getConfig().getDouble("Spawn.z"));
  48. player.teleport(TPSpawn);
  49. player.sendMessage("§2>> Vous etes maintenant au spawn!");
  50. }
  51. return true;
  52.  
  53. }
  54.  
  55.  
  56. }
Advertisement
Add Comment
Please, Sign In to add comment