Example #1
0
  @EventHandler(priority = EventPriority.NORMAL)
  public void onPlayerAnimation(PlayerAnimationEvent event) {
    VPlayer vplayer = VPlayers.i.get(event.getPlayer());
    if (!vplayer.isVampire()) return;

    if (event.getAnimationType() == PlayerAnimationType.ARM_SWING
        && Conf.jumpMaterials.contains(event.getPlayer().getItemInHand().getType())) {
      vplayer.jump(Conf.jumpDeltaSpeed, true);
    }
  }
Example #2
0
  @SuppressWarnings("deprecation")
  @EventHandler(priority = EventPriority.NORMAL)
  public void onPlayerInteract(PlayerInteractEvent event) {
    Action action = event.getAction();
    if (!(action == Action.RIGHT_CLICK_AIR || action == Action.RIGHT_CLICK_BLOCK)) return;

    Player player = event.getPlayer();
    VPlayer vplayer = VPlayers.i.get(player);
    Material itemMaterial = event.getMaterial();

    if (vplayer.isVampire()) {

      if (Conf.foodMaterials.contains(itemMaterial) && !Conf.vampireCanEat(itemMaterial)) {
        vplayer.msg(Lang.vampiresCantEatThat, Txt.getMaterialName(itemMaterial));
        event.setCancelled(true);
      }

      if (action == Action.RIGHT_CLICK_BLOCK
          && event.getClickedBlock().getType() == Material.CAKE_BLOCK
          && Conf.vampireCanEat(Material.CAKE_BLOCK)) {
        vplayer.msg(Lang.vampiresCantEatThat, Txt.getMaterialName(Material.CAKE));
        event.setCancelled(true);
      }

      if (Conf.jumpMaterials.contains(event.getMaterial())) {
        vplayer.jump(Conf.jumpDeltaSpeed, false);
      }
    }

    if (vplayer.isInfected() && itemMaterial == Material.BREAD) {
      vplayer.infectionHeal(Conf.infectionBreadHealAmount);
      player.getInventory().removeItem(new ItemStack(Material.BREAD, 1));
      player.updateInventory();
      event.setCancelled(true);
    }

    if (action != Action.RIGHT_CLICK_BLOCK) return;
    Conf.altarEvil.evalBlockUse(event.getClickedBlock(), player);
    Conf.altarGood.evalBlockUse(event.getClickedBlock(), player);
  }