Skip to content
This repository has been archived by the owner on Jun 19, 2024. It is now read-only.

Commit

Permalink
Beta2 Finally released,
Browse files Browse the repository at this point in the history
Fixed NameTags stacking,
Fixed Text not re appearing for any games other then first.
Fixed several bugs.
  • Loading branch information
JaxkDev committed Apr 19, 2019
1 parent 5bec393 commit 7a0fc9d
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/Jackthehack21/KOTH/Arena.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class Arena{
public $hill = []; //[[20,20],[30,20]] two points corner to corner. (X,Z) no y.
public $players = []; //list of all players currently in-game. (lowercase names)
public $playerOldPositions = []; //["world name",x,y,z] List of where players joined from to TP back to after finish.
public $playerOldNameTags = []; //todo better method
public $minPlayers;
public $maxPlayers;
public $name;
Expand Down Expand Up @@ -217,6 +218,8 @@ public function createKingTextParticle() : void{

public function updateKingTextParticle() : void{
if($this->currentKingParticle !== null){
/** @noinspection PhpUndefinedMethodInspection */
$this->currentKingParticle->setInvisible(false); //fix restarting games.
/** @noinspection PhpUndefinedMethodInspection */
$this->currentKingParticle->setText(C::RED."King: ".C::GOLD.($this->king === null ? "-" : $this->king));
}
Expand All @@ -239,12 +242,23 @@ public function updateNameTags() : void{
if($this->king !== null){
/** @noinspection PhpStrictTypeCheckingInspection */
$player = $this->plugin->getServer()->getPlayerExact($this->king);
$player->setNameTag($format."\n".$player->getNameTag());
if(array_key_exists($this->king,$this->playerOldNameTags) !== true){

This comment has been minimized.

Copy link
@SavionLegends

SavionLegends May 7, 2019

just use if(!isset($this->playerOldNameTags[$this->king]))

This comment has been minimized.

Copy link
@JaxkDev

JaxkDev May 7, 2019

Author Owner

Essentially the same thing lol

$this->playerOldNameTags[$this->king] = $player->getNameTag();
}
$old = $this->playerOldNameTags[$player->getLowerCaseName()];
$player->setNameTag($format."\n".$old);
if($this->oldKing !== null and $this->oldKing !== $this->king){
//remove nametag.
$old = $this->playerOldNameTags[$this->oldKing];
$p = $this->plugin->getServer()->getPlayerExact($this->oldKing);
if($p === null) return;
$p->setNameTag($old);
}
} else {
if($this->oldKing !== null){
$player = $this->plugin->getServer()->getPlayerExact($this->oldKing);
if($player === null) return;
$player->setNameTag($format."\n".$player->getNameTag());
$player->setNameTag($this->playerOldNameTags[strtolower($player->getName())]);
}
}
}
Expand All @@ -258,7 +272,6 @@ public function spawnPlayer(Player $player, $random = false) : void{
if(strtolower($player->getLevel()->getName()) !== strtolower($this->world)){
if(!$this->plugin->getServer()->isLevelGenerated($this->world)) {
//todo config msg.
//world does not exist
$player->sendMessage($this->plugin->prefix.C::RED."This arena is corrupt.");
return;
}
Expand Down Expand Up @@ -331,6 +344,8 @@ public function reset() : void{
}

$this->players = [];
$this->playerOldPositions = [];
$this->playerOldNameTags = [];
$this->checkStatus();
}

Expand Down Expand Up @@ -502,7 +517,6 @@ public function addPlayer(Player $player) : bool{
$player->setGamemode(0);
$this->players[] = strtolower($player->getName());
$this->playerOldPositions[strtolower($player->getName())] = [$player->getLevel()->getName(),$player->getX(), $player->getY(), $player->getZ()];
//todo test ^
$this->broadcastJoin($player);
$this->spawnPlayer($player);
if(count($this->players) >= $this->minPlayers && $this->timerTask === null){
Expand Down

0 comments on commit 7a0fc9d

Please sign in to comment.