Examples of Health


Examples of org.spout.vanilla.component.entity.misc.Health

  }

  @Override
  public void onCollided(EntityCollideEvent event) {
    if (event instanceof EntityCollideEntityEvent) {
      Health health = ((EntityCollideEntityEvent) event).getCollided().get(Health.class);
      if (health != null) {
        health.damage(0);
      }
    }
    spawnChickens(new Point(event.getContactInfo().getNormal(), getOwner().getWorld()));
    getOwner().remove();
  }
View Full Code Here

Examples of org.spout.vanilla.component.entity.misc.Health

   * @param collidedPoint The point where the material was collided with the entity
   * @param block The block this entity collided with
   */
  public void onCollided(Point colliderPoint, Point collidedPoint, Block block) {
    if (getShooter() != null && getShooter() instanceof Player) {
      Health health = getShooter().get(Health.class);
      if (health != null && !health.isDead()) {
        if (!PlayerUtil.isCreativePlayer(getShooter())) {
          health.damage(5);
        }
        ((Player) getShooter()).getPhysics().setPosition(block.translate(BlockFace.TOP).getPosition());
      }
    }
    getOwner().remove();
View Full Code Here

Examples of org.spout.vanilla.component.entity.misc.Health

  @Override
  public void onCollided(EntityCollideEvent event) {
    if (event instanceof EntityCollideEntityEvent) {
      Point point = ((EntityCollideEntityEvent) event).getCollided().getPhysics().getPosition();
      Health health = ((EntityCollideEntityEvent) event).getCollided().get(Health.class);
      if (health != null) {
        health.damage(getOwner().get(Damage.class).getDamageLevel(point.getWorld().getData().get(VanillaData.DIFFICULTY)).getAmount());
      }
    } else {
      //TODO: Fall damage
    }
  }
View Full Code Here

Examples of org.spout.vanilla.component.entity.misc.Health

public class PlayerHealthHandler extends MessageHandler<PlayerHealthMessage> {
  @Override
  public void handleClient(ClientSession session, PlayerHealthMessage message) {
    Player player = session.getPlayer();

    Health health = player.get(Health.class);
    health.setHealth(message.getHealth(), HealthChangeCause.UNKNOWN);

    Hunger hunger = player.get(Hunger.class);
    hunger.setHunger(message.getFood());
    hunger.setFoodSaturation(message.getFoodSaturation());
  }
View Full Code Here

Examples of org.spout.vanilla.component.entity.misc.Health

          entity.remove();
          continue;
        }

        // Check if entity can be damaged
        Health health = entity.get(Health.class);
        if (health == null) {
          continue;
        }
        Human human = entity.get(Human.class);
        if (human != null && human.isCreative()) {
          continue;
        }
        health.damage(getDamage(position, entity.getPhysics().getPosition(), size));
      }
    }

    //explosion packet (TODO: Limit the amount sent per tick? Don't want to lag-out clients!)
    GeneralEffects.EXPLOSION.playGlobal(position, size);
View Full Code Here

Examples of org.spout.vanilla.component.entity.misc.Health

    TestVanilla.init();
    VanillaConfiguration config = TestVanilla.getInstance().getConfig();
    VanillaConfiguration.PLAYER_SURVIVAL_ENABLE_HEALTH.setConfiguration(config);

    Entity entity = EntityMocker.mockEntity();
    Health health = entity.add(Health.class);

    health.setMaxHealth(15);
    assertEquals(15.0f, health.getMaxHealth(), 0.0f);
    assertEquals(1.0f, health.getHealth(), 0.0f);

    health.setSpawnHealth(20);
    assertEquals(20.0f, health.getMaxHealth(), 0.0f);
    assertEquals(20.0f, health.getHealth(), 0.0f);

    health.damage(1.0f);
    assertEquals(19.0f, health.getHealth(), 0.0f);

    health.kill(HealthChangeCause.DAMAGE);
    assertEquals(0.0f, health.getHealth(), 0.0f);
    assertTrue(health.isDead());

    health.heal(5.0f);
    assertEquals(5.0f, health.getHealth(), 0.0f);
    assertFalse(health.isDead());

    health.setDeathTicks(30);
    assertEquals(30, health.getDeathTicks());
    assertTrue(health.isDying());

    health.setHealth(-1.0f, HealthChangeCause.UNKNOWN);
    assertTrue(health.hasInfiniteHealth());
  }
View Full Code Here

Examples of org.springframework.boot.actuate.health.Health

    if (!this.delegate.isEnabled()) {
      // Shouldn't happen because the request mapping should not be registered
      return new ResponseEntity<Map<String, String>>(Collections.singletonMap(
          "message", "This endpoint is disabled"), HttpStatus.NOT_FOUND);
    }
    Health health = getHealth(principal);
    Status status = health.getStatus();
    if (this.statusMapping.containsKey(status.getCode())) {
      return new ResponseEntity<Health>(health, this.statusMapping.get(status
          .getCode()));
    }
    return health;
View Full Code Here

Examples of org.springframework.boot.actuate.health.Health

    }
    return health;
  }

  private Health getHealth(Principal principal) {
    Health health = (useCachedValue(principal) ? this.cached : (Health) this.delegate
        .invoke());
    // Not too worried about concurrent access here, the worst that can happen is the
    // odd extra call to delegate.invoke()
    this.cached = health;
    if (!secure(principal)) {
      // If not secure we only expose the status
      health = Health.status(health.getStatus()).build();
    }
    return health;
  }
View Full Code Here

Examples of org.springframework.boot.actuate.health.Health

    Object result = this.mvc.invoke(this.user);
    assertTrue(result instanceof Health);
    assertTrue(((Health) result).getStatus() == Status.UP);
    given(this.endpoint.invoke()).willReturn(new Health.Builder().down().build());
    result = this.mvc.invoke(this.user);
    @SuppressWarnings("unchecked")
    Health health = ((ResponseEntity<Health>) result).getBody();
    assertTrue(health.getStatus() == Status.DOWN);
  }
View Full Code Here

Examples of org.springframework.boot.actuate.health.Health

    Object result = this.mvc.invoke(this.user);
    assertTrue(result instanceof Health);
    assertTrue(((Health) result).getStatus() == Status.UP);
    given(this.endpoint.invoke()).willReturn(new Health.Builder().down().build());
    result = this.mvc.invoke(null); // insecure now
    Health health = (Health) result;
    // so the result is cached
    assertTrue(health.getStatus() == Status.UP);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.