Skip to content
This repository has been archived by the owner on Jul 11, 2018. It is now read-only.

Update Main.php #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions src/aliuly/manyworlds/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,14 @@
use aliuly\manyworlds\common\BasicHelp;

class Main extends BasicPlugin implements CommandExecutor {
/** @var bool */
public $canUnload = false;
/** @var TeleportManager */
private $tpMgr = null;

/**
* @return void
*/
public function onEnable() {
// We don't really need this...
//if (!is_dir($this->getDataFolder())) mkdir($this->getDataFolder());
Expand Down Expand Up @@ -53,6 +58,12 @@ public function onEnable() {
$this->modules[] = new BasicHelp($this);
}

/**
* @param CommandSender $c
* @param string $world
*
* @return bool
*/
public function autoLoad(CommandSender $c,$world) {
if ($this->getServer()->isLevelLoaded($world)) return true;
if($c !== null && !MPMU::access($c, "mw.cmd.world.load")) return false;
Expand All @@ -72,13 +83,27 @@ public function autoLoad(CommandSender $c,$world) {
// Command dispatcher
//
//////////////////////////////////////////////////////////////////////
/**
* @param CommandSender $sender
* @param Command $cmd
* @param string $label
* @param string[] $args
*
* @return bool
*/
public function onCommand(CommandSender $sender, Command $cmd, $label, array $args) {
if ($cmd->getName() != "manyworlds") return false;
return $this->dispatchSCmd($sender,$cmd,$args);
}
//
// Deprecated Public API
//
/**
* @param Player $pl
* @param Position $pos
*
* @return bool
*/
public function mwtp($pl,$pos) {
if ($this->tpMgr && ($pos instanceof Position)) {
// Using ManyWorlds for teleporting...
Expand All @@ -90,6 +115,13 @@ public function mwtp($pl,$pos) {
$pl->teleport($pos);
return true;
}
/**
* @param Player $player
* @param string $world
* @param Position $spawn
*
* @return bool|void
*/
public function teleport($player,$world,$spawn=null) {
if ($this->tpMgr) {
return $this->tpMgr->teleport($player,$world,$spawn);
Expand Down