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

PlayerInteractEvent candle unlit

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: Minor Minor
    • None
    • None
    • version 3133-Spigot-66f9d3c-3fa79d3 (MC: 1.17)
    • Own one for protecting areas
    • Yes

      I've got a plugin that's supposed to protect players buildings and so on.

      Everything works fine by now except one thing: Candles cannot be LIT but UNLIT by untrusted players.

       

      My method(s) for deactivating this is/are this one:

      @EventHandler(priority = EventPriority.HIGHEST)
      public void candleLitUnlit(final PlayerInteractEvent event) {
          if(!event.hasBlock() || event.getClickedBlock() == null) return;
          if(event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.LEFT_CLICK_BLOCK) return;
      
          Block block = event.getClickedBlock();
          if(!this.districtsQuery.isLocationInsideDistrict(block.getLocation())) return;
          if(!block.getType().name().contains("CANDLE_")) return;
      
          final District district = this.districtsQuery.getDistrictLocationIsInside(block.getLocation());
          final Player player = event.getPlayer();
      
          if(this.districtsQuery.doesNotHaveAccessOnDistrict(player, district)) {
              Util.sendActionBar(player, Messages.get(Paths.DISTRICT_ACCESS));
              event.setCancelled(true);
          }
      }
      
      @EventHandler(priority = EventPriority.HIGHEST)
      public void candleLitUnlit(EntityBlockFormEvent event) {
       Block block = event.getBlock();
       if(!this.districtsQuery.isLocationInsideDistrict(block.getLocation())) return;
       if(!block.getType().name().contains("CANDLE_")) return;
      
       final District district = this.districtsQuery.getDistrictLocationIsInside(block.getLocation());
       if(!(event.getEntity() instanceof Player)) return;
       final Player player = (Player) event.getEntity();
      
       if(this.districtsQuery.doesNotHaveAccessOnDistrict(player, district)) {
       Util.sendActionBar(player, Messages.get(Paths.DISTRICT_ACCESS));
       event.setCancelled(true);
       }
      }
      

            Unassigned Unassigned
            CuzIm1Tigaaa Emil Feuerlein
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: