Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
AntoD3v opened this issue Jun 11, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@AntoD3v
Copy link
Contributor

AntoD3v commented Jun 11, 2023

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):

  • Spigot Version: Paperspigot 1.8.8
  • Factions Version: V4.0.1-RC
  • Minecraft Version: 1.8.9 Lunar Client

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

@AntoD3v AntoD3v added the bug Something isn't working label Jun 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant