Search in sources :

Example 11 with Context

use of com.griefdefender.api.permission.Context in project GDHooks by bloodmc.

the class McMMOProvider method onRepairCheckEvent.

@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onRepairCheckEvent(McMMOPlayerRepairCheckEvent event) {
    final Player player = event.getPlayer();
    final World world = player.getWorld();
    if (!GriefDefender.getCore().isEnabled(world.getUID())) {
        return;
    }
    final Set<Context> contexts = new HashSet<>();
    contexts.add(new Context("mcmmo:repair_amount", String.valueOf(event.getRepairAmount())));
    final String repairMaterialId = GriefDefender.getRegistry().lookupId(event.getRepairMaterial());
    if (repairMaterialId != null) {
        contexts.add(new Context("mcmmo:repair_material", repairMaterialId));
    }
    final String repairObjectId = GriefDefender.getRegistry().lookupId(event.getRepairedObject());
    if (repairObjectId != null) {
        contexts.add(new Context("mcmmo:repair_object", repairObjectId));
    }
    if (!onPlayerSkillEvent(event, "repair", contexts)) {
        event.setCancelled(true);
    }
}
Also used : Context(com.griefdefender.api.permission.Context) Player(org.bukkit.entity.Player) McMMOPlayer(com.gmail.nossr50.datatypes.player.McMMOPlayer) World(org.bukkit.World) HashSet(java.util.HashSet) EventHandler(org.bukkit.event.EventHandler)

Example 12 with Context

use of com.griefdefender.api.permission.Context in project GDHooks by bloodmc.

the class McMMOProvider method onAlchemyBrewEvent.

@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onAlchemyBrewEvent(McMMOPlayerBrewEvent event) {
    final Player player = event.getPlayer();
    final World world = player.getWorld();
    if (!GriefDefender.getCore().isEnabled(world.getUID())) {
        return;
    }
    final Set<Context> contexts = new HashSet<>();
    final String brewingBlockId = GriefDefender.getRegistry().lookupId(event.getBrewingStandBlock());
    if (brewingBlockId != null) {
        contexts.add(new Context("mcmmo:brewing_block", brewingBlockId));
    }
    final String brewingIngredientId = GriefDefender.getRegistry().lookupId(event.getBrewingStand().getInventory().getIngredient());
    if (brewingIngredientId != null) {
        contexts.add(new Context("mcmmo:brewing_ingredient", brewingIngredientId));
    }
    if (!onPlayerSkillEvent(event, "brewing", new HashSet<>())) {
        event.setCancelled(true);
    }
}
Also used : Context(com.griefdefender.api.permission.Context) Player(org.bukkit.entity.Player) McMMOPlayer(com.gmail.nossr50.datatypes.player.McMMOPlayer) World(org.bukkit.World) HashSet(java.util.HashSet) EventHandler(org.bukkit.event.EventHandler)

Example 13 with Context

use of com.griefdefender.api.permission.Context in project CombatLogX by SirBlobman.

the class GriefDefenderRegionHandler method isSafeZone.

@Override
public boolean isSafeZone(Player player, Location location, TagType tagType) {
    if (tagType != TagType.PLAYER) {
        return false;
    }
    Claim claim = getClaimAt(location);
    if (claim == null) {
        return false;
    }
    UUID playerId = player.getUniqueId();
    Core core = GriefDefender.getCore();
    User user = core.getUser(playerId);
    Set<Context> contexts = new HashSet<>();
    TypeToken<Tristate> typeTokenTristate = TypeToken.get(Tristate.class);
    Tristate activeOptionValue = claim.getActiveOptionValue(typeTokenTristate, Options.PVP, user, contexts);
    return (activeOptionValue != Tristate.TRUE);
}
Also used : Context(com.griefdefender.api.permission.Context) User(com.griefdefender.api.User) Tristate(com.griefdefender.api.Tristate) UUID(java.util.UUID) Claim(com.griefdefender.api.claim.Claim) Core(com.griefdefender.api.Core) HashSet(java.util.HashSet)

Example 14 with Context

use of com.griefdefender.api.permission.Context in project GDHooks by bloodmc.

the class AureliumSkillsProvider method onPlayerAbilityActivate.

@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPlayerAbilityActivate(ManaAbilityActivateEvent event) {
    final Player player = event.getPlayer();
    final World world = player.getWorld();
    if (!GriefDefender.getCore().isEnabled(world.getUID())) {
        return;
    }
    final Location location = player.getLocation();
    final PlayerData playerData = GriefDefender.getCore().getPlayerData(world.getUID(), player.getUniqueId());
    final Claim claim = GriefDefender.getCore().getClaimAt(location);
    final String ability = event.getManaAbility().name().toLowerCase().replace(" ", "_");
    final Set<Context> contexts = new HashSet<>();
    contexts.add(new Context("aureliumskills:skill_type", event.getManaAbility().getSkill().name().toLowerCase()));
    contexts.add(new Context("aureliumskills:skill_level", String.valueOf(AureliumAPI.getSkillLevel(player, event.getManaAbility().getSkill()))));
    final com.archyx.aureliumskills.data.PlayerData aureliumPlayerData = this.plugin.getPlayerManager().getPlayerData(player);
    if (aureliumPlayerData != null) {
        contexts.add(new Context("aureliumskills:power_level", String.valueOf(aureliumPlayerData.getPowerLevel())));
    }
    final Tristate result = GriefDefender.getPermissionManager().getActiveFlagPermissionValue(event, location, claim, playerData.getUser(), ABILITY_ACTIVATE, player, ability, contexts, null, true);
    if (result == Tristate.FALSE) {
        event.setCancelled(true);
    }
}
Also used : Context(com.griefdefender.api.permission.Context) Player(org.bukkit.entity.Player) Tristate(com.griefdefender.api.Tristate) World(org.bukkit.World) PlayerData(com.griefdefender.api.data.PlayerData) Claim(com.griefdefender.api.claim.Claim) Location(org.bukkit.Location) HashSet(java.util.HashSet) EventHandler(org.bukkit.event.EventHandler)

Example 15 with Context

use of com.griefdefender.api.permission.Context in project GDHooks by bloodmc.

the class EliteMobsProvider method getEliteMobContexts.

public Set<Context> getEliteMobContexts(Entity entity, EliteMobEntity eliteMobEntity) {
    if (eliteMobEntity == null) {
        eliteMobEntity = EntityTracker.getEliteMobEntity(entity);
        if (eliteMobEntity == null) {
            return Collections.emptySet();
        }
    }
    final Set<Context> contexts = new HashSet<>();
    contexts.add(ContextGroups.TARGET_ELITEMOBS);
    contexts.add(new Context("elitemobs_level", String.valueOf(eliteMobEntity.getLevel())));
    contexts.add(new Context("elitemobs_has_special_loot", String.valueOf(eliteMobEntity.getHasSpecialLoot())));
    contexts.add(new Context("regional_boss", String.valueOf(eliteMobEntity.isRegionalBoss())));
    // add powers
    for (ElitePower power : eliteMobEntity.getPowers()) {
        contexts.add(new Context("elitemobs_power", power.getName().toLowerCase()));
    }
    if (eliteMobEntity.customBossEntity != null) {
        contexts.add(new Context("elitemobs_type", eliteMobEntity.customBossEntity.customBossConfigFields.getFileName().replace(".yml", "").toLowerCase()));
        if (eliteMobEntity.customBossEntity.customBossMount != null) {
            contexts.add(new Context("elitemobs_mount", eliteMobEntity.customBossEntity.customBossMount.customBossConfigFields.getFileName().replace(".yml", "").toLowerCase()));
        }
    } else {
        contexts.add(ELITE_TYPE);
    }
    return contexts;
}
Also used : Context(com.griefdefender.api.permission.Context) HashSet(java.util.HashSet) ElitePower(com.magmaguy.elitemobs.powers.ElitePower)

Aggregations

Context (com.griefdefender.api.permission.Context)18 HashSet (java.util.HashSet)16 World (org.bukkit.World)16 Player (org.bukkit.entity.Player)15 EventHandler (org.bukkit.event.EventHandler)15 Claim (com.griefdefender.api.claim.Claim)13 Tristate (com.griefdefender.api.Tristate)11 PlayerData (com.griefdefender.api.data.PlayerData)11 Location (org.bukkit.Location)11 McMMOPlayer (com.gmail.nossr50.datatypes.player.McMMOPlayer)9 Entity (org.bukkit.entity.Entity)3 Core (com.griefdefender.api.Core)1 User (com.griefdefender.api.User)1 ClaimManager (com.griefdefender.api.claim.ClaimManager)1 McMMOPlayerAbilityData (com.griefdefender.hooks.provider.mcmmo.McMMOPlayerAbilityData)1 EliteMobEntity (com.magmaguy.elitemobs.mobconstructor.EliteMobEntity)1 EliteMobProperties (com.magmaguy.elitemobs.mobconstructor.mobdata.aggressivemobs.EliteMobProperties)1 ElitePower (com.magmaguy.elitemobs.powers.ElitePower)1 UUID (java.util.UUID)1