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