SavageLabs / SavageFactions

The Ultimate Competitve Factions Plugin. Switches focus from casual factions and introduces new features for competitive factions.
https://savagelabs.net
GNU General Public License v3.0
95 stars 63 forks source link

Water and Lava spill when Buld permission seted on deny #242

Closed Kichiro72 closed 4 years ago

Kichiro72 commented 4 years ago

The player can spill water and lava on the territory of the faction, even if the build permission is turned off

I asked the member without permission to build, pour water and lava on the lands of the fraction and it works

**Server VErsion 1.14.4

srleojaco commented 4 years ago

Confirm issue which is very important to fix asap @ProSavage

I will also said that actually is supposed to be using the "item" permission, but it is not working.

For fix, i would suggest using perms

build -> playerbucketemptyevent destroy -> playerbucketfillevent

or a complete different perm "bucket" (keep in mind that for already existing servers it should update factions.json....)

srleojaco commented 4 years ago

A video showing the issue (using a build provided by ProSavage which uses the perms as suggested before by me)

https://youtu.be/FQEYPBZto5M

srleojaco commented 4 years ago

@ProSavage

I fixed it by using api, but would be cool to have fixed on the plugin. What i did was

```

public boolean checkPermAtLoc(Location bloque, Player player, PermissableAction pa) {

    FLocation fLoc = new FLocation(bloque);     
    Faction factionland = Board.getInstance().getFactionAt(fLoc);   

           //to allow in wilderness
    if (factionland == Factions.getInstance().getFactionById("0"))
        return true;

    FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player);   

             //dont know why but leader has some problems with it, so i set this to prevent...
    if (factionland.getFPlayerLeader() == fPlayer)
        return true;

    Access resultado = factionland.getAccess(fPlayer, pa);

    if (resultado == Access.ALLOW)
        return true;
    /*else if (resultado == Access.DENY)
        return false;
    else if (resultado == Access.UNDEFINED)
        return false;*/
    else
        return false;

}

@EventHandler
public void quitarCubo(PlayerBucketFillEvent e) {
    if (e.isCancelled())
        return;

    Location bloque = e.getBlockClicked().getRelative(e.getBlockFace()).getLocation();

    if (!checkPermAtLoc(bloque, e.getPlayer(), PermissableAction.DESTROY)) {

        e.setCancelled(true);
        e.getPlayer().sendMessage("§3§lBUCKET §cYou can't destroy here");
    }

}

@EventHandler
public void colocarCubo(PlayerBucketEmptyEvent e) {
    if (e.isCancelled())
        return;

    Location bloque = e.getBlockClicked().getRelative(e.getBlockFace()).getLocation();

    if (!checkPermAtLoc(bloque, e.getPlayer(), PermissableAction.BUILD)) {

        e.setCancelled(true);
        e.getPlayer().sendMessage("§3§lBUCKET §cYou can't build here");

    }

}


@ProSavage 
Drc-DEV commented 4 years ago

Can't reproduce, can you share your conf.json?

srleojaco commented 4 years ago

@Drc-DEV I'll check for this later, but as said by me before, the issue happens on fresh server. Maybe it has been solved on newer builds.

Drc-DEV commented 4 years ago

Seems like it was finally fixed by using bucket fill/empty listeners instead of the interact check, because sometimes the latter was buggy/not detecting bucket usage.