use of com.iridium.iridiumskyblock.database.IslandTrusted in project IridiumSkyblock by Iridium-Development.
the class EntityDamageListener method handlePlayerDamage.
private void handlePlayerDamage(EntityDamageEvent event, Island island) {
Configuration.IslandDamageSettings pvpSettings = IridiumSkyblock.getInstance().getConfiguration().pvpSettings;
Player player = (Player) event.getEntity();
User user = IridiumSkyblock.getInstance().getUserManager().getUser(player);
Optional<IslandTrusted> trusted = IridiumSkyblock.getInstance().getIslandManager().getIslandTrusted(island, user);
boolean isMember = island.equals(user.getIsland().orElse(null)) || trusted.isPresent();
List<EntityDamageEvent.DamageCause> preventCauses = isMember ? pvpSettings.membersPreventedDamages : pvpSettings.visitorsPreventedDamages;
if (preventCauses.contains(event.getCause())) {
event.setCancelled(true);
}
}
Aggregations