Added support for claim plugins.

This commit is contained in:
Brianna 2019-10-14 20:17:52 -04:00
parent a2a0de7445
commit e8e6463e89

View File

@ -7,11 +7,14 @@ import com.songoda.core.utils.ItemUtils;
import com.songoda.epicanchors.EpicAnchors; import com.songoda.epicanchors.EpicAnchors;
import com.songoda.epicanchors.anchor.Anchor; import com.songoda.epicanchors.anchor.Anchor;
import com.songoda.epicanchors.gui.GUIOverview; import com.songoda.epicanchors.gui.GUIOverview;
import org.bukkit.Bukkit;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.block.Action; import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -23,7 +26,7 @@ public class InteractListeners implements Listener {
this.instance = instance; this.instance = instance;
} }
@EventHandler(ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockInteract(PlayerInteractEvent event) { public void onBlockInteract(PlayerInteractEvent event) {
if (event.getClickedBlock() == null) return; if (event.getClickedBlock() == null) return;
@ -32,12 +35,18 @@ public class InteractListeners implements Listener {
if (anchor == null) return; if (anchor == null) return;
event.setCancelled(true); event.setCancelled(true);
Player player = event.getPlayer();
if (event.getAction() != Action.RIGHT_CLICK_BLOCK) { if (event.getAction() != Action.RIGHT_CLICK_BLOCK) {
BlockBreakEvent blockBreakEvent = new BlockBreakEvent(event.getClickedBlock(), player);
Bukkit.getPluginManager().callEvent(blockBreakEvent);
if (blockBreakEvent.isCancelled())
return;
anchor.bust(); anchor.bust();
return; return;
} }
Player player = event.getPlayer();
ItemStack item = player.getItemInHand(); ItemStack item = player.getItemInHand();
if (instance.getCoreConfig().getMaterial("Main.Anchor Block Material", CompatibleMaterial.AIR).matches(item)) { if (instance.getCoreConfig().getMaterial("Main.Anchor Block Material", CompatibleMaterial.AIR).matches(item)) {