Browse Source

Working on games...

tags/1.0
Ad5001 3 years ago
parent
commit
fb22b22bd3

+ 3
- 0
.gitignore View File

@@ -45,3 +45,6 @@ $RECYCLE.BIN/
Network Trash Folder
Temporary Items
.apdisk

# VS Manager files:
*.vscode

+ 10
- 0
games/Example.php View File

@@ -0,0 +1,10 @@
<?php
use Ad5001\GameManager\Game;
use pocketmine\Player;

class Example extends Game {

public function onGameStart() {
$this->getLogger()->info("Game");
}
}

+ 3
- 0
src/Ad5001/GameManager/Game.php View File

@@ -61,6 +61,9 @@ abstract class Game {
public function onQuit(Player $player) {}


public function onInteract(\pocketmine\event\player\PlayerInteract $event) {}


public function onBlockBreak(\pocketmine\event\block\BlockBreakEvent $event) {}



+ 1
- 1
src/Ad5001/GameManager/GameManager.php View File

@@ -22,7 +22,7 @@ class GameManager {
public function __construct(Main $main) {
$this->main = $main;
$this->server = $main->getServer();
$files = array_diff(scandir($this->getDataFolder() . "/games"), [".", ".."]);
$files = array_diff(scandir($main->getDataFolder() . "games"), [".", ".."]);
$this->games = [];
$this->levels = [];
$this->startedgames = [];

+ 8
- 1
src/Ad5001/GameManager/Main.php View File

@@ -6,6 +6,7 @@ use pocketmine\event\Listener;
use pocketmine\event\player\PlayerInteractEvent;
use pocketmine\plugin\PluginBase;
use pocketmine\Server;
use pocketmine\level\Level;
use pocketmine\Player;
use Ad5001\GameManager\GameManager;

@@ -20,7 +21,13 @@ class Main extends PluginBase implements Listener {
$this->reloadConfig();
$this->getServer()->getPluginManager()->registerEvents($this, $this);
@mkdir($this->getServer()->getFilePath() . "worldsBackups/");
@mkdir($this->getDataFolder() . "games");
$this->manager = new GameManager($this);
foreach(array_diff_key($this->getConfig()->getAll(), ["Game1" => "", "Game2" => "", "InGame3" => "", "InGame4" => "", "GameWait3" => "", "GameWait4" => ""]) as $worldname => $gamename) {
if($this->getServer()->getLevelByName($worldname) instanceof Level) {
$this->manager->registerLevel($this->getServer()->getLevelByName($worldname), $gamename);
}
}
}


@@ -32,7 +39,7 @@ class Main extends PluginBase implements Listener {
$lvl = str_ireplace($lvlex[0], "", $t->getText()[1]);
$lvl = str_ireplace($lvlex[1], "", $lvl);
if($name == $lvl) {
if($this->gameManager->getLevels()[$lvl->getName()]->isStarted()) {
if($this->manager->getLevels()[$lvl->getName()]->isStarted()) {
$event->getPlayer()->teleport($lvl->getDefaultSpawn());
$event->getPlayer()->setGamemode(3);
} else {

Loading…
Cancel
Save