Guest User

Untitled

a guest
Jun 29th, 2018
124
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package me.welshy.Warps;
  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.CommandSender;
  8. import org.bukkit.entity.Player;
  9. import org.bukkit.plugin.java.JavaPlugin;
  10.  
  11. import net.minecraft.server.v1_12_R1.World;
  12.  
  13. public class Main extends JavaPlugin {
  14.  
  15. @Override
  16. public void onEnable() {
  17. Bukkit.getLogger().info(ChatColor.GREEN+"Warps has been activated!");
  18. getConfig().options().copyDefaults(true);
  19. saveConfig();
  20. }
  21.  
  22. @Override
  23. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
  24. if (!(sender instanceof Player)) {
  25. sender.sendMessage(ChatColor.RED+"Only players can execute this command!");
  26. return true;
  27. }
  28.  
  29. Player player = (Player) sender;
  30.  
  31. if (args.length == 0) {
  32. player.sendMessage(ChatColor.RED+"Please specify the name of the warp.");
  33. } else if (args.length == 1) {
  34. String arg = args[0].toLowerCase();
  35.  
  36. if (label.equalsIgnoreCase("setwarp")) {
  37. getConfig().set("warps."+arg+".world", player.getWorld().getName());
  38. getConfig().set("warps."+arg+".x", player.getLocation().getX());
  39. getConfig().set("warps."+arg+".y", player.getLocation().getY());
  40. getConfig().set("warps."+arg+".z", player.getLocation().getZ());
  41. getConfig().set("warps."+arg+".yaw", player.getLocation().getYaw());
  42. getConfig().set("warps."+arg+".pitch", player.getLocation().getPitch());
  43. saveConfig();
  44. player.sendMessage(ChatColor.GREEN+"Successfuly added a new warp: "+ChatColor.DARK_GREEN+arg+ChatColor.GREEN+"!");
  45. } else if (label.equalsIgnoreCase("warp")) {
  46. if (getConfig().getConfigurationSection("warps."+arg) == null) {
  47. player.sendMessage(ChatColor.RED+"A warp with that name does not exist!");
  48. return true;
  49. }
  50.  
  51. World world = (World) Bukkit.getWorld(getConfig().getString("warps."+arg+".world"));
  52. double x = getConfig().getDouble("warps."+arg+".x");
  53. double y = getConfig().getDouble("warps."+arg+".y");
  54. double z = getConfig().getDouble("warps."+arg+".z");
  55. float yaw = (float) getConfig().getDouble("warps."+arg+".yaw");
  56. float pitch = (float) getConfig().getDouble("warps."+arg+".pitch");
  57.  
  58. player.teleport(new Location((org.bukkit.World) world, x, y, z, yaw, pitch));
  59.  
  60. player.sendMessage(ChatColor.GREEN+"You successfully teleported to the warp: "+ChatColor.DARK_GREEN+arg+ChatColor.GREEN+"!");
  61. }
  62.  
  63. /**
  64. * warps:
  65. * args[0]:
  66. * world: world
  67. * x: 1
  68. * y: 1
  69. * z: 1
  70. * yaw: 1
  71. * pitch: 1
  72. */
  73.  
  74. } else {
  75. player.sendMessage(ChatColor.RED+"Too many arguments.");
  76. }
  77.  
  78. return true;
  79. }
  80. }
RAW Paste Data