Advertisement
Guest User

Untitled

a guest
Apr 19th, 2014
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.72 KB | None | 0 0
  1. package com.relocatedgaming;
  2.  
  3. import java.util.HashMap;
  4.  
  5. import org.bukkit.Bukkit;
  6. import org.bukkit.ChatColor;
  7. import org.bukkit.Location;
  8. import org.bukkit.World;
  9. import org.bukkit.command.Command;
  10. import org.bukkit.command.CommandSender;
  11. import org.bukkit.entity.Player;
  12. import org.bukkit.event.EventHandler;
  13. import org.bukkit.event.EventPriority;
  14. import org.bukkit.event.Listener;
  15. import org.bukkit.event.player.PlayerRespawnEvent;
  16. import org.bukkit.plugin.Plugin;
  17. import org.bukkit.plugin.java.JavaPlugin;
  18.  
  19.  
  20. public class Main extends JavaPlugin{ //Extending JavaPlugin so that Bukkit knows its the main class...
  21.  
  22. private static Plugin plugin;
  23. public final HashMap<String, String> Jumpto = new HashMap<String, String>();
  24.  
  25. public void onEnable() {
  26. plugin = this;
  27. registerEvents(this, new Vanish());
  28. registerEvents(this, new Chat());
  29. getCommand("vanish").setExecutor(new Vanish());
  30. getCommand("killme").setExecutor(new Chat());
  31. getCommand("Help").setExecutor(new CommandHelp());
  32. getCommand("Who").setExecutor(new Who());
  33. //This is where we register our events/commands
  34.  
  35.  
  36. }
  37.  
  38. public void onDisable() {
  39. plugin = null;//To stop memory leaks
  40.  
  41. }
  42.  
  43.  
  44. //Much easier then registering events in 10 different methods
  45. public static void registerEvents(org.bukkit.plugin.Plugin plugin, Listener... listeners) {
  46. for (Listener listener : listeners) {
  47. Bukkit.getServer().getPluginManager().registerEvents(listener, plugin);
  48. }
  49. }
  50.  
  51. //To access the plugin variable from other classes
  52. public static Plugin getPlugin() {
  53. return plugin;
  54.  
  55. }
  56.  
  57. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
  58. if (cmd.getName().equalsIgnoreCase("jumpto")) {
  59. if (sender.hasPermission("relocatedgaming.jumpto")) {
  60. Player p = (Player) sender;
  61. if (args.length == 0) {
  62. sender.sendMessage("/jumpto list - List who is allowed to jump to you.");
  63. sender.sendMessage("/jumpto clear - Clear all allowed names.");
  64. sender.sendMessage("/jumpto allow [name] - Allow player to jump to you.");
  65. sender.sendMessage("/jumpto remove [name] - Remove player from your list");
  66. sender.sendMessage("/jumpto [name] - Jump to players location");
  67. sender.sendMessage("/jumpto here - Saves this location to jump to again.");
  68. sender.sendMessage("/jumpto there - Jump to saved location.");
  69. sender.sendMessage("/jumpto up - Jump up to next surface.");
  70. return true;
  71. }
  72. if (args[0].equalsIgnoreCase("allow")) {
  73. if (args.length == 1) {
  74. sender.sendMessage("Allow who dumbass?");
  75. }
  76. if(args.length == 2) {
  77. Player target = getServer().getPlayer(args[1]);
  78. if (target == null) {
  79. sender.sendMessage("Player " + args[1] + " not found.");
  80. return false;
  81. }
  82.  
  83. sendRequest(p, target);
  84. }
  85. return true;
  86. }
  87.  
  88. if (args[0].equalsIgnoreCase("remove")) {
  89.  
  90. }
  91. if (args[0].equalsIgnoreCase("list")) {
  92.  
  93. }
  94. if (args[0].equalsIgnoreCase("up")) {
  95. sender.sendMessage("You have jumped up.");
  96. }
  97.  
  98. else if (args[0].equalsIgnoreCase("here")) {
  99. Player target = (Player) sender;
  100. String uuid = target.getUniqueId().toString();
  101. sender.sendMessage("This location is saved as your jump point.");
  102. getConfig().set(uuid + "." + "jumpto.world", target.getLocation().getWorld().getName());
  103. getConfig().set(uuid + "." + "jumpto.x", target.getLocation().getX());
  104. getConfig().set(uuid + "." + "jumpto.y", target.getLocation().getY());
  105. getConfig().set(uuid + "." + "jumpto.z", target.getLocation().getZ());
  106. getConfig().set(uuid + "." + "jumpto.yaw", target.getLocation().getYaw());
  107. getConfig().set(uuid + "." + "jumpto.pitch", target.getLocation().getPitch());
  108. saveConfig();
  109. }
  110. else if (args[0].equalsIgnoreCase("there")) {
  111. Player target = (Player) sender;
  112. String uuid = target.getUniqueId().toString();
  113. sender.sendMessage("You have jumped to your saved location.");
  114. if (getConfig().getConfigurationSection(uuid) == null) {
  115. target.sendMessage(ChatColor.RED + "You have not set a jumpto location.");
  116. return true;
  117. }
  118. World w = Bukkit.getServer().getWorld(getConfig().getString(uuid + "." + "jumpto.world"));
  119. double x = getConfig().getDouble(uuid + "." + "jumpto.x");
  120. double y = getConfig().getDouble(uuid + "." + "jumpto.y");
  121. double z = getConfig().getDouble(uuid + "." + "jumpto.z");
  122. float yaw = getConfig().getInt(uuid + "." + "jumpto.yaw");
  123. float pitch = getConfig().getInt(uuid + "." + "jumpto.pitch");
  124. target.teleport(new Location(w, x, y, z, yaw, pitch));
  125. }
  126. else if (!(p == null)) {
  127. if (Jumpto.containsValue(p.getName())) { // started fucking up around here.
  128. Player Jumps = getServer().getPlayer(Jumpto.get(p.getName()));
  129.  
  130. if (Jumpto.containsKey(Jumps)) {
  131. p.teleport(Jumps);
  132. p.sendMessage("You jumped to " + Jumps.getDisplayName());
  133. Jumps.sendMessage(sender.getName() + " jumped to your location");
  134. }
  135. else {
  136. sender.sendMessage(args[0] + " has not added you to their jump list.");
  137. }
  138. }
  139. }
  140. }
  141. }
  142. }
  143. public void sendRequest(Player sender, Player recipient) {
  144. sender.sendMessage(recipient.getDisplayName() + " is allowed to jump to you.");
  145.  
  146. String allow = "";
  147. String remove = "";
  148.  
  149. if (recipient.hasPermission("relocatedgaming.jumpto")) {
  150. allow = sender.getDisplayName() + " has added you to their jump list.";
  151. } else {
  152. allow = "";
  153. }
  154.  
  155. if (recipient.hasPermission("relocatedgaming.jumpto")) {
  156. remove = "";
  157. } else {
  158. remove = "";
  159. }
  160.  
  161. recipient.sendMessage(allow);
  162. Jumpto.put(recipient.getName(), sender.getName());
  163.  
  164. }
  165.  
  166. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement