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);
}
}
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."));
}
}
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);
}
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);
}
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) {
}
}
Aggregations