Browse Source

Starting custom events.

pull/6/head
Ad5001 3 years ago
parent
commit
7318c9f1be

+ 2
- 0
src/Ad5001/UHC/Main.php View File

@@ -81,6 +81,8 @@ class Main extends PluginBase implements Listener{
$this->saveDefaultConfig();
mkdir($this->getDataFolder() . "scenarios");
$this->getServer()->getPluginManager()->registerEvents($this, $this);
$this->getServer()->getPluginManager()->registerEvent("\Ad5001\UHC\event\GameStartEvent", $this, \pocketmine\plugin\EventPriority::NORMAL, new \pocketmine\plugin\MethodEventExecutor("onGameStart"), $this, true);
$this->getServer()->getPluginManager()->registerEvent("\Ad5001\UHC\event\GameStopEvent", $this, \pocketmine\plugin\EventPriority::NORMAL, new \pocketmine\plugin\MethodEventExecutor("onGameStop"), $this, true);
$this->UHCManager = new UHCManager($this);
$this->games = [];
$this->quit = [];

+ 1
- 1
src/Ad5001/UHC/UHCGame.php View File

@@ -36,7 +36,7 @@ class UHCGame implements Listener{
public function __construct(Plugin $plugin, UHCWorld $world) {
$this->m = $plugin;
$this->world = $world;
$plugin->getServer()->registerEvets($this, $plugin);
$plugin->getServer()->getPluginManager()->registerEvents($this, $plugin);
$this->players = $world->getLevel()->getPlayers();
$event = new GameStartEvent($this, $world, $this->players);
$this->m->getServer()->getPluginManager()->callEvent($event);

src/Ad5001/UHC/event/GameFinishEvent.php → src/Ad5001/UHC/event/GameStopEvent.php View File

@@ -15,21 +15,34 @@ use Ad5001\UHC\UHCWorld;
protected $game;
protected $world;
protected $winner;
class GameFinishEvent extends UHCEvent implements Cancellable {


class GameStopEvent extends UHCEvent implements Cancellable {



public function __construct($game, $world, $winner) {
$this->game = $game;
$this->world = $world;
$this->winner = $winner;
}


public function getWorld() {
return $this->world;
}


public function getLevel() {
return $this->world;
}


public function getWinner() {
return $this->winner;
}

public function setWinner(Player $winner) {
$this->winner = $winner;
}

+ 4
- 0
src/Ad5001/UHC/event/UHCEvent.php View File

@@ -9,7 +9,11 @@
namespace Ad5001\UHC\event;
use pocketmine\event\Event;
abstract class UHCEvent extends Event {


public function getGame() {
return $this->game;
}

}

Loading…
Cancel
Save