Last active
December 23, 2015 00:29
-
-
Save Omattyao/6554458 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<?php | |
/* | |
__PocketMine Plugin__ | |
name=GroupPermissions | |
description=Manage permissions between groups | |
version=1.0 | |
author=marksmir | |
class=GroupPermissions | |
apiversion=10 | |
*/ | |
//Group Permissions 1.0 built by marksmir | |
//This Plugin lets you create groups and manage permissions within each group | |
//AND it is compatible with every other plugin out there and is easy to configure | |
// Checklist: | |
// 1.Learn the basics : true | |
// 2.Create a config : TRUE | |
// 3.Config to be created only once : TRUE | |
// 4.Create groups : TRUE | |
// 5.Add permissions : false | |
// 6.Access other php files : false | |
// 7.Add permissions into config : false | |
// 8.Add permissions which can be edited : false | |
// 9.Finish and test : false | |
class GroupPermissions1 implements Plugin { | |
private $api; | |
public function __construct(ServerAPI $api, $server = false) { | |
$this->api = $api; | |
} | |
public function init(){ | |
$this->createConfig(); | |
$this->api->console->register("GroupPermissions", "Manages Permissions", array($this, "handleCommand")); | |
$this->api->console->register("GroupTest", "Tells you your group", array($this, "handleC")); | |
$this->api->event('get.permission', array($this, 'returnPermission')); | |
$this->api->event('player.join', array($this, 'handle')); | |
$this->api->addHandler("player.spawn", array($this, 'eventHandler'), 10); | |
$this->api->addHandler('command', array($this, 'handleC'), 15); | |
} | |
public function eventHandler($data, $event){ | |
switch ($event){ | |
case "player.spawn": | |
$username = $data->username; | |
if (!isset($this->config['players'][$username])) { | |
$this->config['players'][$username] ='default'; | |
$this->api->plugin->writeYAML($this->path."config.yml", $this->config); | |
} | |
} | |
} | |
public function handleC($data, $event, $cmd, $args, $alias, $username) { | |
//$groupName = $this->checkGroupPerm($username, $data['cmd']); | |
//$groupName = $path['players'][$username]; | |
//$please = $this->config($_GET['players'][$username]); | |
$groupName = $this->checkGroup($username, $data); | |
console.print($groupName); | |
$this->api->chat->broadcast($please); | |
$this->api->chat->broadcast("Your group is: ", $groupName); | |
$this->api->chat->broadcast($groupName); | |
if (isset($groupName)) { | |
console.print($groupName); | |
} else { | |
console.print("FAIL"); | |
} | |
} | |
public function createConfig() { | |
$config = array( | |
'created' => false, | |
'players' => array(), | |
'groups' => array ( | |
'default' => array( | |
'GroupTest' => false, | |
'ban' => false, | |
'gamemode' => false), | |
'Mod' => array( | |
'GroupTest' => true, | |
'ban' => false, | |
'gamemode' => true), | |
'Admin' => array( | |
'GroupTest' => true, | |
'ban' => true, | |
'gamemode' => true,))); | |
$this->path =$this->api->plugin->createConfig($this, $config); | |
$this->config =$this->api->plugin->readYAML($this->path."config.yml"); | |
} | |
public function __destruct(){ | |
} | |
public function handleCommand($cmd, $args, $alias){ | |
$this->api->chat->broadcast("/gp add"); | |
} | |
public function checkGroup($username) { | |
return $this->config['players'][$username]; | |
//if(!null(checkGroup) { | |
//checkGroup = isset; | |
//} | |
} | |
public function checkGroupPerm($username, $cmd) { | |
$group = $this->checkGroup($username); | |
$groupCommand = $this->config['groups'][$group][$cmd]; | |
if (!isset($groupCommand)) { | |
return false; | |
console.print("[GroupPermissions] The Command Is Not Set"); | |
} | |
elseif ($groupCommand == true) { | |
return true; | |
} | |
} | |
public function returnPermission($event, &$data) { | |
$data = $this->checkGroup($data); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment