Advertisement
Guest User

54654

a guest
Jul 29th, 2015
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. package ru.ShaKe.AGP;
  2.  
  3. import org.bukkit.ChatColor;
  4. import org.bukkit.Material;
  5. import org.bukkit.entity.Player;
  6. import org.bukkit.event.EventHandler;
  7. import org.bukkit.event.Listener;
  8. import org.bukkit.event.block.Action;
  9. import org.bukkit.event.block.BlockBreakEvent;
  10. import org.bukkit.event.player.PlayerInteractEvent;
  11.  
  12. public class AdvancedGriefProtectionListener implements Listener {
  13.  
  14. Core plugin;
  15.  
  16. public AdvancedGriefProtectionListener(Core instance) {
  17. plugin = instance;
  18. }
  19.  
  20. @EventHandler
  21. public void onPlayerInteract(PlayerInteractEvent event) {
  22. Player player = event.getPlayer();
  23. if (event.getAction() == Action.LEFT_CLICK_BLOCK
  24. && player.getPlayer().getItemInHand().getType() == Material.STICK) {
  25. try {
  26. plugin.l1 = event.getClickedBlock().getLocation();
  27. plugin.m.sendMessege(player,
  28. "Позиция 1: " + plugin.m.showBlockCoords(plugin.l1));
  29. event.setCancelled(true);
  30. } catch (Exception e) {
  31. plugin.m.sendMessege(player,
  32. "Plugin Failed To Create Waypoint!");
  33. plugin.m.sendConcole("Plugin Failed To Create Waypoint!");
  34. }
  35. }
  36. if (event.getAction() == Action.RIGHT_CLICK_BLOCK
  37. && player.getItemInHand().getType() == Material.STICK) {
  38. try {
  39. plugin.l2 = event.getClickedBlock().getLocation();
  40. plugin.m.sendMessege(player,
  41. "Позиция 2: " + plugin.m.showBlockCoords(plugin.l2));
  42. event.setCancelled(true);
  43. } catch (Exception e) {
  44. plugin.m.sendMessege(player,
  45. "Plugin Failed To Create Waypoint!");
  46. plugin.m.sendConcole("Plugin Failed To Create Waypoint!");
  47. }
  48. }
  49. if (plugin.protectedBlocks.contains(event.getClickedBlock().getLocation())) {
  50. player.sendMessage(ChatColor.GOLD + "Территория запривачена!");
  51. event.setCancelled(true);
  52. }
  53. }
  54.  
  55. @EventHandler
  56. public void onBlockBreak(BlockBreakEvent event) {
  57. if (plugin.protectedBlocks.contains(event.getBlock())) {
  58. event.setCancelled(true);
  59. }
  60.  
  61. }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement