mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 19:49:44 +00:00
Configuration Base Class updated!
This commit is contained in:
parent
44e53ccc1b
commit
ac570213a5
5 changed files with 44 additions and 91 deletions
|
|
@ -285,7 +285,7 @@ class Player{
|
|||
break;
|
||||
}
|
||||
$o = $this->server->api->player->getOffline($this->username);
|
||||
if($this->server->whitelist !== false and (!in_array($this->username, $this->server->whitelist)/* or ($o["lastID"] != 0 and $o["lastID"] != $this->clientID)*/)){
|
||||
if($this->server->whitelist !== false and $this->server->whitelist->exists($this->username)){
|
||||
$this->close("\"\x1b[33m".$this->username."\x1b[0m\" not being on white-list", false);
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -132,10 +132,10 @@ class PocketMinecraftServer{
|
|||
}
|
||||
|
||||
public function reloadConfig(){
|
||||
if($this->whitelist === true or is_array($this->whitelist)){
|
||||
$this->whitelist = explode("\n", str_replace(array("\t","\r"), "", file_get_contents(FILE_PATH."white-list.txt")));
|
||||
if($this->whitelist === true or ($this->whitelist instanceof Config)){
|
||||
$this->whitelist = new Config(FILE_PATH."white-list.txt", CONFIG_LIST);
|
||||
}
|
||||
$this->bannedIPs = explode("\n", str_replace(array(" ","\t","\r"), "", file_get_contents(FILE_PATH."banned-ips.txt")));
|
||||
$this->bannedIPs = new Config(FILE_PATH."banned-ips.txt", CONFIG_LIST);
|
||||
}
|
||||
|
||||
public function debugInfo($console = false){
|
||||
|
|
@ -398,7 +398,7 @@ class PocketMinecraftServer{
|
|||
), false, $packet["ip"], $packet["port"]);
|
||||
break;
|
||||
}
|
||||
if(in_array($packet["ip"], $this->bannedIPs)){
|
||||
if($this->bannedIPs->exists($packet["ip"])){
|
||||
$this->send(0x1c, array(
|
||||
$data[0],
|
||||
$this->serverID,
|
||||
|
|
@ -422,7 +422,7 @@ class PocketMinecraftServer{
|
|||
$this->custom["times_".$CID] = ($this->custom["times_".$CID] + 1) % strlen($this->description);
|
||||
break;
|
||||
case 0x05:
|
||||
if(in_array($packet["ip"], $this->bannedIPs) or count($this->clients) >= $this->maxClients){
|
||||
if($this->bannedIPs->exists($packet["ip"]) or count($this->clients) >= $this->maxClients){
|
||||
$this->send(0x80, array(
|
||||
0,
|
||||
0x00,
|
||||
|
|
@ -458,7 +458,7 @@ class PocketMinecraftServer{
|
|||
}
|
||||
break;
|
||||
case 0x07:
|
||||
if(in_array($packet["ip"], $this->bannedIPs) or count($this->clients) >= $this->maxClients){
|
||||
if($this->bannedIPs->exists($packet["ip"]) or count($this->clients) >= $this->maxClients){
|
||||
$this->send(0x80, array(
|
||||
0,
|
||||
0x00,
|
||||
|
|
|
|||
|
|
@ -156,8 +156,16 @@ class Config{
|
|||
$this->config[$k] = $v;
|
||||
}
|
||||
|
||||
public function getAll(){
|
||||
return ($this->config);
|
||||
public function exists($k){
|
||||
return isset($this->config[$k]);
|
||||
}
|
||||
|
||||
public function remove($k){
|
||||
unset($this->config[$k]);
|
||||
}
|
||||
|
||||
public function getAll($keys = false){
|
||||
return ($keys === true ? array_keys($this->config):$this->config);
|
||||
}
|
||||
|
||||
private function fillDefaults($default, &$data){
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue