/Stargate/src/Stargate.java

https://github.com/ricin/minecraft-hey0-plugins · Java · 84 lines · 68 code · 16 blank · 0 comment · 23 complexity · 6d66464513a824d40473f0ac2020857f 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 Stargate extends Plugin {
  6. private StargateListener listener = new StargateListener();
  7. static final Logger log = Logger.getLogger("Minecraft");
  8. public void enable() {
  9. log.info("[Stargate] Mod Enabled.");
  10. StargateData.loadStargateData();
  11. }
  12. public void disable() {
  13. log.info("[Stargate] Mod Disabled");
  14. }
  15. public void initialize() {
  16. etc.getLoader().addListener(PluginLoader.Hook.COMMAND, listener, this, PluginListener.Priority.MEDIUM);
  17. etc.getLoader().addListener(PluginLoader.Hook.BLOCK_CREATED, listener, this, PluginListener.Priority.MEDIUM);
  18. etc.getLoader().addListener(PluginLoader.Hook.PLAYER_MOVE, listener, this, PluginListener.Priority.MEDIUM);
  19. }
  20. public class StargateListener extends PluginListener
  21. {
  22. public boolean onBlockCreate(Player player, Block blockPlaced, Block blockClicked, int itemInHand){
  23. if ( (itemInHand==283) && player.canUseCommand("/saveStargate")){
  24. Integer whichPoint = StargateData.setPoint(player.getName(), blockClicked.getX(), blockClicked.getY(), blockClicked.getZ());
  25. if(whichPoint == 2) {
  26. player.sendMessage("First corner of teleport area set");
  27. } else if (whichPoint == 3) {
  28. player.sendMessage("Second corner of teleport area set");
  29. } else if (whichPoint == 4) {
  30. player.sendMessage("First corner of landing area set");
  31. } else {
  32. player.sendMessage("Second corner of landing area set");
  33. }
  34. return true;
  35. }
  36. return false;
  37. }
  38. public boolean onCommand(Player player, String[] split) {
  39. if (!player.canUseCommand(split[0])) {
  40. return false;
  41. }
  42. if (split[0].equalsIgnoreCase("/saveStargate")) {
  43. if (split.length == 4) {
  44. StargateData.Savestargate(player,split);
  45. }
  46. return true;
  47. } else if (split[0].equalsIgnoreCase("/listStargates")) {
  48. return true;
  49. } else if (split[0].equalsIgnoreCase("/removeStargate")) {
  50. boolean worked = false;
  51. if (split.length>1) {
  52. }
  53. if( worked ) {
  54. player.sendMessage("Stargate removed");
  55. } else {
  56. player.sendMessage("Failed to remove Stargate");
  57. }
  58. return true;
  59. } else {
  60. return false;
  61. }
  62. }
  63. public void onPlayerMove(Player player,Location from,Location to) {
  64. StargateData.Checkplayerpos(to,player);
  65. return;
  66. }
  67. }
  68. }