Update PocketMinecraftServer.php

This commit is contained in:
kotyara 2022-05-08 21:40:28 +00:00 • committed by GitHub
parent 5eb27cb742
commit 144dbf5cef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -73,9 +73,10 @@ class PocketMinecraftServer{
} }
console("[INFO] Loading extra.properties..."); console("[INFO] Loading extra.properties...");
$this->extraprops = new Config(DATA_PATH . "extra.properties", CONFIG_PROPERTIES, array( $this->extraprops = new Config(DATA_PATH . "extra.properties", CONFIG_PROPERTIES, array(
"version" => "2", "version" => "3",
"save-player-data" => true, "save-player-data" => true,
"save-console-data" => true, "save-console-data" => true,
"query-plugins" => false,
"discord-msg" => false, "discord-msg" => false,
"discord-webhook-url" => "none", "discord-webhook-url" => "none",
"discord-bot-name" => "NostalgiaCore Logger" "discord-bot-name" => "NostalgiaCore Logger"
@ -90,7 +91,7 @@ class PocketMinecraftServer{
} }
} elseif($this->extraprops->get("version") == null){ } elseif($this->extraprops->get("version") == null){
console("[WARNING] Your extra.properties file is corrupted!"); console("[WARNING] Your extra.properties file is corrupted!");
console("To fix it - just remove it! Server will generate it automatically."); console("To fix it - just remove it! Server will generate it again automatically.");
} }
$dolog = $this->extraprops->get("save-console-data"); $dolog = $this->extraprops->get("save-console-data");
} }
@ -716,15 +717,9 @@ class PocketMinecraftServer{
$url = $this->extraprops->get("discord-webhook-url"); $url = $this->extraprops->get("discord-webhook-url");
$name = $this->extraprops->get("discord-bot-name"); $name = $this->extraprops->get("discord-bot-name");
$headers = [ 'Content-Type: application/json; charset=utf-8' ]; $headers = [ 'Content-Type: application/json; charset=utf-8' ];
$POST = [ 'username' => $name, 'content' => str_replace("@", "", $msg)]; $POST = [ 'username' => $name, 'content' => $msg];
$ch = curl_init(); include_once('discord.php');
curl_setopt($ch, CURLOPT_URL, $url); discord::run($url, $headers, $POST);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($POST));
$response = curl_exec($ch);
} }
} }
} }