Java源码示例:com.github.intellectualsites.plotsquared.plot.object.Plot

示例1
/**
 * Check if a flag is allowed for a player on a plot from PlotSquared
 * @param plot Plot from PlotSquared
 * @param flag Flag to check
 * @param p Player to check
 * @return Whether the flag is allowed for the player
 */
public static boolean isFlagAllowedOnPlot(Plot plot, GroupFlag flag, Player p) {
    if (plot != null && flag != null) {
        Group group = plot.getFlag(flag, Group.NONE);
        ShopChest.getInstance().debug("Flag " + flag.getName() + " is set to " + group);

        switch (group) {
            case OWNERS:
                return plot.getOwners().contains(p.getUniqueId());
            case TRUSTED:
                return plot.getOwners().contains(p.getUniqueId()) || plot.getTrusted().contains(p.getUniqueId());
            case MEMBERS:
                return plot.getOwners().contains(p.getUniqueId()) || plot.getTrusted().contains(p.getUniqueId()) || plot.getMembers().contains(p.getUniqueId());
            case EVERYONE:
                return true;
            case NONE:
                return false;
        }
    }

    ShopChest.getInstance().debug("Flag or plot is null, or value of flag is not a group");

    return true;
}