Search in sources :

Example 1 with McMMOPlayerAbilityData

use of com.griefdefender.hooks.provider.mcmmo.McMMOPlayerAbilityData in project GDHooks by bloodmc.

the class McMMOProvider method onPlayerAbilityActivate.

@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPlayerAbilityActivate(McMMOPlayerAbilityActivateEvent 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.getAbility().name().toLowerCase().replace(" ", "_");
    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(), ABILITY_ACTIVATE, player, ability, contexts, null, true);
    if (result == Tristate.FALSE) {
        event.setCancelled(true);
    }
    this.playerAbilityMap.put(player.getUniqueId(), new McMMOPlayerAbilityData(player.getUniqueId(), event.getAbility(), event.getSkill(), event.getSkillLevel(), contexts));
}
Also used : Context(com.griefdefender.api.permission.Context) Player(org.bukkit.entity.Player) McMMOPlayer(com.gmail.nossr50.datatypes.player.McMMOPlayer) McMMOPlayerAbilityData(com.griefdefender.hooks.provider.mcmmo.McMMOPlayerAbilityData) 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)

Aggregations

McMMOPlayer (com.gmail.nossr50.datatypes.player.McMMOPlayer)1 Tristate (com.griefdefender.api.Tristate)1 Claim (com.griefdefender.api.claim.Claim)1 PlayerData (com.griefdefender.api.data.PlayerData)1 Context (com.griefdefender.api.permission.Context)1 McMMOPlayerAbilityData (com.griefdefender.hooks.provider.mcmmo.McMMOPlayerAbilityData)1 HashSet (java.util.HashSet)1 Location (org.bukkit.Location)1 World (org.bukkit.World)1 Player (org.bukkit.entity.Player)1 EventHandler (org.bukkit.event.EventHandler)1