SaberLLC / Saber-Factions

The Ultimate Factions Plugin
GNU General Public License v3.0
124 stars 101 forks source link

Bug request - onFarmLandDamage event detects change of state of other blocks #249

Open AntoD3v opened 1 year ago

AntoD3v commented 1 year ago

Describe the bug The onFarmLandDamage event detects the change of state when stepping on a redstone mineral in an enemy claim. They consider that you're breaking a crop when you're just stepping on redstone, and spam the player with a message.

To Reproduce Steps to reproduce the behavior:

  1. Player A claim zone and set redstone ore
  2. Player B (not in Player A faction) walk on redstone ore

Expected behavior The event should only be called for crops and not other block state changes such as redstone.

Screenshots We see the messages in French and in the background, the redstone blocks. image

./lang.yml: NOPERMISSION: '&6Faction &7▸ &cVous ne pouvez pas {action} dans la faction {faction}.' ./lang.yml: OTHER: '&6Faction &7▸ &cErreur: Vous ne pouvez pas faire ceci.'

Server Version (please complete the following information):

Patch code In com.massivecraft.factions.listeners.FactionsBlockListener.java (Tested and work !) ` @EventHandler public void onFarmLandDamage(EntityChangeBlockEvent event) {

   /* PATCH */
    if (event.getBlock().getType().equals(Material.REDSTONE_ORE)) return;
   /* END */

    if (event.getEntity() instanceof Player) {
        Player player = (Player) event.getEntity();
        if (!playerCanBuildDestroyBlock(player, event.getBlock().getLocation(), "destroy", true)) {
            FPlayer me = FPlayers.getInstance().getByPlayer(player);
            Faction otherFaction = Board.getInstance().getFactionAt(FLocation.wrap(event.getBlock().getLocation()));
            me.msg(TL.ACTION_DENIED_OTHER, otherFaction.getTag(), "trample crops");
            event.setCancelled(true);
        }
    }
}

`

Antoine