73f454ef37
Squashed commit of the following: commit ccc73db8c51e45372069ec0a42f437cfb25253b1 Merge: 6bf4b40 21c7c68 Author: Alexander Harkness <bearbin@gmail.com> Date: Sun Jul 28 14:00:15 2013 +0100 Merge branch 'master' of github.com:tigerw/MCSCore into tigerw-master Conflicts: main.lua commit 21c7c68d20782a7dfd0d8f9ce0996397549dd425 Author: Tiger Wang <ziwei.tiger@hotmail.co.uk> Date: Sun Jul 28 12:55:50 2013 +0100 Default WorldLimiter = Off commit 141298481f3adef30b68d0c4200204aa264cb3e2 Author: Tiger Wang <ziwei.tiger@hotmail.co.uk> Date: Sun Jul 28 12:47:24 2013 +0100 Fixed Potential WorldLimit & OnDisable Bugs Changed WorldLimiter if detection from nil value to config boolean. Changed OnDisable to use hardcoded name as Plugin:GetName was apparently a nil value. ?? commit 6bf4b40a0e27677afa6df9cb3521266e6b99c4f7 Merge: 1ca4217 bfd6c5f Author: bearbin <bearbin@gmail.com> Date: Sat Jul 27 11:44:18 2013 -0700 Merge pull request #3 from tonibm19/master Added /me command commit bfd6c5f2a47cda4ac98a7225736e2669eaf61849 Author: tonibm19 <tonibm19@gmail.com> Date: Sat Jul 27 20:35:22 2013 +0200 Added /me command commit d25abaf44a6f5828b90297ff80003d2cd2a90be5 Author: tonibm19 <tonibm19@gmail.com> Date: Sat Jul 27 20:30:31 2013 +0200 Added /me command commit 9047f7778aa1cdd42d22c4dcf925db792b4d684e Author: tonibm19 <tonibm19@gmail.com> Date: Sat Jul 27 20:29:24 2013 +0200 added /me command commit 1ca42172391d41ba71c65a3f15d3a96d15a80496 Merge: 52a6f4e 7a40336 Author: Tiger Wang <ziwei.tiger@hotmail.co.uk> Date: Sat Jul 27 09:01:45 2013 -0700 Merge pull request #2 from tigerw/master Fixed /give descriptor & removed webadmin commit 7a40336437525c447adae3d9800e75b39c0300c4 Author: Tiger Wang <ziwei.tiger@hotmail.co.uk> Date: Sat Jul 27 17:00:38 2013 +0100 Fixed /give descriptor & removed webadmin commit 52a6f4e35bdea2ae9f33977928b6693f5800e515 Merge: f5d56ff 2af1da8 Author: Tiger Wang <ziwei.tiger@hotmail.co.uk> Date: Sat Jul 27 08:51:45 2013 -0700 Merge pull request #1 from tigerw/master Added TPA (tonibm9's fork) commit 2af1da8a3cd8e94674b22805662b83de87ac4a95 Author: Tiger Wang <ziwei.tiger@hotmail.co.uk> Date: Sat Jul 27 16:38:10 2013 +0100 Added TPA (tonibm9's fork) With code from STR_Warrior. commit f5d56ffeb02fef4735e846661fa71d15622d25b9 Author: Tiger Wang <ziwei.tiger@hotmail.co.uk> Date: Sat Jul 27 15:51:18 2013 +0100 Integrated SpawnProtect & Bugfixes [SEE DESC.] Integrated bearbin's SpawnProtect. Fixed config file bugs. Improved SpawnProtect to use settings.ini. Variable cleanup (SHOW_PLUGIN_NAMES). File and filename cleanup. commit 56dc51c00af4514253c04e38b5ccc9fbed2f0022 Author: Tiger Wang <ziwei.tiger@hotmail.co.uk> Date: Fri Jul 26 23:14:40 2013 +0100 Update README.md Added info. commit acd7e2849dcd7f3ee7bdc6b0f9b777ee1d9cbb3c Author: Tiger Wang <ziwei.tiger@hotmail.co.uk> Date: Fri Jul 26 19:37:59 2013 +0100 Implemented Block Property checking for Collisions Used g_BlockIsSolid, instead of checking data values. commit 246d423ff9660a2b00a1c51e6276ec74eb3419de Author: Tiger Wang <ziwei.tiger@hotmail.co.uk> Date: Fri Jul 26 15:49:55 2013 +0100 Updated Files Buildpermandcollision: updated collision code to check for torches and redstone torches. Help: attempt at always showing page number Web_serversettings: attempt at introducing a check for Maximum Players (must be above zero). commit 868f99ab49edeee78f4fc1c212c6bf614b860378 Author: Tiger Wang <ziwei.tiger@hotmail.co.uk> Date: Thu Jul 25 19:46:08 2013 +0100 Update README.md Extended 'GUI Redesign' section. commit e0df40bd082bdeb5c6823b485bc5001103a77502 Author: Tiger Wang <ziwei.tiger@hotmail.co.uk> Date: Thu Jul 25 19:43:00 2013 +0100 Update README.md Added features and fixes and instructions for use. commit 332d8221f753f1a38d6c21bfc30af5890f48e3bb Author: Tiger Wang <ziwei.tiger@hotmail.co.uk> Date: Thu Jul 25 19:35:27 2013 +0100 Uploaded All Files All Core files, both modified and unmodified. commit 3dd191f6bed71c863ee264856fbc3660e52cf88b Author: Tiger Wang <ziwei.tiger@hotmail.co.uk> Date: Thu Jul 25 04:59:50 2013 -0700 Initial commit
183 lines
9.4 KiB
Lua
183 lines
9.4 KiB
Lua
--COMMENCE VARIABLES
|
|
PLUGIN = {}
|
|
BannedPlayersIni = {}
|
|
WhiteListIni = {}
|
|
BackCoords = {}
|
|
Messages = {}
|
|
LimitWorldsCuboid = {}
|
|
SPAWNPROTECT = true
|
|
PROTECTRADIUS = 20
|
|
LOGTOFILE = false
|
|
--END VARIABLES
|
|
|
|
--COMMENCE AWESOMENESS!
|
|
function Initialize(Plugin)
|
|
PLUGIN = Plugin
|
|
|
|
Plugin:SetName("Core")
|
|
Plugin:SetVersion(13)
|
|
|
|
--ADD HOOKS
|
|
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)
|
|
|
|
--PLEASE ALPHA SORT http://elmosaukko.com/sort-alphabetically/ THIS LIST
|
|
--BIND COMMANDS
|
|
PluginManager:BindCommand("/back", "core.back", HandleBackCommand, " - Return to your last position");
|
|
PluginManager:BindCommand("/ban", "core.ban", HandleBanCommand, " ~ Ban a player");
|
|
PluginManager:BindCommand("/give", "core.give", HandleGiveCommand, " ~ Give yourself an item");
|
|
PluginManager:BindCommand("/gm", "core.changegm", HandleChangeGMCommand, " ~ Change your gamemode");
|
|
PluginManager:BindCommand("/help", "core.help", HandleHelpCommand, " ~ Show available commands");
|
|
PluginManager:BindCommand("/kick", "core.kick", HandleKickCommand, " ~ Kick a player");
|
|
PluginManager:BindCommand("/list", "core.playerlist", HandlePlayerListCommand, " - Shows list of connected players");
|
|
PluginManager:BindCommand("/listgroups", "core.listgroups", HandleListGroupsCommand, " - Shows a list of all the groups");
|
|
PluginManager:BindCommand("/locate", "core.locate", HandleLocateCommand, " - Show your current server coordinates");
|
|
PluginManager:BindCommand("/motd", "core.motd", HandleMOTDCommand, " - Show message of the day");
|
|
PluginManager:BindCommand("/playerlist", "core.playerlist", HandlePlayerListCommand, " - Shows list of connected players");
|
|
PluginManager:BindCommand("/plugins", "core.plugins", HandlePluginsCommand, " - Show list of plugins");
|
|
PluginManager:BindCommand("/portal", "core.portal", HandlePortalCommand, " ~ Move to a different world");
|
|
PluginManager:BindCommand("/rank", "core.rank", HandleRankCommand, " ~ Add someone to a group");
|
|
PluginManager:BindCommand("/regen", "core.regen", HandleRegenCommand, " ~ Regenerates a chunk, current or specified");
|
|
PluginManager:BindCommand("/reload", "core.reload", HandleReloadCommand, " - Reload all plugins");
|
|
PluginManager:BindCommand("/save-all", "core.save-all", HandleSaveAllCommand, " - Saves all your worlds");
|
|
PluginManager:BindCommand("/spawn", "core.spawn", HandleSpawnCommand, " - Return to the spawn");
|
|
PluginManager:BindCommand("/stop", "core.stop", HandleStopCommand, " - Stops the server");
|
|
PluginManager:BindCommand("/time", "core.time", HandleTimeCommand, " ~ Sets the time of day");
|
|
PluginManager:BindCommand("/toggledownfall", "core.toggledownfall", HandleToggleDownfallCommand, " - Toggles the weather");
|
|
PluginManager:BindCommand("/me", "core.me", HandleMeCommand, " ~ Tell what you are doing");
|
|
PluginManager:BindCommand("/top", "core.top", HandleTopCommand, " - Teleport yourself to the top most block");
|
|
PluginManager:BindCommand("/tp", "core.teleport", HandleTPCommand, " ~ Teleport yourself to a player");
|
|
PluginManager:BindCommand("/tpa", "core.teleport", HandleTPACommand, " ~ Ask to teleport yourself to a player");
|
|
PluginManager:BindCommand("/tpaccept", "core.teleport", HandleTPAcceptCommand, " ~ Accept a teleportation request");
|
|
PluginManager:BindCommand("/unban", "core.unban", HandleUnbanCommand, " ~ Unban a player");
|
|
PluginManager:BindCommand("/viewdistance", "core.viewdistance", HandleViewDistanceCommand, " [".. cClientHandle.MIN_VIEW_DISTANCE .."-".. cClientHandle.MAX_VIEW_DISTANCE .."] - Change your view distance")
|
|
PluginManager:BindCommand("/who", "core.playerlist", HandlePlayerListCommand, " - Shows list of connected players");
|
|
PluginManager:BindCommand("/worlds", "core.worlds", HandleWorldsCommand, " - Shows a list of all the worlds");
|
|
|
|
InitConsoleCommands();
|
|
|
|
--LOAD SETTINGS
|
|
IniFile = cIniFile("settings.ini")
|
|
if ( IniFile:ReadFile() == true ) then
|
|
HardCore = IniFile:GetValueSet("GameMode", "Hardcore", "false")
|
|
LimitWorld = IniFile:GetValueSetB("Worlds", "LimitWorld", false)
|
|
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 LimitWorld == true 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
|
|
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 (BAD LUCK, BRO)
|
|
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
|
|
|
|
--ADD WEB INTERFACE TABULATES (CURRENTLY DEPRECATED DUE TO LIST FORMAT BREAKING CSS)
|
|
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
|
|
--AWESOMENESS STILL GOING!
|
|
|
|
--BEGIN SPAWNPROTECT LOGFILE CODE (COURTSEY OF BEARBIN)
|
|
function WriteLog(breakPlace, X, Y, Z, player, id, meta)
|
|
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 Core!")
|
|
end
|
|
--END AWESOMENESS :'(
|