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

Commit 4f8bb05

Browse files
committed
StaffList-3.0
1 parent f4b1d1f commit 4f8bb05

File tree

2 files changed

+102
-0
lines changed

2 files changed

+102
-0
lines changed

StaffList/plugin.yml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
main: StaffList\Main
2+
api: 1.10.0
3+
load: POSTWORLD
4+
5+
name: StaffList
6+
description: Give list of Staff
7+
version: 3.0
8+
author: [aliuly,Glitchmaster_PE]
9+
10+
commands:
11+
stafflist:
12+
description: Give list of staff
13+
usage: "/stafflist"
14+
permission: stafflist.list
15+
staffadd:
16+
description: Add a staff member
17+
usage: "/staffadd <o|a|m|t> <full username>"
18+
permission: stafflist.add
19+
20+
permissions:
21+
stafflist.list:
22+
default: true
23+
description: "Allow listing staff"
24+
stafflist.add:
25+
default: true
26+
description: "Allow modify staff list"

StaffList/src/StaffList/Main.php

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<?php
2+
namespace StaffList;
3+
4+
use pocketmine\plugin\PluginBase;
5+
use pocketmine\command\CommandExecutor;
6+
use pocketmine\command\CommandSender;
7+
use pocketmine\command\Command;
8+
use pocketmine\utils\Config;
9+
10+
class Main extends PluginBase implements CommandExecutor {
11+
protected $staff;
12+
protected function reload() {
13+
$default = [
14+
"owner" => [],
15+
"admins" => [],
16+
"mods" => [],
17+
"trusted" => [],
18+
];
19+
return (new Config($this->getDataFolder()."staff.yml",
20+
Config::YAML,$default))->getAll();
21+
}
22+
public function onEnable(){
23+
if (!is_dir($this->getDataFolder())) mkdir($this->getDataFolder());
24+
$this->reload();
25+
}
26+
public function onCommand(CommandSender $sender, Command $cmd, $label, array $args) {
27+
switch($cmd->getName()) {
28+
case "stafflist":
29+
if (count($args) != 0) return false;
30+
$staff = $this->reload();
31+
foreach (["owner" => "Owners",
32+
"admins" => "Admins",
33+
"mods" => "Moderators",
34+
"trusted" => "Trusted"] as $i=>$j) {
35+
$sender->sendMessage("[StaffList] $j: ".implode(", ",$staff[$i]));
36+
}
37+
return true;
38+
case "staffadd":
39+
if (count($args) != 2) return false;
40+
switch(strtolower($args[0])) {
41+
case "owner":
42+
case "o":
43+
$lst = "owner";
44+
break;
45+
case "admins":
46+
case "admin":
47+
case "a":
48+
$lst = "admin";
49+
break;
50+
case "moderators" :
51+
case "mod" :
52+
case "moderator" :
53+
case "mods" :
54+
case "m" :
55+
$lst = "mods";
56+
break;
57+
case "trusted" :
58+
case "t" :
59+
$lst = "trusted";
60+
break;
61+
default:
62+
return false;
63+
}
64+
$target = $args[1];
65+
$staff = $this->reload();
66+
$staff[$lst][] = $target;
67+
$yaml = new Config($this->getDataFolder()."staff.yml",Config::YAML,[]);
68+
$yaml->setAll($staff);
69+
$yaml->save();
70+
71+
$sender->sendMessage("$target added to $lst list");
72+
return true;
73+
}
74+
return false;
75+
}
76+
}

0 commit comments

Comments
 (0)