Exemplo n.º 1
0
  /**
   * Apply the mining fatigue game mechanic
   *
   * <p>Players who mine stone below a certain depth increase their hunger
   *
   * @param player The player to act upon
   * @param blockY The Y coordinate of the mined block
   */
  public void doMiningFatigue(int blockY) {
    Double exhaustion = 0.0;

    if (blockY < UhcMatch.DIAMOND_LAYER) {
      exhaustion = this.player.getMatch().getConfig().getMiningFatigueDiamond();
    } else if (blockY < UhcMatch.GOLD_LAYER) {
      exhaustion = this.player.getMatch().getConfig().getMiningFatigueGold();
    }

    if (exhaustion > 0) {
      if (!miningFatigueAlerted) {
        sendMessage(
            ChatColor.GOLD + "Warning: mining at this depth will soon make you very hungry!");
        miningFatigueAlerted = true;
      }
      if (miningFatigueGrace > 0) {
        if (--miningFatigueGrace == 0)
          sendMessage(
              ChatColor.GOLD + "Warning: mining any more at this depth will make you very hungry!");
      } else {
        player.getPlayer().setExhaustion((float) (player.getPlayer().getExhaustion() + exhaustion));
        player
            .getPlayer()
            .addPotionEffect(new PotionEffect(PotionEffectType.SLOW_DIGGING, 1200, 0));
      }
    }
  }
Exemplo n.º 2
0
 public UhcParticipant(UhcPlayer pl, UhcTeam team) {
   this.player = pl;
   this.team = team;
   if (pl.isOnline()) {
     this.currentHealth = pl.getPlayer().getHealth();
     this.currentArmor = ArmorPoints.fromPlayerInventory(pl.getPlayer().getInventory());
   }
 }
Exemplo n.º 3
0
 public void doWorldEdgeWarning(Location borderPoint) {
   if (this.worldEdgeWarningSoundCountdown-- == 0) {
     player.getPlayer().playSound(borderPoint, Sound.NOTE_PIANO, 10, 1);
     this.worldEdgeWarningSoundCountdown = WORLD_EDGE_WARNING_SOUND_COUNTDOWN_LENGTH;
   }
   if (worldEdgeWarningActive) return;
   worldEdgeWarningActive = true;
   sendMessage("You are close to the edge of the world!");
   player
       .getPlayer()
       .addPotionEffect(new PotionEffect(PotionEffectType.SLOW, Integer.MAX_VALUE, 0));
 }
Exemplo n.º 4
0
 public void updateInventory() {
   for (UhcPlayer up : TesseractUHC.getInstance().getMatch().getOnlinePlayers()) {
     if (up.isSpectator()) updateSpectatorOnInventory(up.getPlayer());
   }
 }
Exemplo n.º 5
0
 public void clearWorldEdgeWarning() {
   if (!worldEdgeWarningActive) return;
   worldEdgeWarningActive = false;
   this.worldEdgeWarningSoundCountdown = 0;
   player.getPlayer().removePotionEffect(PotionEffectType.SLOW);
 }