-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
104 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?php | ||
|
||
|
||
namespace BedWars; | ||
|
||
use pocketmine\scheduler\Task; | ||
use pocketmine\level\Level; | ||
use pocketmine\math\Vector3; | ||
use pocketmine\tile\Sign; | ||
use pocketmine\utils\TextFormat; | ||
|
||
class SignUpdater extends Task | ||
{ | ||
|
||
/** @var BedWars $plugin */ | ||
private $plugin; | ||
|
||
public function __construct(BedWars $plugin) | ||
{ | ||
$this->plugin = $plugin; | ||
} | ||
|
||
/** | ||
* @param int $currentTick | ||
*/ | ||
public function onRun(int $currentTick) : void | ||
{ | ||
foreach ($this->plugin->signs as $arena => $positions) { | ||
foreach ($positions as $position) { | ||
$pos = explode(":", $position); | ||
$vector = new Vector3(intval($pos[0]), intval($pos[1]), intval($pos[2])); | ||
|
||
$level = $this->plugin->getServer()->getLevelByName($pos[3]); | ||
|
||
if (!$level instanceof Level) { | ||
continue; | ||
} | ||
|
||
if (!in_array($arena, array_keys($this->plugin->games))) { | ||
continue; | ||
} | ||
|
||
$game = $this->plugin->games[$arena]; | ||
$tile = $level->getTile($vector); | ||
if (!$tile instanceof Sign) { | ||
continue; | ||
} | ||
|
||
$tile->setText(TextFormat::BOLD . TextFormat::DARK_RED . "BedWars", | ||
TextFormat::AQUA . "[" . count($game->players) . "/" . $game->getMaxPlayers() . "]", | ||
TextFormat::BOLD . TextFormat::GOLD . $game->getName(), | ||
$this->getStatus($game->getState())); | ||
|
||
|
||
} | ||
} | ||
} | ||
|
||
/** | ||
* @param int $state | ||
* @return string | ||
*/ | ||
public function getStatus(int $state) : string{ | ||
switch($state){ | ||
case 0; | ||
return TextFormat::YELLOW . "Touch Me"; | ||
case 1; | ||
return TextFormat::RED . "InGame"; | ||
} | ||
return ""; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
|
||
namespace BedWars\game; | ||
|
||
use pocketmine\scheduler\Task; | ||
|
||
class GameTick extends Task | ||
{ | ||
|
||
private $plugin; | ||
|
||
/** | ||
* constructor. | ||
* @param Game $plugin | ||
*/ | ||
public function __construct(Game $plugin) | ||
{ | ||
$this->plugin = $plugin; | ||
} | ||
|
||
public function onRun(int $currentTick) | ||
{ | ||
$this->plugin->tick(); | ||
} | ||
|
||
} |
8d3acec
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dear @boi1216,
C1a — Namespace format:
D1 — Detailed description:
Please resolve these issues and submit the plugin again.