Advertisement
Guest User

Untitled

a guest
Aug 21st, 2014
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.70 KB | None | 0 0
  1. package com.Dobbermann2.BowButton;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.HashMap;
  5.  
  6. import org.bukkit.Bukkit;
  7. import org.bukkit.ChatColor;
  8. import org.bukkit.Location;
  9. import org.bukkit.Material;
  10. import org.bukkit.command.Command;
  11. import org.bukkit.command.CommandSender;
  12. import org.bukkit.enchantments.Enchantment;
  13. import org.bukkit.entity.Player;
  14. import org.bukkit.inventory.ItemStack;
  15. import org.bukkit.inventory.meta.ItemMeta;
  16. import org.bukkit.plugin.java.JavaPlugin;
  17.  
  18.  
  19. public class Main extends JavaPlugin{
  20. public ArrayList<Player> jp = new ArrayList<Player>();
  21. public int a;
  22. public int startCountdownId;
  23. public HashMap<Player, Integer> points = new HashMap<Player, Integer>();
  24.  
  25.  
  26. public void onEnable() {
  27. Bukkit.getPluginManager().registerEvents(new Join(this), this);
  28. Bukkit.broadcastMessage(ChatColor.RED + "BowButton is now ENABLED");
  29. GameState.setState(GameState.IN_LOBBY);
  30. getConfig().addDefault("bowbutton.world", "bowbutton");
  31. getConfig().addDefault("bowbutton.x", 1);
  32. getConfig().addDefault("bowbutton.y", 1);
  33. getConfig().addDefault("bowbutton.z", 1);
  34. getConfig().addDefault("p1.x", 1);
  35. getConfig().addDefault("p1.y", 1);
  36. getConfig().addDefault("p1.z", 1);
  37. getConfig().addDefault("p2.x", 1);
  38. getConfig().addDefault("p2.y", 1);
  39. getConfig().addDefault("p2.z", 1);
  40. getConfig().addDefault("p3.x", 1);
  41. getConfig().addDefault("p3.y", 1);
  42. getConfig().addDefault("p3.z", 1);
  43. getConfig().addDefault("p4.x", 1);
  44. getConfig().addDefault("p4.y", 1);
  45. getConfig().addDefault("p4.z", 1);
  46. getConfig().addDefault("p5.x", 1);
  47. getConfig().addDefault("p5.y", 1);
  48. getConfig().addDefault("p5.z", 1);
  49. getConfig().addDefault("p1.world", "bowbutton");
  50. getConfig().addDefault("p2.world", "bowbutton");
  51. getConfig().addDefault("p3.world", "bowbutton");
  52. getConfig().addDefault("p4.world", "bowbutton");
  53. getConfig().addDefault("p5.world", "bowbutton");
  54. getConfig().options().copyDefaults(true);
  55. saveConfig();
  56.  
  57. }
  58. public void onDisable() {
  59.  
  60. }
  61. @Override
  62. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
  63. Player p = (Player) sender;
  64. if (cmd.getName().equalsIgnoreCase("bowbutton")) {
  65. if (args[0].equalsIgnoreCase("setlobby")) {
  66. if (p.isOp()) {
  67.  
  68. }
  69. }
  70. if (args[0].equalsIgnoreCase("p1")) {
  71. if (p.isOp()) {
  72. getConfig().set("p1.world", p.getWorld().getName());
  73. getConfig().set("p1.x", p.getLocation().getX());
  74. getConfig().set("p1.y", p.getLocation().getY());
  75. getConfig().set("p1.z", p.getLocation().getZ());
  76. p.sendMessage(ChatColor.GREEN + "p1 has been set!");
  77. }
  78. }
  79. if (args[0].equalsIgnoreCase("p2")) {
  80. if (p.isOp()) {
  81. getConfig().set("p2.world", p.getWorld().getName());
  82. getConfig().set("p2.x", p.getLocation().getX());
  83. getConfig().set("p2.y", p.getLocation().getY());
  84. getConfig().set("p2.z", p.getLocation().getZ());
  85. p.sendMessage(ChatColor.GREEN + "p2 has been set!");
  86. }
  87. }
  88. if (args[0].equalsIgnoreCase("p3")) {
  89. if (p.isOp()) {
  90. getConfig().set("p3.world", p.getWorld().getName());
  91. getConfig().set("p3.x", p.getLocation().getX());
  92. getConfig().set("p3.y", p.getLocation().getY());
  93. getConfig().set("p3.z", p.getLocation().getZ());
  94. p.sendMessage(ChatColor.GREEN + "p3 has been set!");
  95. }
  96. }
  97. if (args[0].equalsIgnoreCase("p4")) {
  98. if (p.isOp()) {
  99. getConfig().set("p4.world", p.getWorld().getName());
  100. getConfig().set("p4.x", p.getLocation().getX());
  101. getConfig().set("p4.y", p.getLocation().getY());
  102. getConfig().set("p4.z", p.getLocation().getZ());
  103. p.sendMessage(ChatColor.GREEN + "p4 has been set!");
  104. }
  105. }
  106. if (args[0].equalsIgnoreCase("p5")) {
  107. if (p.isOp()) {
  108. getConfig().set("p5.world", p.getWorld().getName());
  109. getConfig().set("p5.x", p.getLocation().getX());
  110. getConfig().set("p5.y", p.getLocation().getY());
  111. getConfig().set("p5.z", p.getLocation().getZ());
  112. p.sendMessage(ChatColor.GREEN + "p5 has been set!");
  113. }
  114. }
  115.  
  116. if (args[0] == null) {
  117. p.sendMessage(ChatColor.RED + "Invalid Arguments");
  118. }
  119. if (args.length == 0) {
  120. p.sendMessage(ChatColor.RED + "Invalid Arguments");
  121. }
  122. }
  123. return false;
  124. }
  125. public void Start() {
  126. if (GameState.isState(GameState.IN_LOBBY)) {
  127. Countdown.timeUntilStart = 60;
  128. startCountdownId = getServer().getScheduler().scheduleSyncRepeatingTask(this, new Countdown(this), 20L, 20L);
  129. }
  130.  
  131. }
  132. public void StartGame() {
  133. stopCountdown();
  134. if (!(jp.get(0) == null)){
  135. jp.get(0).teleport(new Location(Bukkit.getWorld("bowbutton"), this.getConfig().getInt("p1.x"), this.getConfig().getInt("p1.y"), this.getConfig().getInt("p1.z")));
  136. }else {
  137. return;
  138. }
  139. if (!(jp.get(1) == null)){
  140. jp.get(1).teleport(new Location(Bukkit.getWorld("bowbutton"), this.getConfig().getInt("p2.x"), this.getConfig().getInt("p2.y"), this.getConfig().getInt("p2.z")));
  141. }else {
  142. return;
  143. }
  144. if (!(jp.get(2) == null)){
  145. jp.get(2).teleport(new Location(Bukkit.getWorld("bowbutton"), this.getConfig().getInt("p3.x"), this.getConfig().getInt("p3.y"), this.getConfig().getInt("p3.z")));
  146.  
  147. }else {
  148. return;
  149. }
  150. if (!(jp.get(3) == null)){
  151. jp.get(3).teleport(new Location(Bukkit.getWorld("bowbutton"), this.getConfig().getInt("p4.x"), this.getConfig().getInt("p4.y"), this.getConfig().getInt("p4.z")));
  152.  
  153. }else {
  154. return;
  155. }
  156. if (!(jp.get(4) == null )){
  157. jp.get(4).teleport(new Location(Bukkit.getWorld("bowbutton"), this.getConfig().getInt("p5.x"), this.getConfig().getInt("p5.y"), this.getConfig().getInt("p5.z")));
  158. }else {
  159. return;
  160. }
  161. GameState.setState(GameState.IN_GAME);
  162. ItemStack bow = new ItemStack(Material.BOW);
  163. ItemMeta bom = bow.getItemMeta();
  164. bom.addEnchant(Enchantment.ARROW_INFINITE, 1, true);
  165. bow.setAmount(1);
  166. bow.setItemMeta(bom);
  167. ItemStack arr = new ItemStack(Material.ARROW);
  168. arr.setAmount(1);
  169. jp.get(0).getInventory().addItem(bow);
  170. jp.get(0).getInventory().addItem(arr);
  171. jp.get(1).getInventory().addItem(bow);
  172. jp.get(1).getInventory().addItem(arr);
  173. jp.get(2).getInventory().addItem(bow);
  174. jp.get(2).getInventory().addItem(arr);
  175. jp.get(3).getInventory().addItem(bow);
  176. jp.get(3).getInventory().addItem(arr);
  177. jp.get(4).getInventory().addItem(bow);
  178. jp.get(4).getInventory().addItem(arr);
  179. jp.get(5).getInventory().addItem(bow);
  180. jp.get(5).getInventory().addItem(arr);
  181.  
  182. return;
  183. }
  184. public void stopCountdown() {
  185. getServer().getScheduler().cancelTask(startCountdownId);
  186.  
  187. }
  188. public void RestartCountdown() {
  189. stopCountdown();
  190. Start();
  191.  
  192. }
  193. public void Ending() {
  194.  
  195. jp.clear();
  196. points.clear();
  197.  
  198.  
  199. }
  200.  
  201.  
  202.  
  203. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement