mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 11:39:43 +00:00
code style fix
This commit is contained in:
parent
fc5c5625cb
commit
5e8e9330e2
361 changed files with 4766 additions and 4650 deletions
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
class AchievementAPI{
|
||||
|
||||
|
||||
public static $achievements = [
|
||||
/*"openInventory" => array(
|
||||
"name" => "Taking Inventory",
|
||||
|
|
@ -79,20 +79,19 @@ class AchievementAPI{
|
|||
"buildSword",
|
||||
],
|
||||
],
|
||||
|
||||
|
||||
];
|
||||
|
||||
|
||||
private $server;
|
||||
|
||||
|
||||
function __construct(){
|
||||
$this->server = ServerAPI::request();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add an achievement
|
||||
* @param string $achievementId
|
||||
* @param string $achievementName
|
||||
* @param array $requires
|
||||
* @return boolean
|
||||
*/
|
||||
public static function addAchievement($achievementId, $achievementName, array $requires = []){
|
||||
|
|
@ -105,7 +104,7 @@ class AchievementAPI{
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public static function grantAchievement(Player $player, $achievementId){
|
||||
if(isset(self::$achievements[$achievementId]) and !self::hasAchievement($player, $achievementId)){
|
||||
foreach(self::$achievements[$achievementId]["requires"] as $requerimentId){
|
||||
|
|
@ -123,19 +122,19 @@ class AchievementAPI{
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public static function hasAchievement(Player $player, $achievementId){
|
||||
if(!isset(self::$achievements[$achievementId]) or !isset($player->achievements)){
|
||||
$player->achievements = [];
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if(!isset($player->achievements[$achievementId]) or !$player->achievements[$achievementId]){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public static function broadcastAchievement(Player $player, $achievementId){
|
||||
if(isset(self::$achievements[$achievementId])){
|
||||
$result = ServerAPI::request()->api->dhandle("achievement.broadcast", ["player" => $player, "achievementId" => $achievementId]);
|
||||
|
|
@ -150,13 +149,13 @@ class AchievementAPI{
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public static function removeAchievement(Player $player, $achievementId){
|
||||
if(self::hasAchievement($player, $achievementId)){
|
||||
$player->achievements[$achievementId] = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function viewAchievements($cmd, $params, $issuer, $alias)
|
||||
{
|
||||
if(!isset($params[0])){
|
||||
|
|
@ -171,30 +170,30 @@ class AchievementAPI{
|
|||
}else{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if(!$data){
|
||||
return "Player is not found.";
|
||||
}
|
||||
|
||||
|
||||
if($data instanceof Config){
|
||||
$achs = $data->get("achievements");
|
||||
}else{
|
||||
$achs = $data;
|
||||
}
|
||||
|
||||
|
||||
if(count($achs) <= 0){
|
||||
return "Player {$params[0]} unlocked 0 achievements";
|
||||
}
|
||||
$output = "Unlocked Achievements(".count($achs)."/".count(self::$achievements)."): ";
|
||||
$output = "Unlocked Achievements(" . count($achs) . "/" . count(self::$achievements) . "): ";
|
||||
foreach($achs as $achievement => $unlocked){
|
||||
if($unlocked && isset(self::$achievements[$achievement])){
|
||||
$info = self::$achievements[$achievement];
|
||||
$output .= "{$info["name"]}, ";
|
||||
}
|
||||
}
|
||||
return substr($output, 0, - 2);
|
||||
return substr($output, 0, -2);
|
||||
}
|
||||
|
||||
|
||||
public function init(){
|
||||
$this->server->api->console->register("ach", "<player>", [$this, "viewAchievements"]);
|
||||
$this->server->api->console->alias("getplayerachievements", "ach");
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ class BanAPI{
|
|||
private $ops;
|
||||
/** @var Config */
|
||||
private $bannedIPs;
|
||||
|
||||
|
||||
public $cmdWhitelist = [];//Command WhiteList
|
||||
|
||||
function __construct(){
|
||||
|
|
|
|||
|
|
@ -235,7 +235,7 @@ class BlockAPI{
|
|||
break;
|
||||
}
|
||||
$itemheld = $issuer->getSlot($issuer->slot);
|
||||
$output = self::getItem($itemheld->getID(), $itemheld->getMetadata())."";
|
||||
$output = self::getItem($itemheld->getID(), $itemheld->getMetadata()) . "";
|
||||
break;
|
||||
case "setblock":
|
||||
if(!($issuer instanceof Player)){
|
||||
|
|
@ -259,7 +259,7 @@ class BlockAPI{
|
|||
$output .= "Usage: /setblock <x> <y> <z> <block[:damage]>";
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
$level = $issuer->entity->level;
|
||||
$block = self::fromString($args[3])->getBlock();
|
||||
}
|
||||
|
|
@ -289,13 +289,13 @@ class BlockAPI{
|
|||
break;
|
||||
}else{
|
||||
$level->setBlock($pos, $block, true, false, true);
|
||||
$output .= "Placed $block in ".implode(", ", $coords).", w:".$level->getName();
|
||||
$output .= "Placed $block in " . implode(", ", $coords) . ", w:" . $level->getName();
|
||||
}
|
||||
break;
|
||||
case "give":
|
||||
$player = $this->server->api->player->get($args[0] ?? "");
|
||||
|
||||
if($player instanceof Player){
|
||||
|
||||
if($player instanceof Player){
|
||||
$item = self::fromString($args[1] ?? "");
|
||||
if(($player->gamemode & 0x01) === 0x01){
|
||||
return "Player is in creative mode.";
|
||||
|
|
@ -303,18 +303,18 @@ class BlockAPI{
|
|||
if($item->getID() === 0){
|
||||
return "You cannot give an air block to a player.";
|
||||
}
|
||||
|
||||
|
||||
if(!isset($args[2])){
|
||||
$item->count = $item->getMaxStackSize();
|
||||
}else{
|
||||
$item->count = (int) $args[2];
|
||||
}
|
||||
|
||||
|
||||
$player->addItem($item->getID(), $item->getMetadata(), $item->count);
|
||||
$output .= "Giving ".$item->count." of ".$item->getName()." (".$item->getID().":".$item->getMetadata().") to ".$player->username;
|
||||
$output .= "Giving " . $item->count . " of " . $item->getName() . " (" . $item->getID() . ":" . $item->getMetadata() . ") to " . $player->username;
|
||||
break;
|
||||
}else{
|
||||
$item = self::fromString($args[0] ?? "");
|
||||
$item = self::fromString($args[0] ?? "");
|
||||
if(!($issuer instanceof Player)){
|
||||
return "You cant give an item to a non-player.";
|
||||
}
|
||||
|
|
@ -334,7 +334,7 @@ class BlockAPI{
|
|||
}
|
||||
|
||||
$issuer->addItem($item->getID(), $item->getMetadata(), $item->count);
|
||||
$output .= "Giving ".$item->count." of ".$item->getName()." (".$item->getID().":".$item->getMetadata().") to ".$issuer->username;
|
||||
$output .= "Giving " . $item->count . " of " . $item->getName() . " (" . $item->getID() . ":" . $item->getMetadata() . ") to " . $issuer->username;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -412,7 +412,6 @@ class BlockAPI{
|
|||
return $this->cancelAction($target, $player, false);
|
||||
}
|
||||
|
||||
|
||||
if(is_array($drops) && ($player->gamemode & 0x01) === 0x00 and count($drops) > 0){
|
||||
foreach($drops as $drop){
|
||||
$this->server->api->entity->drop(new Position($target->x + 0.5, $target->y, $target->z + 0.5, $target->level), BlockAPI::getItem($drop[0] & 0xFFFF, $drop[1] & 0xFFFF, $drop[2]));
|
||||
|
|
@ -456,7 +455,7 @@ class BlockAPI{
|
|||
return $this->cancelAction($block, $player);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
StaticBlock::getBlock($target->getID())::interact($target->level, $target->x, $target->y, $target->z, $player);
|
||||
|
||||
if($target->isActivable === true){
|
||||
|
|
@ -501,14 +500,14 @@ class BlockAPI{
|
|||
$hand->position($block);
|
||||
//$face = -1;
|
||||
}
|
||||
|
||||
|
||||
if($hand->isSolid === true && ($hand->getID() != BED_BLOCK && $hand->getID() != CARPET)){
|
||||
$aabb = $hand->getAABB($block->level, $block->x, $block->y, $block->z);
|
||||
$playerbb = $player->entity->boundingBox;
|
||||
if(($aabb->maxX > $playerbb->minX && $aabb->minX < $playerbb->maxX) && ($aabb->maxY > ($playerbb->minY+0.21) && $aabb->minY < $playerbb->maxY) && ($aabb->maxZ > $playerbb->minZ && $aabb->minZ < $playerbb->maxZ)){
|
||||
if(($aabb->maxX > $playerbb->minX && $aabb->minX < $playerbb->maxX) && ($aabb->maxY > ($playerbb->minY + 0.21) && $aabb->minY < $playerbb->maxY) && ($aabb->maxZ > $playerbb->minZ && $aabb->minZ < $playerbb->maxZ)){
|
||||
return $this->cancelAction($block, $player, false); //Entity in block
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if($this->server->api->dhandle("player.block.place", ["player" => $player, "block" => $block, "target" => $target, "item" => $item]) === false){
|
||||
|
|
@ -537,14 +536,12 @@ class BlockAPI{
|
|||
return false;
|
||||
}
|
||||
$level = $block::onUpdate($pos->level, $pos->x, $pos->y, $pos->z, $type);
|
||||
|
||||
|
||||
return $level;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function blockUpdateAround(Position $pos, $type = BLOCK_UPDATE_NORMAL, $delay = false){
|
||||
|
||||
|
||||
if($type == BLOCK_UPDATE_NORMAL){
|
||||
try{
|
||||
throw new Exception("Deprecated: tried updating $pos using BLOCK_UPDATE_NORMAL.");
|
||||
|
|
@ -554,7 +551,7 @@ class BlockAPI{
|
|||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if($delay !== false){
|
||||
$this->scheduleBlockUpdate($pos->getSide(0), $delay, $type);
|
||||
$this->scheduleBlockUpdate($pos->getSide(1), $delay, $type);
|
||||
|
|
@ -576,7 +573,7 @@ class BlockAPI{
|
|||
if($delay < 0){
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
$index = $x . "." . $y . "." . $z . "." . $level->getName() . "." . $type;
|
||||
$delay = microtime(true) + $delay * 0.05;
|
||||
if(!isset($this->scheduledUpdates[$index])){
|
||||
|
|
@ -586,7 +583,7 @@ class BlockAPI{
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public function scheduleBlockUpdate(Position $pos, $delay, $type = BLOCK_UPDATE_SCHEDULED){
|
||||
$type = (int) $type;
|
||||
if($delay < 0){
|
||||
|
|
|
|||
|
|
@ -103,8 +103,6 @@ class ChatAPI{
|
|||
/**
|
||||
* @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 = [
|
||||
|
|
|
|||
|
|
@ -24,12 +24,12 @@ class ConsoleAPI{
|
|||
$this->register("defaultgamemode", "<mode>", [$this, "defaultCommands"]);
|
||||
|
||||
$this->server->api->console->alias("tps", "status");
|
||||
|
||||
|
||||
$this->cmdWhitelist("help");
|
||||
$this->cmdWhitelist("status");
|
||||
$this->cmdWhitelist("?");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Whitelists a CMD so everyone can issue it - Even non OPs.
|
||||
* @param string $cmd Command to Whitelist
|
||||
|
|
@ -37,7 +37,7 @@ class ConsoleAPI{
|
|||
public function cmdWhitelist($cmd){
|
||||
$this->server->api->ban->cmdWhitelist[strtolower(trim($cmd))] = true;
|
||||
}
|
||||
|
||||
|
||||
public function register($cmd, $help, $callback){
|
||||
if(!is_callable($callback)){
|
||||
return false;
|
||||
|
|
@ -272,19 +272,19 @@ class ConsoleAPI{
|
|||
}
|
||||
|
||||
public static function debug($msg){
|
||||
console("[DEBUG] ".$msg, true, true, 2);
|
||||
console("[DEBUG] " . $msg, true, true, 2);
|
||||
}
|
||||
public static function info($msg){
|
||||
console("[INFO] ".$msg);
|
||||
console("[INFO] " . $msg);
|
||||
}
|
||||
public static function notice($msg){
|
||||
console("[NOTICE] ".$msg);
|
||||
console("[NOTICE] " . $msg);
|
||||
}
|
||||
public static function warn($msg){
|
||||
console("[WARNING] ".$msg);
|
||||
console("[WARNING] " . $msg);
|
||||
}
|
||||
public static function error($msg){
|
||||
console("[ERROR] ".$msg);
|
||||
console("[ERROR] " . $msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,26 +8,25 @@ class EntityAPI{
|
|||
function __construct(){
|
||||
$this->entities = [];
|
||||
$this->server = ServerAPI::request();
|
||||
|
||||
|
||||
$this->serverSpawnAnimals = $this->server->api->getProperty("spawn-animals");
|
||||
$this->serverSpawnMobs = $this->server->api->getProperty("spawn-mobs");
|
||||
}
|
||||
|
||||
|
||||
public function init(){
|
||||
$this->server->api->console->register("summon", "<mob>", [$this, "commandHandler"]);
|
||||
$this->server->api->console->register("spawnmob", "<mob>", [$this, "commandHandler"]);
|
||||
$this->server->api->console->register("despawn", "", [$this, "CommandHandler"]);
|
||||
$this->server->api->console->register("entcnt", "", [$this, "CommandHandler"]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function commandHandler($cmd, $args, $issuer, $alias){
|
||||
$mob = [
|
||||
"chicken" => 10,
|
||||
"cow" => 11,
|
||||
"pig" => 12,
|
||||
"sheep" => 13,
|
||||
|
||||
|
||||
"zombie" => 32,
|
||||
"creeper" => 33,
|
||||
"skeleton" => 34,
|
||||
|
|
@ -37,7 +36,7 @@ class EntityAPI{
|
|||
$output = "";
|
||||
switch($cmd){
|
||||
case "entcnt":
|
||||
return "Total amount of entities: ". count($this->entities);
|
||||
return "Total amount of entities: " . count($this->entities);
|
||||
case "summon":
|
||||
case "spawnmob":
|
||||
if(!($issuer instanceof Player)){
|
||||
|
|
@ -46,24 +45,24 @@ class EntityAPI{
|
|||
if((count($args) < 1) or (count($args) > 3)){
|
||||
return "Usage: /$cmd <mob> [amount] [baby]";
|
||||
}
|
||||
|
||||
|
||||
if(is_int($args[0])) $type = $args[0];
|
||||
else $type = $mob[strtolower($args[0])] ?? 0;
|
||||
if($type < 10 || $type > 36){
|
||||
return "Unknown mob.";
|
||||
}
|
||||
$mobName = ucfirst(array_flip($mob)[$type]);
|
||||
|
||||
|
||||
if(((isset($args[1]) && strtolower($args[1]) === "baby") || (isset($args[2]) && strtolower($args[2]) === "baby")) && !Utils::in_range($type, 10, 13)){
|
||||
return "$mobName cannot be a baby!";
|
||||
}
|
||||
|
||||
|
||||
$x = round($issuer->entity->x, 2, PHP_ROUND_HALF_UP);
|
||||
$y = round($issuer->entity->y, 2, PHP_ROUND_HALF_UP);
|
||||
$z = round($issuer->entity->z, 2, PHP_ROUND_HALF_UP);
|
||||
$level = $issuer->entity->level;
|
||||
$pos = new Position($x, $y, $z, $level);
|
||||
|
||||
|
||||
if(count($args) === 1){//summon <mob>
|
||||
$this->summon($pos, ENTITY_MOB, $type);
|
||||
return "$mobName spawned in $x, $y, $z.";
|
||||
|
|
@ -77,12 +76,12 @@ class EntityAPI{
|
|||
if(isset($args[2]) and strtolower($args[2]) === 'baby'){//summon <mob> [amount] [baby]
|
||||
$isBaby = true;
|
||||
}
|
||||
|
||||
|
||||
for($cnt = $amount; $cnt > 0; --$cnt){
|
||||
$this->summon($pos, ENTITY_MOB, $type, ["IsBaby" => $isBaby]);
|
||||
}
|
||||
|
||||
return "$amount ".($isBaby ? "Baby " : "")."$mobName(s) spawned in $x, $y, $z.";
|
||||
|
||||
return "$amount " . ($isBaby ? "Baby " : "") . "$mobName(s) spawned in $x, $y, $z.";
|
||||
}
|
||||
elseif(strtolower($args[1]) == "baby"){//summon <mob> [baby]
|
||||
$this->summon($pos, ENTITY_MOB, $type, ["IsBaby" => 1]);
|
||||
|
|
@ -94,7 +93,7 @@ class EntityAPI{
|
|||
if(!isset($args[0])){
|
||||
return "/despawn <all|mobs|objects|items|fallings|minecarts>";
|
||||
}
|
||||
|
||||
|
||||
$despawnclass = 0;
|
||||
$despawntype = 0;
|
||||
switch($args[0]){
|
||||
|
|
@ -138,12 +137,12 @@ class EntityAPI{
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return "$cnt entities have been despawned!";
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
public function summon(Position $pos, $class, $type, array $data = []){
|
||||
$entity = $this->add($pos->level, $class, $type, [
|
||||
"x" => $pos->x,
|
||||
|
|
@ -152,16 +151,16 @@ class EntityAPI{
|
|||
] + $data);
|
||||
$this->spawnToAll($entity);
|
||||
}
|
||||
|
||||
|
||||
public function getNextEID(){
|
||||
return $this->eCnt++;
|
||||
}
|
||||
|
||||
|
||||
public function addRaw(Entity $e){
|
||||
$eid = $e->eid;
|
||||
$this->entities[$eid] = $e;
|
||||
$cX = (int)$this->entities[$eid]->x >> 4;
|
||||
$cZ = (int)$this->entities[$eid]->z >> 4;
|
||||
$cX = (int) $this->entities[$eid]->x >> 4;
|
||||
$cZ = (int) $this->entities[$eid]->z >> 4;
|
||||
$e->level->entityListPositioned["$cX $cZ"][$eid] = $eid;
|
||||
$e->level->entityList[$eid] = &$this->entities[$eid];
|
||||
$this->server->handle("entity.add", $this->entities[$eid]);
|
||||
|
|
@ -178,7 +177,7 @@ class EntityAPI{
|
|||
}
|
||||
return $this->addRaw($e);
|
||||
}
|
||||
|
||||
|
||||
public function spawnToAll(Entity $e){
|
||||
foreach($this->server->api->player->getAll($e->level) as $player){
|
||||
if($player->eid !== false and $player->eid !== $e->eid and $e->class !== ENTITY_PLAYER and $e instanceof Entity){
|
||||
|
|
@ -186,18 +185,18 @@ class EntityAPI{
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function get($eid){
|
||||
return $this->entities[$eid] ?? false;
|
||||
}
|
||||
|
||||
|
||||
public function remove($eid){
|
||||
if(isset($this->entities[$eid])){
|
||||
$level = $this->entities[$eid]->level;
|
||||
$this->entities[$eid]->closed = true;
|
||||
if($level instanceof Level){
|
||||
$cX = (int)$this->entities[$eid]->x >> 4;
|
||||
$cZ = (int)$this->entities[$eid]->z >> 4;
|
||||
$cX = (int) $this->entities[$eid]->x >> 4;
|
||||
$cZ = (int) $this->entities[$eid]->z >> 4;
|
||||
$index = "$cX $cZ";
|
||||
unset($level->entityListPositioned[$index][$eid]);
|
||||
if(isset($level->mobSpawner->entityAffectedPlayers[$eid])){
|
||||
|
|
@ -221,12 +220,12 @@ class EntityAPI{
|
|||
unset($this->entities[$eid]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function getRadius(Position $center, $radius = 15, $class = false){
|
||||
$minChunkX = ((int)($center->x - $radius)) >> 4;
|
||||
$minChunkZ = ((int)($center->z - $radius)) >> 4;
|
||||
$maxChunkX = ((int)($center->x + $radius)) >> 4;
|
||||
$maxChunkZ = ((int)($center->z + $radius)) >> 4;
|
||||
$minChunkX = ((int) ($center->x - $radius)) >> 4;
|
||||
$minChunkZ = ((int) ($center->z - $radius)) >> 4;
|
||||
$maxChunkX = ((int) ($center->x + $radius)) >> 4;
|
||||
$maxChunkZ = ((int) ($center->z + $radius)) >> 4;
|
||||
$ents = [];
|
||||
//TODO also index by chunkY?
|
||||
for($chunkX = $minChunkX; $chunkX <= $maxChunkX; ++$chunkX){
|
||||
|
|
@ -244,11 +243,11 @@ class EntityAPI{
|
|||
}
|
||||
return $ents;
|
||||
}
|
||||
|
||||
|
||||
public function heal($eid, $heal, $cause){
|
||||
$this->harm($eid, -$heal, $cause);
|
||||
}
|
||||
|
||||
|
||||
public function harm($eid, $attack, $cause, $force = false){
|
||||
$e = $this->get($eid);
|
||||
if($e === false or $e->dead === true){
|
||||
|
|
@ -256,7 +255,7 @@ class EntityAPI{
|
|||
}
|
||||
$e->setHealth($e->getHealth() - $attack, $cause, $force);
|
||||
}
|
||||
|
||||
|
||||
public function dropRawPos(Level $level, $x, $y, $z, $item, $speedX, $speedY, $speedZ){
|
||||
if($item->getID() === AIR or $item->count <= 0){
|
||||
return;
|
||||
|
|
@ -272,7 +271,7 @@ class EntityAPI{
|
|||
"item" => $item,
|
||||
"itemID" => $item->getID()
|
||||
];
|
||||
|
||||
|
||||
if($this->server->api->handle("item.drop", $data) !== false){
|
||||
for($count = $item->count; $count > 0;){
|
||||
$item->count = min($item->getMaxStackSize(), $count);
|
||||
|
|
@ -283,7 +282,7 @@ class EntityAPI{
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function drop(Position $pos, Item $item, $pickupDelay = 10){
|
||||
if($item->getID() === AIR or $item->count <= 0){
|
||||
return;
|
||||
|
|
@ -310,7 +309,7 @@ class EntityAPI{
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function spawnAll(Player $player){
|
||||
foreach($player->level->entityList as $e){
|
||||
if($e->class !== ENTITY_PLAYER){
|
||||
|
|
@ -318,18 +317,18 @@ class EntityAPI{
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function getAll($level = null){
|
||||
if($level instanceof Level){
|
||||
return $level->entityList;
|
||||
}
|
||||
return $this->entities;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated this function doesnt do anything
|
||||
*/
|
||||
public function updateRadius(Position $center, $radius = 15, $class = false){
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ class LevelAPI{
|
|||
console("[ERROR] Could not load level \"" . $name . "\"");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if(PocketMinecraftServer::$KEEP_CHUNKS_LOADED){
|
||||
for($X = 0; $X < 16; ++$X){
|
||||
for($Z = 0; $Z < 16; ++$Z){
|
||||
|
|
@ -48,8 +48,7 @@ class LevelAPI{
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
$entities = new Config($path . "entities.yml", CONFIG_YAML);
|
||||
if(file_exists($path . "tileEntities.yml")){
|
||||
@rename($path . "tileEntities.yml", $path . "tiles.yml");
|
||||
|
|
@ -61,13 +60,13 @@ class LevelAPI{
|
|||
if(!isset($entity["id"])){
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
$entity["x"] = $entity["Pos"][0];
|
||||
$entity["y"] = $entity["Pos"][1];
|
||||
$entity["z"] = $entity["Pos"][2];
|
||||
$entity["yaw"] = $entity["Rotation"][0];
|
||||
$entity["pitch"] = $entity["Rotation"][1];
|
||||
|
||||
|
||||
if($entity["id"] === 64){ //Item Drop
|
||||
$e = $this->server->api->entity->add($this->levels[$name], ENTITY_ITEM, ENTITY_ITEM_TYPE, [
|
||||
"meta" => $entity["Item"]["Damage"],
|
||||
|
|
@ -105,7 +104,7 @@ class LevelAPI{
|
|||
foreach($blockUpdates->getAll() as $bupdate){
|
||||
if($bupdate["type"] !== BLOCK_UPDATE_RANDOM) $this->server->api->block->scheduleBlockUpdate(new Position((int) $bupdate["x"], (int) $bupdate["y"], (int) $bupdate["z"], $this->levels[$name]), (float) $bupdate["delay"], (int) $bupdate["type"]);
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ class PlayerAPI{
|
|||
$this->registerCmd("ping");
|
||||
$this->registerCmd("loc");
|
||||
$this->registerCmd("hotbar", "<slotcount>");
|
||||
|
||||
|
||||
$this->server->api->console->alias("lag", "ping");
|
||||
$this->server->api->console->alias("gm", "gamemode");
|
||||
$this->server->api->console->alias("who", "list");
|
||||
|
|
@ -49,9 +49,9 @@ class PlayerAPI{
|
|||
if($e->shotByEntity && isset($this->server->api->entity->entities[$e->shooterEID]) && $this->server->api->entity->entities[$e->shooterEID] instanceof Entity){
|
||||
$message = " was shot by {$this->server->api->entity->entities[$e->shooterEID]->name}";
|
||||
}else{
|
||||
$message = " was shot";
|
||||
$message = " was shot";
|
||||
}
|
||||
|
||||
|
||||
}else{
|
||||
$message = " was killed by {$e->name}";
|
||||
}
|
||||
|
|
@ -104,12 +104,12 @@ class PlayerAPI{
|
|||
case "hotbar":
|
||||
if(!($issuer instanceof Player)) return "Please run this command in-game.";
|
||||
if(count($args) < 1) return "Slots in hotbar on server: {$issuer->slotCount}";
|
||||
|
||||
|
||||
$scrw = $args[0];
|
||||
if(is_numeric($scrw)){
|
||||
$sc = (int)$scrw;
|
||||
$sc = (int) $scrw;
|
||||
if($sc < 5 || $sc > 9) return "Slot count must be between 5 and 9.";
|
||||
|
||||
|
||||
$issuer->setSlotCount($sc);
|
||||
$issuer->sendInventory();
|
||||
return "Changed slot count to $sc";
|
||||
|
|
@ -235,10 +235,10 @@ class PlayerAPI{
|
|||
$level = $issuer->entity->level->getName();
|
||||
$compass = [0 => "X+", 1 => "Z+", 2 => "X-", 3 => "Z-", null => "null"];
|
||||
$direction = $compass[$issuer->entity->getDirection()];
|
||||
|
||||
|
||||
$xChunk = $x >> 4;
|
||||
$zChunk = $z >> 4;
|
||||
|
||||
|
||||
return "Your coordinates: X: $x ($xChunk), Y: $y, Z: $z ($zChunk), world: $level.\nDirection: $direction";
|
||||
}
|
||||
return $output;
|
||||
|
|
@ -462,7 +462,7 @@ class PlayerAPI{
|
|||
unset($player->entity->player);
|
||||
//unset($player->entity);
|
||||
}
|
||||
|
||||
|
||||
$player = null;
|
||||
unset($player);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -139,8 +139,8 @@ class PluginAPI extends stdClass{
|
|||
if($ext2 === "phar"){
|
||||
++$pharCnt;
|
||||
$pluginInfo = []; //TODO: A PluginInfo class?
|
||||
$filePath = $this->pluginsPath().$file;
|
||||
$p = new Phar($this->pluginsPath().$file, 0);
|
||||
$filePath = $this->pluginsPath() . $file;
|
||||
$p = new Phar($this->pluginsPath() . $file, 0);
|
||||
foreach (new RecursiveIteratorIterator($p) as $file) {
|
||||
$name = $file->getFileName();
|
||||
$content = file_get_contents($file->getPathName());
|
||||
|
|
@ -149,23 +149,23 @@ class PluginAPI extends stdClass{
|
|||
break;
|
||||
}
|
||||
}
|
||||
console("[INFO] Loading PHAR plugin \"".FORMAT_GREEN.$pluginInfo["name"].FORMAT_RESET."\" ".FORMAT_AQUA.$pluginInfo["version"].FORMAT_RESET." by ".FORMAT_AQUA.$pluginInfo["author"].FORMAT_RESET);
|
||||
|
||||
console("[INFO] Loading PHAR plugin \"" . FORMAT_GREEN . $pluginInfo["name"] . FORMAT_RESET . "\" " . FORMAT_AQUA . $pluginInfo["version"] . FORMAT_RESET . " by " . FORMAT_AQUA . $pluginInfo["author"] . FORMAT_RESET);
|
||||
|
||||
$aver = CURRENT_API_VERSION;
|
||||
if(!in_array((string) CURRENT_API_VERSION, $pluginInfo["api"])){
|
||||
if(!in_array((string) CURRENT_API_VERSION, $pluginInfo["api"])){
|
||||
if(is_array($pluginInfo)) $s = implode(",",$pluginInfo["api"]);
|
||||
else $s = $pluginInfo["api"];
|
||||
console("[WARNING] API is not the same as Core, might cause bugs({$s} != {$aver})");
|
||||
}
|
||||
|
||||
|
||||
$phr = "phar://$filePath/";
|
||||
include($phr."/src/".$pluginInfo["classLoader"]);
|
||||
include($phr . "/src/" . $pluginInfo["classLoader"]);
|
||||
$class = $pluginInfo["CLClass"];
|
||||
$loader = new $class();
|
||||
$loader->loadAll($phr);
|
||||
|
||||
|
||||
$pluginName = PharUtils::getNameSpaceClass($pluginInfo["mainFile"]);
|
||||
include($phr."/src/".$pluginInfo["mainFile"]);
|
||||
include($phr . "/src/" . $pluginInfo["mainFile"]);
|
||||
$plugin = new $pluginName($this->server->api, false);
|
||||
if(!($plugin instanceof Plugin)){
|
||||
console("[ERROR] Plugin \"" . $pluginInfo["name"] . "\" doesn't use the Plugin Interface");
|
||||
|
|
@ -268,7 +268,7 @@ class PluginAPI extends stdClass{
|
|||
$names[] = $p[1]["name"];
|
||||
$versions[] = $p[1]["version"];
|
||||
}
|
||||
|
||||
|
||||
foreach($this->plugins as $p){
|
||||
if($p[0] instanceof OtherPluginRequirement){
|
||||
foreach($p[0]->getRequiredPlugins() as $required){
|
||||
|
|
@ -312,4 +312,3 @@ class RequiredPluginEntry{ //Use this as object of requirements array
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ class ServerAPI{
|
|||
|
||||
private static $serverRequest = false;
|
||||
public $restart = false;
|
||||
|
||||
|
||||
/**
|
||||
* @var QueryAPI
|
||||
*/
|
||||
|
|
@ -59,7 +59,7 @@ class ServerAPI{
|
|||
* @var QueryHandler
|
||||
*/
|
||||
public $query;
|
||||
|
||||
|
||||
private $asyncCalls = [];
|
||||
private $server;
|
||||
private $config;
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ class TileAPI{
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public function invalidateAll(Level $level, $x, $y, $z){
|
||||
$x = (int) $x;
|
||||
$y = (int) $y;
|
||||
|
|
@ -31,14 +31,14 @@ class TileAPI{
|
|||
++$invcnt;
|
||||
$tl->close();
|
||||
}
|
||||
|
||||
|
||||
if($invcnt > 1){
|
||||
ConsoleAPI::warn("{$level->getName()}: ($x $y $z) has more than 1 tile entity! Invalidated ID {$t["ID"]} (Total invaliated: $invcnt)");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function get(Position $pos){
|
||||
$tile = $this->server->query("SELECT * FROM tiles WHERE level = '" . $pos->level->getName() . "' AND x = {$pos->x} AND y = {$pos->y} AND z = {$pos->z};", true);
|
||||
if($tile !== false and $tile !== true and ($tile = $this->getByID($tile["ID"])) !== false){
|
||||
|
|
|
|||
|
|
@ -175,5 +175,4 @@ class TimeAPI{
|
|||
return $this->set("sunset");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue