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