Search in sources :

Example 1 with WorldGuardHook

use of me.staartvin.plugins.pluginlibrary.hooks.WorldGuardHook in project Statz by Staartvin.

the class DisableManager method isStatDisabledLocation.

/**
 * Is a stat disabled in a certain location?
 *
 * @param loc  Location to check
 * @param stat Stat to check
 * @return true if it is disabled on this location, false otherwise.
 */
public boolean isStatDisabledLocation(Location loc, PlayerStat stat) {
    // We cannot check if PluginLibrary is not available.
    if (!plugin.getDependencyManager().isAvailable(StatzDependency.PLUGINLIBRARY)) {
        return false;
    }
    LibraryHook worldGuardHook = plugin.getDependencyManager().getLibraryHook(Library.WORLDGUARD);
    // Only check for WG regions if WorldGuard is installed
    if (worldGuardHook != null && worldGuardHook.isAvailable()) {
        List<String> disabledRegions = this.getDisabledWorldGuardRegions(stat);
        WorldGuardHook wgHook = (WorldGuardHook) plugin.getDependencyManager().getLibraryHook(Library.WORLDGUARD);
        // Check for all disabled regions if a player is in them.
        if (!disabledRegions.isEmpty()) {
            for (String regionName : disabledRegions) {
                if (wgHook.isInRegion(loc, regionName)) {
                    return true;
                }
            }
        }
    }
    LibraryHook griefPreventionHook = plugin.getDependencyManager().getLibraryHook(Library.GRIEFPREVENTION);
    // Check GriefPrevention claims
    if (griefPreventionHook != null && griefPreventionHook.isAvailable()) {
        List<String> disabledUUIDs = this.getDisabledGriefPreventionClaims(stat);
        GriefPreventionHook gpHook = (GriefPreventionHook) plugin.getDependencyManager().getLibraryHook(Library.GRIEFPREVENTION);
        // Check for all disabled uuid claims if a player is in them.
        if (!disabledUUIDs.isEmpty()) {
            for (String disabledClaim : disabledUUIDs) {
                if (gpHook.isInRegion(loc, UUID.fromString(disabledClaim))) {
                    return true;
                }
            }
        }
    }
    return false;
}
Also used : LibraryHook(me.staartvin.plugins.pluginlibrary.hooks.LibraryHook) WorldGuardHook(me.staartvin.plugins.pluginlibrary.hooks.WorldGuardHook) GriefPreventionHook(me.staartvin.plugins.pluginlibrary.hooks.GriefPreventionHook)

Aggregations

GriefPreventionHook (me.staartvin.plugins.pluginlibrary.hooks.GriefPreventionHook)1 LibraryHook (me.staartvin.plugins.pluginlibrary.hooks.LibraryHook)1 WorldGuardHook (me.staartvin.plugins.pluginlibrary.hooks.WorldGuardHook)1