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