From b00110d19a5ffa8ecc1b86e16a041df67158863a Mon Sep 17 00:00:00 2001 From: mhsjlw Date: Fri, 28 Aug 2015 11:19:53 -0400 Subject: [PATCH] Added player.updateHealth documentation --- doc/api.md | 5 +++++ lib/playerPlugins/pvp.js | 7 +------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/api.md b/doc/api.md index f748ee2..3ab6cee 100644 --- a/doc/api.md +++ b/doc/api.md @@ -62,6 +62,7 @@ - [player.spawn()](#playerspawn) - [player.setGameMode(gameMode)](#playersetgamemodegamemode) - [player.handleCommand(command)](#playerhandlecommandcommand) + - [player.updateHealth(health)](#playerupdatehealthhealth) - [Low level properties](#low-level-properties) - [player._client](#player_client) - [Low level methods](#low-level-methods) @@ -288,6 +289,10 @@ set player gameMode to `gameMode` handle `command` +#### player.updateHealth(health) + +update the player health. + ### Low level properties #### player._client diff --git a/lib/playerPlugins/pvp.js b/lib/playerPlugins/pvp.js index dc693b2..36066b4 100644 --- a/lib/playerPlugins/pvp.js +++ b/lib/playerPlugins/pvp.js @@ -15,12 +15,7 @@ function inject(serv, player) function attackEntity(entityId) { var attackedPlayer = serv.entities[entityId].player; - attackedPlayer.entity.health -= 1; - attackedPlayer._client.write('update_health', { - food: attackedPlayer.entity.food, - foodSaturation: 0.0, - health: attackedPlayer.entity.health - }); + attackedPlayer.updateHealth(attackedPlayer.entity.health - 1); if(attackedPlayer.entity.health==0) attackedPlayer._writeOthers('entity_status',{