Search in sources :

Example 1 with ClanProvider

use of com.griefdefender.api.provider.ClanProvider in project Bookshelf by LOOHP.

the class GriefDefenderEvents method onLandCheck.

@EventHandler(priority = EventPriority.LOWEST)
public void onLandCheck(PlayerOpenBookshelfEvent event) {
    if (!Bookshelf.griefDefenderHook) {
        return;
    }
    Player player = event.getPlayer();
    Claim claim = GriefDefender.getCore().getClaimAt(event.getLocation());
    ClanProvider clanProvider = GriefDefender.getCore().getClanProvider();
    ClanPlayer clanPlayer = null;
    if (clanProvider != null) {
        clanPlayer = clanProvider.getClanPlayer(player.getUniqueId());
    }
    if (claim == null || claim.isWilderness()) {
        return;
    }
    if (!claim.getOwnerUniqueId().equals(player.getUniqueId()) && !claim.isUserTrusted(player.getUniqueId(), TrustTypes.CONTAINER) && (clanPlayer == null || !claim.isClanTrusted(clanPlayer.getClan(), TrustTypes.CONTAINER))) {
        event.setCancelled(true);
    }
}
Also used : ClanPlayer(com.griefdefender.api.ClanPlayer) Player(org.bukkit.entity.Player) ClanProvider(com.griefdefender.api.provider.ClanProvider) ClanPlayer(com.griefdefender.api.ClanPlayer) Claim(com.griefdefender.api.claim.Claim) EventHandler(org.bukkit.event.EventHandler)

Aggregations

ClanPlayer (com.griefdefender.api.ClanPlayer)1 Claim (com.griefdefender.api.claim.Claim)1 ClanProvider (com.griefdefender.api.provider.ClanProvider)1 Player (org.bukkit.entity.Player)1 EventHandler (org.bukkit.event.EventHandler)1