示例#1
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);
  }
示例#2
0
  @Override
  public void use(VPlayer vplayer, Player player) {
    Conf conf = Conf.get(player);
    vplayer.msg("");
    vplayer.msg(this.desc);

    if (!VPerm.ALTAR_LIGHT.has(player, true)) return;

    if (!vplayer.isVampire() && playerHoldsWaterBottle(player)) {
      if (!ResourceUtil.playerRemoveAttempt(
          player,
          conf.holyWaterResources,
          Lang.altarLightWaterResourceSuccess,
          Lang.altarLightWaterResourceFail)) return;
      ResourceUtil.playerAdd(player, HolyWaterUtil.createItemStack());
      vplayer.msg(Lang.altarLightWaterResult);
      vplayer.runFxEnderBurst();
      return;
    }

    vplayer.msg(Lang.altarLightCommon);
    vplayer.runFxEnder();

    if (vplayer.isVampire()) {
      if (!ResourceUtil.playerRemoveAttempt(
          player, this.resources, Lang.altarResourceSuccess, Lang.altarResourceFail)) return;
      vplayer.msg(Lang.altarLightVampire);
      player.getWorld().strikeLightningEffect(player.getLocation().add(0, 3, 0));
      vplayer.runFxEnderBurst();
      vplayer.setVampire(false);
      return;
    } else if (vplayer.isHealthy()) {
      vplayer.msg(Lang.altarLightHealthy);
    } else if (vplayer.isInfected()) {
      vplayer.msg(Lang.altarLightInfected);
      vplayer.setInfection(0);
      vplayer.runFxEnderBurst();
    }
  }