Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ru.ShaKe.AGP;
- import org.bukkit.ChatColor;
- import org.bukkit.Material;
- import org.bukkit.entity.Player;
- import org.bukkit.event.EventHandler;
- import org.bukkit.event.Listener;
- import org.bukkit.event.block.Action;
- import org.bukkit.event.block.BlockBreakEvent;
- import org.bukkit.event.player.PlayerInteractEvent;
- public class AdvancedGriefProtectionListener implements Listener {
- Core plugin;
- public AdvancedGriefProtectionListener(Core instance) {
- plugin = instance;
- }
- @EventHandler
- public void onPlayerInteract(PlayerInteractEvent event) {
- Player player = event.getPlayer();
- if (event.getAction() == Action.LEFT_CLICK_BLOCK
- && player.getPlayer().getItemInHand().getType() == Material.STICK) {
- try {
- plugin.l1 = event.getClickedBlock().getLocation();
- plugin.m.sendMessege(player,
- "Позиция 1: " + plugin.m.showBlockCoords(plugin.l1));
- event.setCancelled(true);
- } catch (Exception e) {
- plugin.m.sendMessege(player,
- "Plugin Failed To Create Waypoint!");
- plugin.m.sendConcole("Plugin Failed To Create Waypoint!");
- }
- }
- if (event.getAction() == Action.RIGHT_CLICK_BLOCK
- && player.getItemInHand().getType() == Material.STICK) {
- try {
- plugin.l2 = event.getClickedBlock().getLocation();
- plugin.m.sendMessege(player,
- "Позиция 2: " + plugin.m.showBlockCoords(plugin.l2));
- event.setCancelled(true);
- } catch (Exception e) {
- plugin.m.sendMessege(player,
- "Plugin Failed To Create Waypoint!");
- plugin.m.sendConcole("Plugin Failed To Create Waypoint!");
- }
- }
- if (plugin.protectedBlocks.contains(event.getClickedBlock().getLocation())) {
- player.sendMessage(ChatColor.GOLD + "Территория запривачена!");
- event.setCancelled(true);
- }
- }
- @EventHandler
- public void onBlockBreak(BlockBreakEvent event) {
- if (plugin.protectedBlocks.contains(event.getBlock())) {
- event.setCancelled(true);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement