forked from Ad5001/UHC
Starting custom events.
This commit is contained in:
parent
6a533249ff
commit
7318c9f1be
4 changed files with 21 additions and 2 deletions
|
@ -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 = [];
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -9,7 +9,11 @@
|
|||
namespace Ad5001\UHC\event;
|
||||
use pocketmine\event\Event;
|
||||
abstract class UHCEvent extends Event {
|
||||
|
||||
|
||||
public function getGame() {
|
||||
return $this->game;
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in a new issue