Search in sources :

Example 6 with Context

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

the class McMMOProvider method onPlayerSkillEvent.

public boolean onPlayerSkillEvent(McMMOPlayerSkillEvent event, Object target, Set<Context> contexts) {
    final Player player = event.getPlayer();
    final World world = player.getWorld();
    if (!GriefDefender.getCore().isEnabled(world.getUID())) {
        return true;
    }
    final Location location = player.getLocation();
    final PlayerData playerData = GriefDefender.getCore().getPlayerData(world.getUID(), player.getUniqueId());
    final Claim claim = GriefDefender.getCore().getClaimAt(location);
    final String skillType = event.getSkill().name().toLowerCase().replace(" ", "_");
    contexts.add(new Context("mcmmo:skill_level", String.valueOf(event.getSkillLevel())));
    contexts.add(new Context("mcmmo:skill_type", skillType));
    final Tristate result = GriefDefender.getPermissionManager().getActiveFlagPermissionValue(event, location, claim, playerData.getUser(), SKILL_USE, player, target, contexts, null, true);
    if (result == Tristate.FALSE) {
        return false;
    }
    return true;
}
Also used : Context(com.griefdefender.api.permission.Context) Player(org.bukkit.entity.Player) McMMOPlayer(com.gmail.nossr50.datatypes.player.McMMOPlayer) 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)

Example 7 with Context

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

the class McMMOProvider method onPlayerXpGain.

@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPlayerXpGain(McMMOPlayerXpGainEvent event) {
    final String skillType = event.getSkill().name().toLowerCase().replace(" ", "_");
    final String reason = event.getXpGainReason().name().toLowerCase();
    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:skill_level", String.valueOf(event.getSkillLevel())));
    contexts.add(new Context("mcmmo:skill_type", skillType));
    contexts.add(new Context("mcmmo:reason", reason));
    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), MCMMO_XP_GAIN_MODIFIER, playerData.getUser(), claim, contexts);
    if (xpGained != null && xpGained != 1.0) {
        event.setRawXpGained(event.getRawXpGained() * xpGained.floatValue());
    }
}
Also used : Context(com.griefdefender.api.permission.Context) Player(org.bukkit.entity.Player) McMMOPlayer(com.gmail.nossr50.datatypes.player.McMMOPlayer) 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 8 with Context

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

the class McMMOProvider method onPlayerDisarmEvent.

@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPlayerDisarmEvent(McMMOPlayerDisarmEvent event) {
    final Player player = event.getPlayer();
    final World world = player.getWorld();
    if (!GriefDefender.getCore().isEnabled(world.getUID())) {
        return;
    }
    final Player targetPlayer = event.getDefender();
    final Location location = targetPlayer.getLocation();
    final PlayerData playerData = GriefDefender.getCore().getPlayerData(world.getUID(), player.getUniqueId());
    final Claim claim = GriefDefender.getCore().getClaimAt(location);
    final String skillType = event.getSkill().name().toLowerCase().replace(" ", "_");
    final Set<Context> contexts = new HashSet<>();
    contexts.add(new Context("mcmmo:skill_level", String.valueOf(event.getSkillLevel())));
    contexts.add(new Context("mcmmo:skill_type", skillType));
    final Tristate result = GriefDefender.getPermissionManager().getActiveFlagPermissionValue(event, location, claim, playerData.getUser(), PLAYER_DISARM, player, targetPlayer, contexts, null, true);
    if (result == Tristate.FALSE) {
        event.setCancelled(true);
    }
}
Also used : Context(com.griefdefender.api.permission.Context) Player(org.bukkit.entity.Player) McMMOPlayer(com.gmail.nossr50.datatypes.player.McMMOPlayer) 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 9 with Context

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

the class McMMOProvider method onAlchemyCatalysisEvent.

@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onAlchemyCatalysisEvent(McMMOPlayerCatalysisEvent 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:speed", String.valueOf(event.getSpeed())));
    if (!onPlayerSkillEvent(event, "catalysis", 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 10 with Context

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

the class McMMOProvider method onRuptureDamageEvent.

@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onRuptureDamageEvent(McMMOEntityDamageByRuptureEvent event) {
    final McMMOPlayer mcmmoPlayer = event.getMcMMODamager();
    final Player player = mcmmoPlayer.getPlayer();
    final World world = player.getWorld();
    if (!GriefDefender.getCore().isEnabled(world.getUID())) {
        return;
    }
    final Entity targetEntity = event.getEntity();
    final Location location = targetEntity.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("mcmmo:damage_amount", String.valueOf(event.getFinalDamage())));
    final Tristate result = GriefDefender.getPermissionManager().getActiveFlagPermissionValue(event, location, claim, playerData.getUser(), RUPTURE_DAMAGE, player, targetEntity, contexts, null, true);
    if (result == Tristate.FALSE) {
        event.setCancelled(true);
    }
}
Also used : Context(com.griefdefender.api.permission.Context) Entity(org.bukkit.entity.Entity) Player(org.bukkit.entity.Player) McMMOPlayer(com.gmail.nossr50.datatypes.player.McMMOPlayer) Tristate(com.griefdefender.api.Tristate) McMMOPlayer(com.gmail.nossr50.datatypes.player.McMMOPlayer) 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)

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