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

Commit

Permalink
StaffList-3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
alejandroliu committed May 28, 2015
1 parent f4b1d1f commit 4f8bb05
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 0 deletions.
26 changes: 26 additions & 0 deletions StaffList/plugin.yml
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"
76 changes: 76 additions & 0 deletions StaffList/src/StaffList/Main.php
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;
}
}

0 comments on commit 4f8bb05

Please sign in to comment.