forked from Ad5001/UHC
Working ! Just need to test scenarios (and a small bug fix to resolve.)
This commit is contained in:
parent
6273371f06
commit
419b3a29ca
3 changed files with 12 additions and 7 deletions
|
@ -19,7 +19,12 @@ commands:
|
|||
scenarios:
|
||||
description: Manage UHC scenarios
|
||||
usage: "/scenarios [add | remove | list] [scenario]"
|
||||
permission: uhc.command.scenarios
|
||||
permissions:
|
||||
uhc.command.main:
|
||||
default: op
|
||||
uhc.command.scenarios:
|
||||
default: true
|
||||
uhc.scenarios.modify:
|
||||
default: op
|
||||
...
|
|
@ -39,13 +39,13 @@ class Main extends PluginBase implements Listener{
|
|||
|
||||
public function onLevelChange(EntityLevelChangeEvent $event) {
|
||||
foreach($this->UHCManager->getLevels() as $world) {
|
||||
if($event->getTarget()->getName() === $world->getName() and !isset($this->games[$world->getName()])) {
|
||||
if($event->getTarget()->getName() === $world->getName() and !isset($this->UHCManager->getStartedUHCs()[$world->getName()])) {
|
||||
if(count($world->getLevel()->getPlayers()) > $world->maxplayers) {
|
||||
$event->setCancelled();
|
||||
}
|
||||
} elseif($event->getTarget()->getName() === $world->getName() and isset($this->games[$world->getName()]) and !isset($this->quit[$event->getEntity()])) {
|
||||
} elseif($event->getTarget()->getName() === $world->getName() and isset($this->UHCManager->getStartedUHCs()[$world->getName()]) and !isset($this->quit[$event->getEntity()])) {
|
||||
$event->getPlayer()->setGamemode(3);
|
||||
} elseif($event->getTarget()->getName() === $world->getName() and isset($this->games[$world->getName()]) and isset($this->quit[$event->getEntity()])) {
|
||||
} elseif($event->getTarget()->getName() === $world->getName() and isset($this->UHCManager->getStartedUHCs()[$world->getName()]) and isset($this->quit[$event->getEntity()])) {
|
||||
$quit = explode("/", $this->quit[$event->getEntity()]);
|
||||
if($quit[3] === $world->getName()) {
|
||||
$event->getPlayer()->teleport(new Vector3($quit[0], $quit[1], $quit[2]));
|
||||
|
@ -65,7 +65,7 @@ class Main extends PluginBase implements Listener{
|
|||
$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, false);
|
||||
$this->UHCManager = new UHCManager($this);
|
||||
$this->games = [];
|
||||
$this->UHCManager->getStartedUHCs() = [];
|
||||
$this->quit = [];
|
||||
}
|
||||
|
||||
|
@ -111,7 +111,7 @@ switch($cmd->getName()){
|
|||
}
|
||||
break;
|
||||
case "scenarios":
|
||||
if(isset($args[0]) and $sender instanceof Player) {
|
||||
if(isset($args[0]) and $sender instanceof Player and $sender->hasPermission("uhc.scenarios.modify")) {
|
||||
if(isset($this->UHCManager->getLevels()[$sender->getLevel()->getName()]) and !isset($this->UHCManager->getStartedGames()[$sender->getLevel()->getName()])) {
|
||||
switch($args[0]) {
|
||||
case "add":
|
||||
|
|
|
@ -96,7 +96,7 @@ class UHCGame implements Listener{
|
|||
public function onPlayerDeath(PlayerDeathEvent $event) {
|
||||
if($event->getPlayer()->getLevel()->getName() === $this->world->getName() and !$this->cancelled) {
|
||||
foreach($event->getPlayer()->getLevel()->getPlayers() as $p) {
|
||||
$p->sendMessage(Main::PREFIX . C::YELLOW . $event->getPlayer()->getName() . " died.");
|
||||
$p->sendMessage(Main::PREFIX . C::YELLOW . $event->getPlayer()->getName() . " died. " . (count($this->world->getLevel()->getPlayers) - 2)) . " players left !");
|
||||
}
|
||||
$this->respawn[$event->getPlayer()->getName()] = true;
|
||||
$pls = [];
|
||||
|
@ -138,7 +138,7 @@ class UHCGame implements Listener{
|
|||
$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->sendMessage(Main::PREFIX . C::YELLOW . $winner->getName() . " won the game ! Teleporting back to lobby...");
|
||||
$player->teleport($this->m->getServer()->getLevelByName($this->m->getConfig()->get("LobbyWorld"))->getSafeSpawn());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue