Search in sources :

Example 11 with Clan

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

the class CommandClanTrustAllAdmin method execute.

@CommandCompletion("@gdclans @gdtrusttypes @gddummy")
@CommandAlias("clantrustalladmin")
@Description("%clan-trust-all-admin")
@Syntax("<clan> [<accessor|builder|container|manager|resident>]")
@Subcommand("clan trustalladmin")
public void execute(Player player, String clanTag, @Optional String type, @Optional String identifier) {
    TrustType trustType = null;
    final Audience audience = GriefDefender.getAudienceProvider().getSender(player);
    if (type == null) {
        trustType = TrustTypes.BUILDER;
    } else {
        trustType = HooksUtil.getTrustType(type);
        if (trustType == null) {
            audience.sendMessage(MessageConfig.MESSAGE_DATA.getMessage(MessageConfig.TRUST_INVALID));
            return;
        }
    }
    final Clan clan = GDHooks.getInstance().getClanProvider().getClan(clanTag);
    if (clan == null) {
        audience.sendMessage(MessageConfig.MESSAGE_DATA.getMessage(MessageConfig.COMMAND_INVALID_CLAN, ImmutableMap.of("clan", clanTag)));
        return;
    }
    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;
    }
    Set<Claim> claimList = new HashSet<>();
    final ClaimManager claimManager = GriefDefender.getCore().getClaimManager(player.getWorld().getUID());
    for (Claim claim : claimManager.getWorldClaims()) {
        if (claim.isAdminClaim()) {
            claimList.add(claim);
        }
    }
    if (claimList == null || claimList.size() == 0) {
        audience.sendMessage(MessageConfig.MESSAGE_DATA.getMessage(MessageConfig.TRUST_NO_CLAIMS));
        return;
    }
    GriefDefender.getEventManager().getCauseStackManager().pushCause(player);
    GDClanTrustClaimEvent.Add event = new GDClanTrustClaimEvent.Add(new ArrayList<>(claimList), ImmutableSet.of(clan), trustType);
    GriefDefender.getEventManager().post(event);
    GriefDefender.getEventManager().getCauseStackManager().popCause();
    if (event.cancelled()) {
        audience.sendMessage(event.getMessage().orElse(MessageConfig.MESSAGE_DATA.getMessage(MessageConfig.TRUST_PLUGIN_CANCEL, ImmutableMap.of("target", clan.getTag()))));
        return;
    }
    for (Claim claim : claimList) {
        if (trustType == TrustTypes.RESIDENT && !claim.isAdminClaim() && !claim.isTown()) {
            continue;
        }
        claim.addClanTrust(clan, trustType);
    }
    final Component message = MessageConfig.MESSAGE_DATA.getMessage(MessageConfig.TRUST_INDIVIDUAL_ALL_CLAIMS, ImmutableMap.of("player", clan.getTag()));
    audience.sendMessage(message);
}
Also used : Audience(com.griefdefender.lib.kyori.adventure.audience.Audience) GDClanTrustClaimEvent(com.griefdefender.hooks.event.GDClanTrustClaimEvent) TrustType(com.griefdefender.api.claim.TrustType) CommandResult(com.griefdefender.api.CommandResult) ClaimManager(com.griefdefender.api.claim.ClaimManager) Clan(com.griefdefender.api.Clan) Component(com.griefdefender.lib.kyori.adventure.text.Component) Claim(com.griefdefender.api.claim.Claim) HashSet(java.util.HashSet) 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 12 with Clan

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

the class CommandClanTrustAll method execute.

@CommandCompletion("@gdclans @gdtrusttypes @gddummy")
@CommandAlias("clantrustall")
@Description("%clan-trust-all")
@Syntax("<clan> [<accessor|builder|container|manager|resident>]")
@Subcommand("clan trustall")
public void execute(Player player, String clanTag, @Optional String type, @Optional String identifier) {
    TrustType trustType = null;
    final Audience audience = GriefDefender.getAudienceProvider().getSender(player);
    if (type == null) {
        trustType = TrustTypes.BUILDER;
    } else {
        trustType = HooksUtil.getTrustType(type);
        if (trustType == null) {
            audience.sendMessage(MessageConfig.MESSAGE_DATA.getMessage(MessageConfig.TRUST_INVALID));
            return;
        }
    }
    final Clan clan = GDHooks.getInstance().getClanProvider().getClan(clanTag);
    if (clan == null) {
        audience.sendMessage(MessageConfig.MESSAGE_DATA.getMessage(MessageConfig.COMMAND_INVALID_CLAN, ImmutableMap.of("clan", clanTag)));
        return;
    }
    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;
    }
    PlayerData playerData = GriefDefender.getCore().getPlayerData(player.getWorld().getUID(), player.getUniqueId());
    Set<Claim> claimList = null;
    if (playerData != null) {
        claimList = playerData.getClaims();
    }
    if (playerData == null || claimList == null || claimList.size() == 0) {
        audience.sendMessage(MessageConfig.MESSAGE_DATA.getMessage(MessageConfig.TRUST_NO_CLAIMS));
        return;
    }
    GriefDefender.getEventManager().getCauseStackManager().pushCause(player);
    GDClanTrustClaimEvent.Add event = new GDClanTrustClaimEvent.Add(new ArrayList<>(claimList), ImmutableSet.of(clan), trustType);
    GriefDefender.getEventManager().post(event);
    GriefDefender.getEventManager().getCauseStackManager().popCause();
    if (event.cancelled()) {
        audience.sendMessage(event.getMessage().orElse(MessageConfig.MESSAGE_DATA.getMessage(MessageConfig.TRUST_PLUGIN_CANCEL, ImmutableMap.of("target", clan.getTag()))));
        return;
    }
    for (Claim claim : claimList) {
        if (trustType == TrustTypes.RESIDENT && !claim.isAdminClaim() && !claim.isTown()) {
            continue;
        }
        claim.addClanTrust(clan, trustType);
    }
    final Component message = MessageConfig.MESSAGE_DATA.getMessage(MessageConfig.TRUST_INDIVIDUAL_ALL_CLAIMS, ImmutableMap.of("player", clan.getTag()));
    audience.sendMessage(message);
}
Also used : Audience(com.griefdefender.lib.kyori.adventure.audience.Audience) Clan(com.griefdefender.api.Clan) GDClanTrustClaimEvent(com.griefdefender.hooks.event.GDClanTrustClaimEvent) TrustType(com.griefdefender.api.claim.TrustType) Component(com.griefdefender.lib.kyori.adventure.text.Component) PlayerData(com.griefdefender.api.data.PlayerData) 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 13 with Clan

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

the class TownyProvider method getClanPlayers.

@Override
public List<ClanPlayer> getClanPlayers(String tag) {
    final String townName = getTownFriendlyName(tag);
    final Clan clan = this.getClan(townName);
    if (clan == null) {
        return Collections.emptyList();
    }
    return clan.getMembers();
}
Also used : Clan(com.griefdefender.api.Clan)

Example 14 with Clan

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

the class GDClan method getAllies.

@Override
public List<Clan> getAllies() {
    List<Clan> clans = new ArrayList<>();
    for (UUID guildUniqueId : this.pluginClan.getAllies()) {
        final Guild ally = Guilds.getApi().getGuild(guildUniqueId);
        final Clan clan = GDHooks.getInstance().getClanProvider().getClan(ally.getPrefix());
        if (clan != null) {
            clans.add(clan);
        }
    }
    return clans;
}
Also used : Clan(com.griefdefender.api.Clan) ArrayList(java.util.ArrayList) UUID(java.util.UUID) Guild(me.glaremasters.guilds.guild.Guild)

Aggregations

Clan (com.griefdefender.api.Clan)14 CommandAlias (co.aikar.commands.annotation.CommandAlias)9 CommandCompletion (co.aikar.commands.annotation.CommandCompletion)9 Description (co.aikar.commands.annotation.Description)9 Subcommand (co.aikar.commands.annotation.Subcommand)9 Syntax (co.aikar.commands.annotation.Syntax)9 Audience (com.griefdefender.lib.kyori.adventure.audience.Audience)9 Component (com.griefdefender.lib.kyori.adventure.text.Component)9 TrustType (com.griefdefender.api.claim.TrustType)8 CommandResult (com.griefdefender.api.CommandResult)7 Claim (com.griefdefender.api.claim.Claim)7 GDClanTrustClaimEvent (com.griefdefender.hooks.event.GDClanTrustClaimEvent)4 ClanPlayer (com.griefdefender.api.ClanPlayer)3 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)3 UUID (java.util.UUID)3 ClaimManager (com.griefdefender.api.claim.ClaimManager)2 ClaimResult (com.griefdefender.api.claim.ClaimResult)2 PlayerData (com.griefdefender.api.data.PlayerData)2 ClanConfig (com.griefdefender.hooks.config.ClanConfig)2