Search in sources :

Example 1 with ClanPlayer

use of com.griefdefender.api.ClanPlayer 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)

Example 2 with ClanPlayer

use of com.griefdefender.api.ClanPlayer in project GDHooks by bloodmc.

the class CommandClanClaim method execute.

@CommandCompletion("@gdidentifiers")
@CommandAlias("clanclaim")
@Description("%clan-claim")
@Syntax("[identifier]")
@Subcommand("clan claim")
public void execute(Player player, @Optional String identifier) {
    final ClanPlayer clanPlayer = GDHooks.getInstance().getClanProvider().getClanPlayer(player.getUniqueId());
    if (clanPlayer == null) {
        return;
    }
    final Clan clan = clanPlayer.getClan();
    if (clan == null) {
        return;
    }
    if (!clanPlayer.isLeader()) {
        return;
    }
    final Audience audience = GriefDefender.getAudienceProvider().getSender(player);
    final CommandResult result = GriefDefender.getCore().canUseCommand(player, TrustTypes.MANAGER, identifier);
    if (!result.successful()) {
        if (result.getClaim() != null) {
            final Component message = MessageConfig.MESSAGE_DATA.getMessage(MessageConfig.PERMISSION_TRUST, ImmutableMap.of("owner", result.getClaim().getOwnerDisplayName()));
            audience.sendMessage(message);
        } else {
            audience.sendMessage(MessageConfig.MESSAGE_DATA.getMessage(MessageConfig.PERMISSION_COMMAND_TRUST));
        }
        return;
    }
    final Claim claim = result.getClaim();
    if (claim.hasAttribute(GDHooksAttributes.ATTRIBUTE_CLAN)) {
        claim.removeAttribute(GDHooksAttributes.ATTRIBUTE_CLAN);
        audience.sendMessage(Component.text("Removed clan attribute."));
    } else {
        claim.addAttribute(GDHooksAttributes.ATTRIBUTE_CLAN);
        audience.sendMessage(Component.text("Added clan attribute."));
    }
}
Also used : Audience(com.griefdefender.lib.kyori.adventure.audience.Audience) Clan(com.griefdefender.api.Clan) Component(com.griefdefender.lib.kyori.adventure.text.Component) ClanPlayer(com.griefdefender.api.ClanPlayer) Claim(com.griefdefender.api.claim.Claim) CommandResult(com.griefdefender.api.CommandResult) Description(co.aikar.commands.annotation.Description) Subcommand(co.aikar.commands.annotation.Subcommand) CommandCompletion(co.aikar.commands.annotation.CommandCompletion) Syntax(co.aikar.commands.annotation.Syntax) CommandAlias(co.aikar.commands.annotation.CommandAlias)

Example 3 with ClanPlayer

use of com.griefdefender.api.ClanPlayer in project GDHooks by bloodmc.

the class CommandClanTrustRank method execute.

@CommandCompletion("@gdclanranks @gdtrusttypes @gddummy")
@CommandAlias("clantrustrank")
@Description("%clan-trust-rank")
@Syntax("<rank> <accessor|builder|container|manager|resident>")
@Subcommand("clan trust rank")
public void execute(Player player, String rank, String type) {
    final Audience audience = GriefDefender.getAudienceProvider().getSender(player);
    TrustType trustType = HooksUtil.getTrustType(type);
    if (trustType == null) {
        audience.sendMessage(MessageConfig.MESSAGE_DATA.getMessage(MessageConfig.TRUST_INVALID));
        return;
    }
    final ClanPlayer clanPlayer = GDHooks.getInstance().getClanProvider().getClanPlayer(player.getUniqueId());
    if (clanPlayer == null) {
        return;
    }
    final Clan clan = clanPlayer.getClan();
    if (clan == null) {
        return;
    }
    if (!clanPlayer.isLeader()) {
        return;
    }
    final ClanConfig clanConfig = GDHooks.getInstance().getClanConfigMap().get(clan.getTag());
    if (clanConfig == null) {
        return;
    }
    clanConfig.getData().addRankTrust(rank, trustType);
    clanConfig.save();
    final Component message = MessageConfig.MESSAGE_DATA.getMessage(MessageConfig.CLAN_TRUST_RANK, ImmutableMap.of("rank", rank, "type", trustType.getName()));
    audience.sendMessage(message);
}
Also used : ClanConfig(com.griefdefender.hooks.config.ClanConfig) Audience(com.griefdefender.lib.kyori.adventure.audience.Audience) Clan(com.griefdefender.api.Clan) TrustType(com.griefdefender.api.claim.TrustType) Component(com.griefdefender.lib.kyori.adventure.text.Component) ClanPlayer(com.griefdefender.api.ClanPlayer) Description(co.aikar.commands.annotation.Description) Subcommand(co.aikar.commands.annotation.Subcommand) CommandCompletion(co.aikar.commands.annotation.CommandCompletion) Syntax(co.aikar.commands.annotation.Syntax) CommandAlias(co.aikar.commands.annotation.CommandAlias)

Example 4 with ClanPlayer

use of com.griefdefender.api.ClanPlayer in project GDHooks by bloodmc.

the class CommandClanUntrustRank method execute.

@CommandCompletion("@gdclanranks @gdtrusttypes @gddummy")
@CommandAlias("clanuntrustrank")
@Description("%clan-untrust-rank")
@Syntax("<rank>")
@Subcommand("clan untrust rank")
public void execute(Player player, String rank) {
    final Audience audience = GriefDefender.getAudienceProvider().getSender(player);
    final ClanPlayer clanPlayer = GDHooks.getInstance().getClanProvider().getClanPlayer(player.getUniqueId());
    if (clanPlayer == null) {
        return;
    }
    final Clan clan = clanPlayer.getClan();
    if (clan == null) {
        return;
    }
    if (!clanPlayer.isLeader()) {
        return;
    }
    final ClanConfig clanConfig = GDHooks.getInstance().getClanConfigMap().get(clan.getTag());
    if (clanConfig == null) {
        return;
    }
    final TrustType trustType = clanConfig.getData().getRankTrust(rank);
    clanConfig.getData().deleteRankTrust(rank);
    clanConfig.save();
    final Component message = MessageConfig.MESSAGE_DATA.getMessage(MessageConfig.CLAN_UNTRUST_RANK, ImmutableMap.of("rank", rank, "type", trustType.getName()));
    audience.sendMessage(message);
}
Also used : ClanConfig(com.griefdefender.hooks.config.ClanConfig) Audience(com.griefdefender.lib.kyori.adventure.audience.Audience) Clan(com.griefdefender.api.Clan) TrustType(com.griefdefender.api.claim.TrustType) Component(com.griefdefender.lib.kyori.adventure.text.Component) ClanPlayer(com.griefdefender.api.ClanPlayer) Description(co.aikar.commands.annotation.Description) Subcommand(co.aikar.commands.annotation.Subcommand) CommandCompletion(co.aikar.commands.annotation.CommandCompletion) Syntax(co.aikar.commands.annotation.Syntax) CommandAlias(co.aikar.commands.annotation.CommandAlias)

Example 5 with ClanPlayer

use of com.griefdefender.api.ClanPlayer in project GDHooks by bloodmc.

the class UClansEventHandler method onPlayerRankUpdate.

@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPlayerRankUpdate(ClanGlobalEvent event) {
    if (ClanEvents.PLAYERPROMOTE != event.getEvent()) {
        return;
    }
    final Player player = Bukkit.getPlayer(event.getSender());
    if (player == null) {
        return;
    }
    final World world = player.getWorld();
    if (!GriefDefender.getCore().isEnabled(world.getUID())) {
        return;
    }
    final ClanPlayer clanPlayer = GDHooks.getInstance().getClanProvider().getClanPlayer(player.getUniqueId());
    if (clanPlayer == null) {
    }
}
Also used : ClanPlayer(com.griefdefender.api.ClanPlayer) Player(org.bukkit.entity.Player) GDClanPlayer(com.griefdefender.hooks.provider.clan.uclans.GDClanPlayer) World(org.bukkit.World) ClanPlayer(com.griefdefender.api.ClanPlayer) GDClanPlayer(com.griefdefender.hooks.provider.clan.uclans.GDClanPlayer) EventHandler(org.bukkit.event.EventHandler)

Aggregations

ClanPlayer (com.griefdefender.api.ClanPlayer)9 ArrayList (java.util.ArrayList)4 CommandAlias (co.aikar.commands.annotation.CommandAlias)3 CommandCompletion (co.aikar.commands.annotation.CommandCompletion)3 Description (co.aikar.commands.annotation.Description)3 Subcommand (co.aikar.commands.annotation.Subcommand)3 Syntax (co.aikar.commands.annotation.Syntax)3 Clan (com.griefdefender.api.Clan)3 Audience (com.griefdefender.lib.kyori.adventure.audience.Audience)3 Component (com.griefdefender.lib.kyori.adventure.text.Component)3 Claim (com.griefdefender.api.claim.Claim)2 TrustType (com.griefdefender.api.claim.TrustType)2 ClanConfig (com.griefdefender.hooks.config.ClanConfig)2 Player (org.bukkit.entity.Player)2 EventHandler (org.bukkit.event.EventHandler)2 CommandResult (com.griefdefender.api.CommandResult)1 ClanProvider (com.griefdefender.api.provider.ClanProvider)1 GDClanPlayer (com.griefdefender.hooks.provider.clan.uclans.GDClanPlayer)1 UUID (java.util.UUID)1 GuildMember (me.glaremasters.guilds.guild.GuildMember)1