/spleef/src/Spleef.java

https://github.com/ricin/minecraft-hey0-plugins · Java · 140 lines · 121 code · 19 blank · 0 comment · 66 complexity · bb0105b65c48b58251fb44d95fc3e642 MD5 · raw file

  1. import java.util.ArrayList;
  2. import java.util.List;
  3. import java.util.logging.Level;
  4. import java.util.logging.Logger;
  5. public class Spleef extends Plugin {
  6. private SpleefListener listener = new SpleefListener();
  7. static final Logger log = Logger.getLogger("Minecraft");
  8. static Location flypoint = new Location();
  9. static ArrayList<Location> locationList = new ArrayList<Location>(1);
  10. public void enable() {
  11. log.info("[Spleef] Mod Enabled.");
  12. SpleefData.loadSpleefData();
  13. etc.getInstance().addCommand("/saveSpleef", "<AirBlockID> <SolidBlockID> <Spleef Name> - Creates a Spleef area which will be reset by the trigger block");
  14. etc.getInstance().addCommand("/listSpleefs", "Lists the all the Spleef areas");
  15. }
  16. public void disable() {
  17. etc.getInstance().removeCommand("/saveSpleef");
  18. etc.getInstance().removeCommand("/listSpleefs");
  19. log.info("[Spleef] Mod Disabled");
  20. }
  21. public void initialize() {
  22. etc.getLoader().addListener(PluginLoader.Hook.COMMAND, listener, this, PluginListener.Priority.MEDIUM);
  23. etc.getLoader().addListener(PluginLoader.Hook.BLOCK_CREATED, listener, this, PluginListener.Priority.MEDIUM);
  24. }
  25. public class SpleefListener extends PluginListener
  26. {
  27. public boolean onBlockCreate(Player player, Block blockPlaced, Block blockClicked, int itemInHand){
  28. if ( (itemInHand==285) && player.canUseCommand("/saveSpleef")){
  29. Integer whichPoint = SpleefData.setPoint(player.getName(), blockClicked.getX(), blockClicked.getY(), blockClicked.getZ());
  30. if(whichPoint == 2) {
  31. player.sendMessage("First point is set");
  32. } else if (whichPoint == 3) {
  33. player.sendMessage("Second point is set");
  34. } else {
  35. player.sendMessage("Trigger point is set");
  36. }
  37. return true;
  38. } else if (itemInHand==318) {
  39. if(blockClicked.getType()!=6 &&
  40. blockClicked.getType()!=8 &&
  41. blockClicked.getType()!=9 &&
  42. blockClicked.getType()!=10 &&
  43. blockClicked.getType()!=11 &&
  44. blockClicked.getType()!=12 &&
  45. blockClicked.getType()!=13 &&
  46. blockClicked.getType()!=14 &&
  47. blockClicked.getType()!=15 &&
  48. blockClicked.getType()!=16 &&
  49. blockClicked.getType()!=19 &&
  50. blockClicked.getType()!=37 &&
  51. blockClicked.getType()!=38 &&
  52. blockClicked.getType()!=39 &&
  53. blockClicked.getType()!=40 &&
  54. blockClicked.getType()!=41 &&
  55. blockClicked.getType()!=42 &&
  56. blockClicked.getType()!=45 &&
  57. blockClicked.getType()!=48 &&
  58. blockClicked.getType()!=50 &&
  59. blockClicked.getType()!=52 &&
  60. blockClicked.getType()!=55 &&
  61. blockClicked.getType()!=56 &&
  62. blockClicked.getType()!=57 &&
  63. blockClicked.getType()!=59 &&
  64. blockClicked.getType()!=63 &&
  65. blockClicked.getType()!=68 &&
  66. blockClicked.getType()!=69 &&
  67. blockClicked.getType()!=70 &&
  68. blockClicked.getType()!=71 &&
  69. blockClicked.getType()!=72 &&
  70. blockClicked.getType()!=73 &&
  71. blockClicked.getType()!=74 &&
  72. blockClicked.getType()!=75 &&
  73. blockClicked.getType()!=76 &&
  74. blockClicked.getType()!=77 &&
  75. blockClicked.getType()!=79 &&
  76. blockClicked.getType()!=81 &&
  77. blockClicked.getType()!=82 &&
  78. blockClicked.getType()!=83 &&
  79. blockClicked.getType()!=85) {
  80. boolean worked = SpleefData.trytoResetArena(player,blockClicked);
  81. if(worked) {
  82. player.sendMessage("Arena reset");
  83. } else {
  84. }
  85. } else {
  86. player.sendMessage("Disallowed Item type: Either for profit or lag");
  87. }
  88. return true;
  89. }
  90. return false;
  91. }
  92. public boolean onCommand(Player player, String[] split) {
  93. if (!player.canUseCommand(split[0])) {
  94. return false;
  95. }
  96. if (split[0].equalsIgnoreCase("/saveSpleef")) {
  97. if (split.length == 4) {
  98. SpleefData.addSpleefBlocks(player.getName(),Integer.parseInt(split[1]),Integer.parseInt(split[2]),split[3]);
  99. player.sendMessage("Spleef Saved");
  100. }
  101. return true;
  102. } else if (split[0].equalsIgnoreCase("/listSpleefs")) {
  103. SpleefData.listthespleefs(player);
  104. return true;
  105. } else if (split[0].equalsIgnoreCase("/removeSpleef")) {
  106. boolean worked = false;
  107. if (split.length>1) {
  108. worked = SpleefData.removeSpleef(split[1]);
  109. }
  110. if( worked ) {
  111. player.sendMessage("Spleef removed");
  112. } else {
  113. player.sendMessage("Failed to remove spleef");
  114. }
  115. return true;
  116. } else {
  117. return false;
  118. }
  119. }
  120. }
  121. }