Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // TODO this doesn't work
- @Listener(order = Order.FIRST)
- public void onMonster(final DamageEntityEvent event) {
- final Optional<Monster> monster = event.getCause().first(Monster.class);
- if (monster.isPresent()) {
- final Entity entity = event.getTargetEntity();
- final Location<World> location = entity.getLocation();
- if (entity instanceof Player) {
- if (!checkZonePermission(Zone.PERM_MONSTER_PLAYER_DAMAGE, location)) {
- event.setDamage(DamageModifierBuilder.builder().build(), (d) -> {
- log.info("setting damage to 0");
- return -d;
- });
- }
- } else if (entity instanceof Animal || entity instanceof Villager) {
- if (!checkZonePermission(Zone.PERM_MONSTER_PASSIVE_DAMAGE, location)) {
- event.setDamage(DamageModifierBuilder.builder().build(), (d) -> {
- log.info("setting damage to 0");
- return -d;
- });
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement