Guest User

Untitled

a guest
Aug 14th, 2015
202
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package me.jobisingh;
  2.  
  3. import java.lang.reflect.Array;
  4. import java.util.ArrayList;
  5. import java.util.Arrays;
  6. import java.util.Collection;
  7. import java.util.HashMap;
  8. import java.util.HashSet;
  9. import java.util.List;
  10.  
  11. import com.sk89q.worldedit.BlockVector;
  12. import com.sk89q.worldedit.bukkit.WorldEditPlugin;
  13. import com.sk89q.worldedit.bukkit.selections.CuboidSelection;
  14. import com.sk89q.worldedit.bukkit.selections.Selection;
  15. import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
  16. import com.sk89q.worldguard.bukkit.commands.task.RegionAdder;
  17. import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
  18. import com.sk89q.worldguard.protection.regions.ProtectedRegion;
  19.  
  20. import org.bukkit.plugin.Plugin;
  21. import org.bukkit.Bukkit;
  22. import org.bukkit.ChatColor;
  23. import org.bukkit.Location;
  24. import org.bukkit.Material;
  25. import org.bukkit.World;
  26. import org.bukkit.block.Block;
  27.  
  28. // Color Code Here §
  29.  
  30. import org.bukkit.command.Command;
  31. import org.bukkit.command.CommandSender;
  32. import org.bukkit.entity.Player;
  33. import org.bukkit.inventory.Inventory;
  34. import org.bukkit.inventory.InventoryView;
  35. import org.bukkit.inventory.ItemStack;
  36. import org.bukkit.inventory.meta.ItemMeta;
  37. import org.bukkit.plugin.java.JavaPlugin;
  38.  
  39. import me.jobisingh.handlers.Game;
  40.  
  41. //Color Code §
  42.  
  43. public class MainClass extends JavaPlugin {
  44. public static Location lobbyLocation;
  45. public int getPoint1;
  46. @Override
  47. public void onEnable() {
  48. new ListenerClass(this);
  49. new Game();
  50. this.getConfig().addDefault("LobbySpawn:", lobbyLocation);
  51.  
  52.  
  53. this.getConfig().options().copyDefaults(true);
  54. saveConfig();
  55. }
  56.  
  57. @Override
  58. public void onDisable() {
  59. saveConfig();
  60.  
  61.  
  62. }
  63.  
  64. private WorldGuardPlugin getWorldGuard() {
  65. Plugin plugin = getServer().getPluginManager().getPlugin("WorldGuard");
  66.  
  67. // WorldGuard may not be loaded
  68. if (plugin == null || !(plugin instanceof WorldGuardPlugin)) {
  69. return null; // Maybe you want throw an exception instead
  70. }
  71.  
  72. return (WorldGuardPlugin) plugin;
  73. }
  74.  
  75. public WorldEditPlugin getWorldEdit() {
  76.  
  77. Plugin p = Bukkit.getServer().getPluginManager().getPlugin("WorldEdit");
  78. if(p instanceof WorldEditPlugin) return (WorldEditPlugin) p;
  79. else return null;
  80. }
  81.  
  82.  
  83.  
  84. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
  85.  
  86. if (cmd.getName().equalsIgnoreCase("setteam1spawn") && sender instanceof Player) {
  87.  
  88. Player player = (Player) sender;
  89.  
  90. @SuppressWarnings("deprecation")
  91. Block getBlock = player.getTargetBlock((HashSet<Byte>)null, 100);
  92.  
  93. int x = getBlock.getX();
  94. int y = getBlock.getY();
  95. int z = getBlock.getZ();
  96.  
  97. player.sendMessage("Team 1 Spawn Set At " + x + " " + y + " " + z);
  98.  
  99. return true;
  100.  
  101. }
  102. else if (cmd.getName().equalsIgnoreCase("lobbyCreate") && sender instanceof Player) {
  103.  
  104. Player player = (Player) sender;
  105.  
  106. int length = args.length;
  107. if (length == 1) {
  108.  
  109. Object lobbyName = args[0];
  110. if(lobbyName.equals(args[0])) {
  111.  
  112. int getPoint1X = ListenerClass.pointGetter.get("point1X");
  113. int getPoint2X = ListenerClass.pointGetter2.get("point2X");
  114. int getPoint1Y = ListenerClass.pointGetter.get("point1Y");
  115. int getPoint2Y = ListenerClass.pointGetter2.get("point2Y");
  116. int getPoint1Z = ListenerClass.pointGetter.get("point1Z");
  117. int getPoint2Z = ListenerClass.pointGetter2.get("point2Z");
  118. Location getPoint1 = ListenerClass.locationGetter.get("point1");
  119. Location getPoint2 = ListenerClass.locationGetter2.get("point2");
  120. if (getPoint1 != null && getPoint2 != null) {
  121.  
  122. if (getConfig().get((String) lobbyName) == null) {
  123. HashMap<Integer, Location> lobbies = new HashMap<>();
  124.  
  125. Location blockSelector = getPoint1;
  126. int blockSelectorX = blockSelector.getBlockX();
  127. int blockSelectorY = blockSelector.getBlockY();
  128. int blockSelectorZ = blockSelector.getBlockZ();
  129.  
  130. double blockSelector2;
  131. int replaceVarX = 0;
  132. int replaceVarY = 0;
  133. int replaceVarZ = 0;
  134.  
  135. if(getPoint1X > 0 && getPoint2X > 0 && getPoint1X < getPoint2X) {
  136.  
  137. replaceVarX = blockSelector.getBlockX() + 1;
  138.  
  139. }
  140. else if(getPoint1X > 0 && getPoint2X > 0 && getPoint1X > getPoint2X) {
  141.  
  142. replaceVarX = blockSelector.getBlockX() - 1;
  143.  
  144. }
  145.  
  146. else if (getPoint1X < 0 && getPoint2X < 0 && getPoint1X < getPoint2X) {
  147.  
  148. replaceVarX = blockSelector.getBlockX() + 1;
  149.  
  150. }
  151. else if (getPoint1X < 0 && getPoint2X < 0 && getPoint1X > getPoint2X) {
  152.  
  153. replaceVarX = blockSelector.getBlockX() - 1;
  154.  
  155. }
  156. //maybe good code plz
  157. else if (getPoint1X > 0 && getPoint2X < 0) {
  158.  
  159. replaceVarX = blockSelector.getBlockX() - 1;
  160.  
  161. }
  162.  
  163. else if (getPoint1X < 0 && getPoint2X > 0) {
  164.  
  165. replaceVarX = blockSelector.getBlockX() + 1;
  166.  
  167. }
  168.  
  169.  
  170.  
  171. if(getPoint1Z > 0 && getPoint2Z > 0 && getPoint1Z < getPoint2Z) {
  172.  
  173. replaceVarZ = blockSelector.getBlockZ() + 1;
  174.  
  175. }
  176. else if(getPoint1Z > 0 && getPoint2Z > 0 && getPoint1Z > getPoint2Z) {
  177.  
  178. replaceVarZ = blockSelector.getBlockZ() - 1;
  179.  
  180. }
  181.  
  182. else if (getPoint1Z < 0 && getPoint2Z < 0 && getPoint1Z < getPoint2Z) {
  183.  
  184. replaceVarX = blockSelector.getBlockX() + 1;
  185.  
  186. }
  187. else if (getPoint1Z < 0 && getPoint2Z < 0 && getPoint1Z > getPoint2Z) {
  188.  
  189. replaceVarZ = blockSelector.getBlockZ() - 1;
  190.  
  191. }
  192. //maybe good code plz
  193. else if (getPoint1Z > 0 && getPoint2Z < 0) {
  194.  
  195. replaceVarZ = blockSelector.getBlockZ() - 1;
  196.  
  197. }
  198.  
  199. else if (getPoint1Z < 0 && getPoint2Z > 0) {
  200.  
  201. replaceVarZ = blockSelector.getBlockZ() + 1;
  202.  
  203. }
  204.  
  205. if(getPoint1Y > getPoint2Y) {
  206.  
  207. replaceVarY = blockSelector.getBlockY() - 1;
  208.  
  209. }
  210. else if (getPoint1Y < getPoint2Y) {
  211.  
  212. replaceVarY = blockSelector.getBlockY() +1;
  213.  
  214. }
  215.  
  216.  
  217. for(; blockSelector.getBlockX() != getPoint2X; blockSelector.setX(replaceVarX)) {
  218.  
  219. for(; blockSelector.getBlockZ() != getPoint2Z; blockSelector.setZ(replaceVarZ) ) {
  220.  
  221. for(; blockSelector.getBlockY() != getPoint2Y; blockSelector.setY(replaceVarY)) {
  222.  
  223. lobbies.put(blockSelector.getBlockY(), blockSelector);
  224.  
  225. }
  226. lobbies.put(blockSelector.getBlockZ(), blockSelector);
  227. }
  228. lobbies.put(blockSelector.getBlockZ(), blockSelector);
  229. }
  230.  
  231. player.sendMessage("Lobby Created, " + args[0]);
  232.  
  233. return true;
  234. }}
  235. else if (getPoint1 == null || getPoint2 == null) {
  236.  
  237. player.sendMessage("Make Sure You Select Both Point1 and Point2");
  238.  
  239. }
  240. else if (getConfig().get((String) lobbyName) != null) {
  241.  
  242. player.sendMessage("A Lobby With This Name Already Exists! Do /lobbydelete (name) to delete the Lobby!");
  243.  
  244. }
  245.  
  246. }
  247. else {
  248.  
  249. player.sendMessage("Error Invalid Syntax, /lobbycreate (LobbyName)");
  250. }
  251.  
  252.  
  253. }
  254. }
  255.  
  256. else if (cmd.getName().equalsIgnoreCase("lobbySetSpawn") && sender instanceof Player) {
  257.  
  258. Player player = (Player) sender;
  259.  
  260. Location lobbyLocation = player.getLocation();
  261. int Xx = lobbyLocation.getBlockX();
  262. int Yy = lobbyLocation.getBlockY();
  263. int Zz = lobbyLocation.getBlockZ();
  264. World world = player.getWorld();
  265.  
  266. Location lobbyLoc = new Location(player.getWorld(), Xx, Yy, Zz);
  267. getConfig().set("LobbySpawn:", lobbyLocation);
  268.  
  269.  
  270.  
  271. return true;
  272.  
  273. }
  274. else if (cmd.getName().equalsIgnoreCase("positionwand") && sender instanceof Player) {
  275.  
  276. Player player = (Player) sender;
  277.  
  278. int length = args.length;
  279. if (length == 0) {
  280.  
  281. ItemStack wand = new ItemStack(Material.BLAZE_ROD, 1);
  282. Inventory inv = player.getInventory();
  283. int openInv = inv.firstEmpty();
  284. inv.setItem(openInv, wand);
  285. player.updateInventory();
  286. if(inv.getItem(0) != null) {
  287.  
  288.  
  289. ItemMeta wandIM = inv.getItem(openInv).getItemMeta();
  290. wandIM.setDisplayName(ChatColor.GREEN + "§lPositionWand");
  291. List<String> lore = Arrays.asList("§cLeft Click To Set Position 1, ", "§cAnd Right Click To Set Position 2.", " §cThen Simply do /lobbycreate");
  292. wandIM.setLore(lore);
  293. inv.getItem(openInv).setItemMeta(wandIM);
  294.  
  295. }
  296.  
  297. return true;
  298.  
  299. }
  300. else {
  301.  
  302. player.sendMessage("Error Invalid Syntax, /pos1");
  303. }
  304.  
  305.  
  306. }
  307. return false;
  308.  
  309. }
  310.  
  311. }
RAW Paste Data