• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java WorldEvent类的典型用法和代码示例

java 1次浏览

本文整理汇总了Java中org.bukkit.event.world.WorldEvent的典型用法代码示例。如果您正苦于以下问题:Java WorldEvent类的具体用法?Java WorldEvent怎么用?Java WorldEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

WorldEvent类属于org.bukkit.event.world包,在下文中一共展示了WorldEvent类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: evaluate

点赞 2

import org.bukkit.event.world.WorldEvent; //导入依赖的package包/类
@Override
public Boolean evaluate(Event event) {
  if (!(event instanceof EntityDamageEvent)) {
    switch (cause) {
      /* Actor Type */
      case WORLD:
        return event instanceof WorldEvent;
      case LIVING:
        return event instanceof EntityEvent && ((EntityEvent) event).getEntity() instanceof LivingEntity;
      case MOB:
        return event instanceof EntityEvent && ((EntityEvent) event).getEntity() instanceof Creature;
      case PLAYER:
        return event instanceof PlayerEvent;
      /* Block action */
      case PUNCH:
        return event instanceof BlockDamageEvent;
      case TRAMPLE:
        return event instanceof PlayerMoveEvent;
      case MINE:
        return event instanceof BlockBreakEvent;

      case EXPLOSION:
        return event instanceof EntityExplodeEvent;

      default:
        return null;
    }
  } else {
    /* Damage Type */
    EntityDamageEvent.DamageCause damageCause = ((EntityDamageEvent) event).getCause();
    switch (cause) {
      case MELEE:
        return damageCause.equals(EntityDamageEvent.DamageCause.ENTITY_ATTACK);
      case PROJECTILE:
        return damageCause.equals(EntityDamageEvent.DamageCause.PROJECTILE);
      case POTION:
        return damageCause.equals(EntityDamageEvent.DamageCause.MAGIC)
            || damageCause.equals(EntityDamageEvent.DamageCause.POISON)
            || damageCause.equals(EntityDamageEvent.DamageCause.WITHER)
            || damageCause.equals(EntityDamageEvent.DamageCause.DRAGON_BREATH);
      case EXPLOSION:
        return damageCause.equals(EntityDamageEvent.DamageCause.BLOCK_EXPLOSION)
            || damageCause.equals(EntityDamageEvent.DamageCause.ENTITY_EXPLOSION);
      case COMBUSTION:
        return damageCause.equals(EntityDamageEvent.DamageCause.FIRE)
            || damageCause.equals(EntityDamageEvent.DamageCause.FIRE_TICK)
            || damageCause.equals(EntityDamageEvent.DamageCause.MELTING)
            || damageCause.equals(EntityDamageEvent.DamageCause.LAVA)
            || damageCause.equals(EntityDamageEvent.DamageCause.HOT_FLOOR);
      case FALL:
        return damageCause.equals(EntityDamageEvent.DamageCause.FALL);
      case GRAVITY:
        return damageCause.equals(EntityDamageEvent.DamageCause.FALL)
            || damageCause.equals(EntityDamageEvent.DamageCause.VOID);
      case VOID:
        return damageCause.equals(EntityDamageEvent.DamageCause.VOID);
      case SQUASH:
        return damageCause.equals(EntityDamageEvent.DamageCause.FALLING_BLOCK);
      case SUFFOCATION:
        return damageCause.equals(EntityDamageEvent.DamageCause.SUFFOCATION);
      case DROWNING:
        return damageCause.equals(EntityDamageEvent.DamageCause.DROWNING);
      case STARVATION:
        return damageCause.equals(EntityDamageEvent.DamageCause.STARVATION);
      case LIGHTNING:
        return damageCause.equals(EntityDamageEvent.DamageCause.LIGHTNING);
      case CACTUS:
        return damageCause.equals(EntityDamageEvent.DamageCause.CONTACT);
      case THORNS:
        return damageCause.equals(EntityDamageEvent.DamageCause.THORNS);

      default:
        return null;
    }
  }
}
 

开发者ID:CardinalDevelopment,
项目名称:Cardinal,
代码行数:77,
代码来源:CauseFilter.java

示例2: evaluate

点赞 2

import org.bukkit.event.world.WorldEvent; //导入依赖的package包/类
private Boolean evaluate(Event event) {
    if (!(event instanceof EntityDamageEvent)) {
        switch (cause) {
            case WORLD:
                return event instanceof WorldEvent;
            case LIVING:
                return event instanceof EntityEvent && ((EntityEvent) event).getEntity() instanceof LivingEntity;
            case MOB:
                return event instanceof EntityEvent && ((EntityEvent) event).getEntity() instanceof Creature;
            case PLAYER:
                return event instanceof PlayerEvent || event instanceof BlockPlaceEvent || event instanceof BlockBreakEvent;

            case PUNCH:
                return event instanceof PlayerInteractEvent
                        && ((PlayerInteractEvent) event).getAction().equals(Action.LEFT_CLICK_BLOCK);
            case TRAMPLE:
                return event instanceof PlayerMoveEvent;
            case MINE:
                return event instanceof BlockBreakEvent;

            case EXPLOSION:
                return event instanceof EntityExplodeEvent;
        }
    } else {
        EntityDamageEvent.DamageCause damageCause = ((EntityDamageEvent) event).getCause();
        switch (cause) {
            case MELEE:
                return damageCause.equals(EntityDamageEvent.DamageCause.ENTITY_ATTACK);
            case PROJECTILE:
                return damageCause.equals(EntityDamageEvent.DamageCause.PROJECTILE);
            case POTION:
                return damageCause.equals(EntityDamageEvent.DamageCause.MAGIC)
                        || damageCause.equals(EntityDamageEvent.DamageCause.POISON)
                        || damageCause.equals(EntityDamageEvent.DamageCause.WITHER)
                        || damageCause.equals(EntityDamageEvent.DamageCause.DRAGON_BREATH);
            case EXPLOSION:
                return damageCause.equals(EntityDamageEvent.DamageCause.BLOCK_EXPLOSION)
                        || damageCause.equals(EntityDamageEvent.DamageCause.ENTITY_EXPLOSION);
            case COMBUSTION:
                return damageCause.equals(EntityDamageEvent.DamageCause.FIRE)
                        || damageCause.equals(EntityDamageEvent.DamageCause.FIRE_TICK)
                        || damageCause.equals(EntityDamageEvent.DamageCause.MELTING)
                        || damageCause.equals(EntityDamageEvent.DamageCause.LAVA)
                        || damageCause.equals(EntityDamageEvent.DamageCause.HOT_FLOOR);
            case FALL:
                return damageCause.equals(EntityDamageEvent.DamageCause.FALL);
            case GRAVITY:
                return damageCause.equals(EntityDamageEvent.DamageCause.FALL)
                        || damageCause.equals(EntityDamageEvent.DamageCause.VOID);
            case VOID:
                return damageCause.equals(EntityDamageEvent.DamageCause.VOID);
            case SQUASH:
                return damageCause.equals(EntityDamageEvent.DamageCause.FALLING_BLOCK);
            case SUFFOCATION:
                return damageCause.equals(EntityDamageEvent.DamageCause.SUFFOCATION);
            case DROWNING:
                return damageCause.equals(EntityDamageEvent.DamageCause.DROWNING);
            case STARVATION:
                return damageCause.equals(EntityDamageEvent.DamageCause.STARVATION);
            case LIGHTNING:
                return damageCause.equals(EntityDamageEvent.DamageCause.LIGHTNING);
            case CACTUS:
                return damageCause.equals(EntityDamageEvent.DamageCause.CONTACT);
            case THORNS:
                return damageCause.equals(EntityDamageEvent.DamageCause.THORNS);
        }
    }
    return null;
}
 

开发者ID:twizmwazin,
项目名称:CardinalPGM,
代码行数:70,
代码来源:CauseFilter.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)