Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2015
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.13 KB | None | 0 0
  1.     // TODO this doesn't work
  2.     @Listener(order = Order.FIRST)
  3.     public void onMonster(final DamageEntityEvent event) {
  4.         final Optional<Monster> monster = event.getCause().first(Monster.class);
  5.         if (monster.isPresent()) {
  6.             final Entity entity = event.getTargetEntity();
  7.             final Location<World> location = entity.getLocation();
  8.             if (entity instanceof Player) {
  9.                 if (!checkZonePermission(Zone.PERM_MONSTER_PLAYER_DAMAGE, location)) {
  10.                     event.setDamage(DamageModifierBuilder.builder().build(), (d) -> {
  11.                         log.info("setting damage to 0");
  12.                         return -d;
  13.                     });
  14.                 }
  15.             } else if (entity instanceof Animal || entity instanceof Villager) {
  16.                 if (!checkZonePermission(Zone.PERM_MONSTER_PASSIVE_DAMAGE, location)) {
  17.                     event.setDamage(DamageModifierBuilder.builder().build(), (d) -> {
  18.                         log.info("setting damage to 0");
  19.                         return -d;
  20.                     });
  21.                 }
  22.             }
  23.         }
  24.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement