Search in sources :

Example 1 with Context

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

the class AureliumSkillsProvider method onHealthRegen.

@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onHealthRegen(CustomRegenEvent 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 Set<Context> contexts = new HashSet<>();
    contexts.add(new Context("aureliumskills:regen_amount", String.valueOf(event.getAmount())));
    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(), HEALTH_REGEN, player, player, 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 2 with Context

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

the class AureliumSkillsProvider method onManaRegen.

@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onManaRegen(ManaRegenerateEvent 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 Set<Context> contexts = new HashSet<>();
    contexts.add(new Context("aureliumskills:mana_amount", String.valueOf(event.getAmount())));
    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(), MANA_REGEN, player, player, 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 3 with Context

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

the class AureliumSkillsProvider method onPlayerXpGain.

@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPlayerXpGain(XpGainEvent event) {
    final String skillType = event.getSkill().name().toLowerCase().replace(" ", "_");
    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("aureliumskills:mana_ability", String.valueOf(event.getSkill().getManaAbility().name().toLowerCase())));
    contexts.add(new Context("aureliumskills:skill_type", skillType));
    contexts.add(new Context("aureliumskills:skill_level", String.valueOf(AureliumAPI.getSkillLevel(player, event.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 Location location = player.getLocation();
    final PlayerData playerData = GriefDefender.getCore().getPlayerData(world.getUID(), player.getUniqueId());
    final Claim claim = GriefDefender.getCore().getClaimAt(location);
    final Double xpGained = GriefDefender.getPermissionManager().getActiveOptionValue(TypeToken.get(Double.class), XP_GAIN_MODIFIER, playerData.getUser(), claim, contexts);
    if (xpGained != null && xpGained != 1.0) {
        event.setAmount(event.getAmount() * xpGained.floatValue());
    }
}
Also used : Context(com.griefdefender.api.permission.Context) Player(org.bukkit.entity.Player) World(org.bukkit.World) PlayerData(com.griefdefender.api.data.PlayerData) Claim(com.griefdefender.api.claim.Claim) HashSet(java.util.HashSet) Location(org.bukkit.Location) EventHandler(org.bukkit.event.EventHandler)

Example 4 with Context

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

the class AureliumSkillsProvider method onLootDrop.

@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onLootDrop(PlayerLootDropEvent 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 Set<Context> contexts = new HashSet<>();
    contexts.add(new Context("aureliumskills:loot_drop_cause", String.valueOf(event.getCause().name().toLowerCase())));
    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(), LOOT_DROP, player, event.getItemStack(), contexts, TrustTypes.ACCESSOR, 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 5 with Context

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

the class McMMOProvider method onSalvageCheckEvent.

@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onSalvageCheckEvent(McMMOPlayerSalvageCheckEvent event) {
    final Player player = event.getPlayer();
    final World world = player.getWorld();
    if (!GriefDefender.getCore().isEnabled(world.getUID())) {
        return;
    }
    final Set<Context> contexts = new HashSet<>();
    GriefDefender.getPermissionManager().addItemEnchantmentContexts(event.getEnchantedBook(), contexts);
    final String salvageItemId = GriefDefender.getRegistry().lookupId(event.getSalvageItem());
    if (salvageItemId != null) {
    }
    contexts.add(new Context("mcmmo:salvage_item", salvageItemId));
    if (!onPlayerSkillEvent(event, "salvage", 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)

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