Advertisement
Guest User

Untitled

a guest
Jul 24th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.95 KB | None | 0 0
  1. package thom.plugin.hardcoresurvival.modules.survivalcommands.commands;
  2.  
  3. import org.bukkit.Bukkit;
  4. import org.bukkit.ChatColor;
  5. import org.bukkit.Location;
  6. import org.bukkit.command.Command;
  7. import org.bukkit.command.CommandExecutor;
  8. import org.bukkit.command.CommandSender;
  9. import org.bukkit.entity.Player;
  10. import thom.plugin.hardcoresurvival.Main;
  11.  
  12. /**
  13. * Created by Thom on 24-7-2017.
  14. */
  15. public class Spawn implements CommandExecutor {
  16.  
  17. @Override
  18. public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
  19. if (commandSender instanceof Player) {
  20. Player player = (Player) commandSender;
  21. if (command.getName().equalsIgnoreCase("spawn")) {
  22. if (strings.length == 0) {
  23. if (player.hasPermission("hardcoresurvival.spawn")) {
  24. if (Main.getPlugin().getDataManager().getConfig().
  25. getString("HardcoreSurvival.Data.Spawn.World") != null) {
  26. Location location = new Location(
  27. Bukkit.getWorld(Main.getPlugin().getDataManager().getConfig().
  28. getString("HardcoreSurvival.Data.Spawn.World")),
  29. Main.getPlugin().getDataManager().getConfig().
  30. getDouble("HardcoreSurvival.Data.Spawn.X"),
  31. Main.getPlugin().getDataManager().getConfig().
  32. getDouble("HardcoreSurvival.Data.Spawn.Y"),
  33. Main.getPlugin().getDataManager().getConfig().
  34. getDouble("HardcoreSurvival.Data.Spawn.Z"),
  35. (float) Main.getPlugin().getDataManager().getConfig().
  36. getDouble("HardcoreSurvival.Data.Spawn.Pitch"),
  37. (float) Main.getPlugin().getDataManager().getConfig().
  38. getDouble("HardcoreSurvival.Data.Spawn.Yaw"));
  39. if (location != null) {
  40. player.teleport(location);
  41. }
  42. }
  43. }
  44. } else if (strings.length == 1) {
  45. if (strings[0].equalsIgnoreCase("set")) {
  46. if (player.hasPermission("hardcoresurvival.setspawn")) {
  47. Location location = player.getLocation();
  48. Main.getPlugin().getDataManager().getConfig().set("HardcoreSurvival.Data.Spawn.World",
  49. location.getWorld().toString());
  50. Main.getPlugin().getDataManager().getConfig().set("HardcoreSurvival.Data.Spawn.X",
  51. location.getX());
  52. Main.getPlugin().getDataManager().getConfig().set("HardcoreSurvival.Data.Spawn.Y",
  53. location.getY());
  54. Main.getPlugin().getDataManager().getConfig().set("HardcoreSurvival.Data.Spawn.Z",
  55. location.getZ());
  56. Main.getPlugin().getDataManager().getConfig().set("HardcoreSurvival.Data.Spawn.Pitch",
  57. location.getPitch());
  58. Main.getPlugin().getDataManager().getConfig().set("HardcoreSurvival.Data.Spawn.Yaw",
  59. location.getYaw());
  60. player.sendMessage(Main.PREFIX + ChatColor.GRAY + "You have set the spawn!");
  61. }
  62. }
  63. }
  64. }
  65. } else {
  66. commandSender.sendMessage(ChatColor.RED + "Je moet een speler zijn om dit command te kunnen uitvoeren!");
  67. }
  68. return false;
  69. }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement