mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-23 00:55:57 +00:00
Rewrite /defaultgamemode command to allow multiple values
This commit is contained in:
parent
d0d8d281d2
commit
269e63ab50
@ -46,7 +46,7 @@ class ConsoleAPI{
|
||||
$this->register("say", "<message ...>", array($this, "defaultCommands"));
|
||||
$this->register("save-all", "", array($this, "defaultCommands"));
|
||||
$this->register("stop", "", array($this, "defaultCommands"));
|
||||
$this->register("defaultgamemode", "<CREATIVE|SURVIVAL|ADVENTURE|VIEW>", array($this, "defaultCommands"));
|
||||
$this->register("defaultgamemode", "<mode>", array($this, "defaultCommands"));
|
||||
$this->server->api->ban->cmdWhitelist("help");
|
||||
}
|
||||
|
||||
@ -61,29 +61,29 @@ class ConsoleAPI{
|
||||
$output = "";
|
||||
switch($cmd){
|
||||
case "defaultgamemode":
|
||||
$p = strtolower(array_shift($params));
|
||||
switch($p){
|
||||
case "creative":
|
||||
$output .= "Default Gamemode is now Creative\n";
|
||||
$this->server->gamemode = CREATIVE;
|
||||
break;
|
||||
case "survival":
|
||||
$output .= "Default Gamemode is now Survival\n";
|
||||
$this->server->gamemode = SURVIVAL;
|
||||
break;
|
||||
case "adventure":
|
||||
$output .= "Default Gamemode is now Adventure\n";
|
||||
$this->server->gamemode = ADVENTURE;
|
||||
break;
|
||||
case "view":
|
||||
$output .= "Default Gamemode is now View\n";
|
||||
$this->server->gamemode = VIEW;
|
||||
break;
|
||||
default:
|
||||
$output .= "Usage: /defaultgamemode <CREATIVE|SURVIVAL|ADVENTURE|VIEW>\n";
|
||||
break;
|
||||
}
|
||||
$gms = array(
|
||||
"0" => SURVIVAL,
|
||||
"survival" => SURVIVAL,
|
||||
"s" => SURVIVAL,
|
||||
"1" => CREATIVE,
|
||||
"creative" => CREATIVE,
|
||||
"c" => CREATIVE,
|
||||
"2" => ADVENTURE,
|
||||
"adventure" => ADVENTURE,
|
||||
"a" => ADVENTURE,
|
||||
"3" => VIEW,
|
||||
"view" => VIEW,
|
||||
"viewer" => VIEW,
|
||||
"spectator" => VIEW,
|
||||
"v" => VIEW,
|
||||
);
|
||||
if(!isset($gms[strtolower($params[0])])){
|
||||
$output .= "Usage: /$cmd <mode>\n";
|
||||
break;
|
||||
}
|
||||
$this->server->api->setProperty("gamemode", $gms[strtolower($params[0])]);
|
||||
$output .= "Default Gamemode is now ".strtoupper($this->server->getGamemode()).".\n";
|
||||
break;
|
||||
case "invisible":
|
||||
$p = strtolower(array_shift($params));
|
||||
switch($p){
|
||||
|
@ -146,7 +146,7 @@ class PlayerAPI{
|
||||
$player = $this->server->api->player->get($params[1]);
|
||||
}
|
||||
if(!($player instanceof Player) or !isset($gms[strtolower($params[0])])){
|
||||
$output .= "Usage: /$cmd <survival | creative | adventure> [player]\n";
|
||||
$output .= "Usage: /$cmd <mode> [player]\n";
|
||||
break;
|
||||
}
|
||||
if($player->setGamemode($gms[strtolower($params[0])])){
|
||||
|
Loading…
x
Reference in New Issue
Block a user