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 boolean start() {
   return (player.feed()
       && player.clearXP()
       && player.clearPotionEffects()
       && player.heal()
       && player.setGameMode(GameMode.SURVIVAL));
 }
Exemplo n.º 3
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.º 4
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.º 5
0
 public boolean isOutsideBorder(int border) {
   Location l = player.getLocation();
   return l.getBlockX() > border
       || l.getBlockZ() > border
       || l.getBlockX() < -border
       || l.getBlockZ() < -border;
 }
Exemplo n.º 6
0
  /**
   * Apply the hard stone game mechanic
   *
   * <p>Players who mine stone below a certain depth increase their hunger
   *
   * @param blockY The Y coordinate of the mined block
   * @param tool The tool that was used to mine the block
   */
  public void doHardStone(int blockY, ItemStack tool) {

    // Calculate applicable durability penalty

    short penalty;

    if (tool.getType() == Material.GOLD_PICKAXE) {
      penalty = UhcMatch.DURABILITY_PENALTY_GOLD;
    } else if (tool.getType() == Material.WOOD_PICKAXE) {
      penalty = UhcMatch.DURABILITY_PENALTY_WOOD;
    } else if (tool.getType() == Material.STONE_PICKAXE) {
      penalty = UhcMatch.DURABILITY_PENALTY_STONE;
    } else if (tool.getType() == Material.IRON_PICKAXE) {
      penalty = UhcMatch.DURABILITY_PENALTY_IRON;
    } else if (tool.getType() == Material.DIAMOND_PICKAXE) {
      penalty = UhcMatch.DURABILITY_PENALTY_DIAMOND;
    } else return;

    // Warn the player the first time

    if (!warnedHardStone) {
      player.sendMessage(
          ChatColor.GOLD
              + "Warning! Mining smoothstone will wear out your tools more quickly than in normal Minecraft.");
      warnedHardStone = true;
    }

    // Apply durability cost

    tool.setDurability((short) (tool.getDurability() + penalty));
  }
Exemplo n.º 7
0
 public String getName() {
   return player.getName();
 }
Exemplo n.º 8
0
 public void updateInventory() {
   for (UhcPlayer up : TesseractUHC.getInstance().getMatch().getOnlinePlayers()) {
     if (up.isSpectator()) updateSpectatorOnInventory(up.getPlayer());
   }
 }
Exemplo n.º 9
0
 public void clearWorldEdgeWarning() {
   if (!worldEdgeWarningActive) return;
   worldEdgeWarningActive = false;
   this.worldEdgeWarningSoundCountdown = 0;
   player.getPlayer().removePotionEffect(PotionEffectType.SLOW);
 }
Exemplo n.º 10
0
 /** @return whether the player has healed recently */
 public boolean isRecentlyHealed() {
   return (player.getMatch().getStartingWorld().getFullTime() - lastHealTime
       < UhcMatch.PLAYER_HEAL_ALERT_TICKS);
 }
Exemplo n.º 11
0
 /** Mark the player as having healed */
 public void setHealTimer() {
   lastHealTime = player.getMatch().getStartingWorld().getFullTime();
 }
Exemplo n.º 12
0
 /** @return whether the player has taken damage recently */
 public boolean isRecentlyDamaged() {
   return (player.getMatch().getStartingWorld().getFullTime() - lastDamageTime
       < UhcMatch.PLAYER_DAMAGE_ALERT_TICKS);
 }
Exemplo n.º 13
0
 public boolean sendMessage(String message) {
   return player.sendMessage(message);
 }
Exemplo n.º 14
0
 public boolean sendToStartPoint() {
   return (player.setGameMode(GameMode.ADVENTURE)
       && teleport(getStartPoint().getLocation())
       && player.renew());
 }
Exemplo n.º 15
0
 public boolean teleport(Location l, String message) {
   return player.teleport(l, message);
 }