mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-24 13:39:44 +00:00
added ability to add comments for entries in .properties files, deleted experimental-mob-ai since it does nothing
This commit is contained in:
parent
8046d0e17c
commit
2a827c42c4
4 changed files with 65 additions and 9 deletions
|
|
@ -137,6 +137,16 @@ class ServerAPI{
|
||||||
"auto-save" => true,
|
"auto-save" => true,
|
||||||
"enable-mob-ai" => true,
|
"enable-mob-ai" => true,
|
||||||
"abort-reading-after-N-packets" => PocketMinecraftServer::$PACKET_READING_LIMIT
|
"abort-reading-after-N-packets" => PocketMinecraftServer::$PACKET_READING_LIMIT
|
||||||
|
], comments: [
|
||||||
|
"level-type" => [
|
||||||
|
"Alowed types:",
|
||||||
|
"FLAT - flat world",
|
||||||
|
"DEFAULT - use one of the 4 pregenerated worlds from pocketmine",
|
||||||
|
"VANILLA - unfinished, attempts to generate vanilla 0.8.1 world. This geneeator is very slow."
|
||||||
|
],
|
||||||
|
"abort-reading-after-N-packets" => [
|
||||||
|
"Sets max amount of packets the server can read before forcing tick check."
|
||||||
|
]
|
||||||
]);
|
]);
|
||||||
Entity::$allowFly = $this->getProperty("allow-flight", true);
|
Entity::$allowFly = $this->getProperty("allow-flight", true);
|
||||||
if(!Entity::$allowFly){
|
if(!Entity::$allowFly){
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,6 @@ class PocketMinecraftServer{
|
||||||
"discord-bot-name" => "NostalgiaCore Logger",
|
"discord-bot-name" => "NostalgiaCore Logger",
|
||||||
"despawn-mobs" => true,
|
"despawn-mobs" => true,
|
||||||
"mob-despawn-ticks" => 18000,
|
"mob-despawn-ticks" => 18000,
|
||||||
"experimental-mob-ai" => false,
|
|
||||||
"force-20-tps" => false,
|
"force-20-tps" => false,
|
||||||
"enable-mob-pushing" => Living::$entityPushing,
|
"enable-mob-pushing" => Living::$entityPushing,
|
||||||
"keep-chunks-loaded" => self::$KEEP_CHUNKS_LOADED,
|
"keep-chunks-loaded" => self::$KEEP_CHUNKS_LOADED,
|
||||||
|
|
@ -106,6 +105,42 @@ class PocketMinecraftServer{
|
||||||
"allow-dropping-single-items" => Player::$allowDroppingSingleItems,
|
"allow-dropping-single-items" => Player::$allowDroppingSingleItems,
|
||||||
"enable-light-updates" => self::$ENABLE_LIGHT_UPDATES,
|
"enable-light-updates" => self::$ENABLE_LIGHT_UPDATES,
|
||||||
"min-block-breaking-progress" => self::$BLOCK_BREAKING_PROGRESS,
|
"min-block-breaking-progress" => self::$BLOCK_BREAKING_PROGRESS,
|
||||||
|
], comments: [
|
||||||
|
"min-block-breaking-progress" => [
|
||||||
|
"Affects how strict block breaking speed check is.",
|
||||||
|
"0 - allow blocks to be mined instantly",
|
||||||
|
"0.8 - allow breaking blocks after 80% of vanilla block break time.",
|
||||||
|
"The value should be in range from 0 to 1."
|
||||||
|
],
|
||||||
|
"enable-light-updates" => [
|
||||||
|
"Enabling light updates may affects performance and will increase world generation time.",
|
||||||
|
"Disabling light updates will disable all light-related features(like light-based mob spawning)"
|
||||||
|
],
|
||||||
|
"allow-dropping-single-items" => [
|
||||||
|
"Allows players to drop any amount of items from stack in the slot.",
|
||||||
|
"While it is not possible using vanilla client, some custom clients(like Ninecraft) have this feature"
|
||||||
|
],
|
||||||
|
"disable-emojis-in-chat" => [
|
||||||
|
"Disallows players to send certain symbols in chat to prevent client lags"
|
||||||
|
],
|
||||||
|
"use-experimental-hotbar" => [
|
||||||
|
"Changes serverside hotbar behavior to be more like in 0.8 rather than 0.7(when disabled)",
|
||||||
|
"May cause more problems than old hotbar"
|
||||||
|
],
|
||||||
|
"enable-mob-pushing" => [
|
||||||
|
"Enables or disables serverside mob pushing",
|
||||||
|
"If enabled it may cause performance issues when there are a lot of mobs in a small enclosed area",
|
||||||
|
"If disabled it will cause small entity position desync(that should be fixed every time a server sends a new movement packet to the client)"
|
||||||
|
],
|
||||||
|
"force-20-tps" => [
|
||||||
|
"Forces server to run at 20 tps on some platforms where sleeping for small amount of time is not possible(hi windows & 16 tps)",
|
||||||
|
],
|
||||||
|
"discord-ru-smiles" => [
|
||||||
|
"Replaces cyrillic symbols Ы Ь Ъ Ё with emojis when sending a message using discord webhook(as it is done in some custom clients)"
|
||||||
|
],
|
||||||
|
"keep-chunks-loaded" => [
|
||||||
|
"If disabled chunks won't be loaded into memory until the player(or something else) loads them"
|
||||||
|
]
|
||||||
]);
|
]);
|
||||||
self::$BLOCK_BREAKING_PROGRESS = $this->extraprops->get("min-block-breaking-progress");
|
self::$BLOCK_BREAKING_PROGRESS = $this->extraprops->get("min-block-breaking-progress");
|
||||||
Player::$disableEmojisInChat = $this->extraprops->get("disable-emojis-in-chat");
|
Player::$disableEmojisInChat = $this->extraprops->get("disable-emojis-in-chat");
|
||||||
|
|
@ -120,7 +155,6 @@ class PocketMinecraftServer{
|
||||||
self::$KEEP_CHUNKS_LOADED = $this->extraprops->get("keep-chunks-loaded");
|
self::$KEEP_CHUNKS_LOADED = $this->extraprops->get("keep-chunks-loaded");
|
||||||
self::$ENABLE_LIGHT_UPDATES = $this->extraprops->get("enable-light-updates");
|
self::$ENABLE_LIGHT_UPDATES = $this->extraprops->get("enable-light-updates");
|
||||||
PocketMinecraftServer::$SAVE_PLAYER_DATA = $this->extraprops->get("save-player-data");
|
PocketMinecraftServer::$SAVE_PLAYER_DATA = $this->extraprops->get("save-player-data");
|
||||||
MobController::$ADVANCED = $this->extraprops->get("experimental-mob-ai");
|
|
||||||
Explosion::$enableExplosions = $this->extraprops->get("enable-explosions");
|
Explosion::$enableExplosions = $this->extraprops->get("enable-explosions");
|
||||||
NetherReactorBlock::$enableReactor = $this->extraprops->get("enable-nether-reactor");
|
NetherReactorBlock::$enableReactor = $this->extraprops->get("enable-nether-reactor");
|
||||||
if(self::$FORCE_20_TPS){
|
if(self::$FORCE_20_TPS){
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
class MobController
|
class MobController
|
||||||
{
|
{
|
||||||
public static $ADVANCED = false;
|
|
||||||
public static $AUTOJUMP = false;
|
public static $AUTOJUMP = false;
|
||||||
public static $landed = false;
|
public static $landed = false;
|
||||||
public static $DANGEROUS_BLOCKS = [
|
public static $DANGEROUS_BLOCKS = [
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,9 @@ class Config{
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private $config;
|
private $config;
|
||||||
|
|
||||||
|
private $comments;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
|
|
@ -54,8 +57,8 @@ class Config{
|
||||||
* @param array $default
|
* @param array $default
|
||||||
* @param null|boolean $correct
|
* @param null|boolean $correct
|
||||||
*/
|
*/
|
||||||
public function __construct($file, $type = CONFIG_DETECT, $default = [], &$correct = null){
|
public function __construct($file, $type = CONFIG_DETECT, $default = [], &$correct = null, $comments = []){
|
||||||
$this->load($file, $type, $default);
|
$this->load($file, $type, $default, comments:$comments);
|
||||||
$correct = $this->check();
|
$correct = $this->check();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -66,13 +69,14 @@ class Config{
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function load($file, $type = CONFIG_DETECT, $default = []){
|
public function load($file, $type = CONFIG_DETECT, $default = [], $comments = []){
|
||||||
$this->correct = true;
|
$this->correct = true;
|
||||||
$this->type = (int) $type;
|
$this->type = (int) $type;
|
||||||
$this->file = $file;
|
$this->file = $file;
|
||||||
if(!is_array($default)){
|
if(!is_array($default)){
|
||||||
$default = [];
|
$default = [];
|
||||||
}
|
}
|
||||||
|
$this->comments = $comments;
|
||||||
if(!file_exists($file)){
|
if(!file_exists($file)){
|
||||||
$this->config = $default;
|
$this->config = $default;
|
||||||
$this->save();
|
$this->save();
|
||||||
|
|
@ -113,9 +117,8 @@ class Config{
|
||||||
if(!is_array($this->config)){
|
if(!is_array($this->config)){
|
||||||
$this->config = $default;
|
$this->config = $default;
|
||||||
}
|
}
|
||||||
if($this->fillDefaults($default, $this->config) > 0){
|
$this->fillDefaults($default, $this->config);
|
||||||
$this->save();
|
$this->save();
|
||||||
}
|
|
||||||
}else{
|
}else{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -158,6 +161,16 @@ class Config{
|
||||||
private function writeProperties(){
|
private function writeProperties(){
|
||||||
$content = "#Properties Config file\r\n#" . date("D M j H:i:s T Y") . "\r\n";
|
$content = "#Properties Config file\r\n#" . date("D M j H:i:s T Y") . "\r\n";
|
||||||
foreach($this->config as $k => $v){
|
foreach($this->config as $k => $v){
|
||||||
|
//evil \r\n
|
||||||
|
if(isset($this->comments[$k])){
|
||||||
|
$com = $this->comments[$k];
|
||||||
|
$gen = "";
|
||||||
|
if(!is_array($com)) $gen .= "#$com\r\n";
|
||||||
|
else{
|
||||||
|
foreach($com as $lin) $gen .= "#$lin\r\n";
|
||||||
|
}
|
||||||
|
$content .= $gen;
|
||||||
|
}
|
||||||
if(is_bool($v) === true){
|
if(is_bool($v) === true){
|
||||||
$v = $v === true ? "on" : "off";
|
$v = $v === true ? "on" : "off";
|
||||||
}elseif(is_array($v)){
|
}elseif(is_array($v)){
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue