From 983d87e44356c4cfc8f8908ec365006323a4dbe0 Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Sat, 27 Jul 2013 16:24:03 +0100 Subject: Added correct core plugin --- MCServer/Plugins/Core/README.md | 23 + MCServer/Plugins/Core/back.lua | 9 + MCServer/Plugins/Core/ban-unban.lua | 60 ++ MCServer/Plugins/Core/console.lua | 288 +++++++++ MCServer/Plugins/Core/functions.lua | 3 + MCServer/Plugins/Core/give.lua | 39 ++ MCServer/Plugins/Core/gm.lua | 8 + MCServer/Plugins/Core/help.lua | 41 ++ MCServer/Plugins/Core/itemrepair.lua | 202 ++++++ MCServer/Plugins/Core/kick.lua | 42 ++ MCServer/Plugins/Core/locate.lua | 4 + MCServer/Plugins/Core/main.lua | 173 +++++ MCServer/Plugins/Core/motd.lua | 97 +++ MCServer/Plugins/Core/onbreakplaceblock.lua | 115 ++++ MCServer/Plugins/Core/onchunkgenerating.lua | 16 + MCServer/Plugins/Core/ondeath.lua | 65 ++ MCServer/Plugins/Core/onlogin.lua | 19 + MCServer/Plugins/Core/playerjoin.lua | 5 + MCServer/Plugins/Core/playerlist.lua | 14 + MCServer/Plugins/Core/plugins.lua | 15 + MCServer/Plugins/Core/portal-worlds.lua | 36 ++ MCServer/Plugins/Core/rank-groups.lua | 48 ++ MCServer/Plugins/Core/regen.lua | 18 + MCServer/Plugins/Core/save-reload-stop.lua | 19 + MCServer/Plugins/Core/spawn.lua | 7 + MCServer/Plugins/Core/teleport.lua | 38 ++ MCServer/Plugins/Core/time.lua | 23 + MCServer/Plugins/Core/top.lua | 11 + MCServer/Plugins/Core/viewdistance.lua | 10 + MCServer/Plugins/Core/weather.lua | 10 + MCServer/Plugins/Core/web_chat.lua | 157 +++++ MCServer/Plugins/Core/web_manageplugins.lua | 157 +++++ MCServer/Plugins/Core/web_manageserver.lua | 35 + MCServer/Plugins/Core/web_permissions.lua | 134 ++++ MCServer/Plugins/Core/web_playerlist.lua | 38 ++ MCServer/Plugins/Core/web_serversettings.lua | 924 +++++++++++++++++++++++++++ MCServer/Plugins/Core/web_whitelist.lua | 79 +++ MCServer/Plugins/Core/webadmin/backup.html | 375 +++++++++++ MCServer/Plugins/Core/webadmin/template.html | 152 +++++ MCServer/Plugins/Core/worldlimiter.lua | 21 + 40 files changed, 3530 insertions(+) create mode 100644 MCServer/Plugins/Core/README.md create mode 100644 MCServer/Plugins/Core/back.lua create mode 100644 MCServer/Plugins/Core/ban-unban.lua create mode 100644 MCServer/Plugins/Core/console.lua create mode 100644 MCServer/Plugins/Core/functions.lua create mode 100644 MCServer/Plugins/Core/give.lua create mode 100644 MCServer/Plugins/Core/gm.lua create mode 100644 MCServer/Plugins/Core/help.lua create mode 100644 MCServer/Plugins/Core/itemrepair.lua create mode 100644 MCServer/Plugins/Core/kick.lua create mode 100644 MCServer/Plugins/Core/locate.lua create mode 100644 MCServer/Plugins/Core/main.lua create mode 100644 MCServer/Plugins/Core/motd.lua create mode 100644 MCServer/Plugins/Core/onbreakplaceblock.lua create mode 100644 MCServer/Plugins/Core/onchunkgenerating.lua create mode 100644 MCServer/Plugins/Core/ondeath.lua create mode 100644 MCServer/Plugins/Core/onlogin.lua create mode 100644 MCServer/Plugins/Core/playerjoin.lua create mode 100644 MCServer/Plugins/Core/playerlist.lua create mode 100644 MCServer/Plugins/Core/plugins.lua create mode 100644 MCServer/Plugins/Core/portal-worlds.lua create mode 100644 MCServer/Plugins/Core/rank-groups.lua create mode 100644 MCServer/Plugins/Core/regen.lua create mode 100644 MCServer/Plugins/Core/save-reload-stop.lua create mode 100644 MCServer/Plugins/Core/spawn.lua create mode 100644 MCServer/Plugins/Core/teleport.lua create mode 100644 MCServer/Plugins/Core/time.lua create mode 100644 MCServer/Plugins/Core/top.lua create mode 100644 MCServer/Plugins/Core/viewdistance.lua create mode 100644 MCServer/Plugins/Core/weather.lua create mode 100644 MCServer/Plugins/Core/web_chat.lua create mode 100644 MCServer/Plugins/Core/web_manageplugins.lua create mode 100644 MCServer/Plugins/Core/web_manageserver.lua create mode 100644 MCServer/Plugins/Core/web_permissions.lua create mode 100644 MCServer/Plugins/Core/web_playerlist.lua create mode 100644 MCServer/Plugins/Core/web_serversettings.lua create mode 100644 MCServer/Plugins/Core/web_whitelist.lua create mode 100644 MCServer/Plugins/Core/webadmin/backup.html create mode 100644 MCServer/Plugins/Core/webadmin/template.html create mode 100644 MCServer/Plugins/Core/worldlimiter.lua (limited to 'MCServer/Plugins/Core') diff --git a/MCServer/Plugins/Core/README.md b/MCServer/Plugins/Core/README.md new file mode 100644 index 000000000..d840459a0 --- /dev/null +++ b/MCServer/Plugins/Core/README.md @@ -0,0 +1,23 @@ +Core Plugin (Forked) +=========== + +A fork of MCServer's Core plugin. + +**New Features:** +* Simplified commands, such as 'gotoworld' -> 'portal' +* Simplified and combined LUA files, such as 'listworlds.lua & gotoworld.lua' -> 'worlds-portal.lua' +* Fixed 'tp' command not working due to typography errors +* Fixed 'arithmetic on nil value' on startup due to inactivation of world limiter +* Massive overhaul / redesign of webadmin GUI interface. + * Added jQuery transition effect + * Completely redesigned CSS + * Added new logo + * Made HTML5 compliant +* Beautified 'help' menu +* Rewrite of death messages - fixed strange grammar and edited to more faithfully reflect Vanilla +* Added 'unban' console command + +**How to Use** + +Simply copy all LUA files into Plugins/Core (delete existing files first, except banned.ini and whitelist.ini!) +Then, copy webadmin to MCServer root directory (delete existing directory first!) diff --git a/MCServer/Plugins/Core/back.lua b/MCServer/Plugins/Core/back.lua new file mode 100644 index 000000000..cc215ba11 --- /dev/null +++ b/MCServer/Plugins/Core/back.lua @@ -0,0 +1,9 @@ +function HandleBackCommand( Split, Player ) + if BackCoords[Player:GetName()] == nil then + Player:SendMessage(cChatColor.Green .. "There is no last position known") + else + Player:TeleportToCoords(BackCoords[Player:GetName()].x, BackCoords[Player:GetName()].y, BackCoords[Player:GetName()].z) + Player:SendMessage(cChatColor.Green .. "You teleported back to your last known position") + end + return true +end \ No newline at end of file diff --git a/MCServer/Plugins/Core/ban-unban.lua b/MCServer/Plugins/Core/ban-unban.lua new file mode 100644 index 000000000..cee511e37 --- /dev/null +++ b/MCServer/Plugins/Core/ban-unban.lua @@ -0,0 +1,60 @@ +function HandleBanCommand( Split, Player ) + if( #Split < 2 ) then + Player:SendMessage( cChatColor.Green .. "Usage: /ban [Player] " ) + return true + end + + local Reason = "You have been banned" + if( #Split > 2 ) then + Reason = table.concat(Split, " ", 3) + end + + if( BanPlayer(Split[2], Reason) == false ) then + Player:SendMessage( cChatColor.Green .. "Could not find player " .. Split[2] ) + return true + end + + return true +end + +function BanPlayer(PlayerName, Reason) + -- Ban the player in the banned.ini: + BannedPlayersIni:SetValueB("Banned", PlayerName, true) + BannedPlayersIni:WriteFile() + + -- Kick the player: + if (Reason == nil) then + Reason = "You have been banned" + end + local Success = KickPlayer(PlayerName, Reason) + if (not(Success)) then + return false; + end + + LOGINFO("'" .. PlayerName .. "' has been banned (\"" .. Reason .. "\") "); + local Server = cRoot:Get():GetServer(); + Server:SendMessage("Banned " .. PlayerName); + + return true +end + +function HandleUnbanCommand( Split, Player ) + if( #Split < 2 ) then + Player:SendMessage( cChatColor.Green .. "Usage: /unban [Player]" ) + return true + end + + if( BannedPlayersIni:GetValueB("Banned", Split[2], false) == false ) then + Player:SendMessage( cChatColor.Green .. Split[2] .. " is not banned!" ) + return true + end + + BannedPlayersIni:SetValueB("Banned", Split[2], false, false) + BannedPlayersIni:WriteFile() + + local Server = cRoot:Get():GetServer() + LOGINFO( Player:GetName() .. " is unbanning " .. Split[2] ) + Server:SendMessage( "Unbanning " .. Split[2] ) + + return true +end \ No newline at end of file diff --git a/MCServer/Plugins/Core/console.lua b/MCServer/Plugins/Core/console.lua new file mode 100644 index 000000000..b1c454d59 --- /dev/null +++ b/MCServer/Plugins/Core/console.lua @@ -0,0 +1,288 @@ +-- Implements things related to console commands + +function InitConsoleCommands() + local PluginMgr = cPluginManager:Get(); + + -- Please keep the list alpha-sorted + PluginMgr:BindConsoleCommand("ban", HandleConsoleBan, "Bans a player by name"); + PluginMgr:BindConsoleCommand("unban", HandleConsoleUnban, "Unbans a player by name"); + PluginMgr:BindConsoleCommand("banlist", HandleConsoleBanList, "Lists all players banned by name"); + PluginMgr:BindConsoleCommand("banlist ips", HandleConsoleBanList, "Lists all players banned by IP"); + PluginMgr:BindConsoleCommand("help", HandleConsoleHelp, "Lists all commands"); + PluginMgr:BindConsoleCommand("list", HandleConsoleList, "Lists all players in a machine-readable format"); + PluginMgr:BindConsoleCommand("listgroups", HandleConsoleListGroups, "Shows a list of all the groups"); + PluginMgr:BindConsoleCommand("numchunks", HandleConsoleNumChunks, "Shows number of chunks currently loaded"); + PluginMgr:BindConsoleCommand("players", HandleConsolePlayers, "Lists all connected players"); + PluginMgr:BindConsoleCommand("primaryserverversion", HandleConsolePrimaryServerVersion, "Gets or sets server version reported to 1.4+ clients"); + PluginMgr:BindConsoleCommand("rank", HandleConsoleRank, " [Player] [Group] - add a player to a group"); + PluginMgr:BindConsoleCommand("reload", HandleConsoleReload, "Reloads all plugins"); + PluginMgr:BindConsoleCommand("save-all", HandleConsoleSaveAll, "Saves all chunks"); + PluginMgr:BindConsoleCommand("say", HandleConsoleSay, "Sends a chat message to all players"); + PluginMgr:BindConsoleCommand("unload", HandleConsoleUnload, "Unloads all unused chunks"); +end + +function HandleConsoleBan(Split) + if (#Split < 2) then + return true, "Usage: ban [Player] "; + end + + local Reason = "You have been banned" + if (#Split > 2) then + Reason = table.concat(Split, " ", 3); + end + + + if (not(BanPlayer(Split[2], Reason))) then + return true, "Could not find player " .. Split[2]; + end + + return true, "Player " .. Split[2] .. " has been banned."; +end + +function HandleConsoleUnban(Split) + if( #Split < 2 ) then + return true, "Usage: /unban [Player]" + end + + if( BannedPlayersIni:GetValueB("Banned", Split[2], false) == false ) then + return true, Split[2] .. " is not banned!" + end + + BannedPlayersIni:SetValueB("Banned", Split[2], false, false) + BannedPlayersIni:WriteFile() + + local Server = cRoot:Get():GetServer() + return true, "Unbanned " .. Split[2] +end + +function HandleConsoleBanList(Split) + if (#Split == 1) then + return true, BanListByName(); + end + + if (string.lower(Split[2]) == "ips") then + return true, BanListByIPs(); + end + + return true, "Unknown banlist subcommand"; +end + +function HandleConsoleHelp(Split) + local Commands = {}; -- {index => {"Command", "HelpString"} } + local MaxLength = 0; + local AddToTable = function(Command, HelpString) + table.insert(Commands, { Command, HelpString }); + local CmdLen = Command:len(); + if (CmdLen > MaxLength) then + MaxLength = CmdLen; + end + end + + cPluginManager:Get():ForEachConsoleCommand(AddToTable); + + -- Sort the table: + local CompareCommands = function(a, b) + return a[1] < b[1]; -- compare command strings + end + table.sort(Commands, CompareCommands); + + local Out = ""; + for i, Command in ipairs(Commands) do + Out = Out .. Command[1] .. string.rep(" ", MaxLength - Command[1]:len()); -- Align to a table + Out = Out .. " - " .. Command[2] .. "\n"; + end + return true, Out; +end + +function HandleConsoleList(Split) + -- Get a list of all players, one playername per line + local Out = ""; + cRoot:Get():ForEachWorld( + function (a_World) + a_World:ForEachPlayer( + function (a_Player) + Out = Out .. a_Player:GetName() .. "\n"; + end + ); + end + ); + return true, Out; +end + +function HandleConsoleListGroups(Split) + -- Read the groups.ini file: + local GroupsIni = cIniFile("groups.ini"); + if (not(GroupsIni:ReadFile())) then + return true, "No groups found"; + end + + -- Read the groups: + Number = GroupsIni:NumKeys(); + Groups = {}; + for i = 0, Number do + table.insert(Groups, GroupsIni:KeyName(i)) + end + + -- Output the groups, concatenated to a string: + local Out = "Groups:\n" + Out = Out .. table.concat(Groups, ", "); + return true, Out; +end + +function HandleConsoleNumChunks(Split) + local Output = {}; + local AddNumChunks = function(World) + Output[World:GetName()] = World:GetNumChunks(); + end; + + cRoot:Get():ForEachWorld(AddNumChunks); + + local Total = 0; + local Out = ""; + for name, num in pairs(Output) do + Out = Out .. " " .. name .. ": " .. num .. " chunks\n"; + Total = Total + num; + end + Out = Out .. "Total: " .. Total .. " chunks\n"; + + return true, Out; +end + +function HandleConsolePlayers(Split) + local PlayersInWorlds = {}; -- "WorldName" => [players array] + local AddToTable = function(Player) + local WorldName = Player:GetWorld():GetName(); + if (PlayersInWorlds[WorldName] == nil) then + PlayersInWorlds[WorldName] = {}; + end + table.insert(PlayersInWorlds[WorldName], Player:GetName() .. " @ " .. Player:GetIP()); + end + + cRoot:Get():ForEachPlayer(AddToTable); + + local Out = ""; + for WorldName, Players in pairs(PlayersInWorlds) do + Out = Out .. "World " .. WorldName .. ":\n"; + for i, PlayerName in ipairs(Players) do + Out = Out .. " " .. PlayerName .. "\n"; + end + end + + return true, Out; +end + +function HandleConsolePrimaryServerVersion(Split) + if (#Split == 1) then + -- Display current version: + local Version = cRoot:Get():GetPrimaryServerVersion(); + return true, "Primary server version: #" .. Version .. ", " .. cRoot:GetProtocolVersionTextFromInt(Version); + end + + -- Set new value as the version: + cRoot:Get():SetPrimaryServerVersion(tonumber(Split[2])); + local Version = cRoot:Get():GetPrimaryServerVersion(); + return true, "Primary server version is now #" .. Version .. ", " .. cRoot:GetProtocolVersionTextFromInt(Version); +end + +function HandleConsoleRank(Split) + if (Split[2] == nil) or (Split[3] == nil) then + return true, "Usage: /rank [Player] [Group]"; + end + local Out = ""; + + -- Read the groups.ini file: + local GroupsIni = cIniFile("groups.ini") + if (not(GroupsIni:ReadFile())) then + Out = "Could not read groups.ini, creating anew!\n" + end + + -- Find the group: + if (GroupsIni:FindKey(Split[3]) == -1) then + return true, Out .. "Group does not exist"; + end + + -- Read the users.ini file: + local UsersIni = cIniFile("users.ini"); + if (not(UsersIni:ReadFile())) then + Out = Out .. "Could not read users.ini, creating anew!\n"; + end + + -- Write the new group value to users.ini: + UsersIni:DeleteKey(Split[2]); + UsersIni:GetValueSet(Split[2], "Groups", Split[3]); + UsersIni:WriteFile(); + + -- Reload the player's permissions: + cRoot:Get():ForEachWorld( + function (World) + World:ForEachPlayer( + function (Player) + if (Player:GetName() == Split[2]) then + Player:SendMessage(cChatColor.Green .. "You were moved to group " .. Split[3]); + Player:LoadPermissionsFromDisk(); + end + end + ); + end + ) + + return true, Out .. "Player " .. Split[2] .. " was moved to " .. Split[3]; +end + +function HandleConsoleReload(Split) + Server = cRoot:Get():GetServer(); + Server:SendMessage(cChatColor.Green .. "Reloading all plugins."); + cPluginManager:Get():ReloadPlugins(); + return true; +end + +function HandleConsoleSaveAll(Split) + cRoot:Get():SaveAllChunks(); + return true; +end + +function HandleConsoleSay(Split) + table.remove(Split, 1); + local Message = ""; + for i, Text in ipairs(Split) do + Message = Message .. " " .. Text; + end + Message = Message:sub(2); -- Cut off the first space + cRoot:Get():GetServer():BroadcastChat(cChatColor.Purple .. "[SERVER] " .. Message); + return true; +end + +function HandleConsoleUnload(Split) + local UnloadChunks = function(World) + World:UnloadUnusedChunks(); + end + + local Out = "Num loaded chunks before: " .. cRoot:Get():GetTotalChunkCount() .. "\n"; + cRoot:Get():ForEachWorld(UnloadChunks); + Out = Out .. "Num loaded chunks after: " .. cRoot:Get():GetTotalChunkCount(); + return true, Out; +end + + +-- Helper functions: + +--- Returns the list of players banned by name, separated by ", " +function BanListByName() + local NumValues = BannedPlayersIni:NumValues("Banned"); + local Banned = {}; + local KeyID = BannedPlayersIni:FindKey("Banned"); + for i = 1, NumValues do + local PlayerName = BannedPlayersIni:ValueName(KeyID, i - 1); + if (BannedPlayersIni:GetValueB("Banned", PlayerName)) then + -- Player listed AND banned + table.insert(Banned, PlayerName); + end + end + return table.concat(Banned, ", "); +end + +--- Returns the list of players banned by IP, separated by ", " +function BanListByIPs() + -- TODO: No IP ban implemented yet + return ""; +end \ No newline at end of file diff --git a/MCServer/Plugins/Core/functions.lua b/MCServer/Plugins/Core/functions.lua new file mode 100644 index 000000000..5fc0173b9 --- /dev/null +++ b/MCServer/Plugins/Core/functions.lua @@ -0,0 +1,3 @@ +function SetBackCoordinates( Player ) + BackCoords[Player:GetName()] = Vector3i( Player:GetPosX(), Player:GetPosY(), Player:GetPosZ() ) +end \ No newline at end of file diff --git a/MCServer/Plugins/Core/give.lua b/MCServer/Plugins/Core/give.lua new file mode 100644 index 000000000..baabdf557 --- /dev/null +++ b/MCServer/Plugins/Core/give.lua @@ -0,0 +1,39 @@ +function HandleGiveCommand(Split, Player) + if ((#Split ~= 2) and (#Split ~=3)) then + Player:SendMessage(cChatColor.Green .. "Usage: /item [ItemType/Name:Dmg] "); + return true; + end + + local Item = cItem(); + local FoundItem = StringToItem(Split[2], Item); + + if not(IsValidItem(Item.m_ItemType)) then -- StringToItem does not check if item is valid + FoundItem = false + end + + if not(FoundItem) then + Player:SendMessage( cChatColor.Green .. "Invalid item id or name!" ) + return true + end + + local ItemAmount = 1; + if (#Split == 3) then + ItemAmount = tonumber(Split[3]); + if ((ItemAmount == nil) or (ItemAmount < 1) or (ItemAmount > 512)) then + Player:SendMessage(cChatColor.Green .. "Invalid amount!"); + return true; + end + end + + Item.m_ItemCount = ItemAmount; + + local ItemsGiven = Player:GetInventory():AddItem(Item); + if (ItemsGiven == ItemAmount) then + Player:SendMessage( cChatColor.Green .. "There you go!"); + LOG("Gave " .. Player:GetName() .. " " .. Item.m_ItemCount .. " times " .. Item.m_ItemType .. ":" .. Item.m_ItemDamage); + else + Player:SendMessage(cChatColor.Green .. "Not enough space in inventory, only gave " .. ItemsGiven); + LOG("Player " .. Player:GetName() .. " asked for " .. Item.m_ItemCount .. " times " .. Item.m_ItemType .. ":" .. Item.m_ItemDamage ..", but only could fit " .. ItemsGiven); + end + return true; +end \ No newline at end of file diff --git a/MCServer/Plugins/Core/gm.lua b/MCServer/Plugins/Core/gm.lua new file mode 100644 index 000000000..85bcf984b --- /dev/null +++ b/MCServer/Plugins/Core/gm.lua @@ -0,0 +1,8 @@ +function HandleChangeGMCommand( Split, Player ) + if( #Split ~= 2 ) then + Player:SendMessage( cChatColor.Green .. "Usage: /gm [GameMode (0|1)]" ) + return true + end + Player:SetGameMode(Split[2]) + return true +end \ No newline at end of file diff --git a/MCServer/Plugins/Core/help.lua b/MCServer/Plugins/Core/help.lua new file mode 100644 index 000000000..339fc054b --- /dev/null +++ b/MCServer/Plugins/Core/help.lua @@ -0,0 +1,41 @@ +function HandleHelpCommand(Split, Player) + local PluginManager = cRoot:Get():GetPluginManager() + + local LinesPerPage = 8; + local CurrentPage = 1; + local CurrentLine = 0; + local PageRequested = 1; + local Output = {}; + + if (#Split == 2) then + PageRequested = tonumber(Split[2]); + end + + local Process = function(Command, Permission, HelpString) + if not(Player:HasPermission(Permission)) then + return false; + end; + if (HelpString == "") then + return false; + end; + + CurrentLine = CurrentLine + 1; + CurrentPage = math.floor(CurrentLine / LinesPerPage) + 1; + if (CurrentPage ~= PageRequested) then + return false; + end; + table.insert(Output, cChatColor.Blue .. Command .. HelpString); + end + + PluginManager:ForEachCommand(Process); + + -- CurrentPage now contains the total number of pages, and Output has the individual help lines to be sent + + Player:SendMessage(cChatColor.Purple .. "---------- [COMMANDS HELP " .. cChatColor.Gold .. "(Page " .. PageRequested .. " / " .. CurrentPage .. ")" .. cChatColor.Purple .. "] -----------"); + Player:SendMessage(cChatColor.Purple .. "'-' means no prefix, '~' means a value is required."); + for idx, msg in ipairs(Output) do + Player:SendMessage(msg); + end; + + return true +end \ No newline at end of file diff --git a/MCServer/Plugins/Core/itemrepair.lua b/MCServer/Plugins/Core/itemrepair.lua new file mode 100644 index 000000000..ee411dcc2 --- /dev/null +++ b/MCServer/Plugins/Core/itemrepair.lua @@ -0,0 +1,202 @@ +-- Based on Fixies plugin v2 by Taugeshtu +-- how much "extra" points are healed per a repair operation (fraction of full health) +BONUS = 0.1 + +function OnCraftingNoRecipe(Player, Grid, Recipe) + local _do_fix = false + local Items = {} + for x = 0, Grid:GetWidth() - 1 do + for y = 0, Grid:GetHeight() - 1 do + local Item = Grid:GetItem(x, y) + if (Item.m_ItemType ~= E_ITEM_EMPTY) then + table.insert(Items, Item) + end + end + end + + if (#Items ~= 2) then + -- Only two items together can be fixed + return false + end + + if (Items[1].m_ItemType ~= Items[2].m_ItemType) then + -- Only items of the same type may be fixed + return false + end + + if ( + (Items[1].m_ItemDamage == 0) or + (Items[2].m_ItemDamage == 0) + ) + then + -- Only damaged items may be fixed + return false + end + + local _ID = Items[1].m_ItemType + local _least_hp = math.max(Items[1].m_ItemDamage, Items[2].m_ItemDamage) + local _most_hp = math.min(Items[1].m_ItemDamage, Items[2].m_ItemDamage) + local _item_hp = 0 + + -- TODO: This could be refactored into better code, using an _ID-indexed table for _item_hp + + if ( + (_ID == E_ITEM_WOODEN_SHOVEL) or + (_ID == E_ITEM_WOODEN_AXE) or + (_ID == E_ITEM_WOODEN_PICKAXE) or + (_ID == E_ITEM_WOODEN_SWORD) or + (_ID == E_ITEM_WOODEN_HOE) + ) + then + _item_hp = 60 + _do_fix = true + end + + if ( + (_ID == E_ITEM_STONE_SHOVEL) or + (_ID == E_ITEM_STONE_AXE) or + (_ID == E_ITEM_STONE_PICKAXE) or + (_ID == E_ITEM_STONE_SWORD) or + (_ID == E_ITEM_STONE_HOE) + ) + then + _item_hp = 132 + _do_fix = true + end + + if ( + (_ID == E_ITEM_IRON_SHOVEL) or + (_ID == E_ITEM_IRON_AXE) or + (_ID == E_ITEM_IRON_PICKAXE) or + (_ID == E_ITEM_IRON_SWORD) or + (_ID == E_ITEM_IRON_HOE) + ) + then + _item_hp = 251 + _do_fix = true + end + + if ( + (_ID == E_ITEM_GOLD_SHOVEL) or + (_ID == E_ITEM_GOLD_AXE) or + (_ID == E_ITEM_GOLD_PICKAXE) or + (_ID == E_ITEM_GOLD_SWORD) or + (_ID == E_ITEM_GOLD_HOE) + ) + then + _item_hp = 33 + _do_fix = true + end + + if ( + (_ID == E_ITEM_DIAMOND_SHOVEL) or + (_ID == E_ITEM_DIAMOND_AXE) or + (_ID == E_ITEM_DIAMOND_PICKAXE) or + (_ID == E_ITEM_DIAMOND_SWORD) or + (_ID == E_ITEM_DIAMOND_HOE) + ) + then + _item_hp = 1562 + _do_fix = true + end + + if (_ID == E_ITEM_LEATHER_CAP) then + _item_hp = 56 + _do_fix = true + end + if (_ID == E_ITEM_LEATHER_TUNIC) then + _item_hp = 82 + _do_fix = true + end + if (_ID == E_ITEM_LEATHER_PANTS) then + _item_hp = 76 + _do_fix = true + end + if (_ID == E_ITEM_LEATHER_BOOTS) then + _item_hp = 66 + _do_fix = true + end + + + if (_ID == E_ITEM_CHAIN_HELMET) then + _item_hp = 78 + _do_fix = true + end + if (_ID == E_ITEM_CHAIN_CHESTPLATE) then + _item_hp = 114 + _do_fix = true + end + if (_ID == E_ITEM_CHAIN_LEGGINGS) then + _item_hp = 106 + _do_fix = true + end + if (_ID == E_ITEM_CHAIN_BOOTS) then + _item_hp = 92 + _do_fix = true + end + + + if (_ID == E_ITEM_IRON_HELMET) then + _item_hp = 166 + _do_fix = true + end + if (_ID == E_ITEM_IRON_CHESTPLATE) then + _item_hp = 242 + _do_fix = true + end + if (_ID == E_ITEM_IRON_LEGGINGS) then + _item_hp = 226 + _do_fix = true + end + if (_ID == E_ITEM_IRON_BOOTS) then + _item_hp = 196 + _do_fix = true + end + + + if (_ID == E_ITEM_GOLD_HELMET) then + _item_hp = 78 + _do_fix = true + end + if (_ID == E_ITEM_GOLD_CHESTPLATE) then + _item_hp = 114 + _do_fix = true + end + if (_ID == E_ITEM_GOLD_LEGGINGS) then + _item_hp = 106 + _do_fix = true + end + if (_ID == E_ITEM_GOLD_BOOTS) then + _item_hp = 92 + _do_fix = true + end + + + if (_ID == E_ITEM_DIAMOND_HELMET) then + _item_hp = 364 + _do_fix = true + end + if (_ID == E_ITEM_DIAMOND_CHESTPLATE)then + _item_hp = 529 + _do_fix = true + end + if (_ID == E_ITEM_DIAMOND_LEGGINGS) then + _item_hp = 496 + _do_fix = true + end + if (_ID == E_ITEM_DIAMOND_BOOTS) then + _item_hp = 430 + _do_fix = true + end + -- ///////////////////////////////////////////////////// + + if (_do_fix == true) then + local _hp = _most_hp - (_item_hp - _least_hp) - _item_hp * BONUS + _hp = math.max(_hp, 0) + Recipe:SetResult(_ID, 1, _hp) + Recipe:SetIngredient(Items[1].x, Items[1].y, Items[1]); + Recipe:SetIngredient(Items[2].x, Items[2].y, Items[2]); + return true + end + return false +end \ No newline at end of file diff --git a/MCServer/Plugins/Core/kick.lua b/MCServer/Plugins/Core/kick.lua new file mode 100644 index 000000000..be6215df4 --- /dev/null +++ b/MCServer/Plugins/Core/kick.lua @@ -0,0 +1,42 @@ +function HandleKickCommand( Split, Player ) + if( #Split < 2 ) then + Player:SendMessage( cChatColor.Green .. "Usage: /kick [Player] " ) + return true + end + + local Reason = "You have been kicked" + if( #Split > 2 ) then + Reason = table.concat(Split, " ", 3) + end + + if( KickPlayer( Split[2], Reason ) == false ) then + Player:SendMessage( cChatColor.Green .. "Could not find player " .. Split[2] ) + end + + return true +end + +--- Kicks a player by name, with the specified reason; returns bool whether found and player's real name +function KickPlayer(PlayerName, Reason) + local RealName = ""; + if (Reason == nil) then + Reason = "You have been kicked"; + end + + local FoundPlayerCallback = function(a_Player) + RealName = a_Player:GetName() + + local Server = cRoot:Get():GetServer() + LOGINFO( "'" .. RealName .. "' is being kicked for ( "..Reason..") " ) + Server:SendMessage("Kicking " .. RealName) + + a_Player:GetClientHandle():Kick(Reason); + end + + if (not(cRoot:Get():FindAndDoWithPlayer( PlayerName, FoundPlayerCallback))) then + -- Could not find player + return false; + end + + return true, RealName; -- Player has been kicked +end \ No newline at end of file diff --git a/MCServer/Plugins/Core/locate.lua b/MCServer/Plugins/Core/locate.lua new file mode 100644 index 000000000..27fcad229 --- /dev/null +++ b/MCServer/Plugins/Core/locate.lua @@ -0,0 +1,4 @@ +function HandleLocateCommand( Split, Player ) + Player:SendMessage(cChatColor.Green .. string.format("[X:%0.2f] [Y:%0.2f] [Z:%0.2f]", Player:GetPosX(), Player:GetPosY(), Player:GetPosZ() ) ) + return true +end \ No newline at end of file diff --git a/MCServer/Plugins/Core/main.lua b/MCServer/Plugins/Core/main.lua new file mode 100644 index 000000000..b4d03ce9d --- /dev/null +++ b/MCServer/Plugins/Core/main.lua @@ -0,0 +1,173 @@ +-- Global variables +PLUGIN = {} -- Reference to own plugin object +BannedPlayersIni = {} +WhiteListIni = {} +BackCoords = {} +Messages = {} +LimitWorldsCuboid = {} +SPAWNPROTECT = true +PROTECTRADIUS = 20 +LOGTOFILE = false + +function Initialize(Plugin) + PLUGIN = Plugin + + Plugin:SetName("Core") + Plugin:SetVersion(13) + + PluginManager = cRoot:Get():GetPluginManager() + PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_JOINED) + PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_BREAKING_BLOCK) + PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_PLACING_BLOCK) + PluginManager:AddHook(Plugin, cPluginManager.HOOK_LOGIN) + PluginManager:AddHook(Plugin, cPluginManager.HOOK_KILLING) + PluginManager:AddHook(Plugin, cPluginManager.HOOK_CRAFTING_NO_RECIPE) + PluginManager:AddHook(Plugin, cPluginManager.HOOK_CHAT) -- used in web_chat.lua + PluginManager:AddHook(Plugin, cPluginManager.HOOK_CHUNK_GENERATING) + PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_MOVING) + + PluginManager:BindCommand("/worlds", "core.worlds", HandleWorldsCommand, " - Shows a list of all the worlds"); + PluginManager:BindCommand("/listgroups", "core.listgroups", HandleListGroupsCommand, " - Shows a list of all the groups"); + PluginManager:BindCommand("/toggledownfall", "core.toggledownfall", HandleToggleDownfallCommand, " - Toggles the weather"); + PluginManager:BindCommand("/back", "core.back", HandleBackCommand, " - Return to your last position"); + PluginManager:BindCommand("/save-all", "core.save-all", HandleSaveAllCommand, " - Saves all your worlds"); + PluginManager:BindCommand("/help", "core.help", HandleHelpCommand, " ~ Show available commands"); + PluginManager:BindCommand("/rank", "core.rank", HandleRankCommand, " ~ Add someone to a group"); + PluginManager:BindCommand("/plugins", "core.plugins", HandlePluginsCommand, " - Show list of plugins"); + PluginManager:BindCommand("/tp", "core.teleport", HandleTPCommand, " ~ Teleport yourself to a player"); + PluginManager:BindCommand("/give", "core.give", HandleGiveCommand, " ~ Give yourself an item"); + PluginManager:BindCommand("/list", "core.playerlist", HandlePlayerListCommand, " - Shows list of connected players"); + PluginManager:BindCommand("/who", "core.playerlist", HandlePlayerListCommand, " - Shows list of connected players"); + PluginManager:BindCommand("/playerlist", "core.playerlist", HandlePlayerListCommand, " - Shows list of connected players"); + PluginManager:BindCommand("/motd", "core.motd", HandleMOTDCommand, " - Show message of the day"); + PluginManager:BindCommand("/reload", "core.reload", HandleReloadCommand, " - Reload all plugins"); + PluginManager:BindCommand("/stop", "core.stop", HandleStopCommand, " - Stops the server"); + PluginManager:BindCommand("/time", "core.time", HandleTimeCommand, " ~ Sets the time of day"); + PluginManager:BindCommand("/spawn", "core.spawn", HandleSpawnCommand, " - Return to the spawn"); + PluginManager:BindCommand("/kick", "core.kick", HandleKickCommand, " ~ Kick a player"); + PluginManager:BindCommand("/ban", "core.ban", HandleBanCommand, " ~ Ban a player"); + PluginManager:BindCommand("/unban", "core.unban", HandleUnbanCommand, " ~ Unban a player"); + PluginManager:BindCommand("/top", "core.top", HandleTopCommand, " - Teleport yourself to the top most block"); + PluginManager:BindCommand("/gm", "core.changegm", HandleChangeGMCommand, " ~ Change your gamemode"); + PluginManager:BindCommand("/portal", "core.portal", HandlePortalCommand, " ~ Move to a different world"); + PluginManager:BindCommand("/locate", "core.locate", HandleLocateCommand, " - Show your current server coordinates"); + PluginManager:BindCommand("/regen", "core.regen", HandleRegenCommand, " ~ Regenerates a chunk, current or specified"); + PluginManager:BindCommand("/viewdistance", "core.viewdistance", HandleViewDistanceCommand, " [".. cClientHandle.MIN_VIEW_DISTANCE .."-".. cClientHandle.MAX_VIEW_DISTANCE .."] - Change your view distance") + + InitConsoleCommands(); + + -- Load the settings + IniFile = cIniFile("settings.ini") + if ( IniFile:ReadFile() == true ) then + HardCore = IniFile:GetValueSet("GameMode", "Hardcore", "false") + LimitWorld = IniFile:GetValueSetB("Worlds", "LimitWorld", true) + LimitWorldWidth = IniFile:GetValueSetI("Worlds", "LimitWorldWidth", 10) + SPAWNPROTECT = IniFile:GetValueSetB("SpawnProtect", "Enable", true) + PROTECTRADIUS = IniFile:GetValueSetI("SpawnProtect", "ProtectRadius", 20) + LOGTOFILE = IniFile:GetValueSetB("SpawnProtect", "LogToFile", false) + IniFile:WriteFile() + end + + if LimitWorldWidth ~= nil then + cRoot:Get():ForEachWorld( + function( World ) + LimitWorldsCuboid[World:GetName()] = cCuboid() + LimitWorldsCuboid[World:GetName()].p1 = Vector3i( math.floor(World:GetSpawnX() / 16) + LimitWorldWidth, 0, math.floor(World:GetSpawnZ() / 16) + LimitWorldWidth) + LimitWorldsCuboid[World:GetName()].p2 = Vector3i( math.floor(World:GetSpawnX() / 16) - LimitWorldWidth, 256, math.floor(World:GetSpawnZ() / 16) - LimitWorldWidth) + LimitWorldsCuboid[World:GetName()]:Sort() + end + ) + end + -- Load whitelist, and add default values and stuff + WhiteListIni = cIniFile( Plugin:GetLocalDirectory() .. "/whitelist.ini" ) + if ( WhiteListIni:ReadFile() == true ) then + if( WhiteListIni:GetValueB("WhiteListSettings", "WhiteListOn", false) == true ) then + if( WhiteListIni:GetNumValues("WhiteList") > 0 ) then + LOGINFO("Core: loaded " .. WhiteListIni:GetNumValues('WhiteList') .. " whitelisted players.") + else + LOGWARN("WARNING: WhiteList is on, but there are no people in the whitelist!") + end + end + else + WhiteListIni:SetValueB("WhiteListSettings", "WhiteListOn", false ) + WhiteListIni:SetValue("WhiteList", "", "") -- So it adds an empty header + WhiteListIni:DeleteValue("WhiteList", "") -- And remove the value + WhiteListIni:KeyComment("WhiteList", "PlayerName=1") + if( WhiteListIni:WriteFile() == false ) then + LOGWARN("WARNING: Could not write to whitelist.ini") + end + end + + -- Load banned players, and add default values and stuff + BannedPlayersIni = cIniFile( Plugin:GetLocalDirectory() .. "/banned.ini" ) + if ( BannedPlayersIni:ReadFile() == true ) then + if( BannedPlayersIni:GetNumValues("Banned") > 0 ) then + LOGINFO("Core: loaded " .. BannedPlayersIni:GetNumValues("Banned") .. " banned players.") + end + else + BannedPlayersIni:SetValue("Banned", "", "") -- So it adds an empty header + BannedPlayersIni:DeleteValue("Banned", "") -- And remove the value + BannedPlayersIni:KeyComment("Banned", "PlayerName=1") + if( BannedPlayersIni:WriteFile() == false ) then + LOGWARN("WARNING: Could not write to banned.ini") + end + end + + Plugin:AddWebTab("Manage Server", HandleRequest_ManageServer); + Plugin:AddWebTab("Server Settings", HandleRequest_ServerSettings); + Plugin:AddWebTab("Chat", HandleRequest_Chat); + Plugin:AddWebTab("Playerlist", HandleRequest_PlayerList); + Plugin:AddWebTab("Whitelist", HandleRequest_WhiteList); + Plugin:AddWebTab("Permissions", HandleRequest_Permissions); + Plugin:AddWebTab("Manage Plugins", HandleRequest_ManagePlugins); + + LoadMotd() + LOG( "Initialized " .. Plugin:GetName() .. " v." .. Plugin:GetVersion() ) + + return true +end + +function WriteLog(breakPlace, X, Y, Z, player, id, meta) + PLUGIN = Plugin + + local logText = {} + + table.insert(logText, player) + table.insert(logText, " tried to ") + + if breakPlace == 0 then + table.insert(logText, "break ") + else + table.insert(logText, "place ") + end + + + table.insert(logText, ItemToString(cItem(id, 1, meta))) + + table.insert(logText, " at ") + table.insert(logText, tostring(X)) + table.insert(logText, ", ") + table.insert(logText, tostring(Y)) + table.insert(logText, ", ") + table.insert(logText, tostring(Z)) + table.insert(logText, ".") + + LOGINFO(table.concat(logText,'')) + + if LOGTOFILE then + local logFile = io.open( Plugin:GetLocalDirectory() .. '/blocks.log', 'a') + logFile:write(table.concat(logText,'').."\n") + logFile:close() + end + + return +end + +function WarnPlayer(Player) + Player:SendMessage("Go further from spawn to build") + return +end + +function OnDisable() + LOG( "Disabled " .. Plugin:GetName() .. " v." .. Plugin:GetVersion() ) +end \ No newline at end of file diff --git a/MCServer/Plugins/Core/motd.lua b/MCServer/Plugins/Core/motd.lua new file mode 100644 index 000000000..2a42c80af --- /dev/null +++ b/MCServer/Plugins/Core/motd.lua @@ -0,0 +1,97 @@ +function HandleMOTDCommand( Split, Player ) + ShowMOTDTo( Player ) + return true +end + + + + +function LoadMotd() + local File = io.open("motd.txt", "r") + -- Check if the file 'motd.txt' exists, else create it. + if not File then + CreateFile = io.open("motd.txt", "w") + CreateFile:write("@6Welcome to the MCServer test server!\n@6http://www.mc-server.org/\n@6Type /help for all commands") + CreateFile:close() + else + File:close() + end + for line in io.lines("motd.txt") do + local TempMessage = line + -- Do a for loop that goes to each char in the line. + for I=1, string.len(TempMessage) do + -- If the char is a '@' then check if the next char represents a color. + if string.sub(TempMessage, I, I) == "@" then + local Char = string.sub(TempMessage, I + 1, I + 1) + local Color = ReturnColorFromChar(TempMessage, Char) + -- If the next char represented a color then put the color in the string. + if (Color ~= nil) then + TempMessage = string.gsub(TempMessage, "@" .. Char, Color) + end + end + end + -- Add the message to the list of messages. + Messages[#Messages + 1] = TempMessage + end +end + + + + +function ShowMOTDTo( Player ) + for I=1, #Messages do + Player:SendMessage(Messages[I]) + end +end + + + + +function ReturnColorFromChar( Split, char ) + -- Check if the char represents a color. Else return nil. + if char == "0" then + return cChatColor.Black + elseif char == "1" then + return cChatColor.Navy + elseif char == "2" then + return cChatColor.Green + elseif char == "3" then + return cChatColor.Blue + elseif char == "4" then + return cChatColor.Red + elseif char == "5" then + return cChatColor.Purple + elseif char == "6" then + return cChatColor.Gold + elseif char == "7" then + return cChatColor.LightGray + elseif char == "8" then + return cChatColor.Gray + elseif char == "9" then + return cChatColor.DarkPurple + elseif char == "a" then + return cChatColor.LightGreen + elseif char == "b" then + return cChatColor.LightBlue + elseif char == "c" then + return cChatColor.Rose + elseif char == "d" then + return cChatColor.LightPurple + elseif char == "e" then + return cChatColor.Yellow + elseif char == "f" then + return cChatColor.White + elseif char == "k" then + return cChatColor.Random + elseif char == "l" then + return cChatColor.Bold + elseif char == "m" then + return cChatColor.Strikethrough + elseif char == "n" then + return cChatColor.Underlined + elseif char == "o" then + return cChatColor.Italic + elseif char == "r" then + return cChatColor.Plain + end +end \ No newline at end of file diff --git a/MCServer/Plugins/Core/onbreakplaceblock.lua b/MCServer/Plugins/Core/onbreakplaceblock.lua new file mode 100644 index 000000000..89ccd3919 --- /dev/null +++ b/MCServer/Plugins/Core/onbreakplaceblock.lua @@ -0,0 +1,115 @@ +function OnPlayerPlacingBlock(Player, BlockX, BlockY, BlockZ, BlockFace, CursorX, CursorY, CursorZ, BlockType) + -- Direction is air check + if (BlockFace == -1) then + return false + end + + if( Player:HasPermission("core.build") == false ) then + return true + else + if Player:HasPermission("core.spawnprotect.bypass") == false and SPAWNPROTECT == true then + local World = Player:GetWorld() + local xcoord = World:GetSpawnX() + local ycoord = World:GetSpawnY() + local zcoord = World:GetSpawnZ() + + if not ((BlockX <= (xcoord + PROTECTRADIUS)) and (BlockX >= (xcoord - PROTECTRADIUS))) then + return false -- Not in spawn area. + end + if not ((BlockY <= (ycoord + PROTECTRADIUS)) and (BlockY >= (ycoord - PROTECTRADIUS))) then + return false -- Not in spawn area. + end + if not ((BlockZ <= (zcoord + PROTECTRADIUS)) and (BlockZ >= (zcoord - PROTECTRADIUS))) then + return false -- Not in spawn area. + end + + --WriteLog(1, BlockX, BlockY, BlockZ, Player:GetName(), id, meta) + + WarnPlayer(Player) + + return true + else + if BlockType == "50" or BlockType == "76" then + local X = BlockX + local Y = BlockY + local Z = BlockZ + X, Y, Z = AddFaceDirection(X, Y, Z, BlockFace) + if (Y >= 256 or Y < 0) then + return true + end + + local CheckCollision = function(Player) + -- drop the decimals, we only care about the full block X,Y,Z + local PlayerX = math.floor(Player:GetPosX(), 0) + local PlayerY = math.floor(Player:GetPosY(), 0) + local PlayerZ = math.floor(Player:GetPosZ(), 0) + + local collision = false + if ((BlockFace == BLOCK_FACE_TOP) and (PlayerY == BlockY - 2) and (PlayerX == BlockX) and (PlayerZ == BlockZ)) then + collision = true + end + + if ((BlockFace == BLOCK_FACE_BOTTOM) and (PlayerY == BlockY + 1) and (PlayerX == BlockX) and (PlayerZ == BlockZ)) then + collision = true + end + + if ((BlockFace == BLOCK_FACE_NORTH) and (PlayerX == BlockX) and (PlayerZ == BlockZ - 1)) then + if ((PlayerY == BlockY) or (PlayerY + 1 == BlockY)) then collision = true end + end + + if ((BlockFace == BLOCK_FACE_SOUTH) and (PlayerX == BlockX) and (PlayerZ == BlockZ + 1)) then + if ((PlayerY == BlockY) or (PlayerY + 1 == BlockY)) then collision = true end + end + + if ((BlockFace == BLOCK_FACE_WEST) and (PlayerX == BlockX - 1) and (PlayerZ == BlockZ)) then + if ((PlayerY == BlockY) or (PlayerY + 1 == BlockY)) then collision = true end + end + + if ((BlockFace == BLOCK_FACE_EAST) and (PlayerX == BlockX + 1) and (PlayerZ == BlockZ)) then + if ((PlayerY == BlockY) or (PlayerY + 1 == BlockY)) then collision = true end + end + return collision + end + if (Player:GetWorld():ForEachPlayer(CheckCollision) == false) then + return true + end + end + end + end + return false +end + +function OnPlayerBreakingBlock(Player, BlockX, BlockY, BlockZ, BlockFace, Status, OldBlockType, OldBlockMeta) + -- dont check if the direction is in the air + if (BlockFace ~= -1) then + + if (Player:HasPermission("core.build") == false) then + return true + else + if Player:HasPermission("core.spawnprotect.bypass") == false and SPAWNPROTECT == true then + local World = Player:GetWorld() + local xcoord = World:GetSpawnX() + local ycoord = World:GetSpawnY() + local zcoord = World:GetSpawnZ() + + if not ((BlockX <= (xcoord + PROTECTRADIUS)) and (BlockX >= (xcoord - PROTECTRADIUS))) then + return false -- Not in spawn area. + end + if not ((BlockY <= (ycoord + PROTECTRADIUS)) and (BlockY >= (ycoord - PROTECTRADIUS))) then + return false -- Not in spawn area. + end + if not ((BlockZ <= (zcoord + PROTECTRADIUS)) and (BlockZ >= (zcoord - PROTECTRADIUS))) then + return false -- Not in spawn area. + end + + --WriteLog(0, BlockX, BlockY, BlockZ, Player:GetName(), id, meta) + + WarnPlayer(Player) + + return true + end + end + end + + return false +end \ No newline at end of file diff --git a/MCServer/Plugins/Core/onchunkgenerating.lua b/MCServer/Plugins/Core/onchunkgenerating.lua new file mode 100644 index 000000000..44a6cf298 --- /dev/null +++ b/MCServer/Plugins/Core/onchunkgenerating.lua @@ -0,0 +1,16 @@ +function OnChunkGenerating(World, ChunkX, ChunkZ, ChunkDesc) + if (LimitWorld == true) then + if not LimitWorldsCuboid[World:GetName()]:IsInside( Vector3i(ChunkX, 128, ChunkZ) ) then + FillBlocks(ChunkDesc) + end + end +end + +function FillBlocks(ChunkDesc) + ChunkDesc:FillBlocks(0,0) + ChunkDesc:SetUseDefaultBiomes(false) + ChunkDesc:SetUseDefaultHeight(false) + ChunkDesc:SetUseDefaultComposition(false) + ChunkDesc:SetUseDefaultStructures(false) + ChunkDesc:SetUseDefaultFinish(false) +end \ No newline at end of file diff --git a/MCServer/Plugins/Core/ondeath.lua b/MCServer/Plugins/Core/ondeath.lua new file mode 100644 index 000000000..47a7532a6 --- /dev/null +++ b/MCServer/Plugins/Core/ondeath.lua @@ -0,0 +1,65 @@ +function OnKilling(Victim, Killer) + if Victim:IsPlayer() then + SetBackCoordinates( Victim ) + Server = cRoot:Get():GetServer() + if Killer == nil then + if Victim:IsOnFire() then + Server:SendMessage( cChatColor.Red .. Victim:GetName() .. " was burnt to a cinder" ) + CheckHardcore(Victim) + return false + end + if Victim:GetWorld():GetBlock(Victim:GetPosX(), Victim:GetPosY(), Victim:GetPosZ()) == 10 or Victim:GetWorld():GetBlock(Victim:GetPosX(), Victim:GetPosY(), Victim:GetPosZ()) == 11 then + Server:SendMessage( cChatColor.Red .. Victim:GetName() .. " tried to swim in lava (and failed)" ) + CheckHardcore(Victim) + return false + end + else + if Killer:IsPlayer() then + Server:SendMessage( cChatColor.Red .. Victim:GetName() .. " was terminated by " .. Killer:GetName() ) + CheckHardcore(Victim) + return false + elseif Killer:IsMob() then + if Killer:IsA("cZombie") then + Server:SendMessage( cChatColor.Red .. Victim:GetName() .. " was eaten by a Zombie") + elseif Killer:IsA("cSkeleton") then + Server:SendMessage( cChatColor.Red .. Victim:GetName() .. " was shot by a Skeleton" ) + elseif Killer:IsA("cCreeper") then + Server:SendMessage( cChatColor.Red .. Victim:GetName() .. " was blown up by a Creeper") + elseif Killer:IsA("cSpider") then + Server:SendMessage( cChatColor.Red .. Victim:GetName() .. " was ripped apart by a giant Spider") + elseif Killer:IsA("cCaveSpider") then + Server:SendMessage( cChatColor.Red .. Victim:GetName() .. " was poisoned by a giant Cave Spider") + elseif Killer:IsA("cBlaze") then + Server:SendMessage( cChatColor.Red .. Victim:GetName() .. " was flamed by a Blaze") + elseif Killer:IsA("cEnderman") then + Server:SendMessage( cChatColor.Red .. Victim:GetName() .. " was " .. cChatColor.Random .. " by an Enderman") + elseif Killer:IsA("cSilverfish") then + Server:SendMessage( cChatColor.Red .. Victim:GetName() .. " was... DERPED by a Silverfish!") + elseif Killer:IsA("cSlime") then + Server:SendMessage( cChatColor.Red .. Victim:GetName() .. " was stuck fast and killed by a Slime") + elseif Killer:IsA("cWitch") then + Server:SendMessage( cChatColor.Red .. Victim:GetName() .. " was enchanted (to death) by a Witch") + elseif Killer:IsA("cZombiepigman") then + Server:SendMessage( cChatColor.Red .. Victim:GetName() .. " was slain by a Zombie Pigman") + elseif Killer:IsA("cMagmacube") then + Server:SendMessage( cChatColor.Red .. Victim:GetName() .. " was incinerated by a Magmacube") + elseif Killer:IsA("cWolf") then + Server:SendMessage( cChatColor.Red .. Victim:GetName() .. " was savaged by a Wolf") + end + CheckHardcore(Victim) + return false + end + end + Server:SendMessage( cChatColor.Red .. Victim:GetName() .. " died of mysterious circumstances") + CheckHardcore(Victim) + end +end + +function CheckHardcore(Victim) + if HardCore == "true" then + if Victim:IsPlayer() == true then + local KilledPlayer = tolua.cast(Victim, "cPlayer") + BanPlayer(KilledPlayer:GetName(), "You died, haha. Good game, bro.") + end + end +end \ No newline at end of file diff --git a/MCServer/Plugins/Core/onlogin.lua b/MCServer/Plugins/Core/onlogin.lua new file mode 100644 index 000000000..4b2f24f17 --- /dev/null +++ b/MCServer/Plugins/Core/onlogin.lua @@ -0,0 +1,19 @@ +function OnLogin(Client, ProtocolVersion, Username) + if( Username ~= "" ) then + if( BannedPlayersIni:GetValueB("Banned", Username, false) == true ) then + local Server = cRoot:Get():GetServer() + Server:SendMessage( Username .. " tried to join, but is banned!" ) + LOGINFO( Username .. " tried to join, but is banned!") + return true -- Player is banned, return true to deny access + end + if( WhiteListIni:GetValueB("WhiteListSettings", "WhiteListOn", false ) == true ) then + if( WhiteListIni:GetValueB("WhiteList", Username, false ) == false ) then -- not on whitelist + local Server = cRoot:Get():GetServer() + Server:SendMessage( Username .. " tried to join, but is not on the whitelist." ) + LOGINFO( Username .. " tried to join, but is not on the whitelist." ) + return true -- Deny access to the server + end + end + end + return false +end \ No newline at end of file diff --git a/MCServer/Plugins/Core/playerjoin.lua b/MCServer/Plugins/Core/playerjoin.lua new file mode 100644 index 000000000..884acb66a --- /dev/null +++ b/MCServer/Plugins/Core/playerjoin.lua @@ -0,0 +1,5 @@ +function OnPlayerJoined(Player) + ShowMOTDTo( Player ) + AddMessage( Player:GetName() .. " has joined the game", " " ) + return false +end \ No newline at end of file diff --git a/MCServer/Plugins/Core/playerlist.lua b/MCServer/Plugins/Core/playerlist.lua new file mode 100644 index 000000000..73d9e5b24 --- /dev/null +++ b/MCServer/Plugins/Core/playerlist.lua @@ -0,0 +1,14 @@ +function HandlePlayerListCommand( Split, Player ) + + local PlayerTable = {} + local AppendToTable = function( Player ) + table.insert(PlayerTable, Player:GetName() ) + end + Player:GetWorld():ForEachPlayer( AppendToTable ) + + local Message = cChatColor.Green .. "Connected players: (".. cChatColor.White.. #PlayerTable .. cChatColor.Green .. ")" + Player:SendMessage( Message ) + + Player:SendMessage( table.concat(PlayerTable, " ") ) + return true +end \ No newline at end of file diff --git a/MCServer/Plugins/Core/plugins.lua b/MCServer/Plugins/Core/plugins.lua new file mode 100644 index 000000000..6d74cf29e --- /dev/null +++ b/MCServer/Plugins/Core/plugins.lua @@ -0,0 +1,15 @@ +function HandlePluginsCommand( Split, Player ) + local PluginManager = cRoot:Get():GetPluginManager() + local PluginList = PluginManager:GetAllPlugins() + + local PluginTable = {} + for k, Plugin in pairs( PluginList ) do + if ( Plugin ) then + table.insert(PluginTable, Plugin:GetName() ) + end + end + + Player:SendMessage( cChatColor.Green .. "Loaded plugins: (" .. #PluginTable .. ")" ) + Player:SendMessage( cChatColor.Gold .. table.concat(PluginTable, cChatColor.Gold.." ") ) + return true +end \ No newline at end of file diff --git a/MCServer/Plugins/Core/portal-worlds.lua b/MCServer/Plugins/Core/portal-worlds.lua new file mode 100644 index 000000000..136edb82e --- /dev/null +++ b/MCServer/Plugins/Core/portal-worlds.lua @@ -0,0 +1,36 @@ +function HandlePortalCommand( Split, Player ) + if( #Split ~= 2 ) then + Player:SendMessage( cChatColor.Green .. "Usage: /gotoworld [WorldName]" ) + return true + end + + if( Player:MoveToWorld(Split[2]) == false ) then + Player:SendMessage( cChatColor.Green .. "Could not move to world '" .. Split[2] .. "'!" ) + return true + end + + + Player:SendMessage( cChatColor.Green .. "Moved successfully to '" .. Split[2] .. "'! :D" ) + return true +end + +function HandleWorldsCommand( Split, Player ) + local SettingsIni = cIniFile("settings.ini") + if SettingsIni:ReadFile() == false then + Player:SendMessage( cChatColor.Green .. "No worlds found" ) + end + Number = SettingsIni:NumValues("Worlds") - 1 + Worlds = {} + for i=0, SettingsIni:GetNumKeys() - 1 do + if SettingsIni:GetKeyName(i) == "Worlds" then + Key = i + break + end + end + for i=0, Number do + table.insert( Worlds, SettingsIni:GetValue( Key, i) ) + end + Player:SendMessage( cChatColor.Green .. "Worlds:" ) + Player:SendMessage( cChatColor.Green .. table.concat( Worlds, ", " ) ) + return true +end \ No newline at end of file diff --git a/MCServer/Plugins/Core/rank-groups.lua b/MCServer/Plugins/Core/rank-groups.lua new file mode 100644 index 000000000..157d91744 --- /dev/null +++ b/MCServer/Plugins/Core/rank-groups.lua @@ -0,0 +1,48 @@ +function HandleRankCommand( Split, Player ) + if Split[2] == nil or Split[3] == nil then + Player:SendMessage(cChatColor.Rose .. "Usage: /rank [Player] [Group]") + return true + end + local GroupsIni = cIniFile("groups.ini") + if( GroupsIni:ReadFile() == false ) then + LOG("Could not read groups.ini!") + end + if GroupsIni:FindKey(Split[3]) == -1 then + Player:SendMessage(cChatColor.Rose .. "Group does not exist") + return true + end + local UsersIni = cIniFile("users.ini") + if( UsersIni:ReadFile() == false ) then + LOG("Could not read users.ini!") + end + UsersIni:DeleteKey(Split[2]) + UsersIni:GetValueSet(Split[2], "Groups", Split[3]) + UsersIni:WriteFile() + local loopPlayers = function( Player ) + if Player:GetName() == Split[2] then + Player:SendMessage( cChatColor.Green .. "You were moved to group " .. Split[3] ) + Player:LoadPermissionsFromDisk() + end + end + local loopWorlds = function ( World ) + World:ForEachPlayer( loopPlayers ) + end + cRoot:Get():ForEachWorld( loopWorlds ) + Player:SendMessage(cChatColor.Green .. "Player " .. Split[2] .. " Was moved to " .. Split[3]) + return true +end + +function HandleListGroupsCommand( Split, Player ) + local GroupsIni = cIniFile("groups.ini") + if GroupsIni:ReadFile() == false then + Player:SendMessage( cChatColor.Green .. "No groups found" ) + end + Number = GroupsIni:NumKeys() - 1 + Groups = {} + for i=0, Number do + table.insert( Groups, GroupsIni:KeyName(i) ) + end + Player:SendMessage( cChatColor.Green .. "Groups:" ) + Player:SendMessage( cChatColor.Green .. table.concat( Groups, ", " ) ) + return true +end \ No newline at end of file diff --git a/MCServer/Plugins/Core/regen.lua b/MCServer/Plugins/Core/regen.lua new file mode 100644 index 000000000..f1dd4e118 --- /dev/null +++ b/MCServer/Plugins/Core/regen.lua @@ -0,0 +1,18 @@ +function HandleRegenCommand(Split, Player) + if ((#Split == 2) or (#Split > 3)) then + Player:SendMessage( cChatColor.Green .. "Usage: '/regeneratechunk' or '/regeneratechunk [X] [Z]'"); + return true; + end + + local X = Player:GetChunkX(); + local Z = Player:GetChunkZ(); + + if (#Split == 3) then + X = Split[2]; + Z = Split[3]; + end + + Player:SendMessage(cChatColor.Green .. "Regenerating chunk ["..X..", "..Z.."]"); + Player:GetWorld():RegenerateChunk(X, Z); + return true; +end \ No newline at end of file diff --git a/MCServer/Plugins/Core/save-reload-stop.lua b/MCServer/Plugins/Core/save-reload-stop.lua new file mode 100644 index 000000000..57744b088 --- /dev/null +++ b/MCServer/Plugins/Core/save-reload-stop.lua @@ -0,0 +1,19 @@ +function HandleSaveAllCommand( Split, Player ) + cRoot:Get():SaveAllChunks(); + Player:SendMessage(cChatColor.Green .. "All the worlds are saved") + return true; +end + +function HandleStopCommand( Split, Player ) + Server = cRoot:Get():GetServer() + Server:SendMessage( cChatColor.Green .. "Stopping the server..." ) + cRoot:Get():QueueExecuteConsoleCommand("stop") + return true +end + +function HandleReloadCommand( Split, Player ) + Server = cRoot:Get():GetServer() + Server:SendMessage( cChatColor.Green .. "Reloading all plugins." ) + cRoot:Get():GetPluginManager():ReloadPlugins() + return true +end \ No newline at end of file diff --git a/MCServer/Plugins/Core/spawn.lua b/MCServer/Plugins/Core/spawn.lua new file mode 100644 index 000000000..2b07c5767 --- /dev/null +++ b/MCServer/Plugins/Core/spawn.lua @@ -0,0 +1,7 @@ +function HandleSpawnCommand(Split, Player) + World = Player:GetWorld() + SetBackCoordinates(Player) + Player:TeleportToCoords(World:GetSpawnX(), World:GetSpawnY(), World:GetSpawnZ()) + LOGINFO(Player:GetName() .. " returned to spawn.") + return true +end \ No newline at end of file diff --git a/MCServer/Plugins/Core/teleport.lua b/MCServer/Plugins/Core/teleport.lua new file mode 100644 index 000000000..4d3d98fee --- /dev/null +++ b/MCServer/Plugins/Core/teleport.lua @@ -0,0 +1,38 @@ +function HandleTPCommand(a_Split, a_Player) + if ((#a_Split == 2) or (#a_Split == 3)) then + -- Teleport to player specified in a_Split[2], tell them unless a_Split[3] equals "-h": + TeleportToPlayer(a_Player, a_Split[2], (a_Split[3] ~= "-h")); + return true; + elseif (#a_Split == 4) then + -- Teleport to XYZ coords specified in a_Split[2, 3, 4]: + SetBackCoordinates(a_Player); + a_Player:TeleportToCoords(a_Split[2], a_Split[3], a_Split[4]); + a_Player:SendMessage(cChatColor.Green .. "You teleported to {" .. a_Split[2] .. ", " .. a_Split[3] .. ", " .. a_Split[4] .. "}"); + return true; + else + a_Player:SendMessage( cChatColor.Green .. "Usage: /tp [PlayerName] (-h) or /tp [X Y Z]" ) + return true + end +end + +-- Teleports a_SrcPlayer to a player named a_DstPlayerName; if a_TellDst is true, will send a notice to the destination player +function TeleportToPlayer(a_SrcPlayer, a_DstPlayerName, a_TellDst) + local teleport = function(OtherPlayer) + if (OtherPlayer == a_SrcPlayer) then + -- Asked to teleport to self? + a_SrcPlayer:SendMessage(cChatColor.Green .. "Y' can't teleport to yerself!"); + else + SetBackCoordinates(a_SrcPlayer); + a_SrcPlayer:TeleportToEntity(OtherPlayer); + a_SrcPlayer:SendMessage(cChatColor.Green .. "You teleported to " .. OtherPlayer:GetName() .. "!"); + if (a_TellDst) then + OtherPlayer:SendMessage(cChatColor.Green .. Player:GetName().." teleported to you!"); + end + end + end + + local World = a_SrcPlayer:GetWorld(); + if (not(World:DoWithPlayer(a_DstPlayerName, teleport))) then + a_SrcPlayer:SendMessage(cChatColor.Green .. "Can't find player " .. a_DstPlayerName); + end +end \ No newline at end of file diff --git a/MCServer/Plugins/Core/time.lua b/MCServer/Plugins/Core/time.lua new file mode 100644 index 000000000..85593695a --- /dev/null +++ b/MCServer/Plugins/Core/time.lua @@ -0,0 +1,23 @@ +function HandleTimeCommand( Split, Player ) + if Split[2] == nil then + Player:SendMessage( cChatColor.Green .. "Usage: /time [Day/Night/Set/Add]" ) + return true + end + local Server = cRoot:Get():GetServer() + if( string.upper( Split[2] ) == "DAY") then + Player:GetWorld():SetTimeOfDay( 0 ) + Server:SendMessage( cChatColor.Green .. Player:GetName() .. " set the time to Day.") + elseif( string.upper( Split[2] ) == "NIGHT") then + Player:GetWorld():SetTimeOfDay( 12000 + 1000 ) + Server:SendMessage( cChatColor.Green .. Player:GetName() .. " set the time to Night.") + elseif( string.upper(Split[2]) == "SET" ) and ( tonumber(Split[3]) ~= nil) then + Player:GetWorld():SetTimeOfDay( tonumber(Split[3]) ) + Server:SendMessage( cChatColor.Green .. Player:GetName() .. " set the time to " .. Split[3] ) + elseif( string.upper(Split[2]) == "ADD" ) and ( tonumber(Split[3]) ~= nil) then + Player:GetWorld():SetTimeOfDay( Player:GetWorld():GetTimeOfDay() + Split[3] ) + Server:SendMessage( cChatColor.Green .. Player:GetName() .. " Added " .. Split[3] .. " to the time" ) + else + Player:SendMessage( cChatColor.Green .. "Usage: /time [Day/Night/Set/Add]" ) + end + return true +end \ No newline at end of file diff --git a/MCServer/Plugins/Core/top.lua b/MCServer/Plugins/Core/top.lua new file mode 100644 index 000000000..bc2343f7f --- /dev/null +++ b/MCServer/Plugins/Core/top.lua @@ -0,0 +1,11 @@ +function HandleTopCommand( Split, Player ) + local World = Player:GetWorld() + + local PlayerPos = Player:GetPosition() + local Height = World:GetHeight( math.floor(PlayerPos.x), math.floor(PlayerPos.z) ) + SetBackCoordinates( Player ) + Player:TeleportToCoords( PlayerPos.x, Height+1, PlayerPos.z ) + Player:SendMessage("Teleported to the top block") + + return true +end \ No newline at end of file diff --git a/MCServer/Plugins/Core/viewdistance.lua b/MCServer/Plugins/Core/viewdistance.lua new file mode 100644 index 000000000..dfd310aa7 --- /dev/null +++ b/MCServer/Plugins/Core/viewdistance.lua @@ -0,0 +1,10 @@ +function HandleViewDistanceCommand( Split, Player ) + if( #Split ~= 2 ) then + Player:SendMessage( cChatColor.Green .. "Usage: /viewdistance [".. cClientHandle.MIN_VIEW_DISTANCE .."-".. cClientHandle.MAX_VIEW_DISTANCE .."]" ) + return true + end + + Player:GetClientHandle():SetViewDistance( Split[2] ) + Player:SendMessage(cChatColor.Green .. "Your viewdistance has been set to " .. Player:GetClientHandle():GetViewDistance() ) + return true +end \ No newline at end of file diff --git a/MCServer/Plugins/Core/weather.lua b/MCServer/Plugins/Core/weather.lua new file mode 100644 index 000000000..7176e544e --- /dev/null +++ b/MCServer/Plugins/Core/weather.lua @@ -0,0 +1,10 @@ +function HandleToggleDownfallCommand( Split, Player ) + World = Player:GetWorld() + if World:GetWeather() == 0 then + World:SetWeather(1) + else + World:SetWeather(0) + end + Player:SendMessage( cChatColor.Green .. "Weather toggled") + return true +end \ No newline at end of file diff --git a/MCServer/Plugins/Core/web_chat.lua b/MCServer/Plugins/Core/web_chat.lua new file mode 100644 index 000000000..dfb17091e --- /dev/null +++ b/MCServer/Plugins/Core/web_chat.lua @@ -0,0 +1,157 @@ +local CHAT_HISTORY = 50 +local LastMessageID = 0 + +local JavaScript = [[ + +]] + +local ChatLogMessages = {} + +function AddMessage( PlayerName, Message ) + LastMessageID = LastMessageID + 1 + table.insert( ChatLogMessages, { name = PlayerName, message = Message, id = LastMessageID } ) + while( #ChatLogMessages > CHAT_HISTORY ) do + table.remove( ChatLogMessages, 1 ) + end +end + +function OnChat( Player, Message ) + AddMessage( Player:GetName(), Message ) +end + +function HandleRequest_Chat( Request ) + if( Request.PostParams["JustChat"] ~= nil ) then + local LastIdx = 0 + if( Request.PostParams["LastMessageID"] ~= nil ) then LastIdx = tonumber( Request.PostParams["LastMessageID"] ) end + local Content = "" + for key, value in pairs(ChatLogMessages) do + if( value.id > LastIdx ) then + Content = Content .. "[" .. value.name .. "]: " .. value.message .. "
" + end + end + Content = Content .. "<>" .. LastMessageID .. "<>" .. LastIdx + return Content + end + + if( Request.PostParams["ChatMessage"] ~= nil ) then + if( Request.PostParams["ChatMessage"] == "/help" ) then + Commands = "Available commands" + AddMessage(Commands, "
" .. "/help, /reload" ) + return Commands + elseif( Request.PostParams["ChatMessage"] == "/reload" ) then + Server = cRoot:Get():GetServer() + Server:SendMessage( cChatColor.Green .. "Reloading all plugins." ) + AddMessage("Reloading all plugins", "") + cRoot:Get():GetPluginManager():ReloadPlugins() + return "" + else + cmd = Request.PostParams["ChatMessage"] + if string.sub(cmd,1,string.len("/")) == "/" then + AddMessage('Unknown Command "' .. Request.PostParams["ChatMessage"] .. '"', "") + return "" + end + end + local Message = "[WebAdmin]: " .. Request.PostParams["ChatMessage"] + cRoot:Get():GetServer():SendMessage( Message ) + AddMessage("WebAdmin", Request.PostParams["ChatMessage"] ) + return "" + end + + local Content = JavaScript + Content = Content .. [[ +
+ + ]] + return Content +end \ No newline at end of file diff --git a/MCServer/Plugins/Core/web_manageplugins.lua b/MCServer/Plugins/Core/web_manageplugins.lua new file mode 100644 index 000000000..543638183 --- /dev/null +++ b/MCServer/Plugins/Core/web_manageplugins.lua @@ -0,0 +1,157 @@ +local function Button_RemovePlugin( Name, Index ) + return "
" +end + +local function Button_EnablePlugin( Name ) + return [[
]] +end + +local function Button_DisablePlugin( Name ) + return [[
]] +end + +local function FindPluginID( SettingsIni, PluginName ) + local KeyIdx = SettingsIni:FindKey("Plugins") + local NumValues = SettingsIni:GetNumValues( KeyIdx ) + + for i = 0, NumValues-1 do + LOGINFO( SettingsIni:GetValue(KeyIdx, i) ) + if( SettingsIni:GetValue(KeyIdx, i) == PluginName ) then + return i + end + end + + return nil +end + +local function RemovePluginFromIni( SettingsIni, PluginName ) + local KeyIdx = SettingsIni:FindKey("Plugins") + local PluginIdx = FindPluginID( SettingsIni, PluginName ) + + if( PluginIdx == nil ) then + LOGINFO("Got nil! NOOOO") + return false + end + + local Name = SettingsIni:GetValue( KeyIdx, PluginIdx ) + if( Name ~= PluginName ) then + LOGINFO("not the same name T_T '" .. Name .. "' '" .. PluginName .. "'") + end + if( (Name == PluginName) and (SettingsIni:DeleteValueByID( KeyIdx, PluginIdx ) == true) ) then + return SettingsIni:WriteFile() + end + + return false +end + +local function AddPluginToIni( SettingsIni, PluginName ) + RemovePluginFromIni( SettingsIni, PluginName ) -- Make sure there are no duplicates + + if( SettingsIni:SetValue("Plugins", "Plugin", PluginName, true ) == true ) then + return SettingsIni:WriteFile() + end + + return false +end + +local function HandlePluginListChanges( Request, SettingsIni ) + local Content = "" + + if( Request.PostParams["EnablePlugin"] ~= nil + and Request.PostParams["PluginName"] ~= nil ) then + + local PluginName = Request.PostParams["PluginName"] + + local PM = cRoot:Get():GetPluginManager() + if( PM:LoadPlugin( PluginName ) == false ) then + Content = "Could not enable '".. PluginName .."'!" + end + + if( AddPluginToIni( SettingsIni, PluginName ) == true ) then + Content = "Enabled plugin '".. PluginName .."'" + else + Content = "Enabled plugin '".. PluginName .."' but could not add it to settings.ini" + end + + + elseif( Request.PostParams["DisablePlugin"] ~= nil + and Request.PostParams["PluginName"] ~= nil ) then + + local PluginName = Request.PostParams["PluginName"] + + local PM = cRoot:Get():GetPluginManager() + PM:DisablePlugin( PluginName ) + + if( RemovePluginFromIni( SettingsIni, PluginName ) == true ) then + Content = "Disabled plugin '".. PluginName .."'" + else + Content = "Disabled plugin '".. PluginName .."' but could not remove it from settings.ini" + end + + + + end + + if( #Content > 0 ) then + return "

INFO: " .. Content .. "

" + else + return "" + end +end + +function HandleRequest_ManagePlugins( Request ) + local Content = "" + + if( Request.PostParams["reload"] ~= nil ) then + Content = Content .. "" + Content = Content .. "

Reloading plugins... This can take a while depending on the plugins you're using.

" + cRoot:Get():GetPluginManager():ReloadPlugins() + return Content + end + + local SettingsIni = cIniFile("settings.ini") + if( SettingsIni:ReadFile() == true ) then + Content = Content .. HandlePluginListChanges( Request, SettingsIni ) + else + Content = Content .. "Cannot find/modify settings.ini" + end + + local PluginManager = cRoot:Get():GetPluginManager() + PluginManager:FindPlugins() -- Refreshes the plugin list + local PluginList = PluginManager:GetAllPlugins() + + Content = Content .. "

Currently installed plugins

" + Content = Content .. "" + ActivePluginsName = {} + ActivePluginVersion = {} + InactivePlugins = {} + for k, Plugin in pairs(PluginList) do + if( Plugin ) then + table.insert( ActivePluginsName, k ) + table.insert( ActivePluginVersion, Plugin:GetVersion() ) + else + table.insert( InactivePlugins, k ) + end + end + table.sort( ActivePluginsName ) + table.sort( InactivePlugins ) + for i = 1, #ActivePluginsName do + Content = Content .. "" + Content = Content .. "" + Content = Content .. "" + end + for i = 1, #InactivePlugins do + Content = Content .. "" + Content = Content .. "" + Content = Content .. "" + end + Content = Content .. "
".. ActivePluginsName[i] .."" .. ActivePluginsName[i] .. " V. " .. ActivePluginVersion[i] .. "" .. Button_DisablePlugin(ActivePluginsName[i]) .. "
".. InactivePlugins[i] .."" .. Button_EnablePlugin(InactivePlugins[i]) .. "
" + + Content = Content .. "

Reload

" + Content = Content .. "
" + Content = Content .. "

Click the reload button to reload all plugins according to settings.ini!" + Content = Content .. "

" + Content = Content .. "
" + + return Content +end \ No newline at end of file diff --git a/MCServer/Plugins/Core/web_manageserver.lua b/MCServer/Plugins/Core/web_manageserver.lua new file mode 100644 index 000000000..a2936c1a8 --- /dev/null +++ b/MCServer/Plugins/Core/web_manageserver.lua @@ -0,0 +1,35 @@ +function HandleRequest_ManageServer( Request ) + local Content = "" + if (Request.PostParams["RestartServer"] ~= nil) then + cRoot:Get():QueueExecuteConsoleCommand("restart"); + elseif (Request.PostParams["ReloadServer"] ~= nil) then + cRoot:Get():GetPluginManager():ReloadPlugins(); + elseif (Request.PostParams["StopServer"] ~= nil) then + cRoot:Get():QueueExecuteConsoleCommand("stop"); + elseif (Request.PostParams["WorldSaveAllChunks"] ~= nil) then + cRoot:Get():GetWorld(Request.PostParams["WorldSaveAllChunks"]):SaveAllChunks(); + end + Content = Content .. [[ +
+ + +
+
+
+ +
Manage Server
restart the server
reload the server
stop the server
+ + + ]] + local LoopWorlds = function( World ) + Content = Content .. [[ +
+ + ]] + end + cRoot:Get():ForEachWorld( LoopWorlds ) + Content = Content .. "
Manage Worlds
Save all the chunks of world ]] .. World:GetName() .. [[
" + + return Content +end + diff --git a/MCServer/Plugins/Core/web_permissions.lua b/MCServer/Plugins/Core/web_permissions.lua new file mode 100644 index 000000000..7a8af56e9 --- /dev/null +++ b/MCServer/Plugins/Core/web_permissions.lua @@ -0,0 +1,134 @@ +local function HTML_Option( value, text, selected ) + if( selected == true ) then + return [[]] + else + return [["]] + end +end + +local function ShowUsersTable() + local Content = "

Users

" + + local NumUsers = UsersIni:GetNumKeys() + + Content = Content .. "" + + if( NumUsers > 0 ) then + Content = Content .. "" + + for i=0, NumUsers-1 do + local UserName = UsersIni:GetKeyName( i ) + + Content = Content .. "" + Content = Content .. "" + Content = Content .. "" + Content = Content .. "" + Content = Content .. "" + end + else + Content = Content .. "" + end + Content = Content .. "
UserGroups
" .. i .. "." .. UserName .. "" + Content = Content .. UsersIni:GetValue( UserName, "Groups", "-" ) + Content = Content .. "
None
" + + + return Content +end + +local function ShowGroupsTable() + local Content = "

Groups

" + + local NumGroups = GroupsIni:GetNumKeys() + + Content = Content .. "" + if( NumGroups > 0 ) then + Content = Content .. "" + + for i=0, NumGroups-1 do + local GroupName = GroupsIni:GetKeyName( i ) + + Content = Content .. "" + Content = Content .. "" + Content = Content .. "" + Content = Content .. "" + Content = Content .. "" + Content = Content .. "" + end + else + Content = Content .. "" + end + Content = Content .. "
NamePermissionsColor
" .. i .. "." .. GroupName .. "" + Content = Content .. GroupsIni:GetValue( GroupName, "Permissions", "-" ) + Content = Content .. "" + Content = Content .. GroupsIni:GetValue( GroupName, "Color", "-" ) + Content = Content .. "
None
" + + return Content +end + +local function HTML_Select_Group( name, defaultValue ) + Groups = "" + for I=0, GroupsIni:GetNumKeys() - 1 do + Groups = Groups .. + HTML_Option(GroupsIni:KeyName(I), GroupsIni:KeyName(I), defaultValue == GroupsIni:KeyName(I) ) + end + return [[]] +end + + +local function AddPlayers( Request ) + local Content = "

Add or change Players

" + if( Request.PostParams["AddPlayerToGroup"] ~= nil ) then + if Request.PostParams["AddPlayer"] ~= "" then + if Request.PostParams["AddGroups"] ~= "" then + if GroupsIni:FindKey(Request.PostParams["AddGroup"]) == -1 then + return "Group does not exist" + end + UsersIni:DeleteKey(Request.PostParams["AddPlayer"]) + UsersIni:GetValueSet(Request.PostParams["AddPlayer"], "Groups", Request.PostParams["AddGroup"]) + UsersIni:WriteFile() + local loopPlayers = function( Player ) + if Player:GetName() == Request.PostParams["AddPlayer"] then + Player:SendMessage( cChatColor.Green .. "You were moved to group " .. Request.PostParams["AddGroup"] ) + Player:LoadPermissionsFromDisk() + end + end + local loopWorlds = function ( World ) + World:ForEachPlayer( loopPlayers ) + end + cRoot:Get():ForEachWorld( loopWorlds ) + end + end + end + Content = Content .. [[ + + + +
+ + +
Player:
Group:]] .. HTML_Select_Group("AddGroup", GroupsIni:KeyName(0) ) .. [[
+ ]] + + return Content +end + +function HandleRequest_Permissions( Request ) + GroupsIni = cIniFile("groups.ini") + if( GroupsIni:ReadFile() == false ) then + return "Could not read groups.ini!" + end + UsersIni = cIniFile("users.ini") + if( UsersIni:ReadFile() == false ) then + return "Could not read users.ini!" + end + + local Content = "" + + Content = Content .. AddPlayers( Request ) + Content = Content .. ShowGroupsTable() + Content = Content .. ShowUsersTable() + + return Content +end \ No newline at end of file diff --git a/MCServer/Plugins/Core/web_playerlist.lua b/MCServer/Plugins/Core/web_playerlist.lua new file mode 100644 index 000000000..6ac25db86 --- /dev/null +++ b/MCServer/Plugins/Core/web_playerlist.lua @@ -0,0 +1,38 @@ +function HandleRequest_PlayerList( Request ) + local World = cRoot:Get():GetDefaultWorld() + local Content = "" + + if( Request.Params["playerlist-kick"] ~= nil ) then + local KickPlayerName = Request.Params["playerlist-kick"] + local FoundPlayerCallback = function( Player ) + if( Player:GetName() == KickPlayerName ) then + Player:GetClientHandle():Kick("You were kicked from the game!") + Content = Content .. "

" .. KickPlayerName .. " has been kicked from the game!

" + end + end + if( World:DoWithPlayer( KickPlayerName, FoundPlayerCallback ) == false ) then + Content = Content .. "

Could not find player " .. KickPlayerName .. " !

" + end + end + + Content = Content .. "

Connected Players: " .. World:GetNumPlayers() .. "

" + Content = Content .. "" + + local PlayerNum = 0 + local AddPlayerToTable = function( Player ) + PlayerNum = PlayerNum + 1 + Content = Content .. "" + Content = Content .. "" + Content = Content .. "" + Content = Content .. "" + Content = Content .. "" + end + cRoot:Get():ForEachPlayer( AddPlayerToTable ) + + if( PlayerNum == 0 ) then + Content = Content .. "" + end + Content = Content .. "
" .. PlayerNum .. "." .. Player:GetName() .. "Kick
None
" + Content = Content .. "
" + return Content +end \ No newline at end of file diff --git a/MCServer/Plugins/Core/web_serversettings.lua b/MCServer/Plugins/Core/web_serversettings.lua new file mode 100644 index 000000000..700d84ae1 --- /dev/null +++ b/MCServer/Plugins/Core/web_serversettings.lua @@ -0,0 +1,924 @@ +-- Some HTML helper functions +local function HTML_Option( value, text, selected ) + if( selected == true ) then + return [[]] + else + return [["]] + end +end + +local function HTML_Select_On_Off( name, defaultValue ) + return [[]] +end + +local function HTML_Select_Version( name, defaultValue ) + return [[]] +end + + +local function ShowGeneralSettings( Request ) + local Content = "" + local InfoMsg = nil + + local SettingsIni = cIniFile("settings.ini") + if( SettingsIni:ReadFile() == false ) then + InfoMsg = "ERROR: Could not read settings.ini!" + end + + if( Request.PostParams["general_submit"] ~= nil ) then + + SettingsIni:SetValue("Server", "Description",Request.PostParams["Server_Description"],false ) + if( tonumber( Request.PostParams["Server_MaxPlayers"] ) ~= nil ) then + SettingsIni:SetValue("Server", "MaxPlayers", Request.PostParams["Server_MaxPlayers"], false ) + end + if( tonumber( Request.PostParams["Server_Port"] ) ~= nil ) then + if( tonumber( Request.PostParams["Server_Port"] ) > 0 ) then + SettingsIni:SetValue("Server", "Port", Request.PostParams["Server_Port"], false ) + end + end + if( tonumber( Request.PostParams["Server_PortsIPv6"] ) ~= nil ) then + SettingsIni:SetValue("Server", "PortsIPv6", Request.PostParams["Server_PortsIPv6"], false ) + end + if( tonumber( Request.PostParams["Server_Version"] ) ~= nil ) then + SettingsIni:SetValue("Server", "PrimaryServerVersion", Request.PostParams["Server_Version"], false ) + end + if( tonumber( Request.PostParams["Authentication_Authenticate"] ) ~= nil ) then + SettingsIni:SetValue("Authentication", "Authenticate", Request.PostParams["Authentication_Authenticate"], false ) + end + if( tonumber( Request.PostParams["Limit_World"] ) ~= nil ) then + SettingsIni:SetValue("Worlds", "LimitWorld", Request.PostParams["Limit_World"], false ) + end + if( tonumber( Request.PostParams["LimitWorldWidth"] ) ~= nil ) then + SettingsIni:SetValue("Worlds", "LimitWorldWidth", Request.PostParams["LimitWorldWidth"], false ) + end + + if( SettingsIni:WriteFile() == false ) then + InfoMsg = [[ERROR: Could not write to settings.ini!]] + else + InfoMsg = [[INFO: Successfully saved changes to settings.ini]] + end + end + + + Content = Content .. [[ + +

General Settings

]] + + if( InfoMsg ~= nil ) then + Content = Content .. "

" .. InfoMsg .. "

" + end + Content = Content .. [[ + + + + + + + + + + + + +
Server
Description:
Max Players:
Port:
PortsIPv6:
Shown Version:]] .. HTML_Select_Version("Server_Version", SettingsIni:GetValueI("Server", "PrimaryServerVersion") ) .. [[

+ + + + + +
Authentication
Authenticate:]] .. HTML_Select_On_Off("Authentication_Authenticate", SettingsIni:GetValueI("Authentication", "Authenticate") ) .. [[

+ + + + + + + +
LimitWorld
Limit World:]] .. HTML_Select_On_Off("Limit_World", SettingsIni:GetValueI("Worlds", "LimitWorld") ) .. [[
Max Chunks from spawn:

+ WARNING: Any changes made here might require a server restart in order to be applied! +
]] + + return Content +end + + +local function ShowMonstersSettings( Request ) + local Content = "" + local InfoMsg = nil + + local SettingsIni = cIniFile("settings.ini") + if( SettingsIni:ReadFile() == false ) then + InfoMsg = "ERROR: Could not read settings.ini!" + 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 = "ERROR: Could not write to settings.ini!" + else + InfoMsg = "INFO: Successfully saved changes to settings.ini" + end + end + + + Content = Content .. "
" + + Content = Content .. "

Monsters Settings

" + if( InfoMsg ~= nil ) then + Content = Content .. "

" .. InfoMsg .. "

" + end + + Content = Content .. [[ + + + + + + + + +
Monsters
Animals On:]] .. HTML_Select_On_Off("Monsters_AnimalsOn", SettingsIni:GetValueI("Monsters", "AnimalsOn") ) .. [[
Animal Spawn Interval:
Monster Types:

+ WARNING: Any changes made here might require a server restart in order to be applied! +
]] + + return Content +end + +local function ShowWorldsSettings( Request ) + local Content = "" + local InfoMsg = nil + local bSaveIni = false + + local SettingsIni = cIniFile("settings.ini") + if( SettingsIni:ReadFile() == false ) then + InfoMsg = [[ERROR: Could not read settings.ini!]] + end + + if( Request.PostParams["RemoveWorld"] ~= nil ) then + Content = Content .. Request.PostParams["RemoveWorld"] + local WorldIdx = string.sub( Request.PostParams["RemoveWorld"], string.len("Remove ") ) + local KeyIdx = SettingsIni:FindKey("Worlds") + local WorldName = SettingsIni:GetValue( KeyIdx, WorldIdx ) + if( SettingsIni:DeleteValueByID( KeyIdx, WorldIdx ) == true ) then + InfoMsg = "INFO: Successfully removed world " .. WorldName .. "!
" + bSaveIni = true + end + end + + if( Request.PostParams["AddWorld"] ~= nil ) then + if( Request.PostParams["WorldName"] ~= nil and Request.PostParams["WorldName"] ~= "" ) then + SettingsIni:SetValue("Worlds", "World", Request.PostParams["WorldName"], true ) + InfoMsg = "INFO: Successfully added world " .. Request.PostParams["WorldName"] .. "!
" + bSaveIni = true + end + end + + if( Request.PostParams["worlds_submit"] ~= nil ) then + SettingsIni:SetValue("Worlds", "DefaultWorld", Request.PostParams["Worlds_DefaultWorld"], false ) + if( Request.PostParams["Worlds_World"] ~= nil ) then + SettingsIni:SetValue("Worlds", "World", Request.PostParams["Worlds_World"], true ) + end + bSaveIni = true + end + + if( bSaveIni == true ) then + if( InfoMsg == nil ) then InfoMsg = "" end + if( SettingsIni:WriteFile() == false ) then + InfoMsg = InfoMsg .. "ERROR: Could not write to settings.ini!" + else + InfoMsg = InfoMsg .. "INFO: Successfully saved changes to settings.ini" + end + end + + Content = Content .. "

Worlds Settings

" + if( InfoMsg ~= nil ) then + Content = Content .. "

" .. InfoMsg .. "

" + end + + Content = Content .. [[ +
+ + + + ]] + + local KeyIdx = SettingsIni:FindKey("Worlds") + local NumValues = SettingsIni:GetNumValues( KeyIdx ) + for i = 0, NumValues-1 do + local ValueName = SettingsIni:GetValueName(KeyIdx, i ) + if( ValueName == "World" ) then + local WorldName = SettingsIni:GetValue(KeyIdx, i) + Content = Content .. [[ + ]] + end + end + + Content = Content .. [[ + + +
Worlds
Default World:
]] .. ValueName .. [[:
]] .. WorldName .. [[
Add World:

+ + WARNING: Any changes made here might require a server restart in order to be applied! +
]] + return Content +end + +local function SelectWorldButton( WorldName ) + return "
" +end + +local function HTML_Select_Dimension( name, defaultValue ) + return [[]] +end + +local function HTML_Select_Scheme( name, defaultValue ) + return [[]] +end + +local function HTML_Select_GameMode( name, defaultValue ) + return [[]] +end + +local function HTML_Select_Simulator( name, defaultValue ) + return [[]] +end + +local function HTML_Select_BiomeGen( name, defaultValue ) + return [[]] +end + +local function HTML_Select_HeightGen( name, defaultValue ) + return [[]] +end + +local function HTML_Select_CompositionGen( name, defaultValue ) + return [[]] +end + +local function HTML_Select_Generator( name, defaultValue ) + return [[]] +end + +local function HTML_Select_Biome( name, defaultValue ) + return [[]] +end + +function ShowWorldSettings( Request ) + local Content = "" + local InfoMsg = nil + local SettingsIni = cIniFile("settings.ini") + if( SettingsIni:ReadFile() == false ) then + InfoMsg = [[ERROR: Could not read settings.ini!]] + end + if (Request.PostParams["SelectWorld"] ~= nil and Request.PostParams["WorldName"] ~= nil) then -- World is selected! + WORLD = Request.PostParams["WorldName"] + SelectedWorld = cRoot:Get():GetWorld(WORLD) + elseif SelectedWorld == nil then + WORLD = SettingsIni:GetValue("Worlds", "DefaultWorld") + SelectedWorld = cRoot:Get():GetWorld( WORLD ) + end + local WorldIni = cIniFile(SelectedWorld:GetName() .. "/world.ini") + WorldIni:ReadFile() + if (Request.PostParams["world_submit"]) ~= nil then + if( tonumber( Request.PostParams["World_Dimension"] ) ~= nil ) then + WorldIni:DeleteValue( "General", "Dimension" ) + WorldIni:SetValue( "General", "Dimension", Request.PostParams["World_Dimension"] ) + end + if( tonumber( Request.PostParams["World_Schema"] ) ~= nil ) then + WorldIni:DeleteValue( "General", "Schema" ) + WorldIni:SetValue( "General", "Schema", Request.PostParams["World_Schema"] ) + end + if( tonumber( Request.PostParams["World_SpawnX"] ) ~= nil ) then + WorldIni:DeleteValue( "SpawnPosition", "X" ) + WorldIni:SetValue( "SpawnPosition", "X", Request.PostParams["World_SpawnX"] ) + end + if( tonumber( Request.PostParams["World_SpawnY"] ) ~= nil ) then + WorldIni:DeleteValue( "SpawnPosition", "Y" ) + WorldIni:SetValue( "SpawnPosition", "Y", Request.PostParams["World_SpawnY"] ) + end + if( tonumber( Request.PostParams["World_SpawnZ"] ) ~= nil ) then + WorldIni:DeleteValue( "SpawnPosition", "Z" ) + WorldIni:SetValue( "SpawnPosition", "Z", Request.PostParams["World_SpawnZ"] ) + end + if( tonumber( Request.PostParams["World_Seed"] ) ~= nil ) then + WorldIni:DeleteValue( "Seed", "Seed" ) + WorldIni:SetValue( "Seed", "Seed", Request.PostParams["World_Seed"] ) + end + if( tonumber( Request.PostParams["World_PVP"] ) ~= nil ) then + WorldIni:DeleteValue( "PVP", "Enabled" ) + WorldIni:SetValue( "PVP", "Enabled", Request.PostParams["World_PVP"] ) + end + if( tonumber( Request.PostParams["World_GameMode"] ) ~= nil ) then + WorldIni:DeleteValue( "GameMode", "GameMode" ) + WorldIni:SetValue( "GameMode", "GameMode", Request.PostParams["World_GameMode"] ) + end + if( tonumber( Request.PostParams["World_DeepSnow"] ) ~= nil ) then + WorldIni:DeleteValue( "Physics", "DeepSnow" ) + WorldIni:SetValue( "Physics", "DeepSnow", Request.PostParams["World_DeepSnow"] ) + end + if( tonumber( Request.PostParams["World_SandInstantFall"] ) ~= nil ) then + WorldIni:DeleteValue( "Physics", "SandInstantFall" ) + WorldIni:SetValue( "Physics", "SandInstantFall", Request.PostParams["World_SandInstantFall"] ) + end + if( tonumber( Request.PostParams["World_WaterSimulator"] ) ~= nil ) then + WorldIni:DeleteValue( "Physics", "WaterSimulator" ) + WorldIni:SetValue( "Physics", "WaterSimulator", Request.PostParams["World_WaterSimulator"] ) + end + if( tonumber( Request.PostParams["World_LavaSimulator"] ) ~= nil ) then + WorldIni:DeleteValue( "Physics", "LavaSimulator" ) + WorldIni:SetValue( "Physics", "LavaSimulator", Request.PostParams["World_LavaSimulator"] ) + end + if( tonumber( Request.PostParams["World_MaxSugarcaneHeight"] ) ~= nil ) then + WorldIni:DeleteValue( "Plants", "MaxSugarcaneHeight" ) + WorldIni:SetValue( "Plants", "MaxSugarcaneHeight", Request.PostParams["World_MaxSugarcaneHeight"] ) + end + if( tonumber( Request.PostParams["World_MaxCactusHeight"] ) ~= nil ) then + WorldIni:DeleteValue( "Plants", "MaxCactusHeight" ) + WorldIni:SetValue( "Plants", "MaxCactusHeight", Request.PostParams["World_MaxCactusHeight"] ) + end + if( tonumber( Request.PostParams["World_CarrotsBonemealable"] ) ~= nil ) then + WorldIni:DeleteValue( "Plants", "IsCarrotsBonemealable" ) + WorldIni:SetValue( "Plants", "IsCarrotsBonemealable", Request.PostParams["World_CarrotsBonemealable"] ) + end + if( tonumber( Request.PostParams["World_CropsBonemealable"] ) ~= nil ) then + WorldIni:DeleteValue( "Plants", "IsCropsBonemealable" ) + WorldIni:SetValue( "Plants", "IsCropsBonemealable", Request.PostParams["World_CropsBonemealable"] ) + end + if( tonumber( Request.PostParams["World_GrassBonemealable"] ) ~= nil ) then + WorldIni:DeleteValue( "Plants", "IsGrassBonemealable" ) + WorldIni:SetValue( "Plants", "IsGrassBonemealable", Request.PostParams["World_GrassBonemealable"] ) + end + if( tonumber( Request.PostParams["World_SaplingBonemealable"] ) ~= nil ) then + WorldIni:DeleteValue( "Plants", "IsSaplingBonemealable" ) + WorldIni:SetValue( "Plants", "IsSaplingBonemealable", Request.PostParams["World_SaplingBonemealable"] ) + end + if( tonumber( Request.PostParams["World_MelonStemBonemealable"] ) ~= nil ) then + WorldIni:DeleteValue( "Plants", "IsMelonStemBonemealable" ) + WorldIni:SetValue( "Plants", "IsMelonStemBonemealable", Request.PostParams["World_MelonStemBonemealable"] ) + end + if( tonumber( Request.PostParams["World_MelonBonemealable"] ) ~= nil ) then + WorldIni:DeleteValue( "Plants", "IsMelonBonemealable" ) + WorldIni:SetValue( "Plants", "IsMelonBonemealable", Request.PostParams["World_MelonBonemealable"] ) + end + if( tonumber( Request.PostParams["World_PotatoesBonemealable"] ) ~= nil ) then + WorldIni:DeleteValue( "Plants", "IsPotatoesBonemealable" ) + WorldIni:SetValue( "Plants", "IsPotatoesBonemealable", Request.PostParams["World_PotatoesBonemealable"] ) + end + if( tonumber( Request.PostParams["World_PumpkinStemBonemealable"] ) ~= nil ) then + WorldIni:DeleteValue( "Plants", "IsPumpkinStemBonemealable" ) + WorldIni:SetValue( "Plants", "IsPumpkinStemBonemealable", Request.PostParams["World_PumpkinStemBonemealable"] ) + end + if( tonumber( Request.PostParams["World_PumpkinBonemealable"] ) ~= nil ) then + WorldIni:DeleteValue( "Plants", "IsPumpkinBonemealable" ) + WorldIni:SetValue( "Plants", "IsPumpkinBonemealable", Request.PostParams["World_PumpkinBonemealable"] ) + end + if( tonumber( Request.PostParams["World_SugarCaneBonemealable"] ) ~= nil ) then + WorldIni:DeleteValue( "Plants", "IsSugarCaneBonemealable" ) + WorldIni:SetValue( "Plants", "IsSugarCaneBonemealable", Request.PostParams["World_SugarCaneBonemealable"] ) + end + if( tonumber( Request.PostParams["World_CactusBonemealable"] ) ~= nil ) then + WorldIni:DeleteValue( "Plants", "IsCactusBonemealable" ) + WorldIni:SetValue( "Plants", "IsCactusBonemealable", Request.PostParams["World_CactusBonemealable"] ) + end + if( ( Request.PostParams["World_BiomeGen"] ) ~= nil ) then + WorldIni:DeleteValue( "Generator", "BiomeGen" ) + WorldIni:SetValue( "Generator", "BiomeGen", Request.PostParams["World_BiomeGen"] ) + end + if( ( Request.PostParams["World_Biome"] ) ~= nil ) then + WorldIni:DeleteValue( "Generator", "ConstantBiome" ) + WorldIni:SetValue( "Generator", "ConstantBiome", Request.PostParams["World_Biome"] ) + end + if( ( Request.PostParams["World_MultiStepMapOceanCellSize"] ) ~= nil ) then + WorldIni:DeleteValue( "Generator", "MultiStepMapOceanCellSize" ) + WorldIni:SetValue( "Generator", "MultiStepMapOceanCellSize", Request.PostParams["World_MultiStepMapOceanCellSize"] ) + end + if( ( Request.PostParams["World_MultiStepMapMushroomIslandSize"] ) ~= nil ) then + WorldIni:DeleteValue( "Generator", "MultiStepMapMushroomIslandSize" ) + WorldIni:SetValue( "Generator", "MultiStepMapMushroomIslandSize", Request.PostParams["World_MultiStepMapMushroomIslandSize"] ) + end + if( ( Request.PostParams["World_MultiStepMapRiverCellSize"] ) ~= nil ) then + WorldIni:DeleteValue( "Generator", "MultiStepMapRiverCellSize" ) + WorldIni:SetValue( "Generator", "MultiStepMapRiverCellSize", Request.PostParams["World_MultiStepMapRiverCellSize"] ) + end + if( ( Request.PostParams["World_MultiStepMapRiverWidth"] ) ~= nil ) then + WorldIni:DeleteValue( "Generator", "MultiStepMapRiverWidth" ) + WorldIni:SetValue( "Generator", "MultiStepMapRiverWidth", Request.PostParams["World_MultiStepMapRiverWidth"] ) + end + if( ( Request.PostParams["World_MultiStepMapLandBiomeSize"] ) ~= nil ) then + WorldIni:DeleteValue( "Generator", "MultiStepMapLandBiomeSize" ) + WorldIni:SetValue( "Generator", "MultiStepMapLandBiomeSize", Request.PostParams["World_MultiStepMapLandBiomeSize"] ) + end + if( ( Request.PostParams["World_DistortedVoronoiCellSize"] ) ~= nil ) then + WorldIni:DeleteValue( "Generator", "DistortedVoronoiCellSize" ) + WorldIni:SetValue( "Generator", "DistortedVoronoiCellSize", Request.PostParams["World_DistortedVoronoiCellSize"] ) + end + if( ( Request.PostParams["World_DistortedVoronoiBiomes"] ) ~= nil ) then + WorldIni:DeleteValue( "Generator", "DistortedVoronoiBiomes" ) + WorldIni:SetValue( "Generator", "DistortedVoronoiBiomes", Request.PostParams["World_DistortedVoronoiBiomes"] ) + end + if( ( Request.PostParams["World_VoronoiCellSize"] ) ~= nil ) then + WorldIni:DeleteValue( "Generator", "VoronoiCellSize" ) + WorldIni:SetValue( "Generator", "VoronoiCellSize", Request.PostParams["World_VoronoiCellSize"] ) + end + if( ( Request.PostParams["World_VoronoiBiomesdVoronoiBiomes"] ) ~= nil ) then + WorldIni:DeleteValue( "Generator", "VoronoiBiomes" ) + WorldIni:SetValue( "Generator", "VoronoiBiomes", Request.PostParams["World_VoronoiBiomes"] ) + end + if( ( Request.PostParams["World_CheckerBoardBiomes"] ) ~= nil ) then + WorldIni:DeleteValue( "Generator", "CheckerBoardBiomes" ) + WorldIni:SetValue( "Generator", "CheckerBoardBiomes", Request.PostParams["World_CheckerBoardBiomes"] ) + end + if( ( Request.PostParams["World_CheckerBoardBiomeSize"] ) ~= nil ) then + WorldIni:DeleteValue( "Generator", "CheckerBoardBiomeSize" ) + WorldIni:SetValue( "Generator", "CheckerBoardBiomeSize", Request.PostParams["World_CheckerBoardBiomeSize"] ) + end + if( ( Request.PostParams["World_HeightGen"] ) ~= nil ) then + WorldIni:DeleteValue( "Generator", "HeightGen" ) + WorldIni:SetValue( "Generator", "HeightGen", Request.PostParams["World_HeightGen"] ) + end + if( ( Request.PostParams["World_FlatHeight"] ) ~= nil ) then + WorldIni:DeleteValue( "Generator", "FlatHeight" ) + WorldIni:SetValue( "Generator", "FlatHeight", Request.PostParams["World_FlatHeight"] ) + end + if( ( Request.PostParams["World_CompositionGen"] ) ~= nil ) then + WorldIni:DeleteValue( "Generator", "CompositionGen" ) + WorldIni:SetValue( "Generator", "CompositionGen", Request.PostParams["World_CompositionGen"] ) + end + if( ( Request.PostParams["World_Noise3DSeaLevel"] ) ~= nil ) then + WorldIni:DeleteValue( "Generator", "Noise3DSeaLevel" ) + WorldIni:SetValue( "Generator", "Noise3DSeaLevel", Request.PostParams["World_Noise3DSeaLevel"] ) + end + if( ( Request.PostParams["World_Noise3DHeightAmplification"] ) ~= nil ) then + WorldIni:DeleteValue( "Generator", "Noise3DHeightAmplification" ) + WorldIni:SetValue( "Generator", "Noise3DHeightAmplification", Request.PostParams["World_Noise3DHeightAmplification"] ) + end + if( ( Request.PostParams["World_Noise3DMidPoint"] ) ~= nil ) then + WorldIni:DeleteValue( "Generator", "Noise3DMidPoint" ) + WorldIni:SetValue( "Generator", "Noise3DMidPoint", Request.PostParams["World_Noise3DMidPoint"] ) + end + if( ( Request.PostParams["World_Noise3DFrequencyX"] ) ~= nil ) then + WorldIni:DeleteValue( "Generator", "Noise3DFrequencyX" ) + WorldIni:SetValue( "Generator", "Noise3DFrequencyX", Request.PostParams["World_Noise3DFrequencyX"] ) + end + if( ( Request.PostParams["World_Noise3DFrequencyY"] ) ~= nil ) then + WorldIni:DeleteValue( "Generator", "Noise3DFrequencyY" ) + WorldIni:SetValue( "Generator", "Noise3DFrequencyY", Request.PostParams["World_Noise3DFrequencyY"] ) + end + if( ( Request.PostParams["World_Noise3DFrequencyZ"] ) ~= nil ) then + WorldIni:DeleteValue( "Generator", "Noise3DFrequencyZ" ) + WorldIni:SetValue( "Generator", "Noise3DFrequencyZ", Request.PostParams["World_Noise3DFrequencyZ"] ) + end + if( ( Request.PostParams["World_Noise3DAirThreshold"] ) ~= nil ) then + WorldIni:DeleteValue( "Generator", "Noise3DAirThreshold" ) + WorldIni:SetValue( "Generator", "Noise3DAirThreshold", Request.PostParams["World_Noise3DAirThreshold"] ) + end + if( ( Request.PostParams["World_ClassicSeaLevel"] ) ~= nil ) then + WorldIni:DeleteValue( "Generator", "ClassicSeaLevel" ) + WorldIni:SetValue( "Generator", "ClassicSeaLevel", Request.PostParams["World_ClassicSeaLevel"] ) + end + if( ( Request.PostParams["World_ClassicBeachHeight"] ) ~= nil ) then + WorldIni:DeleteValue( "Generator", "ClassicBeachHeight" ) + WorldIni:SetValue( "Generator", "ClassicBeachHeight", Request.PostParams["World_ClassicBeachHeight"] ) + end + if( ( Request.PostParams["World_ClassicBeachDepth"] ) ~= nil ) then + WorldIni:DeleteValue( "Generator", "ClassicBeachDepth" ) + WorldIni:SetValue( "Generator", "ClassicBeachDepth", Request.PostParams["World_ClassicBeachDepth"] ) + end + if( ( Request.PostParams["World_ClassicBlockTop"] ) ~= nil ) then + WorldIni:DeleteValue( "Generator", "ClassicBlockTop" ) + WorldIni:SetValue( "Generator", "ClassicBlockTop", Request.PostParams["World_ClassicBlockTop"] ) + end + if( ( Request.PostParams["World_ClassicBlockMiddle"] ) ~= nil ) then + WorldIni:DeleteValue( "Generator", "ClassicBlockMiddle" ) + WorldIni:SetValue( "Generator", "ClassicBlockMiddle", Request.PostParams["World_ClassicBlockMiddle"] ) + end + if( ( Request.PostParams["World_ClassicBlockBottom"] ) ~= nil ) then + WorldIni:DeleteValue( "Generator", "ClassicBlockBottom" ) + WorldIni:SetValue( "Generator", "ClassicBlockBottom", Request.PostParams["World_ClassicBlockBottom"] ) + end + if( ( Request.PostParams["World_ClassicBlockBeach"] ) ~= nil ) then + WorldIni:DeleteValue( "Generator", "ClassicBlockBeach" ) + WorldIni:SetValue( "Generator", "ClassicBlockBeach", Request.PostParams["World_ClassicBlockBeach"] ) + end + if( ( Request.PostParams["World_ClassicBlockBeachBottom"] ) ~= nil ) then + WorldIni:DeleteValue( "Generator", "ClassicBlockBeachBottom" ) + WorldIni:SetValue( "Generator", "ClassicBlockBeachBottom", Request.PostParams["World_ClassicBlockBeachBottom"] ) + end + if( ( Request.PostParams["World_ClassicBlockSea"] ) ~= nil ) then + WorldIni:DeleteValue( "Generator", "ClassicBlockSea" ) + WorldIni:SetValue( "Generator", "ClassicBlockSea", Request.PostParams["World_ClassicBlockSea"] ) + end + if( ( Request.PostParams["World_SameBlockType"] ) ~= nil ) then + WorldIni:DeleteValue( "Generator", "SameBlockType" ) + WorldIni:SetValue( "Generator", "SameBlockType", Request.PostParams["World_SameBlockType"] ) + end + if( ( Request.PostParams["World_SameBlockBedrocked"] ) ~= nil ) then + WorldIni:DeleteValue( "Generator", "SameBlockBedrocked" ) + WorldIni:SetValue( "Generator", "SameBlockBedrocked", Request.PostParams["World_SameBlockBedrocked"] ) + end + if( ( Request.PostParams["World_Structures"] ) ~= nil ) then + WorldIni:DeleteValue( "Generator", "Structures" ) + WorldIni:SetValue( "Generator", "Structures", Request.PostParams["World_Structures"] ) + end + if( ( Request.PostParams["World_Finishers"] ) ~= nil ) then + WorldIni:DeleteValue( "Generator", "Finishers" ) + WorldIni:SetValue( "Generator", "Finishers", Request.PostParams["World_Finishers"] ) + end + if( ( Request.PostParams["World_Generator"] ) ~= nil ) then + WorldIni:DeleteValue( "Generator", "Generator" ) + WorldIni:SetValue( "Generator", "Generator", Request.PostParams["World_Generator"] ) + end + if( ( Request.PostParams["World_MineShaftsGridSize"] ) ~= nil ) then + WorldIni:DeleteValue( "Generator", "MineShaftsGridSize" ) + WorldIni:SetValue( "Generator", "MineShaftsGridSize", Request.PostParams["World_MineShaftsGridSize"] ) + end + if( ( Request.PostParams["World_MineShaftsMaxSystemSize"] ) ~= nil ) then + WorldIni:DeleteValue( "Generator", "MineShaftsMaxSystemSize" ) + WorldIni:SetValue( "Generator", "MineShaftsMaxSystemSize", Request.PostParams["World_MineShaftsMaxSystemSize"] ) + end + if( ( Request.PostParams["World_MineShaftsChanceCorridor"] ) ~= nil ) then + WorldIni:DeleteValue( "Generator", "MineShaftsChanceCorridor" ) + WorldIni:SetValue( "Generator", "MineShaftsChanceCorridor", Request.PostParams["World_MineShaftsChanceCorridor"] ) + end + if( ( Request.PostParams["World_MineShaftsChanceCrossing"] ) ~= nil ) then + WorldIni:DeleteValue( "Generator", "MineShaftsChanceCrossing" ) + WorldIni:SetValue( "Generator", "MineShaftsChanceCrossing", Request.PostParams["World_MineShaftsChanceCrossing"] ) + end + if( ( Request.PostParams["World_MineShaftsChanceStaircase"] ) ~= nil ) then + WorldIni:DeleteValue( "Generator", "MineShaftsChanceStaircase" ) + WorldIni:SetValue( "Generator", "MineShaftsChanceStaircase", Request.PostParams["World_MineShaftsChanceStaircase"] ) + end + if( ( Request.PostParams["World_LavaLakesProbability"] ) ~= nil ) then + WorldIni:DeleteValue( "Generator", "LavaLakesProbability" ) + WorldIni:SetValue( "Generator", "LavaLakesProbability", Request.PostParams["World_LavaLakesProbability"] ) + end + if( ( Request.PostParams["World_WaterLakesProbability"] ) ~= nil ) then + WorldIni:DeleteValue( "Generator", "WaterLakesProbability" ) + WorldIni:SetValue( "Generator", "WaterLakesProbability", Request.PostParams["World_WaterLakesProbability"] ) + end + if( ( Request.PostParams["World_BottomLavaLevel"] ) ~= nil ) then + WorldIni:DeleteValue( "Generator", "BottomLavaLevel" ) + WorldIni:SetValue( "Generator", "BottomLavaLevel", Request.PostParams["World_BottomLavaLevel"] ) + end + + WorldIni:WriteFile() + end + Content = Content .. "

World for operations: " .. WORLD .. "

" + Content = Content .. "" + local WorldNum = 0 + local AddWorldToTable = function(World) + WorldNum = WorldNum + 1 + Content = Content .. "" + Content = Content .. "" + Content = Content .. "" + Content = Content .. "" + Content = Content .. "" + end + cRoot:Get():ForEachWorld(AddWorldToTable) + Content = Content .. "
" .. WorldNum .. "." .. World:GetName() .. "" .. SelectWorldButton(World:GetName()) .. "
" + + + Content = Content .. [[ + +
+ + + +
General
Dimension:]] .. HTML_Select_Dimension("World_Dimension", WorldIni:GetValueI("General", "Dimension") ) .. [[
+
+ + + + +
Storage
Schema:]] .. HTML_Select_Scheme("World_Schema", WorldIni:GetValueI("Storage", "Schema") ) .. [[
+
+ + + + + + + + +
Spawn Position
X:
Y:
Z:
+
+ + + + +
Seed
Seed:
+
+ + + + +
PVP
PVP:]] .. HTML_Select_On_Off("World_PVP", WorldIni:GetValueI("PVP", "Enabled") ) .. [[
+
+ + + + +
GameMode
GameMode:]] .. HTML_Select_GameMode("World_GameMode", WorldIni:GetValueI("GameMode", "GameMode") ) .. [[
+
+ + + + + + + + + + +
Physics
DeepSnow:]] .. HTML_Select_On_Off("World_DeepSnow", WorldIni:GetValueI("Physics", "DeepSnow") ) .. [[
SandInstantFall:]] .. HTML_Select_On_Off("World_SandInstantFall", WorldIni:GetValueI("Physics", "SandInstantFall") ) .. [[
WaterSimulator:]] .. HTML_Select_Simulator("World_WaterSimulator", WorldIni:GetValue("Physics", "WaterSimulator") ) .. [[
LavaSimulator:]] .. HTML_Select_Simulator("World_LavaSimulator", WorldIni:GetValue("Physics", "LavaSimulator") ) .. [[
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Plants
MaxCactusHeight:
MaxSugarcaneHeigh:
CarrotsBonemealable:]] .. HTML_Select_On_Off("World_CarrotsBonemealable", WorldIni:GetValueI("Plants", "IsCarrotsBonemealable") ) .. [[
CropsBonemealable:]] .. HTML_Select_On_Off("World_CropsBonemealable", WorldIni:GetValueI("Plants", "IsCropsBonemealable") ) .. [[
GrassBonemealabl:]] .. HTML_Select_On_Off("World_GrassBonemealable", WorldIni:GetValueI("Plants", "IsGrassBonemealable") ) .. [[
SaplingBonemealable:]] .. HTML_Select_On_Off("World_SaplingBonemealable", WorldIni:GetValueI("Plants", "IsSaplingBonemealable") ) .. [[
MelonStemBonemealable:]] .. HTML_Select_On_Off("World_MelonStemBonemealable", WorldIni:GetValueI("Plants", "IsMelonStemBonemealable") ) .. [[
MelonBonemealable:]] .. HTML_Select_On_Off("World_MelonBonemealable", WorldIni:GetValueI("Plants", "IsMelonBonemealable") ) .. [[
PotatoesBonemealable:]] .. HTML_Select_On_Off("World_PotatoesBonemealable", WorldIni:GetValueI("Plants", "IsPotatoesBonemealable") ) .. [[
PumpkinStemBonemealable:]] .. HTML_Select_On_Off("World_PumpkinStemBonemealable", WorldIni:GetValueI("Plants", "IsPumpkinStemBonemealable") ) .. [[
PumpkinBonemealable:]] .. HTML_Select_On_Off("World_PumpkinBonemealable", WorldIni:GetValueI("Plants", "IsPumpkinBonemealable") ) .. [[
SugarcaneBonemealabl:]] .. HTML_Select_On_Off("World_SugarcaneBonemealable", WorldIni:GetValueI("Plants", "IsSugarcaneBonemealable") ) .. [[
CactusBonemealable:]] .. HTML_Select_On_Off("World_CactusBonemealable", WorldIni:GetValueI("Plants", "IsCactusBonemealable") ) .. [[
+
+ + + + + + + + + + + + + + + +
Generator
BiomeGen:]] .. HTML_Select_BiomeGen("World_BiomeGen", WorldIni:GetValue("Generator", "BiomeGen") ) .. [[
HeightGen:]] .. HTML_Select_HeightGen("World_HeightGen", WorldIni:GetValue("Generator", "HeightGen") ) .. [[
CompositionGen:]] .. HTML_Select_CompositionGen("World_CompositionGen", WorldIni:GetValue("Generator", "CompositionGen") ) .. [[
Structures:
Finishers:
Generator:]] .. HTML_Select_Generator("World_Generator", WorldIni:GetValue("Generator", "Generator") ) .. [[
+
+ +
+
Finetuning
+ + ]] + if WorldIni:GetValue( "Generator", "BiomeGen" ) == "Constant" then + Content = Content .. [[ + + + ]] + elseif WorldIni:GetValue( "Generator", "BiomeGen" ) == "MultiStepMap" then + Content = Content .. [[ + + + + + + + + + + + ]] + elseif WorldIni:GetValue( "Generator", "BiomeGen" ) == "DistortedVoronoi" then + Content = Content .. [[ + + + + + ]] + elseif WorldIni:GetValue( "Generator", "BiomeGen" ) == "Voronoi" then + Content = Content .. [[ + + + + + ]] + elseif WorldIni:GetValue( "Generator", "BiomeGen" ) == "CheckerBoard" then + Content = Content .. [[ + + + + + ]] + end + + if WorldIni:GetValue( "Generator", "CompositionGen" ) == "Noise3D" then + Content = Content .. [[ + + + + + + + + + + + + + + + ]] + elseif WorldIni:GetValue( "Generator", "CompositionGen" ) == "Classic" then + Content = Content .. [[ + + + + + + + + + + + + + + + + + + + ]] + elseif WorldIni:GetValue( "Generator", "CompositionGen" ) == "SameBlock" then + Content = Content .. [[ + + + + + ]] + end + if WorldIni:GetValue( "Generator", "HeightGen" ) == "Flat" then + Content = Content .. [[ + + + ]] + end + if string.find( WorldIni:GetValue( "Generator", "Structures" ), "MineShafts" ) ~= nil then + Content = Content .. [[ + + + + + + + + + + + ]] + end + if string.find( WorldIni:GetValue( "Generator", "Structures" ), "LavaLakes" ) ~= nil then + Content = Content .. [[ + + + ]] + end + if string.find( WorldIni:GetValue( "Generator", "Structures" ), "WaterLakes" ) ~= nil then + Content = Content .. [[ + + + ]] + end + if string.find( WorldIni:GetValue( "Generator", "Finishers" ), "BottomLava" ) ~= nil then + Content = Content .. [[ + + + ]] + end + Content = Content .. [[
Biome Generator
ConstantBiome:]] .. HTML_Select_Biome( "World_Biome", WorldIni:GetValue("Generator", "ConstantBiome" ) ) .. [[
Biome Generator
MultiStepMapOceanCellSize:
MultiStepMapOceanCellSize:
MultiStepMapOceanCellSize:
MultiStepMapOceanCellSize:
MultiStepMapOceanCellSize:
Biome Generator
DistortedVoronoiCellSize:
DistortedVoronoiBiomes:
Biome Generator
VoronoiCellSize:
VoronoiBiomes:
Biome Generator
CheckerBoardBiomes:
CheckerBoardBiomeSize:
Composition Generator
Noise3DSeaLevel:
Noise3DHeightAmplification:
Noise3DMidPoint:
Noise3DFrequencyX:
Noise3DFrequencyY:
Noise3DFrequencyZ:
Noise3DAirThreshold:
Composition Generator
ClassicSeaLevel:
ClassicBeachHeight:
ClassicBeachDepth:
ClassicBlockTop:
ClassicBlockMiddle:
ClassicBlockBottom:
ClassicBlockBeach:
ClassicBlockBeachBottom:
ClassicBlockSea:
Composition Generator
SameBlockType:
SameBlockBedrocked:
Height Generator
FlatHeight:
MineShafts
MineShaftsGridSize:
MineShaftsMaxSystemSize:
MineShaftsChanceCorridor:
MineShaftsChanceCrossing:
MineShaftsChanceStaircase:
LavaLakes
LavaLakesProbability:
WaterLakes
WaterLakesProbability:
BottomLavaLevel
BottomLavaLevel:
]] + + Content = Content .. [[
+ WARNING: Any changes made here might require a server restart in order to be applied! + ]] + return Content +end + + + +function HandleRequest_ServerSettings( Request ) + local Content = "" + + Content = Content .. [[ +

Server Settings

+ + + + + + + +
GeneralMonstersWorldsWorld
+
]] + + if( Request.Params["tab"] == "Monsters" ) then + Content = Content .. ShowMonstersSettings( Request ) + elseif( Request.Params["tab"] == "Worlds" ) then + Content = Content .. ShowWorldsSettings( Request ) + elseif( Request.Params["tab"] == "World" ) then + Content = Content .. ShowWorldSettings( Request ) + else + Content = Content .. ShowGeneralSettings( Request ) -- Default to general settings + end + + return Content +end \ No newline at end of file diff --git a/MCServer/Plugins/Core/web_whitelist.lua b/MCServer/Plugins/Core/web_whitelist.lua new file mode 100644 index 000000000..61cc6fd8b --- /dev/null +++ b/MCServer/Plugins/Core/web_whitelist.lua @@ -0,0 +1,79 @@ +local function HTMLDeleteButton( name ) + return "
" +end + +function HandleRequest_WhiteList( Request ) + local UpdateMessage = "" + if( Request.PostParams["whitelist-add"] ~= nil ) then + local PlayerName = Request.PostParams["whitelist-add"] + + if( WhiteListIni:GetValueB("WhiteList", PlayerName, false) == true ) then + UpdateMessage = "".. PlayerName.." is already on the whitelist" + else + WhiteListIni:SetValueB("WhiteList", PlayerName, true ) + UpdateMessage = "Added " .. PlayerName .. " to whitelist." + WhiteListIni:WriteFile() + end + elseif( Request.PostParams["whitelist-delete"] ~= nil ) then + local PlayerName = Request.PostParams["whitelist-delete"] + WhiteListIni:DeleteValue( "WhiteList", PlayerName ) + UpdateMessage = "Removed " .. PlayerName .. " from whitelist." + WhiteListIni:WriteFile() + elseif( Request.PostParams["whitelist-reload"] ~= nil ) then + WhiteListIni:Erase() -- Empty entire loaded ini first, otherwise weird shit goes down + WhiteListIni:ReadFile() + UpdateMessage = "Loaded from disk" + elseif( Request.Params["whitelist-setenable"] ~= nil ) then + local Enabled = Request.Params["whitelist-setenable"] + local CreateNewValue = false + if( WhiteListIni:FindValue( WhiteListIni:FindKey("WhiteListSettings"), "WhiteListOn" ) == cIniFile.noID ) then -- Find out whether the value is in the ini + CreateNewValue = true + end + + if( Enabled == "1" ) then + WhiteListIni:SetValueB("WhiteListSettings", "WhiteListOn", true, CreateNewValue ) + else + WhiteListIni:SetValueB("WhiteListSettings", "WhiteListOn", false, CreateNewValue ) + end + WhiteListIni:WriteFile() + end + + + local Content = "" + + local WhiteListEnabled = WhiteListIni:GetValueB("WhiteListSettings", "WhiteListOn", false) + if( WhiteListEnabled == false ) then + Content = Content .. "

Whitelist is currently disabled! Click here to enable.

" + end + + + Content = Content .. "

Whitelisted players

" + Content = Content .. "" + local KeyNum = WhiteListIni:FindKey("WhiteList") + local NumValues = WhiteListIni:GetNumValues(KeyNum) + if( NumValues > 0 ) then + for Num = 0, NumValues-1 do + if( WhiteListIni:GetValue(KeyNum, Num, "0") == "1" ) then + local PlayerName = WhiteListIni:GetValueName(KeyNum, Num ) + Content = Content .. "" + end + end + else + Content = Content .. "" + end + Content = Content .. "
" .. PlayerName .. "" .. HTMLDeleteButton( PlayerName ) .. "
None
" + Content = Content .. "

Add player to whitelist

" + Content = Content .. "
" + Content = Content .. "" + Content = Content .. "
" + Content = Content .. "
" + Content = Content .. "" + Content = Content .. "
" + Content = Content .. "
"..UpdateMessage + + if( WhiteListEnabled == true ) then + Content = Content .. "

Whitelist is currently enabled, click here to disable.

" + end + + return Content +end \ No newline at end of file diff --git a/MCServer/Plugins/Core/webadmin/backup.html b/MCServer/Plugins/Core/webadmin/backup.html new file mode 100644 index 000000000..239a255e5 --- /dev/null +++ b/MCServer/Plugins/Core/webadmin/backup.html @@ -0,0 +1,375 @@ + + + + +{TITLE} + + + + + + +
+ +

{TITLE}

+ +
+
+ + + + +

Welcome {USERNAME}

+ +
+

{PLUGIN_NAME}

+ + {CONTENT} + +
+ + +
+
+ +
+ + + +
+ + + diff --git a/MCServer/Plugins/Core/webadmin/template.html b/MCServer/Plugins/Core/webadmin/template.html new file mode 100644 index 000000000..16c78bdd0 --- /dev/null +++ b/MCServer/Plugins/Core/webadmin/template.html @@ -0,0 +1,152 @@ + + + + {TITLE} | {PLUGIN_NAME} + + + + + + + + + +
+
+ +

MCServer, the Minecraft Server coded in C++!

+
+ +
+

Welcome {USERNAME}, to the Control Panel! :D

+ {CONTENT} +
+ +
+ + diff --git a/MCServer/Plugins/Core/worldlimiter.lua b/MCServer/Plugins/Core/worldlimiter.lua new file mode 100644 index 000000000..8bd9b5509 --- /dev/null +++ b/MCServer/Plugins/Core/worldlimiter.lua @@ -0,0 +1,21 @@ +function OnPlayerMoving( Player ) + if LimitWorld == true then + local World = Player:GetWorld() + local SpawnX = math.floor(World:GetSpawnX() / 16) + local SpawnZ = math.floor(World:GetSpawnZ() / 16) + local X = math.floor(Player:GetPosX() / 16) + local Z = math.floor(Player:GetPosZ() / 16) + if ( (SpawnX + LimitWorldWidth - 1) < X ) then + Player:TeleportToCoords(Player:GetPosX() - 1, Player:GetPosY(), Player:GetPosZ()) + end + if ( (SpawnX - LimitWorldWidth + 1) > X ) then + Player:TeleportToCoords(Player:GetPosX() + 1, Player:GetPosY(), Player:GetPosZ()) + end + if ( (SpawnZ + LimitWorldWidth - 1) < Z ) then + Player:TeleportToCoords(Player:GetPosX(), Player:GetPosY(), Player:GetPosZ() - 1) + end + if ( (SpawnZ - LimitWorldWidth + 1) > Z ) then + Player:TeleportToCoords(Player:GetPosX(), Player:GetPosY(), Player:GetPosZ() + 1) + end + end +end \ No newline at end of file -- cgit v1.2.3