forked from Ad5001/UHC
Working....
This commit is contained in:
parent
8a940dfe58
commit
6273371f06
4 changed files with 12 additions and 8 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
LobbyWorld: world
|
||||||
worlds:
|
worlds:
|
||||||
uhc:
|
uhc:
|
||||||
maxplayers: 8
|
maxplayers: 8
|
||||||
|
|
|
@ -63,7 +63,7 @@ class Main extends PluginBase implements Listener{
|
||||||
@mkdir($this->getDataFolder() . "scenarios");
|
@mkdir($this->getDataFolder() . "scenarios");
|
||||||
$this->getServer()->getPluginManager()->registerEvents($this, $this);
|
$this->getServer()->getPluginManager()->registerEvents($this, $this);
|
||||||
$this->getServer()->getPluginManager()->registerEvent("Ad5001\\UHC\\event\\GameStartEvent", $this, \pocketmine\event\EventPriority::NORMAL, new \pocketmine\plugin\MethodEventExecutor("onGameStart"), $this, true);
|
$this->getServer()->getPluginManager()->registerEvent("Ad5001\\UHC\\event\\GameStartEvent", $this, \pocketmine\event\EventPriority::NORMAL, new \pocketmine\plugin\MethodEventExecutor("onGameStart"), $this, true);
|
||||||
$this->getServer()->getPluginManager()->registerEvent("Ad5001\\UHC\\event\\GameStopEvent", $this, \pocketmine\event\EventPriority::NORMAL, new \pocketmine\plugin\MethodEventExecutor("onGameStop"), $this, true);
|
$this->getServer()->getPluginManager()->registerEvent("Ad5001\\UHC\\event\\GameStopEvent", $this, \pocketmine\event\EventPriority::NORMAL, new \pocketmine\plugin\MethodEventExecutor("onGameStop"), $this, false);
|
||||||
$this->UHCManager = new UHCManager($this);
|
$this->UHCManager = new UHCManager($this);
|
||||||
$this->games = [];
|
$this->games = [];
|
||||||
$this->quit = [];
|
$this->quit = [];
|
||||||
|
@ -397,4 +397,6 @@ return false;
|
||||||
|
|
||||||
|
|
||||||
public function onGameStop(\Ad5001\UHC\event\GameStopEvent $event) {}
|
public function onGameStop(\Ad5001\UHC\event\GameStopEvent $event) {}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ use pocketmine\event\player\PlayerChatEvent;
|
||||||
use pocketmine\event\player\PlayerQuitEvent;
|
use pocketmine\event\player\PlayerQuitEvent;
|
||||||
use pocketmine\event\player\PlayerRespawnEvent;
|
use pocketmine\event\player\PlayerRespawnEvent;
|
||||||
use pocketmine\event\entity\EntityRegainHealthEvent;
|
use pocketmine\event\entity\EntityRegainHealthEvent;
|
||||||
|
use Ad5001\UHC\event\GameStopEvent;
|
||||||
use pocketmine\level\Level;
|
use pocketmine\level\Level;
|
||||||
use pocketmine\plugin\Plugin;
|
use pocketmine\plugin\Plugin;
|
||||||
use pocketmine\math\Vector3;
|
use pocketmine\math\Vector3;
|
||||||
|
@ -94,10 +95,9 @@ class UHCGame implements Listener{
|
||||||
|
|
||||||
public function onPlayerDeath(PlayerDeathEvent $event) {
|
public function onPlayerDeath(PlayerDeathEvent $event) {
|
||||||
if($event->getPlayer()->getLevel()->getName() === $this->world->getName() and !$this->cancelled) {
|
if($event->getPlayer()->getLevel()->getName() === $this->world->getName() and !$this->cancelled) {
|
||||||
$players = $this->world->getPlayers();
|
foreach($event->getPlayer()->getLevel()->getPlayers() as $p) {
|
||||||
unset($players[$event->getPlayer()]);
|
$p->sendMessage(Main::PREFIX . C::YELLOW . $event->getPlayer()->getName() . " died.");
|
||||||
$this->worlds->setPlayers($players);
|
}
|
||||||
$event->setDeathMessage(Main::PREFIX . C::YELLOW . $event->getDeathMessage());
|
|
||||||
$this->respawn[$event->getPlayer()->getName()] = true;
|
$this->respawn[$event->getPlayer()->getName()] = true;
|
||||||
$pls = [];
|
$pls = [];
|
||||||
foreach($this->players as $pl) {
|
foreach($this->players as $pl) {
|
||||||
|
@ -135,11 +135,11 @@ class UHCGame implements Listener{
|
||||||
|
|
||||||
public function stop(Player $winner) {
|
public function stop(Player $winner) {
|
||||||
if(!$this->cancelled) {
|
if(!$this->cancelled) {
|
||||||
$event = $this->getServer()->getPluginManager()->callEvent(new GameFinishEvent($this, $this->world, $winner));
|
$this->m->getServer()->getPluginManager()->callEvent($event = new GameStopEvent($this, $this->world, $winner));
|
||||||
if(!$event->isCancelled()) {
|
if(!$event->isCancelled()) {
|
||||||
foreach($this->players as $player) {
|
foreach($this->players as $player) {
|
||||||
$player->sendMessage(Main::PREFIX . C::YELLOW . $winner->getName());
|
$player->sendMessage(Main::PREFIX . C::YELLOW . $winner->getName());
|
||||||
$player->teleport($this->m->getServer()->getLevelByName($this->m->getConfig()->get("LobbyWorld")));
|
$player->teleport($this->m->getServer()->getLevelByName($this->m->getConfig()->get("LobbyWorld"))->getSafeSpawn());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ use pocketmine\plugin\Plugin;
|
||||||
use pocketmine\level\particle\FloatingTextParticle;
|
use pocketmine\level\particle\FloatingTextParticle;
|
||||||
use pocketmine\Player;
|
use pocketmine\Player;
|
||||||
use pocketmine\utils\TextFormat as C;
|
use pocketmine\utils\TextFormat as C;
|
||||||
|
use pocketmine\math\Vector3;
|
||||||
|
|
||||||
use Ad5001\UHC\Main;
|
use Ad5001\UHC\Main;
|
||||||
use Ad5001\UHC\scenario\ScenarioManager;
|
use Ad5001\UHC\scenario\ScenarioManager;
|
||||||
|
@ -65,7 +66,7 @@ class UHCWorld {
|
||||||
if(!in_array($player, $players)){
|
if(!in_array($player, $players)){
|
||||||
foreach($this->players as $pl) {
|
foreach($this->players as $pl) {
|
||||||
$pl->sendMessage(Main::PREFIX . C::YELLOW . "{$player->getName()} joined the game.");
|
$pl->sendMessage(Main::PREFIX . C::YELLOW . "{$player->getName()} joined the game.");
|
||||||
$part = new TextParticle(new FloatingTextParticle(new Vector3($this->x, $this->y, $this->z), C::GREEN . "Welcome to the UHC {$player->getName()} !\n" . C::GREEN . "To get help about the plugin , please type command /uhc howtoplay .", C::YELLOW . "-=<UHC>=-"), $this->level, $player);
|
$this->getLevel()->addParticle($part = new FloatingTextParticle(new Vector3($this->getLevel()->getSafeSpawn()->x, $this->getLevel()->getSafeSpawn()->y, $this->getLevel()->getSafeSpawn()->z), C::GREEN . "Welcome to the UHC {$player->getName()} !\n" . C::GREEN . "To get help about the plugin , please type command /uhc howtoplay .", C::YELLOW . "-=<UHC>=-"), [$pl]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue