summaryrefslogtreecommitdiffstats
path: root/MCServer/Plugins/Core
diff options
context:
space:
mode:
authorfaketruth <faketruth@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-08-20 21:10:19 +0200
committerfaketruth <faketruth@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-08-20 21:10:19 +0200
commit9a08f3dc599f7bb193ed16cddebc533e8e63c159 (patch)
treea8a98d930f8d52afe794c097b7f08d0c72dab0d9 /MCServer/Plugins/Core
parentCan now edit some generic server settings through the WebAdmin (port, description, etc) (diff)
downloadcuberite-9a08f3dc599f7bb193ed16cddebc533e8e63c159.tar
cuberite-9a08f3dc599f7bb193ed16cddebc533e8e63c159.tar.gz
cuberite-9a08f3dc599f7bb193ed16cddebc533e8e63c159.tar.bz2
cuberite-9a08f3dc599f7bb193ed16cddebc533e8e63c159.tar.lz
cuberite-9a08f3dc599f7bb193ed16cddebc533e8e63c159.tar.xz
cuberite-9a08f3dc599f7bb193ed16cddebc533e8e63c159.tar.zst
cuberite-9a08f3dc599f7bb193ed16cddebc533e8e63c159.zip
Diffstat (limited to 'MCServer/Plugins/Core')
-rw-r--r--MCServer/Plugins/Core/web_serversettings.lua53
1 files changed, 48 insertions, 5 deletions
diff --git a/MCServer/Plugins/Core/web_serversettings.lua b/MCServer/Plugins/Core/web_serversettings.lua
index 4e4901f4c..4f33f53ff 100644
--- a/MCServer/Plugins/Core/web_serversettings.lua
+++ b/MCServer/Plugins/Core/web_serversettings.lua
@@ -1,5 +1,3 @@
-local CurrentlyEditingIni = nil
-
-- Some HTML helper functions
local function HTML_Option( value, text, selected )
if( selected == true ) then
@@ -68,9 +66,9 @@ local function ShowGeneralSettings( Request )
Content = Content .. "<th colspan=\"2\">Authentication</th>"
Content = Content .. "<tr><td style=\"width: 50%;\">Authenticate:</td>"
Content = Content .. "<td>" .. HTML_Select_On_Off("Authentication_Authenticate", SettingsIni:GetValueI("Authentication", "Authenticate") ) .. "</td></tr>"
- Content = Content .. "</table>"
+ Content = Content .. "</table><br>"
- Content = Content .. "<input type=\"submit\" value=\"Save Settings\" name=\"general_submit\"> WARNING: Any changes made here might require a server restart to be applied!"
+ Content = Content .. "<input type=\"submit\" value=\"Save Settings\" name=\"general_submit\"> WARNING: Any changes made here might require a server restart in order to be applied!"
Content = Content .. "</form>"
return Content
@@ -78,7 +76,52 @@ end
local function ShowMonstersSettings( Request )
- return "<p><b>Monsters Settings</b></p>"
+ local Content = ""
+ local InfoMsg = nil
+
+ local SettingsIni = cIniFile("settings.ini")
+ if( SettingsIni:ReadFile() == false ) then
+ InfoMsg = "<b style=\"color: red;\">ERROR: Could not read settings.ini!</b>"
+ end
+
+ if( Request.PostParams["monsters_submit"] ~= nil ) then
+
+ if( tonumber( Request.PostParams["Monsters_AnimalsOn"] ) ~= nil ) then
+ SettingsIni:SetValue("Monsters", "AnimalsOn", Request.PostParams["Monsters_AnimalsOn"], false )
+ end
+ if( tonumber( Request.PostParams["Monsters_AnimalSpawnInterval"] ) ~= nil ) then
+ SettingsIni:SetValue("Monsters", "AnimalSpawnInterval", Request.PostParams["Monsters_AnimalSpawnInterval"], false )
+ end
+ SettingsIni:SetValue("Monsters", "Types", Request.PostParams["Monsters_Types"], false )
+ if( SettingsIni:WriteFile() == false ) then
+ InfoMsg = "<b style=\"color: red;\">ERROR: Could not write to settings.ini!</b>"
+ else
+ InfoMsg = "<b style=\"color: green;\">INFO: Successfully saved changes to settings.ini</b>"
+ end
+ end
+
+
+ Content = Content .. "<form method=\"POST\">"
+
+ Content = Content .. "<p><b>Monsters Settings</b></p>"
+ if( InfoMsg ~= nil ) then
+ Content = Content .. "<p>" .. InfoMsg .. "</p>"
+ end
+
+ Content = Content .. "<table>"
+ Content = Content .. "<th colspan=\"2\">Monsters</th>"
+ Content = Content .. "<tr><td style=\"width: 50%;\">Animals On:</td>"
+ Content = Content .. "<td>" .. HTML_Select_On_Off("Monsters_AnimalsOn", SettingsIni:GetValueI("Monsters", "AnimalsOn") ) .. "</td></tr>"
+ Content = Content .. "<tr><td>Animal Spawn Interval:</td>"
+ Content = Content .. "<td><input type=\"text\" name=\"Monsters_AnimalSpawnInterval\" value=\"" .. SettingsIni:GetValue("Monsters", "AnimalSpawnInterval") .. "\"></td></tr>"
+ Content = Content .. "<tr><td>Monster Types:</td>"
+ Content = Content .. "<td><input type=\"text\" name=\"Monsters_Types\" value=\"" .. SettingsIni:GetValue("Monsters", "Types") .. "\"></td></tr>"
+ Content = Content .. "</table><br>"
+
+ Content = Content .. "<input type=\"submit\" value=\"Save Settings\" name=\"monsters_submit\"> WARNING: Any changes made here might require a server restart in order to be applied!"
+ Content = Content .. "</form>"
+
+ return Content
end
local function ShowWorldsSettings( Request )