Search in sources :

Example 1 with ClanConfig

use of com.griefdefender.hooks.config.ClanConfig 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 2 with ClanConfig

use of com.griefdefender.hooks.config.ClanConfig in project GDHooks by bloodmc.

the class GuildsClanProvider method addClan.

public void addClan(Guild clan) {
    this.getClanMap().put(clan.getPrefix(), new GDClan(clan));
    final Path clanConfigPath = CLAN_DATA_PATH.resolve(clan.getPrefix() + ".conf");
    if (!clanConfigPath.toFile().exists()) {
        final ClanConfig clanConfig = new ClanConfig(clanConfigPath);
        GDHooks.getInstance().getClanConfigMap().put(clan.getPrefix(), clanConfig);
    }
}
Also used : Path(java.nio.file.Path) ClanConfig(com.griefdefender.hooks.config.ClanConfig)

Example 3 with ClanConfig

use of com.griefdefender.hooks.config.ClanConfig 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 4 with ClanConfig

use of com.griefdefender.hooks.config.ClanConfig in project GDHooks by bloodmc.

the class SimpleClanProvider method addClan.

public void addClan(net.sacredlabyrinth.phaed.simpleclans.Clan clan) {
    this.clanMap.put(clan.getTag(), new GDClan(clan));
    final Path clanConfigPath = CLAN_DATA_PATH.resolve(clan.getTag() + ".conf");
    if (!clanConfigPath.toFile().exists()) {
        final ClanConfig clanConfig = new ClanConfig(clanConfigPath);
        GDHooks.getInstance().getClanConfigMap().put(clan.getTag(), clanConfig);
    }
}
Also used : Path(java.nio.file.Path) ClanConfig(com.griefdefender.hooks.config.ClanConfig)

Example 5 with ClanConfig

use of com.griefdefender.hooks.config.ClanConfig in project GDHooks by bloodmc.

the class UClansProvider method addClan.

public void addClan(me.ulrich.clans.data.ClanData clan) {
    this.getClanMap().put(clan.getTag(), new GDClan(clan));
    final Path clanConfigPath = CLAN_DATA_PATH.resolve(clan.getTag() + ".conf");
    if (!clanConfigPath.toFile().exists()) {
        final ClanConfig clanConfig = new ClanConfig(clanConfigPath);
        GDHooks.getInstance().getClanConfigMap().put(clan.getTag(), clanConfig);
    }
}
Also used : Path(java.nio.file.Path) ClanConfig(com.griefdefender.hooks.config.ClanConfig)

Aggregations

ClanConfig (com.griefdefender.hooks.config.ClanConfig)5 Path (java.nio.file.Path)3 CommandAlias (co.aikar.commands.annotation.CommandAlias)2 CommandCompletion (co.aikar.commands.annotation.CommandCompletion)2 Description (co.aikar.commands.annotation.Description)2 Subcommand (co.aikar.commands.annotation.Subcommand)2 Syntax (co.aikar.commands.annotation.Syntax)2 Clan (com.griefdefender.api.Clan)2 ClanPlayer (com.griefdefender.api.ClanPlayer)2 TrustType (com.griefdefender.api.claim.TrustType)2 Audience (com.griefdefender.lib.kyori.adventure.audience.Audience)2 Component (com.griefdefender.lib.kyori.adventure.text.Component)2