PreciousStones

PreciousStones

269k Downloads

Question on api

batkins62 opened this issue ยท 2 comments

commented

In my plugin i referenced pstone protection regions by creating a method canBuild(Player player, Block block) then i want to (in the method) return true if player can build at block in a pstone region.

looking through your plugin i dont see any method that can help me, i skimmed through forcefieldmanager fairly thoroughly and didnt see anything that returns boolean for player and block... though, maybe i missed it, any suggestions?

commented
/**
     * If the block is ps protected
     *
     * @param block
     * @return
     */
    private boolean canBuild(Player player, Block block)
    {
        if (ps != null)
        {
            Field field= ps.getForceFieldManager().getEnabledSourceField(block.getLocation(), FieldFlag.PREVENT_DESTROY);

            if (field != null)
            {
                boolean allowed = ps.getForceFieldManager().isApplyToAllowed(field, player.getName());

                if (!allowed || field.hasFlag(FieldFlag.APPLY_TO_ALL))
                {
                     return false;
                }
            }
        }

        return true;
    }
commented

Use FieldFlag.PREVENT_PLACE to detect if players are allowed to place blocks, FieldFlag.PREVENT_DESTROY to see if they are allowed to destroy block.