1
0

Merge pull request #9 from mc-server/core-integrate

Core integrate
This commit is contained in:
bearbin 2013-07-27 09:19:22 -07:00
commit 1d0b57d8ab
47 changed files with 2977 additions and 3021 deletions

View File

@ -1,126 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<file>
<filename>back.lua</filename>
</file>
<file>
<filename>ban.lua</filename>
</file>
<file>
<filename>console.lua</filename>
</file>
<file>
<filename>coords.lua</filename>
</file>
<file>
<filename>gamemode.lua</filename>
</file>
<file>
<filename>gotoworld.lua</filename>
</file>
<file>
<filename>help.lua</filename>
</file>
<file>
<filename>item.lua</filename>
</file>
<file>
<filename>kick.lua</filename>
</file>
<file>
<filename>listgroups.lua</filename>
</file>
<file>
<filename>main.lua</filename>
</file>
<file>
<filename>motd.lua</filename>
</file>
<file>
<filename>onchunkgenerating.lua</filename>
</file>
<file>
<filename>oncraftingnorecipe.lua</filename>
</file>
<file>
<filename>onkilling.lua</filename>
</file>
<file>
<filename>onlogin.lua</filename>
</file>
<file>
<filename>onplayerbreakingblock.lua</filename>
</file>
<file>
<filename>onplayerjoined.lua</filename>
</file>
<file>
<filename>onplayermoving.lua</filename>
</file>
<file>
<filename>onplayerplacingblock.lua</filename>
</file>
<file>
<filename>playerlist.lua</filename>
</file>
<file>
<filename>pluginlist.lua</filename>
</file>
<file>
<filename>rank.lua</filename>
</file>
<file>
<filename>regeneratechunk.lua</filename>
</file>
<file>
<filename>reload.lua</filename>
</file>
<file>
<filename>saveall.lua</filename>
</file>
<file>
<filename>spawn.lua</filename>
</file>
<file>
<filename>stop.lua</filename>
</file>
<file>
<filename>teleport.lua</filename>
</file>
<file>
<filename>time.lua</filename>
</file>
<file>
<filename>top.lua</filename>
</file>
<file>
<filename>unban.lua</filename>
</file>
<file>
<filename>viewdistance.lua</filename>
</file>
<file>
<filename>weather.lua</filename>
</file>
<file>
<filename>web_chat.lua</filename>
</file>
<file>
<filename>web_manageplugins.lua</filename>
</file>
<file>
<filename>web_manageserver.lua</filename>
</file>
<file>
<filename>web_permissions.lua</filename>
</file>
<file>
<filename>web_playerlist.lua</filename>
</file>
<file>
<filename>web_serversettings.lua</filename>
</file>
<file>
<filename>web_whitelist.lua</filename>
</file>
</project>

View File

@ -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!)

View File

@ -9,7 +9,6 @@ function HandleBanCommand( Split, Player )
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
@ -18,10 +17,6 @@ function HandleBanCommand( Split, Player )
return true
end
function BanPlayer(PlayerName, Reason)
-- Ban the player in the banned.ini:
BannedPlayersIni:SetValueB("Banned", PlayerName, true)
@ -42,3 +37,24 @@ function BanPlayer(PlayerName, Reason)
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

View File

@ -1,17 +1,11 @@
-- console.lua
-- 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");
@ -27,13 +21,9 @@ function InitConsoleCommands()
PluginMgr:BindConsoleCommand("unload", HandleConsoleUnload, "Unloads all unused chunks");
end
function HandleConsoleBan(Split)
if (#Split < 2) then
return true, cChatColor.Green .. "Usage: /ban [Player] <Reason>";
return true, "Usage: ban [Player] <Reason>";
end
local Reason = "You have been banned"
@ -43,15 +33,27 @@ function HandleConsoleBan(Split)
if (not(BanPlayer(Split[2], Reason))) then
return true, cChatColor.Green .. "Could not find player " .. Split[2];
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
@ -65,10 +67,6 @@ function HandleConsoleBanList(Split)
return true, "Unknown banlist subcommand";
end
function HandleConsoleHelp(Split)
local Commands = {}; -- {index => {"Command", "HelpString"} }
local MaxLength = 0;
@ -96,10 +94,6 @@ function HandleConsoleHelp(Split)
return true, Out;
end
function HandleConsoleList(Split)
-- Get a list of all players, one playername per line
local Out = "";
@ -115,10 +109,6 @@ function HandleConsoleList(Split)
return true, Out;
end
function HandleConsoleListGroups(Split)
-- Read the groups.ini file:
local GroupsIni = cIniFile("groups.ini");
@ -139,10 +129,6 @@ function HandleConsoleListGroups(Split)
return true, Out;
end
function HandleConsoleNumChunks(Split)
local Output = {};
local AddNumChunks = function(World)
@ -162,10 +148,6 @@ function HandleConsoleNumChunks(Split)
return true, Out;
end
function HandleConsolePlayers(Split)
local PlayersInWorlds = {}; -- "WorldName" => [players array]
local AddToTable = function(Player)
@ -189,10 +171,6 @@ function HandleConsolePlayers(Split)
return true, Out;
end
function HandleConsolePrimaryServerVersion(Split)
if (#Split == 1) then
-- Display current version:
@ -206,10 +184,6 @@ function HandleConsolePrimaryServerVersion(Split)
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]";
@ -255,10 +229,6 @@ function HandleConsoleRank(Split)
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.");
@ -266,19 +236,11 @@ function HandleConsoleReload(Split)
return true;
end
function HandleConsoleSaveAll(Split)
cRoot:Get():SaveAllChunks();
return true;
end
function HandleConsoleSay(Split)
table.remove(Split, 1);
local Message = "";
@ -290,10 +252,6 @@ function HandleConsoleSay(Split)
return true;
end
function HandleConsoleUnload(Split)
local UnloadChunks = function(World)
World:UnloadUnusedChunks();
@ -306,11 +264,6 @@ function HandleConsoleUnload(Split)
end
-------------------------------------------------------------------------------------------
-- Helper functions:
--- Returns the list of players banned by name, separated by ", "
@ -328,16 +281,8 @@ function BanListByName()
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

View File

@ -1,6 +1,6 @@
function HandleItemCommand(Split, Player)
function HandleGiveCommand(Split, Player)
if ((#Split ~= 2) and (#Split ~=3)) then
Player:SendMessage(cChatColor.Green .. "Usage: /item [ItemType/Name:Dmg] <Amount>");
Player:SendMessage(cChatColor.Green .. "Usage: /give [ItemType/Name:Dmg] <Amount>");
return true;
end
@ -12,7 +12,7 @@ function HandleItemCommand(Split, Player)
end
if not(FoundItem) then
Player:SendMessage( cChatColor.Green .. "Invalid Item type / name !" )
Player:SendMessage( cChatColor.Green .. "Invalid item id or name!" )
return true
end
@ -20,7 +20,7 @@ function HandleItemCommand(Split, Player)
if (#Split == 3) then
ItemAmount = tonumber(Split[3]);
if ((ItemAmount == nil) or (ItemAmount < 1) or (ItemAmount > 512)) then
Player:SendMessage(cChatColor.Green .. "Invalid Amount!");
Player:SendMessage(cChatColor.Green .. "Invalid amount!");
return true;
end
end

View File

@ -3,8 +3,6 @@ function HandleChangeGMCommand( Split, Player )
Player:SendMessage( cChatColor.Green .. "Usage: /gm [GameMode (0|1)]" )
return true
end
Player:SetGameMode(Split[2])
return true
end

View File

@ -1,15 +0,0 @@
function HandleGotoWorldCommand( 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

View File

@ -1,7 +1,7 @@
function HandleHelpCommand(Split, Player)
local PluginManager = cRoot:Get():GetPluginManager()
local LinesPerPage = 9;
local LinesPerPage = 8;
local CurrentPage = 1;
local CurrentLine = 0;
local PageRequested = 1;
@ -31,7 +31,8 @@ function HandleHelpCommand(Split, Player)
-- CurrentPage now contains the total number of pages, and Output has the individual help lines to be sent
Player:SendMessage(cChatColor.Purple .. "- All commands - " .. cChatColor.Gold .. "[Page " .. PageRequested .. " / " .. CurrentPage .. "]");
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;

View File

@ -1,15 +1,7 @@
-- Implements item-repair using the HOOK_CRAFTING_NO_RECIPE hook
-- 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 = {}
@ -208,7 +200,3 @@ function OnCraftingNoRecipe(Player, Grid, Recipe)
end
return false
end

View File

@ -16,10 +16,6 @@ function HandleKickCommand( Split, Player )
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 = "";

View File

@ -1,14 +0,0 @@
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

View File

@ -1,20 +0,0 @@
function HandleListWorldsCommand( 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

View File

@ -1,4 +1,4 @@
function HandleCoordsCommand( Split, Player )
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

View File

@ -1,25 +1,23 @@
---- Some settings -----
SHOW_PLUGIN_NAMES = true -- If true, plugin name will be shown before commands
-- This is overwritten in the Initialize() function
------------------------
-- Global variables
PLUGIN = {} -- Reference to own plugin object
--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)
@ -31,47 +29,53 @@ function Initialize(Plugin)
PluginManager:AddHook(Plugin, cPluginManager.HOOK_CHUNK_GENERATING)
PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_MOVING)
PluginManager:BindCommand("/listworlds", "core.listworlds", HandleListWorldsCommand, " - 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");
--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("/save-all", "core.save-all", HandleSaveAllCommand, " - Saves all your worlds");
PluginManager:BindCommand("/help", "core.help", HandleHelpCommand, " [Page] - Show available commands");
PluginManager:BindCommand("/rank", "core.rank", HandleRankCommand, " [Player] [Rank] - to add someone to a group");
PluginManager:BindCommand("/pluginlist", "core.pluginlist", HandlePluginListCommand, " - Show list of plugins");
PluginManager:BindCommand("/tp", "core.teleport", HandleTPCommand, " [Player] - Teleport yourself to a player");
PluginManager:BindCommand("/item", "core.item", HandleItemCommand, " [ItemType/Name] <Amount> - Give yourself an item");
PluginManager:BindCommand("/i", "core.item", HandleItemCommand, "");
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("/who", "core.playerlist", HandlePlayerListCommand, " - Shows list of connected players");
PluginManager:BindCommand("/playerlist", "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("/stop", "core.stop", HandleStopCommand, " - Stops the server");
PluginManager:BindCommand("/time", "core.time", HandleTimeCommand, " [Day/Night] - Sets the time of day");
PluginManager:BindCommand("/save-all", "core.save-all", HandleSaveAllCommand, " - Saves all your worlds");
PluginManager:BindCommand("/spawn", "core.spawn", HandleSpawnCommand, " - Return to the spawn");
PluginManager:BindCommand("/kick", "core.kick", HandleKickCommand, " [Player] - Kick a player");
PluginManager:BindCommand("/ban", "core.ban", HandleBanCommand, " [Player] - Ban a player");
PluginManager:BindCommand("/unban", "core.unban", HandleUnbanCommand, " [Player] - Unban a player");
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("/top", "core.top", HandleTopCommand, " - Teleport yourself to the top most block");
PluginManager:BindCommand("/gm", "core.changegm", HandleChangeGMCommand, " [0|1] - Change your gamemode");
PluginManager:BindCommand("/gotoworld", "core.gotoworld", HandleGotoWorldCommand, " [WorldName] - Move to a different world!");
PluginManager:BindCommand("/coords", "core.coords", HandleCoordsCommand, " - Show your current server coordinates");
PluginManager:BindCommand("/regeneratechunk", "core.regeneratechunk", HandleRegenerateChunkCommand, " <[X] [Z]> - Regenerates a chunk, current or specified");
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 the settings
IniFile = cIniFile("Settings.ini")
--LOAD 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)
SHOW_PLUGIN_NAMES = IniFile:GetValueSetB("HelpPlugin", "ShowPluginNames", true )
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()
@ -80,7 +84,8 @@ function Initialize(Plugin)
LimitWorldsCuboid[World:GetName()]:Sort()
end
)
-- Load whitelist, and add default values and stuff
end
--LOAD WHITELIST
WhiteListIni = cIniFile( Plugin:GetLocalDirectory() .. "/whitelist.ini" )
if ( WhiteListIni:ReadFile() == true ) then
if( WhiteListIni:GetValueB("WhiteListSettings", "WhiteListOn", false) == true ) then
@ -100,7 +105,7 @@ function Initialize(Plugin)
end
end
-- Load banned players, and add default values and stuff
--LOAD BANNED (BAD LUCK, BRO)
BannedPlayersIni = cIniFile( Plugin:GetLocalDirectory() .. "/banned.ini" )
if ( BannedPlayersIni:ReadFile() == true ) then
if( BannedPlayersIni:GetNumValues("Banned") > 0 ) then
@ -115,6 +120,7 @@ function Initialize(Plugin)
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);
@ -125,5 +131,53 @@ function Initialize(Plugin)
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)
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
--END AWESOMENESS :'(

View File

@ -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

View File

@ -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

View File

@ -1,65 +0,0 @@
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 .. "Player " .. Victim:GetName() .. " burned away." )
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" )
CheckHardcore(Victim)
return false
end
else
if Killer:IsPlayer() then
Server:SendMessage( cChatColor.Red .. "Player " .. Victim:GetName() .. " is killed by " .. Killer:GetName() )
CheckHardcore(Victim)
return false
elseif Killer:IsMob() then
if Killer:IsA("cZombie") then
Server:SendMessage( cChatColor.Red .. "Player " .. Victim:GetName() .. " is eaten by a zombie")
elseif Killer:IsA("cSkeleton") then
Server:SendMessage( cChatColor.Red .. "Player " .. Victim:GetName() .. " is killed by a skeleton" )
elseif Killer:IsA("cCreeper") then
Server:SendMessage( cChatColor.Red .. "Player " .. Victim:GetName() .. " is blown up by a creeper")
elseif Killer:IsA("cSpider") then
Server:SendMessage( cChatColor.Red .. "Player " .. Victim:GetName() .. " is killed by a spider")
elseif Killer:IsA("cCaveSpider") then
Server:SendMessage( cChatColor.Red .. "Player " .. Victim:GetName() .. " is killed by a cavespider")
elseif Killer:IsA("cBlaze") then
Server:SendMessage( cChatColor.Red .. "Player " .. Victim:GetName() .. " is killed by a blaze")
elseif Killer:IsA("cEnderman") then
Server:SendMessage( cChatColor.Red .. "Player " .. Victim:GetName() .. " is slain by a enderman")
elseif Killer:IsA("cSilverfish") then
Server:SendMessage( cChatColor.Red .. "Player " .. Victim:GetName() .. " is killed by a silverfish")
elseif Killer:IsA("cSlime") then
Server:SendMessage( cChatColor.Red .. "Player " .. Victim:GetName() .. " is killed by a slime")
elseif Killer:IsA("cWitch") then
Server:SendMessage( cChatColor.Red .. "Player " .. Victim:GetName() .. " is killed by a witch")
elseif Killer:IsA("cZombiepigman") then
Server:SendMessage( cChatColor.Red .. "Player " .. Victim:GetName() .. " is slain by a zombiepigman")
elseif Killer:IsA("cMagmacube") then
Server:SendMessage( cChatColor.Red .. "Player " .. Victim:GetName() .. " is killed by a magmacube")
elseif Killer:IsA("cWolf") then
Server:SendMessage( cChatColor.Red .. "Player " .. Victim:GetName() .. " is killed by a wolf")
end
CheckHardcore(Victim)
return false
end
end
Server:SendMessage( cChatColor.Red .. Victim:GetName() .. " Died")
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")
end
end
end

View File

@ -15,6 +15,5 @@ function OnLogin(Client, ProtocolVersion, Username)
end
end
end
return false
end

View File

@ -1,10 +0,0 @@
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
end
end
return false
end

View File

@ -1,63 +0,0 @@
function OnPlayerPlacingBlock(Player, BlockX, BlockY, BlockZ, BlockFace, CursorX, CursorY, CursorZ, BlockType)
-- dont check if the direction is in the air
if (BlockFace == -1) then
return false
end
if( Player:HasPermission("core.build") == false ) then
return true
end
-- TODO: If the placed block is not a block (torch etc.), allow it without checking for collisions
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)
-- player height is 2 blocks, so we check the position and then offset it up one
-- so they can't place a block in anyone's face
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
return false
end

View File

@ -1,4 +1,4 @@
function HandlePluginListCommand( Split, Player )
function HandlePluginsCommand( Split, Player )
local PluginManager = cRoot:Get():GetPluginManager()
local PluginList = PluginManager:GetAllPlugins()

View File

@ -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

View File

@ -31,3 +31,18 @@ function HandleRankCommand( Split, Player )
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

View File

@ -1,4 +1,4 @@
function HandleRegenerateChunkCommand(Split, Player)
function HandleRegenCommand(Split, Player)
if ((#Split == 2) or (#Split > 3)) then
Player:SendMessage( cChatColor.Green .. "Usage: '/regeneratechunk' or '/regeneratechunk [X] [Z]'");
return true;

View File

@ -1,6 +0,0 @@
function HandleReloadCommand( Split, Player )
Server = cRoot:Get():GetServer()
Server:SendMessage( cChatColor.Green .. "Reloading all plugins." )
cRoot:Get():GetPluginManager():ReloadPlugins()
return true
end

View File

@ -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

View File

@ -1,5 +0,0 @@
function HandleSaveAllCommand( Split, Player )
cRoot:Get():SaveAllChunks();
Player:SendMessage(cChatColor.Green .. "All the worlds are saved")
return true;
end

View File

@ -1,6 +0,0 @@
function HandleStopCommand( Split, Player )
Server = cRoot:Get():GetServer()
Server:SendMessage( cChatColor.Green .. "Stopping the server..." )
cRoot:Get():QueueExecuteConsoleCommand("stop")
return true
end

View File

@ -10,21 +10,59 @@ function HandleTPCommand(a_Split, a_Player)
a_Player:SendMessage(cChatColor.Green .. "You teleported to {" .. a_Split[2] .. ", " .. a_Split[3] .. ", " .. a_Split[4] .. "}");
return true;
else
Player:SendMessage( cChatColor.Green .. "Usage: /tp [PlayerName] (-h)" )
a_Player:SendMessage( cChatColor.Green .. "Usage: /tp [PlayerName] (-h) or /tp [X Y Z]" )
return true
end
end
function HandleTPACommand( Split, Player )
if Split[2] == nil then
Player:SendMessage( cChatColor.Green .. "Usage: /tpa [Player]" )
return true
end
local loopPlayer = function( OtherPlayer )
if OtherPlayer:GetName() == Split[2] then
OtherPlayer:SendMessage( cChatColor.Green .. Player:GetName() .. " send a teleport request" )
Player:SendMessage( cChatColor.Green .. "You send a teleport request to " .. OtherPlayer:GetName() )
Destination[OtherPlayer:GetName()] = Player:GetName()
end
end
local loopWorlds = function( World )
World:ForEachPlayer( loopPlayer )
end
cRoot:Get():ForEachWorld( loopWorlds )
return true
end
function HandleTPAcceptCommand( Split, Player )
if Destination[Player:GetName()] == nil then
Player:SendMessage( cChatColor.Green .. "Nobody has send you a teleport request" )
return true
end
local loopPlayer = function( OtherPlayer )
if Destination[Player:GetName()] == OtherPlayer:GetName() then
if OtherPlayer:GetWorld():GetName() ~= Player:GetWorld():GetName() then
OtherPlayer:MoveToWorld( Player:GetWorld():GetName() )
end
OtherPlayer:TeleportToEntity( Player )
Player:SendMessage( cChatColor.Green .. OtherPlayer:GetName() .. " teleported to you" )
OtherPlayer:SendMessage( cChatColor.Green .. "You teleported to " .. Player:GetName() )
Destination[Player:GetName()] = nil
end
end
local loopWorlds = function( World )
World:ForEachPlayer( loopPlayer )
end
cRoot:Get():ForEachWorld( loopWorlds )
return true
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 .. "Already there :)");
a_SrcPlayer:SendMessage(cChatColor.Green .. "Y' can't teleport to yerself!");
else
SetBackCoordinates(a_SrcPlayer);
a_SrcPlayer:TeleportToEntity(OtherPlayer);
@ -35,12 +73,8 @@ function TeleportToPlayer(a_SrcPlayer, a_DstPlayerName, a_TellDst)
end
end
local World = Player:GetWorld();
if (not(World:DoWithPlayer(s_DstPlayerName, teleport))) then
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

View File

@ -1,20 +0,0 @@
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

View File

@ -43,8 +43,10 @@ local function ShowGeneralSettings( Request )
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