This repository has been archived by the owner on Jul 11, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f4b1d1f
commit 4f8bb05
Showing
2 changed files
with
102 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
main: StaffList\Main | ||
api: 1.10.0 | ||
load: POSTWORLD | ||
|
||
name: StaffList | ||
description: Give list of Staff | ||
version: 3.0 | ||
author: [aliuly,Glitchmaster_PE] | ||
|
||
commands: | ||
stafflist: | ||
description: Give list of staff | ||
usage: "/stafflist" | ||
permission: stafflist.list | ||
staffadd: | ||
description: Add a staff member | ||
usage: "/staffadd <o|a|m|t> <full username>" | ||
permission: stafflist.add | ||
|
||
permissions: | ||
stafflist.list: | ||
default: true | ||
description: "Allow listing staff" | ||
stafflist.add: | ||
default: true | ||
description: "Allow modify staff list" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<?php | ||
namespace StaffList; | ||
|
||
use pocketmine\plugin\PluginBase; | ||
use pocketmine\command\CommandExecutor; | ||
use pocketmine\command\CommandSender; | ||
use pocketmine\command\Command; | ||
use pocketmine\utils\Config; | ||
|
||
class Main extends PluginBase implements CommandExecutor { | ||
protected $staff; | ||
protected function reload() { | ||
$default = [ | ||
"owner" => [], | ||
"admins" => [], | ||
"mods" => [], | ||
"trusted" => [], | ||
]; | ||
return (new Config($this->getDataFolder()."staff.yml", | ||
Config::YAML,$default))->getAll(); | ||
} | ||
public function onEnable(){ | ||
if (!is_dir($this->getDataFolder())) mkdir($this->getDataFolder()); | ||
$this->reload(); | ||
} | ||
public function onCommand(CommandSender $sender, Command $cmd, $label, array $args) { | ||
switch($cmd->getName()) { | ||
case "stafflist": | ||
if (count($args) != 0) return false; | ||
$staff = $this->reload(); | ||
foreach (["owner" => "Owners", | ||
"admins" => "Admins", | ||
"mods" => "Moderators", | ||
"trusted" => "Trusted"] as $i=>$j) { | ||
$sender->sendMessage("[StaffList] $j: ".implode(", ",$staff[$i])); | ||
} | ||
return true; | ||
case "staffadd": | ||
if (count($args) != 2) return false; | ||
switch(strtolower($args[0])) { | ||
case "owner": | ||
case "o": | ||
$lst = "owner"; | ||
break; | ||
case "admins": | ||
case "admin": | ||
case "a": | ||
$lst = "admin"; | ||
break; | ||
case "moderators" : | ||
case "mod" : | ||
case "moderator" : | ||
case "mods" : | ||
case "m" : | ||
$lst = "mods"; | ||
break; | ||
case "trusted" : | ||
case "t" : | ||
$lst = "trusted"; | ||
break; | ||
default: | ||
return false; | ||
} | ||
$target = $args[1]; | ||
$staff = $this->reload(); | ||
$staff[$lst][] = $target; | ||
$yaml = new Config($this->getDataFolder()."staff.yml",Config::YAML,[]); | ||
$yaml->setAll($staff); | ||
$yaml->save(); | ||
|
||
$sender->sendMessage("$target added to $lst list"); | ||
return true; | ||
} | ||
return false; | ||
} | ||
} |