Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-2694

BlockBreakEvent is not cancel properly

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • None
    • all event listener setting, Java 8, Minecraft 1.10.2

    • MyCustomPlugin

      here is my video https://youtu.be/ejPz-N3b-3U

      and here is my code

      public class BlockListener implements Listener {
          private ESIsland plugin;
      
          public BlockListener(ESIsland plugin) {
              this.plugin = plugin;
          }
      
          @EventHandler(priority = EventPriority.LOWEST)
          public void onBlockBreak(BlockBreakEvent event) {
              Location location = event.getBlock().getLocation();
              if (!location.getWorld().equals(Values.ISLAND_WORLD)) {
                  return;
              }
      
              Island island = plugin.getIslandManager().getIsland(location);
              if (island == null) {
                  event.setCancelled(true);
                  event.getPlayer().sendMessage("§cIsland protected");
                  return;
              }
      
              if (island.getValue(Island.Flag.ALLOW_BUILD).equals(Island.Value.PRIVATE)) {
                  if (!event.getPlayer().getUniqueId().equals(island.getOwner().getUniqueId())) {
                      event.setCancelled(true);
                      event.getPlayer().sendMessage("§cIsland protected");
                  }
              } else if (island.getValue(Island.Flag.ALLOW_BUILD).equals(Island.Value.FRIENDS)) {
                  if (!(event.getPlayer().getUniqueId().equals(island.getOwner().getUniqueId()) /* || check friends */)) {
                      event.setCancelled(true);
                      event.getPlayer().sendMessage("§cIsland protected");
                  }
              }
          }
      }
      

            Unassigned Unassigned
            horyu1234 horyu1234
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: