Advertisement
Guest User

Untitled

a guest
Aug 14th, 2015
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.87 KB | None | 0 0
  1. package me.jobisingh;
  2.  
  3. import java.util.HashMap;
  4. import java.util.HashSet;
  5.  
  6. import org.bukkit.ChatColor;
  7. import org.bukkit.Location;
  8. import org.bukkit.Material;
  9. import org.bukkit.block.Block;
  10. import org.bukkit.entity.Player;
  11. import org.bukkit.event.EventHandler;
  12. import org.bukkit.event.Listener;
  13. import org.bukkit.event.block.Action;
  14. import org.bukkit.event.block.BlockPlaceEvent;
  15. import org.bukkit.event.player.PlayerInteractEvent;
  16.  
  17. public class ListenerClass implements Listener {
  18.  
  19. MainClass configgetter;
  20.  
  21. public ListenerClass(MainClass plugin) {
  22. plugin.getServer().getPluginManager().registerEvents(this, plugin);
  23. configgetter = plugin;
  24. }
  25.  
  26. // @EventHandler
  27. // public void onEvent(BlockPlaceEvent e) {
  28. //
  29. // Player player = e.getPlayer();
  30. //
  31. // e.setCancelled(true);
  32. //
  33. // }
  34.  
  35. @EventHandler //you NEED to have @EventHandler before any event
  36. public void playerInteract(PlayerInteractEvent e){
  37. //this will be called automatically by bukkit whenever a player interacts
  38.  
  39. Player player = e.getPlayer();
  40. Material block = player.getTargetBlock((HashSet<Byte>)null, 100).getType();
  41. if(block.equals(Material.WALL_SIGN) || block.equals(Material.SIGN) || block.equals(Material.SIGN_POST)) {
  42.  
  43. if(e.getAction().equals(Action.RIGHT_CLICK_BLOCK)){
  44. //the player right-clicked a block
  45. Material m = e.getClickedBlock().getType(); //get the block type clicked
  46.  
  47. if(m.equals(Material.WALL_SIGN) || m.equals(Material.SIGN) || m.equals(Material.SIGN_POST)){
  48.  
  49. e.getPlayer().sendMessage("You Right Clicked A Sign!");
  50. Location location = e.getPlayer().getLocation();
  51. e.getPlayer().teleport((Location) configgetter.getConfig().get("LobbySpawn:"));
  52.  
  53. //the block clicked was stone.
  54. }
  55. else {
  56.  
  57. e.getPlayer().sendMessage("Error This is not suppose to execute");
  58.  
  59. }
  60. }
  61. }
  62. }
  63. static HashMap<String, Integer> pointGetter = new HashMap<>();
  64. static HashMap<String, Location> locationGetter = new HashMap<>();
  65. static HashMap<String, Integer> pointGetter2 = new HashMap<>();
  66. static HashMap<String, Location> locationGetter2 = new HashMap<>();
  67. @EventHandler
  68. public void onWandLeftClick(PlayerInteractEvent e) {
  69.  
  70. Player player = e.getPlayer();
  71.  
  72. if(player.getInventory().getItemInHand().getItemMeta().getDisplayName().equals(ChatColor.GREEN + "§lPositionWand")) {
  73.  
  74. Material block = player.getTargetBlock((HashSet<Byte>)null, 100).getType();
  75.  
  76.  
  77. if(e.getAction().equals(Action.LEFT_CLICK_BLOCK)) {
  78.  
  79. player.sendMessage("§1Server> §eSuccefully Set Point One!");
  80. int point1X = e.getClickedBlock().getLocation().getBlockX();
  81. int point1Y = e.getClickedBlock().getLocation().getBlockY();
  82. int point1Z = e.getClickedBlock().getLocation().getBlockZ();
  83. Location point1 = e.getClickedBlock().getLocation();
  84.  
  85. pointGetter.put("point1X", point1X);
  86. pointGetter.put("point1Y", point1Y);
  87. pointGetter.put("point1Z", point1Z);
  88. locationGetter.put("point1", point1);
  89.  
  90.  
  91.  
  92.  
  93. }
  94.  
  95. }
  96.  
  97. }
  98.  
  99.  
  100. @EventHandler
  101. public void onWandRightClick(PlayerInteractEvent e) {
  102.  
  103. Player player = e.getPlayer();
  104.  
  105. if(player.getInventory().getItemInHand().getItemMeta().getDisplayName().equals(ChatColor.GREEN + "§lPositionWand")) {
  106.  
  107. Material block = player.getTargetBlock((HashSet<Byte>)null, 100).getType();
  108.  
  109.  
  110. if(e.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
  111.  
  112.  
  113. player.sendMessage("§1Server> §eSuccefully Set Point Two!");
  114. int point2X = e.getClickedBlock().getLocation().getBlockX();
  115. int point2Y = e.getClickedBlock().getLocation().getBlockY();
  116. int point2Z = e.getClickedBlock().getLocation().getBlockZ();
  117. Location point2 = e.getClickedBlock().getLocation();
  118.  
  119.  
  120. pointGetter2.put("point2X", point2X);
  121. pointGetter2.put("point2Y", point2Y);
  122. pointGetter2.put("point2Z", point2Z);
  123. locationGetter2.put("point2", point2);
  124.  
  125. }
  126.  
  127. }
  128.  
  129. }
  130.  
  131. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement