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