mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 11:39:43 +00:00
Some changes.
This commit is contained in:
parent
20c16068ec
commit
d6cc8415dc
30 changed files with 359 additions and 106 deletions
|
|
@ -145,6 +145,10 @@ class BanAPI{
|
|||
break;
|
||||
case "op":
|
||||
$user = strtolower($params[0]);
|
||||
if($user == NULL){
|
||||
$output .= "Usage: /op <player>\n";
|
||||
break;
|
||||
}
|
||||
$player = $this->server->api->player->get($user);
|
||||
if(!($player instanceof Player)){
|
||||
$this->ops->set($user);
|
||||
|
|
|
|||
|
|
@ -422,7 +422,7 @@ class BlockAPI{
|
|||
if($target->isReplaceable === true){
|
||||
$block = $target;
|
||||
$hand->position($block);
|
||||
$face = -1;
|
||||
//$face = -1;
|
||||
}
|
||||
|
||||
if($hand->isSolid === true and $player->entity->inBlock($block)){
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ class ConsoleAPI{
|
|||
|
||||
$max = ceil(count($cmds) / 5);
|
||||
$page = (int) (isset($params[0]) ? min($max, max(1, intval($params[0]))):1);
|
||||
$output .= "\x1b[31;1m-\x1b[0m Showing help page $page of $max (/help <page>) \x1b[31;1m-\x1b[0m\n";
|
||||
$output .= FORMAT_RED."-".FORMAT_RESET." Showing help page $page of $max (/help <page>) ".FORMAT_RED."-".FORMAT_RESET."\n";
|
||||
$current = 1;
|
||||
foreach($cmds as $c => $h){
|
||||
$curpage = (int) ceil($current / 5);
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ class EntityAPI{
|
|||
|
||||
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){
|
||||
if($player->eid !== false and $player->eid !== $e->eid and $e->class !== ENTITY_PLAYER and $e instanceof Entity){
|
||||
$e->spawn($player);
|
||||
}
|
||||
}
|
||||
|
|
@ -124,6 +124,7 @@ class EntityAPI{
|
|||
"x" => $pos->x + mt_rand(-10, 10) / 50,
|
||||
"y" => $pos->y + 0.19,
|
||||
"z" => $pos->z + mt_rand(-10, 10) / 50,
|
||||
"level" => $pos->level,
|
||||
//"speedX" => mt_rand(-3, 3) / 8,
|
||||
"speedY" => mt_rand(5, 8) / 2,
|
||||
//"speedZ" => mt_rand(-3, 3) / 8,
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ class PlayerAPI{
|
|||
$this->server->api->console->register("kill", "<player>", array($this, "commandHandler"));
|
||||
$this->server->api->console->register("gamemode", "<mode> [player]", array($this, "commandHandler"));
|
||||
$this->server->api->console->register("tp", "[target player] <destination player|w:world> OR /tp [target player] <x> <y> <z>", array($this, "commandHandler"));
|
||||
$this->server->api->console->register("spawnpoint", "[player] [x] [y] [z]", array($this, "commandHandler"));
|
||||
$this->server->api->console->register("setspawn", "[player] [x] [y] [z]", array($this, "commandHandler"));
|
||||
$this->server->api->console->register("spawn", "", array($this, "commandHandler"));
|
||||
$this->server->api->console->register("ping", "", array($this, "commandHandler"));
|
||||
$this->server->api->console->alias("lag", "ping");
|
||||
|
|
@ -118,7 +118,7 @@ class PlayerAPI{
|
|||
public function commandHandler($cmd, $params, $issuer, $alias){
|
||||
$output = "";
|
||||
switch($cmd){
|
||||
case "spawnpoint":
|
||||
case "setspawn":
|
||||
if(!($issuer instanceof Player)){
|
||||
$output .= "Please run this command in-game.\n";
|
||||
break;
|
||||
|
|
@ -306,17 +306,34 @@ class PlayerAPI{
|
|||
return false;
|
||||
}
|
||||
|
||||
public function get($name, $alike = true){
|
||||
public function get($name, $alike = true, $multiple = false){
|
||||
$name = trim(strtolower($name));
|
||||
if($name === ""){
|
||||
return false;
|
||||
}
|
||||
$CID = $this->server->query("SELECT ip,port FROM players WHERE name ".($alike === true ? "LIKE '%".$name."%'":"= '".$name."'").";", true);
|
||||
$CID = PocketMinecraftServer::clientID($CID["ip"], $CID["port"]);
|
||||
if(isset($this->server->clients[$CID])){
|
||||
return $this->server->clients[$CID];
|
||||
}
|
||||
return false;
|
||||
$query = $this->server->query("SELECT ip,port,name FROM players WHERE name ".($alike === true ? "LIKE '%".$name."%'":"= '".$name."'").";");
|
||||
$players = array();
|
||||
if($query !== false and $query !== true){
|
||||
while(($d = $query->fetchArray(SQLITE3_ASSOC)) !== false){
|
||||
$CID = PocketMinecraftServer::clientID($d["ip"], $d["port"]);
|
||||
if(isset($this->server->clients[$CID])){
|
||||
$players[$CID] = $this->server->clients[$CID];
|
||||
if($multiple === false and $d["name"] === $name){
|
||||
return $players[$CID];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($multiple === false){
|
||||
if(count($players) > 0){
|
||||
return array_shift($players);
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}else{
|
||||
return $players;
|
||||
}
|
||||
}
|
||||
|
||||
public function getAll($level = null){
|
||||
|
|
@ -429,7 +446,7 @@ class PlayerAPI{
|
|||
$this->server->query("DELETE FROM players WHERE name = '".$player->username."';");
|
||||
if($player->entity instanceof Entity){
|
||||
unset($player->entity->player);
|
||||
unset($player->entity);
|
||||
//unset($player->entity);
|
||||
}
|
||||
$this->server->api->entity->remove($player->eid);
|
||||
$player = null;
|
||||
|
|
@ -454,6 +471,7 @@ class PlayerAPI{
|
|||
"z" => $this->server->spawn->z,
|
||||
),
|
||||
"inventory" => array_fill(0, PLAYER_SURVIVAL_SLOTS, array(AIR, 0, 0)),
|
||||
"hotbar" => array(0, -1, -1, -1, -1, -1, -1, -1, -1),
|
||||
"armor" => array_fill(0, 4, array(AIR, 0)),
|
||||
"gamemode" => $this->server->gamemode,
|
||||
"health" => 20,
|
||||
|
|
|
|||
|
|
@ -28,6 +28,13 @@ class PluginAPI extends stdClass{
|
|||
$this->randomNonce = Utils::getRandomBytes(16, false);
|
||||
}
|
||||
|
||||
public function __destruct(){
|
||||
foreach($this->plugins as $p){
|
||||
$p[0]->__destruct();
|
||||
}
|
||||
unset($plugins);
|
||||
}
|
||||
|
||||
public function getList(){
|
||||
$list = array();
|
||||
foreach($this->plugins as $p){
|
||||
|
|
|
|||
|
|
@ -135,6 +135,7 @@ class ServerAPI{
|
|||
|
||||
$this->parseProperties();
|
||||
define("DEBUG", $this->getProperty("debug", 1));
|
||||
define("ADVANCED_CACHE", $this->getProperty("enable-advanced-cache", false));
|
||||
if($this->getProperty("port") !== false){
|
||||
$this->setProperty("server-port", $this->getProperty("port"));
|
||||
$this->config->remove("port");
|
||||
|
|
@ -146,6 +147,10 @@ class ServerAPI{
|
|||
console("[INFO] This server is running PocketMine-MP version ".($version->isDev() ? FORMAT_YELLOW:"").MAJOR_VERSION.FORMAT_RESET." \"".CODENAME."\" (MCPE: ".CURRENT_MINECRAFT_VERSION.") (API ".CURRENT_API_VERSION.")", true, true, 0);
|
||||
console("[INFO] PocketMine-MP is distibuted under the LGPL License", true, true, 0);
|
||||
|
||||
if(ADVANCED_CACHE == true){
|
||||
console("[INFO] Advanced cache enabled");
|
||||
}
|
||||
|
||||
if($this->getProperty("upnp-forwarding") === true){
|
||||
console("[INFO] [UPnP] Trying to port forward...");
|
||||
UPnP_PortForward($this->getProperty("server-port"));
|
||||
|
|
@ -290,7 +295,6 @@ class ServerAPI{
|
|||
$this->server->gamemode = $this->getProperty("gamemode");
|
||||
$this->server->difficulty = $this->getProperty("difficulty");
|
||||
$this->server->whitelist = $this->getProperty("white-list");
|
||||
$this->server->reloadConfig();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue