mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-23 04:59:46 +00:00
fixed regeneration on difficulty 0
This commit is contained in:
parent
9f5386fd08
commit
a10c6a1d57
2 changed files with 7 additions and 18 deletions
|
|
@ -9,7 +9,6 @@ class PlayerAPI{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function init(){
|
public function init(){
|
||||||
$this->server->schedule(20 * 15, [$this, "handle"], 1, true, "server.regeneration");
|
|
||||||
$this->server->addHandler("player.death", [$this, "handle"], 1);
|
$this->server->addHandler("player.death", [$this, "handle"], 1);
|
||||||
$this->registerCmd("list");
|
$this->registerCmd("list");
|
||||||
$this->registerCmd("kill", "<player>");
|
$this->registerCmd("kill", "<player>");
|
||||||
|
|
@ -32,7 +31,6 @@ class PlayerAPI{
|
||||||
$this->server->api->console->cmdWhitelist("ping");
|
$this->server->api->console->cmdWhitelist("ping");
|
||||||
$this->server->api->console->cmdWhitelist("spawn");
|
$this->server->api->console->cmdWhitelist("spawn");
|
||||||
$this->server->api->console->cmdWhitelist("loc");
|
$this->server->api->console->cmdWhitelist("loc");
|
||||||
//$this->server->preparedSQL->selectPlayersToHeal = $this->server->database->prepare("SELECT EID FROM entities WHERE class = " . ENTITY_PLAYER . " AND health < 20;");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function registerCmd($cmd, $help = ""){
|
public function registerCmd($cmd, $help = ""){
|
||||||
|
|
@ -41,22 +39,6 @@ class PlayerAPI{
|
||||||
|
|
||||||
public function handle($data, $event){
|
public function handle($data, $event){
|
||||||
switch($event){
|
switch($event){
|
||||||
case "server.regeneration":
|
|
||||||
if($this->server->difficulty === 0){
|
|
||||||
//$result = $this->server->preparedSQL->selectPlayersToHeal->execute();
|
|
||||||
if($result !== false){
|
|
||||||
while(($player = $result->fetchArray()) !== false){
|
|
||||||
if(($player = $this->server->api->entity->get($player["EID"])) !== false){
|
|
||||||
if($player->getHealth() <= 0){
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$player->setHealth(min(20, $player->getHealth() + $data), "regeneration");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "player.death":
|
case "player.death":
|
||||||
if(is_numeric($data["cause"])){
|
if(is_numeric($data["cause"])){
|
||||||
$e = $this->server->api->entity->get($data["cause"]);
|
$e = $this->server->api->entity->get($data["cause"]);
|
||||||
|
|
|
||||||
|
|
@ -1398,6 +1398,13 @@ class Player{
|
||||||
}
|
}
|
||||||
public function entityTick(){
|
public function entityTick(){
|
||||||
if($this->isSleeping) ++$this->sleepingTime;
|
if($this->isSleeping) ++$this->sleepingTime;
|
||||||
|
|
||||||
|
if($this->server->difficulty == 0 && $this->entity->counter % (20 * 15) == 0){
|
||||||
|
if($this->entity->health < 20 && $this->entity->health > 0){
|
||||||
|
$this->entity->setHealth(min(20, $this->entity->health + 1), "regeneration");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
public function handleDataPacket(RakNetDataPacket $packet){
|
public function handleDataPacket(RakNetDataPacket $packet){
|
||||||
if($this->connected === false){
|
if($this->connected === false){
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue