Skip to content

Commit

Permalink
Fix for poggit
Browse files Browse the repository at this point in the history
  • Loading branch information
boi1216 committed Mar 4, 2020
1 parent 7dbb6e8 commit 8d3acec
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 93 deletions.
74 changes: 3 additions & 71 deletions src/BedWars/BedWars.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ public function onEnable() : void
$this->saveResource("skins/264.png");
$this->saveResource("skins/388.png");

$this->signTick();
$this->getScheduler()->scheduleRepeatingTask(
new SignUpdater($this), 20
);
$this->getServer()->getPluginManager()->registerEvents(new GameListener($this), $this);

foreach(glob($this->getDataFolder() . "arenas/*.json") as $location){
Expand Down Expand Up @@ -175,73 +177,6 @@ public function validateGame(array $arenaData) : bool{
return !$error > 0;
}

private function signTick() : void{
$this->getScheduler()->scheduleRepeatingTask(
new class($this) 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 "";
}


}, 20
);
}

/**
* @param Player $player
* @param bool $isSpectator
Expand Down Expand Up @@ -271,7 +206,4 @@ public function getPlayerTeam(Player $player) : ?Team{
}
return null;
}



}
73 changes: 73 additions & 0 deletions src/BedWars/SignUpdater.php
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 "";
}

}
23 changes: 1 addition & 22 deletions src/BedWars/game/Game.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,29 +141,8 @@ public function __construct(BedWars $plugin, string $arenaName, int $minPlayers,
}

$this->maxPlayers = count($this->teams) * $playersPerTeam;


$this->reload();

$this->plugin->getScheduler()->scheduleRepeatingTask(new class($this) extends Task{

private $plugin;

/**
* constructor.
* @param Game $plugin
*/
public function __construct(Game $plugin)
{
$this->plugin = $plugin;
}

public function onRun(int $currentTick)
{
$this->plugin->tick();
}
}, 20);

$this->plugin->getScheduler()->scheduleRepeatingTask(new GameTick($this), 20);
}

/**
Expand Down
27 changes: 27 additions & 0 deletions src/BedWars/game/GameTick.php
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();
}

}

1 comment on commit 8d3acec

@JaxkDev
Copy link

@JaxkDev JaxkDev commented on 8d3acec Mar 5, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dear @boi1216,

I regret to inform you that your plugin "BedWarsUltimate" (v1.0 submitted on 2020-03-04T14:46:26.000Z) has been rejected.

C1a — Namespace format:

All plugins must choose a unique namespace that will not be accidentally collided by other plugins. The plugin must begin with the author name (unless its an official plugin, because the namespace pocketmine is disallowed), followed by any identifier such that the author himself remembers which plugin it corresponds to. The recommended namespace format is AuthorName\PluginName. The author name should use one that corresponds to the GitHub username/org name to prevent collision.

D1 — Detailed description:

The description should give an idea what the plugin is about, why it is useful, etc. Do not assume everyone knows the terminology; explain them. Do not just post screenshots or videos without explaining with text; videos are not searchable.

Please resolve these issues and submit the plugin again.

This comment is posted here because this is the last commit when the released build was created.

Please sign in to comment.