Guest User

Untitled

a guest
Feb 16th, 2014
84
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. public final Logger logger = Logger.getLogger("Minecraft");
  3. PluginDescriptionFile pdf = this.getDescription();
  4.  
  5. public void onEnable() {
  6.  
  7. this.logger.info(pdf.getName() + "v" + pdf.getVersion() + " has been enabled!");
  8. this.saveDefaultConfig();
  9.  
  10. if(!getDataFolder().exists())
  11. getDataFolder().mkdir();
  12.  
  13. if(getConfig() == null)
  14. saveDefaultConfig();
  15.  
  16. new BT2ArenaManager(this);
  17. BT2ArenaManager.getManager().loadGames();
  18.  
  19. this.getServer().getPluginManager().registerEvents(new BT2GameListener(this), this);
  20.  
  21. }
  22.  
  23. public void onDisable() {
  24. this.logger.info(pdf.getName() + "v" + pdf.getVersion() + " has been disabled!");
  25. this.saveConfig();
  26.  
  27. }
  28.  
  29. public boolean onCommand(CommandSender s, Command c, String label, String[] args) {
  30. Player p = (Player) s;
  31.  
  32. if (c.getName().equalsIgnoreCase("bowthrow")) {
  33.  
  34. if (!(s instanceof Player)) {
  35. return true;
  36. }
  37. if (args.length > 2) {
  38. p.sendMessage(ChatColor.RED + "Invalid command! Do /bowthrow for help!");
  39. return true;
  40. }
  41. else if (args.length == 0) {
  42. if (p.hasPermission("bowthrow.help")) {
  43. p.sendMessage(ChatColor.BLUE + "BowThrow " + ChatColor.GREEN + "v" + pdf.getVersion() + ChatColor.BLUE + " by " + ChatColor.GREEN + "GiraffeKnee" + ChatColor.BLUE + "!");
  44. p.sendMessage(ChatColor.GREEN + "/" + ChatColor.BLUE + "bowthrow create" + ChatColor.GREEN + " - " + ChatColor.BLUE + "create an arena!");
  45. p.sendMessage(ChatColor.GREEN + "/" + ChatColor.BLUE + "bowthrow remove <arena#>" + ChatColor.GREEN + " - " + ChatColor.BLUE + "remove <arena#>!");
  46. p.sendMessage(ChatColor.GREEN + "/" + ChatColor.BLUE + "bowthrow join <arena#>" + ChatColor.GREEN + " - " + ChatColor.BLUE + "join <arena#>!");
  47. p.sendMessage(ChatColor.GREEN + "/" + ChatColor.BLUE + "bowthrow leave" + ChatColor.GREEN + " - " + ChatColor.BLUE + "leave the arena!");
  48. p.sendMessage(ChatColor.GREEN + "/" + ChatColor.BLUE + "bowthrow list" + ChatColor.GREEN + " - " + ChatColor.BLUE + "lists all arenas!");
  49. p.sendMessage(ChatColor.GREEN + "/" + ChatColor.BLUE + "bowthrow reload" + ChatColor.GREEN + " - " + ChatColor.BLUE + "reloads the config!");
  50.  
  51.  
  52. return true;
  53. }
  54. else {
  55. p.sendMessage(ChatColor.RED + "You don't have permission!");
  56. return true;
  57. }
  58. }
  59. else if (args.length == 1) {
  60. if (args[0].equalsIgnoreCase("create")) {
  61. if (p.hasPermission("bowthrow.create")) {
  62. Location loc = p.getLocation();
  63. BT2ArenaManager.getManager().createBT2Arena(loc);
  64. p.sendMessage(ChatColor.BLUE + "Created a new arena!");
  65. return true;
  66. }
  67. else {
  68. p.sendMessage(ChatColor.RED + "You don't have permission!");
  69. return true;
  70. }
  71. }
  72. else if (args[0].equalsIgnoreCase("leave")) {
  73. if (p.hasPermission("bowthrow.leave")) {
  74. BT2ArenaManager.getManager().removePlayer(p);
  75. if (BT2ArenaManager.getManager().isInGame(p)) {
  76. p.sendMessage(ChatColor.RED + "You left the arena!");
  77. Bukkit.broadcastMessage(ChatColor.BLUE + p.getName() + ChatColor.RED +" left the BowThrow arena!");
  78. return true;
  79. }
  80. return true;
  81. }
  82. else {
  83. p.sendMessage(ChatColor.RED + "You don't have permission!");
  84. return true;
  85. }
  86. }
  87. else if (args[0].equalsIgnoreCase("list")) {
  88. if (p.hasPermission("bowthrow.list")) {
  89. p.sendMessage(ChatColor.GREEN + "Arenas: ");
  90. String arenas = this.getConfig().getIntegerList("BT2Arenas.BT2Arenas").toString();
  91. p.sendMessage(ChatColor.BLUE + arenas);
  92. return true;
  93. }
  94. else {
  95. p.sendMessage(ChatColor.RED + "You don't have permission!");
  96. return true;
  97. }
  98. }
  99. else if (args[0].equalsIgnoreCase("reload")) {
  100. if (p.hasPermission("bowthrow.reload")) {
  101. this.reloadConfig();
  102. p.sendMessage(ChatColor.GREEN + "BowThrow config reloaded!");
  103. return true;
  104. }
  105. else {
  106. p.sendMessage(ChatColor.RED + "You don't have permission!");
  107. return true;
  108. }
  109. }
  110. else {
  111. p.sendMessage(ChatColor.RED + "Invalid command!");
  112. return true;
  113. }
  114. }
  115. else if (args.length == 2) {
  116. if (args[0].equalsIgnoreCase("remove")) {
  117. if (p.hasPermission("bowthrow.remove")) {
  118. int numb = 0;
  119. try{
  120. numb = Integer.parseInt(args[1]);
  121. }catch(NumberFormatException e){
  122. p.sendMessage(ChatColor.RED + "Invalid arena ID");
  123. return true;
  124. }
  125. numb = Integer.parseInt(args[1]);
  126.  
  127. if (BT2ArenaManager.getManager().getBT2Arena(numb) == null) {
  128. p.sendMessage(ChatColor.RED + "That arena is null (probably doesn't exist!)");
  129. return true;
  130. }
  131.  
  132. BT2ArenaManager.getManager().removeBT2Arena(numb);
  133. List<Integer> l = this.getConfig().getIntegerList("BT2Arenas.BT2Arenas");
  134. l.remove(numb);
  135. this.getConfig().set("BT2Arenas.BT2Arenas", l);
  136. p.sendMessage(ChatColor.GREEN + "Arena " + numb + " was removed!");
  137. this.saveConfig();
  138.  
  139. return true;
  140. }
  141. else {
  142. p.sendMessage(ChatColor.RED + "You don't have permission!");
  143. return true;
  144. }
  145. }
  146. else if (args[0].equalsIgnoreCase("join")) {
  147. if (p.hasPermission("bowthrow.join")) {
  148. int num = 0;
  149. try{
  150. num = Integer.parseInt(args[1]);
  151. }catch(NumberFormatException e){
  152. p.sendMessage(ChatColor.RED + "Invalid arena ID");
  153. return true;
  154. }
  155. BT2ArenaManager.getManager().addPlayer(p, num);
  156. return true;
  157. }
  158. else {
  159. p.sendMessage(ChatColor.RED + "You don't have permission!");
  160. return true;
  161. }
  162. }
  163. else {
  164. p.sendMessage(ChatColor.RED + "Invalid command!");
  165. return true;
  166. }
  167. }
  168. }
  169. return false;
  170. }
  171. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×