mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 08:44:01 +00:00
Some PHPDoc comment updates.
This commit is contained in:
parent
2339525478
commit
68076fedc8
@ -51,12 +51,20 @@ class BanAPI{
|
||||
$this->server->addHandler("player.block.place", array($this, "permissionsCheck"), 1);//Event handler for blocks
|
||||
$this->server->addHandler("player.flying", array($this, "permissionsCheck"), 1);//Flying Event
|
||||
}
|
||||
|
||||
public function cmdWhitelist($cmd){//Whitelists a CMD so everyone can issue it - Even non OPs.
|
||||
|
||||
/**
|
||||
* @param string $cmd Command to Whitelist
|
||||
*/
|
||||
public function cmdWhitelist($cmd){//Whitelists a CMD so everyone can issue it - Even non OPs.
|
||||
$this->cmdWhitelist[strtolower(trim($cmd))] = true;
|
||||
}
|
||||
|
||||
public function isOp($username){//Is a player op?
|
||||
|
||||
/**
|
||||
* @param string $username
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isOp($username){//Is a player op?
|
||||
$username = strtolower($username);
|
||||
if($this->server->api->dhandle("op.check", $username) === true){
|
||||
return true;
|
||||
@ -65,8 +73,14 @@ class BanAPI{
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function permissionsCheck($data, $event){
|
||||
|
||||
/**
|
||||
* @param mixed $data
|
||||
* @param string $event
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function permissionsCheck($data, $event){
|
||||
switch($event){
|
||||
case "player.flying"://OPs can fly around the server.
|
||||
if($this->isOp($data->iusername)){
|
||||
@ -100,8 +114,16 @@ class BanAPI{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public function commandHandler($cmd, $params, $issuer, $alias){
|
||||
|
||||
/**
|
||||
* @param string $cmd
|
||||
* @param array $params
|
||||
* @param string $issuer
|
||||
* @param string $alias
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function commandHandler($cmd, $params, $issuer, $alias){
|
||||
$output = "";
|
||||
switch($cmd){
|
||||
case "sudo":
|
||||
@ -274,24 +296,40 @@ class BanAPI{
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
public function ban($username){
|
||||
|
||||
/**
|
||||
* @param string $username
|
||||
*/
|
||||
public function ban($username){
|
||||
$this->commandHandler("ban", array("add", $username), "console", "");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $username
|
||||
*/
|
||||
public function pardon($username){
|
||||
$this->commandHandler("ban", array("pardon", $username), "console", "");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $ip
|
||||
*/
|
||||
public function banIP($ip){
|
||||
$this->commandHandler("banip", array("add", $ip), "console", "");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $ip
|
||||
*/
|
||||
public function pardonIP($ip){
|
||||
$this->commandHandler("banip", array("pardon", $ip), "console", "");
|
||||
}
|
||||
|
||||
public function kick($username, $reason = "No Reason"){
|
||||
|
||||
/**
|
||||
* @param string $username
|
||||
* @param string $reason
|
||||
*/
|
||||
public function kick($username, $reason = "No Reason"){
|
||||
$this->commandHandler("kick", array($username, $reason), "console", "");
|
||||
}
|
||||
|
||||
@ -300,8 +338,13 @@ class BanAPI{
|
||||
$this->commandHandler("banip", array("reload"), "console", "");
|
||||
$this->commandHandler("whitelist", array("reload"), "console", "");
|
||||
}
|
||||
|
||||
public function isIPBanned($ip){
|
||||
|
||||
/**
|
||||
* @param string $ip
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isIPBanned($ip){
|
||||
if($this->server->api->dhandle("api.ban.ip.check", $ip) === false){
|
||||
return true;
|
||||
}elseif($this->bannedIPs->exists($ip)){
|
||||
@ -309,8 +352,13 @@ class BanAPI{
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function isBanned($username){
|
||||
|
||||
/**
|
||||
* @param string $username
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isBanned($username){
|
||||
$username = strtolower($username);
|
||||
if($this->server->api->dhandle("api.ban.check", $username) === false){
|
||||
return true;
|
||||
@ -319,8 +367,13 @@ class BanAPI{
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function inWhitelist($username){
|
||||
|
||||
/**
|
||||
* @param string $username
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function inWhitelist($username){
|
||||
$username = strtolower($username);
|
||||
if($this->isOp($username)){
|
||||
return true;
|
||||
|
@ -32,8 +32,16 @@ class ChatAPI{
|
||||
$this->server->api->ban->cmdWhitelist("tell");
|
||||
$this->server->api->ban->cmdWhitelist("me");
|
||||
}
|
||||
|
||||
public function commandHandler($cmd, $params, $issuer, $alias){
|
||||
|
||||
/**
|
||||
* @param string $cmd
|
||||
* @param array $params
|
||||
* @param string $issuer
|
||||
* @param string $alias
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function commandHandler($cmd, $params, $issuer, $alias){
|
||||
$output = "";
|
||||
switch($cmd){
|
||||
case "say":
|
||||
@ -87,16 +95,30 @@ class ChatAPI{
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
public function broadcast($message){
|
||||
|
||||
/**
|
||||
* @param string $message
|
||||
*/
|
||||
public function broadcast($message){
|
||||
$this->send(false, $message);
|
||||
}
|
||||
|
||||
public function sendTo($owner, $text, $player){
|
||||
|
||||
/**
|
||||
* @param string $owner
|
||||
* @param string $text
|
||||
* @param mixed $player Can be either Player object or string username. Boolean false for broadcast.
|
||||
*/
|
||||
public function sendTo($owner, $text, $player){
|
||||
$this->send($owner, $text, array($player));
|
||||
}
|
||||
|
||||
public function send($owner, $text, $whitelist = false, $blacklist = false){
|
||||
|
||||
/**
|
||||
* @param mixed $owner Can be either Player object or string username. Boolean false for broadcast.
|
||||
* @param string $text
|
||||
* @param $whitelist
|
||||
* @param $blacklist
|
||||
*/
|
||||
public function send($owner, $text, $whitelist = false, $blacklist = false){
|
||||
$message = array(
|
||||
"player" => $owner,
|
||||
"message" => $text,
|
||||
|
@ -86,7 +86,13 @@ class Player{
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param integer $clientID
|
||||
* @param string $ip
|
||||
* @param integer $port
|
||||
* @param integer $MTU
|
||||
*/
|
||||
public function __construct($clientID, $ip, $port, $MTU){
|
||||
$this->bigCnt = 0;
|
||||
$this->MTU = $MTU;
|
||||
@ -113,7 +119,10 @@ class Player{
|
||||
public function getSpawn(){
|
||||
return $this->spawnPosition;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Vector3 $pos
|
||||
*/
|
||||
public function setSpawn(Vector3 $pos){
|
||||
if(!($pos instanceof Position)){
|
||||
$level = $this->level;
|
||||
@ -255,6 +264,10 @@ class Player{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $reason Reason for closing connection
|
||||
* @param boolean $msg Set to false to silently disconnect player. No broadcast.
|
||||
*/
|
||||
public function close($reason = "", $msg = true){
|
||||
if($this->connected === true){
|
||||
foreach($this->evid as $ev){
|
||||
@ -294,8 +307,13 @@ class Player{
|
||||
$this->received = array();
|
||||
}
|
||||
}
|
||||
|
||||
public function sleepOn(Vector3 $pos){
|
||||
|
||||
/**
|
||||
* @param Vector3 $pos
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function sleepOn(Vector3 $pos){
|
||||
foreach($this->server->api->player->getAll($this->level) as $p){
|
||||
if($p->isSleeping instanceof Vector3){
|
||||
if($pos->distance($p->isSleeping) <= 0.1){
|
||||
@ -335,8 +353,15 @@ class Player{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function hasSpace($type, $damage, $count){
|
||||
|
||||
/**
|
||||
* @param $type
|
||||
* @param $damage
|
||||
* @param $count
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function hasSpace($type, $damage, $count){
|
||||
$inv = $this->inventory;
|
||||
while($count > 0){
|
||||
$add = 0;
|
||||
@ -362,7 +387,15 @@ class Player{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function addItem($type, $damage, $count, $send = true){
|
||||
/**
|
||||
* @param $type
|
||||
* @param $damage
|
||||
* @param integer $count
|
||||
* @param boolean $send
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function addItem($type, $damage, $count, $send = true){
|
||||
while($count > 0){
|
||||
$add = 0;
|
||||
foreach($this->inventory as $s => $item){
|
||||
@ -417,16 +450,28 @@ class Player{
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function setSlot($slot, Item $item, $send = true){
|
||||
|
||||
/**
|
||||
* @param integer $slot
|
||||
* @param Item $item
|
||||
* @param boolean $send
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function setSlot($slot, Item $item, $send = true){
|
||||
$this->inventory[(int) $slot] = $item;
|
||||
if($send === true){
|
||||
$this->sendInventorySlot((int) $slot);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getSlot($slot){
|
||||
|
||||
/**
|
||||
* @param integer $slot
|
||||
*
|
||||
* @return Item
|
||||
*/
|
||||
public function getSlot($slot){
|
||||
if(isset($this->inventory[(int) $slot])){
|
||||
return $this->inventory[(int) $slot];
|
||||
}else{
|
||||
@ -466,8 +511,13 @@ class Player{
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getArmor($slot){
|
||||
|
||||
/**
|
||||
* @param integer $slot
|
||||
*
|
||||
* @return Item
|
||||
*/
|
||||
public function getArmor($slot){
|
||||
if(isset($this->armor[(int) $slot])){
|
||||
return $this->armor[(int) $slot];
|
||||
}else{
|
||||
@ -483,8 +533,12 @@ class Player{
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function eventHandler($data, $event){
|
||||
|
||||
/**
|
||||
* @param mixed $data
|
||||
* @param string $event
|
||||
*/
|
||||
public function eventHandler($data, $event){
|
||||
switch($event){
|
||||
case "tile.update":
|
||||
if($data->level === $this->level){
|
||||
|
Loading…
x
Reference in New Issue
Block a user