Working....

This commit is contained in:
Ad5001 2016-08-20 19:24:35 +03:00
parent 8a940dfe58
commit 6273371f06
4 changed files with 12 additions and 8 deletions

View file

@ -1,3 +1,4 @@
LobbyWorld: world
worlds:
uhc:
maxplayers: 8

View file

@ -63,7 +63,7 @@ class Main extends PluginBase implements Listener{
@mkdir($this->getDataFolder() . "scenarios");
$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\\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->games = [];
$this->quit = [];
@ -397,4 +397,6 @@ return false;
public function onGameStop(\Ad5001\UHC\event\GameStopEvent $event) {}
}

View file

@ -16,6 +16,7 @@ use pocketmine\event\player\PlayerChatEvent;
use pocketmine\event\player\PlayerQuitEvent;
use pocketmine\event\player\PlayerRespawnEvent;
use pocketmine\event\entity\EntityRegainHealthEvent;
use Ad5001\UHC\event\GameStopEvent;
use pocketmine\level\Level;
use pocketmine\plugin\Plugin;
use pocketmine\math\Vector3;
@ -94,10 +95,9 @@ class UHCGame implements Listener{
public function onPlayerDeath(PlayerDeathEvent $event) {
if($event->getPlayer()->getLevel()->getName() === $this->world->getName() and !$this->cancelled) {
$players = $this->world->getPlayers();
unset($players[$event->getPlayer()]);
$this->worlds->setPlayers($players);
$event->setDeathMessage(Main::PREFIX . C::YELLOW . $event->getDeathMessage());
foreach($event->getPlayer()->getLevel()->getPlayers() as $p) {
$p->sendMessage(Main::PREFIX . C::YELLOW . $event->getPlayer()->getName() . " died.");
}
$this->respawn[$event->getPlayer()->getName()] = true;
$pls = [];
foreach($this->players as $pl) {
@ -135,11 +135,11 @@ class UHCGame implements Listener{
public function stop(Player $winner) {
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()) {
foreach($this->players as $player) {
$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());
}
}
}

View file

@ -16,6 +16,7 @@ use pocketmine\plugin\Plugin;
use pocketmine\level\particle\FloatingTextParticle;
use pocketmine\Player;
use pocketmine\utils\TextFormat as C;
use pocketmine\math\Vector3;
use Ad5001\UHC\Main;
use Ad5001\UHC\scenario\ScenarioManager;
@ -65,7 +66,7 @@ class UHCWorld {
if(!in_array($player, $players)){
foreach($this->players as $pl) {
$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]);
}
}
}