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

@ -1,9 +1,9 @@
function HandleBackCommand( Split, Player ) function HandleBackCommand( Split, Player )
if BackCoords[Player:GetName()] == nil then if BackCoords[Player:GetName()] == nil then
Player:SendMessage(cChatColor.Green .. "There is no last position known") Player:SendMessage(cChatColor.Green .. "There is no last position known")
else else
Player:TeleportToCoords(BackCoords[Player:GetName()].x, BackCoords[Player:GetName()].y, BackCoords[Player:GetName()].z) 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") Player:SendMessage(cChatColor.Green .. "You teleported back to your last known position")
end end
return true return true
end end

View File

@ -1,44 +1,60 @@
function HandleBanCommand( Split, Player ) function HandleBanCommand( Split, Player )
if( #Split < 2 ) then if( #Split < 2 ) then
Player:SendMessage( cChatColor.Green .. "Usage: /ban [Player] <Reason>" ) Player:SendMessage( cChatColor.Green .. "Usage: /ban [Player] <Reason>" )
return true return true
end end
local Reason = "You have been banned" local Reason = "You have been banned"
if( #Split > 2 ) then if( #Split > 2 ) then
Reason = table.concat(Split, " ", 3) Reason = table.concat(Split, " ", 3)
end end
if( BanPlayer(Split[2], Reason) == false ) then
if( BanPlayer(Split[2], Reason) == false ) then Player:SendMessage( cChatColor.Green .. "Could not find player " .. Split[2] )
Player:SendMessage( cChatColor.Green .. "Could not find player " .. Split[2] ) return true
return true end
end
return true
return true end
end
function BanPlayer(PlayerName, Reason)
-- Ban the player in the banned.ini:
BannedPlayersIni:SetValueB("Banned", PlayerName, true)
BannedPlayersIni:WriteFile()
function BanPlayer(PlayerName, Reason) -- Kick the player:
-- Ban the player in the banned.ini: if (Reason == nil) then
BannedPlayersIni:SetValueB("Banned", PlayerName, true) Reason = "You have been banned"
BannedPlayersIni:WriteFile() end
local Success = KickPlayer(PlayerName, Reason)
-- Kick the player: if (not(Success)) then
if (Reason == nil) then return false;
Reason = "You have been banned" end
end
local Success = KickPlayer(PlayerName, Reason) LOGINFO("'" .. PlayerName .. "' has been banned (\"" .. Reason .. "\") ");
if (not(Success)) then local Server = cRoot:Get():GetServer();
return false; Server:SendMessage("Banned " .. PlayerName);
end
return true
LOGINFO("'" .. PlayerName .. "' has been banned (\"" .. Reason .. "\") "); end
local Server = cRoot:Get():GetServer();
Server:SendMessage("Banned " .. PlayerName); function HandleUnbanCommand( Split, Player )
if( #Split < 2 ) then
return true 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 end

View File

@ -1,343 +1,288 @@
-- Implements things related to console commands
-- console.lua
function InitConsoleCommands()
-- Implements things related to console commands 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");
function InitConsoleCommands() PluginMgr:BindConsoleCommand("banlist ips", HandleConsoleBanList, "Lists all players banned by IP");
local PluginMgr = cPluginManager:Get(); PluginMgr:BindConsoleCommand("help", HandleConsoleHelp, "Lists all commands");
PluginMgr:BindConsoleCommand("list", HandleConsoleList, "Lists all players in a machine-readable format");
-- Please keep the list alpha-sorted PluginMgr:BindConsoleCommand("listgroups", HandleConsoleListGroups, "Shows a list of all the groups");
PluginMgr:BindConsoleCommand("ban", HandleConsoleBan, "Bans a player by name"); PluginMgr:BindConsoleCommand("numchunks", HandleConsoleNumChunks, "Shows number of chunks currently loaded");
PluginMgr:BindConsoleCommand("banlist", HandleConsoleBanList, "Lists all players banned by name"); PluginMgr:BindConsoleCommand("players", HandleConsolePlayers, "Lists all connected players");
PluginMgr:BindConsoleCommand("banlist ips", HandleConsoleBanList, "Lists all players banned by IP"); PluginMgr:BindConsoleCommand("primaryserverversion", HandleConsolePrimaryServerVersion, "Gets or sets server version reported to 1.4+ clients");
PluginMgr:BindConsoleCommand("help", HandleConsoleHelp, "Lists all commands"); PluginMgr:BindConsoleCommand("rank", HandleConsoleRank, " [Player] [Group] - add a player to a group");
PluginMgr:BindConsoleCommand("list", HandleConsoleList, "Lists all players in a machine-readable format"); PluginMgr:BindConsoleCommand("reload", HandleConsoleReload, "Reloads all plugins");
PluginMgr:BindConsoleCommand("listgroups", HandleConsoleListGroups, "Shows a list of all the groups"); PluginMgr:BindConsoleCommand("save-all", HandleConsoleSaveAll, "Saves all chunks");
PluginMgr:BindConsoleCommand("numchunks", HandleConsoleNumChunks, "Shows number of chunks currently loaded"); PluginMgr:BindConsoleCommand("say", HandleConsoleSay, "Sends a chat message to all players");
PluginMgr:BindConsoleCommand("players", HandleConsolePlayers, "Lists all connected players"); PluginMgr:BindConsoleCommand("unload", HandleConsoleUnload, "Unloads all unused chunks");
PluginMgr:BindConsoleCommand("primaryserverversion", HandleConsolePrimaryServerVersion, "Gets or sets server version reported to 1.4+ clients"); end
PluginMgr:BindConsoleCommand("rank", HandleConsoleRank, " [Player] [Group] - add a player to a group");
PluginMgr:BindConsoleCommand("reload", HandleConsoleReload, "Reloads all plugins"); function HandleConsoleBan(Split)
PluginMgr:BindConsoleCommand("save-all", HandleConsoleSaveAll, "Saves all chunks"); if (#Split < 2) then
PluginMgr:BindConsoleCommand("say", HandleConsoleSay, "Sends a chat message to all players"); return true, "Usage: ban [Player] <Reason>";
PluginMgr:BindConsoleCommand("unload", HandleConsoleUnload, "Unloads all unused chunks"); end
end
local Reason = "You have been banned"
if (#Split > 2) then
Reason = table.concat(Split, " ", 3);
end
function HandleConsoleBan(Split)
if (#Split < 2) then if (not(BanPlayer(Split[2], Reason))) then
return true, cChatColor.Green .. "Usage: /ban [Player] <Reason>"; return true, "Could not find player " .. Split[2];
end end
local Reason = "You have been banned" return true, "Player " .. Split[2] .. " has been banned.";
if (#Split > 2) then end
Reason = table.concat(Split, " ", 3);
end function HandleConsoleUnban(Split)
if( #Split < 2 ) then
return true, "Usage: /unban [Player]"
if (not(BanPlayer(Split[2], Reason))) then end
return true, cChatColor.Green .. "Could not find player " .. Split[2];
end if( BannedPlayersIni:GetValueB("Banned", Split[2], false) == false ) then
return true, Split[2] .. " is not banned!"
return true, "Player " .. Split[2] .. " has been banned."; end
end
BannedPlayersIni:SetValueB("Banned", Split[2], false, false)
BannedPlayersIni:WriteFile()
local Server = cRoot:Get():GetServer()
return true, "Unbanned " .. Split[2]
function HandleConsoleBanList(Split) end
if (#Split == 1) then
return true, BanListByName(); function HandleConsoleBanList(Split)
end if (#Split == 1) then
return true, BanListByName();
if (string.lower(Split[2]) == "ips") then end
return true, BanListByIPs();
end if (string.lower(Split[2]) == "ips") then
return true, BanListByIPs();
return true, "Unknown banlist subcommand"; end
end
return true, "Unknown banlist subcommand";
end
function HandleConsoleHelp(Split)
local Commands = {}; -- {index => {"Command", "HelpString"} }
function HandleConsoleHelp(Split) local MaxLength = 0;
local Commands = {}; -- {index => {"Command", "HelpString"} } local AddToTable = function(Command, HelpString)
local MaxLength = 0; table.insert(Commands, { Command, HelpString });
local AddToTable = function(Command, HelpString) local CmdLen = Command:len();
table.insert(Commands, { Command, HelpString }); if (CmdLen > MaxLength) then
local CmdLen = Command:len(); MaxLength = CmdLen;
if (CmdLen > MaxLength) then end
MaxLength = CmdLen; end
end
end cPluginManager:Get():ForEachConsoleCommand(AddToTable);
cPluginManager:Get():ForEachConsoleCommand(AddToTable); -- Sort the table:
local CompareCommands = function(a, b)
-- Sort the table: return a[1] < b[1]; -- compare command strings
local CompareCommands = function(a, b) end
return a[1] < b[1]; -- compare command strings table.sort(Commands, CompareCommands);
end
table.sort(Commands, CompareCommands); local Out = "";
for i, Command in ipairs(Commands) do
local Out = ""; Out = Out .. Command[1] .. string.rep(" ", MaxLength - Command[1]:len()); -- Align to a table
for i, Command in ipairs(Commands) do Out = Out .. " - " .. Command[2] .. "\n";
Out = Out .. Command[1] .. string.rep(" ", MaxLength - Command[1]:len()); -- Align to a table end
Out = Out .. " - " .. Command[2] .. "\n"; return true, Out;
end 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 HandleConsoleList(Split) function (a_Player)
-- Get a list of all players, one playername per line Out = Out .. a_Player:GetName() .. "\n";
local Out = ""; end
cRoot:Get():ForEachWorld( );
function (a_World) end
a_World:ForEachPlayer( );
function (a_Player) return true, Out;
Out = Out .. a_Player:GetName() .. "\n"; end
end
); function HandleConsoleListGroups(Split)
end -- Read the groups.ini file:
); local GroupsIni = cIniFile("groups.ini");
return true, Out; if (not(GroupsIni:ReadFile())) then
end return true, "No groups found";
end
-- Read the groups:
Number = GroupsIni:NumKeys();
Groups = {};
function HandleConsoleListGroups(Split) for i = 0, Number do
-- Read the groups.ini file: table.insert(Groups, GroupsIni:KeyName(i))
local GroupsIni = cIniFile("groups.ini"); end
if (not(GroupsIni:ReadFile())) then
return true, "No groups found"; -- Output the groups, concatenated to a string:
end local Out = "Groups:\n"
Out = Out .. table.concat(Groups, ", ");
-- Read the groups: return true, Out;
Number = GroupsIni:NumKeys(); end
Groups = {};
for i = 0, Number do function HandleConsoleNumChunks(Split)
table.insert(Groups, GroupsIni:KeyName(i)) local Output = {};
end local AddNumChunks = function(World)
Output[World:GetName()] = World:GetNumChunks();
-- Output the groups, concatenated to a string: end;
local Out = "Groups:\n"
Out = Out .. table.concat(Groups, ", "); cRoot:Get():ForEachWorld(AddNumChunks);
return true, Out;
end local Total = 0;
local Out = "";
for name, num in pairs(Output) do
Out = Out .. " " .. name .. ": " .. num .. " chunks\n";
Total = Total + num;
end
function HandleConsoleNumChunks(Split) Out = Out .. "Total: " .. Total .. " chunks\n";
local Output = {};
local AddNumChunks = function(World) return true, Out;
Output[World:GetName()] = World:GetNumChunks(); end
end;
function HandleConsolePlayers(Split)
cRoot:Get():ForEachWorld(AddNumChunks); local PlayersInWorlds = {}; -- "WorldName" => [players array]
local AddToTable = function(Player)
local Total = 0; local WorldName = Player:GetWorld():GetName();
local Out = ""; if (PlayersInWorlds[WorldName] == nil) then
for name, num in pairs(Output) do PlayersInWorlds[WorldName] = {};
Out = Out .. " " .. name .. ": " .. num .. " chunks\n"; end
Total = Total + num; table.insert(PlayersInWorlds[WorldName], Player:GetName() .. " @ " .. Player:GetIP());
end end
Out = Out .. "Total: " .. Total .. " chunks\n";
cRoot:Get():ForEachPlayer(AddToTable);
return true, Out;
end 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
function HandleConsolePlayers(Split) end
local PlayersInWorlds = {}; -- "WorldName" => [players array]
local AddToTable = function(Player) return true, Out;
local WorldName = Player:GetWorld():GetName(); end
if (PlayersInWorlds[WorldName] == nil) then
PlayersInWorlds[WorldName] = {}; function HandleConsolePrimaryServerVersion(Split)
end if (#Split == 1) then
table.insert(PlayersInWorlds[WorldName], Player:GetName() .. " @ " .. Player:GetIP()); -- Display current version:
end local Version = cRoot:Get():GetPrimaryServerVersion();
return true, "Primary server version: #" .. Version .. ", " .. cRoot:GetProtocolVersionTextFromInt(Version);
cRoot:Get():ForEachPlayer(AddToTable); end
local Out = ""; -- Set new value as the version:
for WorldName, Players in pairs(PlayersInWorlds) do cRoot:Get():SetPrimaryServerVersion(tonumber(Split[2]));
Out = Out .. "World " .. WorldName .. ":\n"; local Version = cRoot:Get():GetPrimaryServerVersion();
for i, PlayerName in ipairs(Players) do return true, "Primary server version is now #" .. Version .. ", " .. cRoot:GetProtocolVersionTextFromInt(Version);
Out = Out .. " " .. PlayerName .. "\n"; end
end
end function HandleConsoleRank(Split)
if (Split[2] == nil) or (Split[3] == nil) then
return true, Out; return true, "Usage: /rank [Player] [Group]";
end end
local Out = "";
-- Read the groups.ini file:
local GroupsIni = cIniFile("groups.ini")
if (not(GroupsIni:ReadFile())) then
function HandleConsolePrimaryServerVersion(Split) Out = "Could not read groups.ini, creating anew!\n"
if (#Split == 1) then end
-- Display current version:
local Version = cRoot:Get():GetPrimaryServerVersion(); -- Find the group:
return true, "Primary server version: #" .. Version .. ", " .. cRoot:GetProtocolVersionTextFromInt(Version); if (GroupsIni:FindKey(Split[3]) == -1) then
end return true, Out .. "Group does not exist";
end
-- Set new value as the version:
cRoot:Get():SetPrimaryServerVersion(tonumber(Split[2])); -- Read the users.ini file:
local Version = cRoot:Get():GetPrimaryServerVersion(); local UsersIni = cIniFile("users.ini");
return true, "Primary server version is now #" .. Version .. ", " .. cRoot:GetProtocolVersionTextFromInt(Version); if (not(UsersIni:ReadFile())) then
end 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]);
function HandleConsoleRank(Split) UsersIni:WriteFile();
if (Split[2] == nil) or (Split[3] == nil) then
return true, "Usage: /rank [Player] [Group]"; -- Reload the player's permissions:
end cRoot:Get():ForEachWorld(
local Out = ""; function (World)
World:ForEachPlayer(
-- Read the groups.ini file: function (Player)
local GroupsIni = cIniFile("groups.ini") if (Player:GetName() == Split[2]) then
if (not(GroupsIni:ReadFile())) then Player:SendMessage(cChatColor.Green .. "You were moved to group " .. Split[3]);
Out = "Could not read groups.ini, creating anew!\n" Player:LoadPermissionsFromDisk();
end end
end
-- Find the group: );
if (GroupsIni:FindKey(Split[3]) == -1) then end
return true, Out .. "Group does not exist"; )
end
return true, Out .. "Player " .. Split[2] .. " was moved to " .. Split[3];
-- Read the users.ini file: end
local UsersIni = cIniFile("users.ini");
if (not(UsersIni:ReadFile())) then function HandleConsoleReload(Split)
Out = Out .. "Could not read users.ini, creating anew!\n"; Server = cRoot:Get():GetServer();
end Server:SendMessage(cChatColor.Green .. "Reloading all plugins.");
cPluginManager:Get():ReloadPlugins();
-- Write the new group value to users.ini: return true;
UsersIni:DeleteKey(Split[2]); end
UsersIni:GetValueSet(Split[2], "Groups", Split[3]);
UsersIni:WriteFile(); function HandleConsoleSaveAll(Split)
cRoot:Get():SaveAllChunks();
-- Reload the player's permissions: return true;
cRoot:Get():ForEachWorld( end
function (World)
World:ForEachPlayer( function HandleConsoleSay(Split)
function (Player) table.remove(Split, 1);
if (Player:GetName() == Split[2]) then local Message = "";
Player:SendMessage(cChatColor.Green .. "You were moved to group " .. Split[3]); for i, Text in ipairs(Split) do
Player:LoadPermissionsFromDisk(); Message = Message .. " " .. Text;
end end
end Message = Message:sub(2); -- Cut off the first space
); cRoot:Get():GetServer():BroadcastChat(cChatColor.Purple .. "[SERVER] " .. Message);
end return true;
) end
return true, Out .. "Player " .. Split[2] .. " was moved to " .. Split[3]; function HandleConsoleUnload(Split)
end local UnloadChunks = function(World)
World:UnloadUnusedChunks();
end
local Out = "Num loaded chunks before: " .. cRoot:Get():GetTotalChunkCount() .. "\n";
cRoot:Get():ForEachWorld(UnloadChunks);
function HandleConsoleReload(Split) Out = Out .. "Num loaded chunks after: " .. cRoot:Get():GetTotalChunkCount();
Server = cRoot:Get():GetServer(); return true, Out;
Server:SendMessage(cChatColor.Green .. "Reloading all plugins."); end
cPluginManager:Get():ReloadPlugins();
return true;
end -- Helper functions:
--- Returns the list of players banned by name, separated by ", "
function BanListByName()
local NumValues = BannedPlayersIni:NumValues("Banned");
local Banned = {};
function HandleConsoleSaveAll(Split) local KeyID = BannedPlayersIni:FindKey("Banned");
cRoot:Get():SaveAllChunks(); for i = 1, NumValues do
return true; local PlayerName = BannedPlayersIni:ValueName(KeyID, i - 1);
end if (BannedPlayersIni:GetValueB("Banned", PlayerName)) then
-- Player listed AND banned
table.insert(Banned, PlayerName);
end
end
return table.concat(Banned, ", ");
function HandleConsoleSay(Split) end
table.remove(Split, 1);
local Message = ""; --- Returns the list of players banned by IP, separated by ", "
for i, Text in ipairs(Split) do function BanListByIPs()
Message = Message .. " " .. Text; -- TODO: No IP ban implemented yet
end return "";
Message = Message:sub(2); -- Cut off the first space end
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

View File

@ -1,3 +1,3 @@
function SetBackCoordinates( Player ) function SetBackCoordinates( Player )
BackCoords[Player:GetName()] = Vector3i( Player:GetPosX(), Player:GetPosY(), Player:GetPosZ() ) BackCoords[Player:GetName()] = Vector3i( Player:GetPosX(), Player:GetPosY(), Player:GetPosZ() )
end end

View File

@ -1,39 +1,39 @@
function HandleItemCommand(Split, Player) function HandleGiveCommand(Split, Player)
if ((#Split ~= 2) and (#Split ~=3)) then 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; return true;
end end
local Item = cItem(); local Item = cItem();
local FoundItem = StringToItem(Split[2], Item); local FoundItem = StringToItem(Split[2], Item);
if not(IsValidItem(Item.m_ItemType)) then -- StringToItem does not check if item is valid if not(IsValidItem(Item.m_ItemType)) then -- StringToItem does not check if item is valid
FoundItem = false FoundItem = false
end end
if not(FoundItem) then if not(FoundItem) then
Player:SendMessage( cChatColor.Green .. "Invalid Item type / name !" ) Player:SendMessage( cChatColor.Green .. "Invalid item id or name!" )
return true return true
end end
local ItemAmount = 1; local ItemAmount = 1;
if (#Split == 3) then if (#Split == 3) then
ItemAmount = tonumber(Split[3]); ItemAmount = tonumber(Split[3]);
if ((ItemAmount == nil) or (ItemAmount < 1) or (ItemAmount > 512)) then if ((ItemAmount == nil) or (ItemAmount < 1) or (ItemAmount > 512)) then
Player:SendMessage(cChatColor.Green .. "Invalid Amount!"); Player:SendMessage(cChatColor.Green .. "Invalid amount!");
return true; return true;
end end
end end
Item.m_ItemCount = ItemAmount; Item.m_ItemCount = ItemAmount;
local ItemsGiven = Player:GetInventory():AddItem(Item); local ItemsGiven = Player:GetInventory():AddItem(Item);
if (ItemsGiven == ItemAmount) then if (ItemsGiven == ItemAmount) then
Player:SendMessage( cChatColor.Green .. "There you go !"); Player:SendMessage( cChatColor.Green .. "There you go!");
LOG("Gave " .. Player:GetName() .. " " .. Item.m_ItemCount .. " times " .. Item.m_ItemType .. ":" .. Item.m_ItemDamage); LOG("Gave " .. Player:GetName() .. " " .. Item.m_ItemCount .. " times " .. Item.m_ItemType .. ":" .. Item.m_ItemDamage);
else else
Player:SendMessage(cChatColor.Green .. "Not enough space in inventory, only gave " .. ItemsGiven); 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); LOG("Player " .. Player:GetName() .. " asked for " .. Item.m_ItemCount .. " times " .. Item.m_ItemType .. ":" .. Item.m_ItemDamage ..", but only could fit " .. ItemsGiven);
end end
return true; return true;
end end

View File

@ -1,10 +1,8 @@
function HandleChangeGMCommand( Split, Player ) function HandleChangeGMCommand( Split, Player )
if( #Split ~= 2 ) then if( #Split ~= 2 ) then
Player:SendMessage( cChatColor.Green .. "Usage: /gm [GameMode (0|1)]" ) Player:SendMessage( cChatColor.Green .. "Usage: /gm [GameMode (0|1)]" )
return true return true
end end
Player:SetGameMode(Split[2])
Player:SetGameMode(Split[2]) return true
return true
end 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,40 +1,41 @@
function HandleHelpCommand(Split, Player) function HandleHelpCommand(Split, Player)
local PluginManager = cRoot:Get():GetPluginManager() local PluginManager = cRoot:Get():GetPluginManager()
local LinesPerPage = 9; local LinesPerPage = 8;
local CurrentPage = 1; local CurrentPage = 1;
local CurrentLine = 0; local CurrentLine = 0;
local PageRequested = 1; local PageRequested = 1;
local Output = {}; local Output = {};
if (#Split == 2) then if (#Split == 2) then
PageRequested = tonumber(Split[2]); PageRequested = tonumber(Split[2]);
end end
local Process = function(Command, Permission, HelpString) local Process = function(Command, Permission, HelpString)
if not(Player:HasPermission(Permission)) then if not(Player:HasPermission(Permission)) then
return false; return false;
end; end;
if (HelpString == "") then if (HelpString == "") then
return false; return false;
end; end;
CurrentLine = CurrentLine + 1; CurrentLine = CurrentLine + 1;
CurrentPage = math.floor(CurrentLine / LinesPerPage) + 1; CurrentPage = math.floor(CurrentLine / LinesPerPage) + 1;
if (CurrentPage ~= PageRequested) then if (CurrentPage ~= PageRequested) then
return false; return false;
end; end;
table.insert(Output, cChatColor.Blue .. Command .. HelpString); table.insert(Output, cChatColor.Blue .. Command .. HelpString);
end end
PluginManager:ForEachCommand(Process); PluginManager:ForEachCommand(Process);
-- CurrentPage now contains the total number of pages, and Output has the individual help lines to be sent -- 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 .. "] -----------");
for idx, msg in ipairs(Output) do Player:SendMessage(cChatColor.Purple .. "'-' means no prefix, '~' means a value is required.");
Player:SendMessage(msg); for idx, msg in ipairs(Output) do
end; Player:SendMessage(msg);
end;
return true
return true
end end

View File

@ -1,214 +1,202 @@
-- Based on Fixies plugin v2 by Taugeshtu
-- Implements item-repair using the HOOK_CRAFTING_NO_RECIPE hook -- how much "extra" points are healed per a repair operation (fraction of full health)
-- Based on Fixies plugin v2 by Taugeshtu BONUS = 0.1
function OnCraftingNoRecipe(Player, Grid, Recipe)
-- how much "extra" points are healed per a repair operation (fraction of full health) local _do_fix = false
BONUS = 0.1 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)
function OnCraftingNoRecipe(Player, Grid, Recipe) end
local _do_fix = false end
local Items = {} end
for x = 0, Grid:GetWidth() - 1 do
for y = 0, Grid:GetHeight() - 1 do if (#Items ~= 2) then
local Item = Grid:GetItem(x, y) -- Only two items together can be fixed
if (Item.m_ItemType ~= E_ITEM_EMPTY) then return false
table.insert(Items, Item) end
end
end if (Items[1].m_ItemType ~= Items[2].m_ItemType) then
end -- Only items of the same type may be fixed
return false
if (#Items ~= 2) then end
-- Only two items together can be fixed
return false if (
end (Items[1].m_ItemDamage == 0) or
(Items[2].m_ItemDamage == 0)
if (Items[1].m_ItemType ~= Items[2].m_ItemType) then )
-- Only items of the same type may be fixed then
return false -- Only damaged items may be fixed
end return false
end
if (
(Items[1].m_ItemDamage == 0) or local _ID = Items[1].m_ItemType
(Items[2].m_ItemDamage == 0) 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)
then local _item_hp = 0
-- Only damaged items may be fixed
return false -- TODO: This could be refactored into better code, using an _ID-indexed table for _item_hp
end
if (
local _ID = Items[1].m_ItemType (_ID == E_ITEM_WOODEN_SHOVEL) or
local _least_hp = math.max(Items[1].m_ItemDamage, Items[2].m_ItemDamage) (_ID == E_ITEM_WOODEN_AXE) or
local _most_hp = math.min(Items[1].m_ItemDamage, Items[2].m_ItemDamage) (_ID == E_ITEM_WOODEN_PICKAXE) or
local _item_hp = 0 (_ID == E_ITEM_WOODEN_SWORD) or
(_ID == E_ITEM_WOODEN_HOE)
-- TODO: This could be refactored into better code, using an _ID-indexed table for _item_hp )
then
if ( _item_hp = 60
(_ID == E_ITEM_WOODEN_SHOVEL) or _do_fix = true
(_ID == E_ITEM_WOODEN_AXE) or end
(_ID == E_ITEM_WOODEN_PICKAXE) or
(_ID == E_ITEM_WOODEN_SWORD) or if (
(_ID == E_ITEM_WOODEN_HOE) (_ID == E_ITEM_STONE_SHOVEL) or
) (_ID == E_ITEM_STONE_AXE) or
then (_ID == E_ITEM_STONE_PICKAXE) or
_item_hp = 60 (_ID == E_ITEM_STONE_SWORD) or
_do_fix = true (_ID == E_ITEM_STONE_HOE)
end )
then
if ( _item_hp = 132
(_ID == E_ITEM_STONE_SHOVEL) or _do_fix = true
(_ID == E_ITEM_STONE_AXE) or end
(_ID == E_ITEM_STONE_PICKAXE) or
(_ID == E_ITEM_STONE_SWORD) or if (
(_ID == E_ITEM_STONE_HOE) (_ID == E_ITEM_IRON_SHOVEL) or
) (_ID == E_ITEM_IRON_AXE) or
then (_ID == E_ITEM_IRON_PICKAXE) or
_item_hp = 132 (_ID == E_ITEM_IRON_SWORD) or
_do_fix = true (_ID == E_ITEM_IRON_HOE)
end )
then
if ( _item_hp = 251
(_ID == E_ITEM_IRON_SHOVEL) or _do_fix = true
(_ID == E_ITEM_IRON_AXE) or end
(_ID == E_ITEM_IRON_PICKAXE) or
(_ID == E_ITEM_IRON_SWORD) or if (
(_ID == E_ITEM_IRON_HOE) (_ID == E_ITEM_GOLD_SHOVEL) or
) (_ID == E_ITEM_GOLD_AXE) or
then (_ID == E_ITEM_GOLD_PICKAXE) or
_item_hp = 251 (_ID == E_ITEM_GOLD_SWORD) or
_do_fix = true (_ID == E_ITEM_GOLD_HOE)
end )
then
if ( _item_hp = 33
(_ID == E_ITEM_GOLD_SHOVEL) or _do_fix = true
(_ID == E_ITEM_GOLD_AXE) or end
(_ID == E_ITEM_GOLD_PICKAXE) or
(_ID == E_ITEM_GOLD_SWORD) or if (
(_ID == E_ITEM_GOLD_HOE) (_ID == E_ITEM_DIAMOND_SHOVEL) or
) (_ID == E_ITEM_DIAMOND_AXE) or
then (_ID == E_ITEM_DIAMOND_PICKAXE) or
_item_hp = 33 (_ID == E_ITEM_DIAMOND_SWORD) or
_do_fix = true (_ID == E_ITEM_DIAMOND_HOE)
end )
then
if ( _item_hp = 1562
(_ID == E_ITEM_DIAMOND_SHOVEL) or _do_fix = true
(_ID == E_ITEM_DIAMOND_AXE) or end
(_ID == E_ITEM_DIAMOND_PICKAXE) or
(_ID == E_ITEM_DIAMOND_SWORD) or if (_ID == E_ITEM_LEATHER_CAP) then
(_ID == E_ITEM_DIAMOND_HOE) _item_hp = 56
) _do_fix = true
then end
_item_hp = 1562 if (_ID == E_ITEM_LEATHER_TUNIC) then
_do_fix = true _item_hp = 82
end _do_fix = true
end
if (_ID == E_ITEM_LEATHER_CAP) then if (_ID == E_ITEM_LEATHER_PANTS) then
_item_hp = 56 _item_hp = 76
_do_fix = true _do_fix = true
end end
if (_ID == E_ITEM_LEATHER_TUNIC) then if (_ID == E_ITEM_LEATHER_BOOTS) then
_item_hp = 82 _item_hp = 66
_do_fix = true _do_fix = true
end end
if (_ID == E_ITEM_LEATHER_PANTS) then
_item_hp = 76
_do_fix = true if (_ID == E_ITEM_CHAIN_HELMET) then
end _item_hp = 78
if (_ID == E_ITEM_LEATHER_BOOTS) then _do_fix = true
_item_hp = 66 end
_do_fix = true if (_ID == E_ITEM_CHAIN_CHESTPLATE) then
end _item_hp = 114
_do_fix = true
end
if (_ID == E_ITEM_CHAIN_HELMET) then if (_ID == E_ITEM_CHAIN_LEGGINGS) then
_item_hp = 78 _item_hp = 106
_do_fix = true _do_fix = true
end end
if (_ID == E_ITEM_CHAIN_CHESTPLATE) then if (_ID == E_ITEM_CHAIN_BOOTS) then
_item_hp = 114 _item_hp = 92
_do_fix = true _do_fix = true
end end
if (_ID == E_ITEM_CHAIN_LEGGINGS) then
_item_hp = 106
_do_fix = true if (_ID == E_ITEM_IRON_HELMET) then
end _item_hp = 166
if (_ID == E_ITEM_CHAIN_BOOTS) then _do_fix = true
_item_hp = 92 end
_do_fix = true if (_ID == E_ITEM_IRON_CHESTPLATE) then
end _item_hp = 242
_do_fix = true
end
if (_ID == E_ITEM_IRON_HELMET) then if (_ID == E_ITEM_IRON_LEGGINGS) then
_item_hp = 166 _item_hp = 226
_do_fix = true _do_fix = true
end end
if (_ID == E_ITEM_IRON_CHESTPLATE) then if (_ID == E_ITEM_IRON_BOOTS) then
_item_hp = 242 _item_hp = 196
_do_fix = true _do_fix = true
end end
if (_ID == E_ITEM_IRON_LEGGINGS) then
_item_hp = 226
_do_fix = true if (_ID == E_ITEM_GOLD_HELMET) then
end _item_hp = 78
if (_ID == E_ITEM_IRON_BOOTS) then _do_fix = true
_item_hp = 196 end
_do_fix = true if (_ID == E_ITEM_GOLD_CHESTPLATE) then
end _item_hp = 114
_do_fix = true
end
if (_ID == E_ITEM_GOLD_HELMET) then if (_ID == E_ITEM_GOLD_LEGGINGS) then
_item_hp = 78 _item_hp = 106
_do_fix = true _do_fix = true
end end
if (_ID == E_ITEM_GOLD_CHESTPLATE) then if (_ID == E_ITEM_GOLD_BOOTS) then
_item_hp = 114 _item_hp = 92
_do_fix = true _do_fix = true
end end
if (_ID == E_ITEM_GOLD_LEGGINGS) then
_item_hp = 106
_do_fix = true if (_ID == E_ITEM_DIAMOND_HELMET) then
end _item_hp = 364
if (_ID == E_ITEM_GOLD_BOOTS) then _do_fix = true
_item_hp = 92 end
_do_fix = true if (_ID == E_ITEM_DIAMOND_CHESTPLATE)then
end _item_hp = 529
_do_fix = true
end
if (_ID == E_ITEM_DIAMOND_HELMET) then if (_ID == E_ITEM_DIAMOND_LEGGINGS) then
_item_hp = 364 _item_hp = 496
_do_fix = true _do_fix = true
end end
if (_ID == E_ITEM_DIAMOND_CHESTPLATE)then if (_ID == E_ITEM_DIAMOND_BOOTS) then
_item_hp = 529 _item_hp = 430
_do_fix = true _do_fix = true
end end
if (_ID == E_ITEM_DIAMOND_LEGGINGS) then -- /////////////////////////////////////////////////////
_item_hp = 496
_do_fix = true if (_do_fix == true) then
end local _hp = _most_hp - (_item_hp - _least_hp) - _item_hp * BONUS
if (_ID == E_ITEM_DIAMOND_BOOTS) then _hp = math.max(_hp, 0)
_item_hp = 430 Recipe:SetResult(_ID, 1, _hp)
_do_fix = true Recipe:SetIngredient(Items[1].x, Items[1].y, Items[1]);
end Recipe:SetIngredient(Items[2].x, Items[2].y, Items[2]);
-- ///////////////////////////////////////////////////// return true
end
if (_do_fix == true) then return false
local _hp = _most_hp - (_item_hp - _least_hp) - _item_hp * BONUS end
_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

View File

@ -1,46 +1,42 @@
function HandleKickCommand( Split, Player ) function HandleKickCommand( Split, Player )
if( #Split < 2 ) then if( #Split < 2 ) then
Player:SendMessage( cChatColor.Green .. "Usage: /kick [Player] <Reason>" ) Player:SendMessage( cChatColor.Green .. "Usage: /kick [Player] <Reason>" )
return true return true
end end
local Reason = "You have been kicked" local Reason = "You have been kicked"
if( #Split > 2 ) then if( #Split > 2 ) then
Reason = table.concat(Split, " ", 3) Reason = table.concat(Split, " ", 3)
end end
if( KickPlayer( Split[2], Reason ) == false ) then if( KickPlayer( Split[2], Reason ) == false ) then
Player:SendMessage( cChatColor.Green .. "Could not find player " .. Split[2] ) Player:SendMessage( cChatColor.Green .. "Could not find player " .. Split[2] )
end end
return true return true
end 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
--- Kicks a player by name, with the specified reason; returns bool whether found and player's real name Reason = "You have been kicked";
function KickPlayer(PlayerName, Reason) end
local RealName = "";
if (Reason == nil) then local FoundPlayerCallback = function(a_Player)
Reason = "You have been kicked"; RealName = a_Player:GetName()
end
local Server = cRoot:Get():GetServer()
local FoundPlayerCallback = function(a_Player) LOGINFO( "'" .. RealName .. "' is being kicked for ( "..Reason..") " )
RealName = a_Player:GetName() Server:SendMessage("Kicking " .. RealName)
local Server = cRoot:Get():GetServer() a_Player:GetClientHandle():Kick(Reason);
LOGINFO( "'" .. RealName .. "' is being kicked for ( "..Reason..") " ) end
Server:SendMessage("Kicking " .. RealName)
if (not(cRoot:Get():FindAndDoWithPlayer( PlayerName, FoundPlayerCallback))) then
a_Player:GetClientHandle():Kick(Reason); -- Could not find player
end return false;
end
if (not(cRoot:Get():FindAndDoWithPlayer( PlayerName, FoundPlayerCallback))) then
-- Could not find player return true, RealName; -- Player has been kicked
return false;
end
return true, RealName; -- Player has been kicked
end end

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() ) ) Player:SendMessage(cChatColor.Green .. string.format("[X:%0.2f] [Y:%0.2f] [Z:%0.2f]", Player:GetPosX(), Player:GetPosY(), Player:GetPosZ() ) )
return true return true
end end

View File

@ -1,129 +1,183 @@
---- Some settings ----- --COMMENCE VARIABLES
SHOW_PLUGIN_NAMES = true -- If true, plugin name will be shown before commands PLUGIN = {}
-- This is overwritten in the Initialize() function BannedPlayersIni = {}
------------------------ WhiteListIni = {}
BackCoords = {}
-- Global variables Messages = {}
PLUGIN = {} -- Reference to own plugin object LimitWorldsCuboid = {}
BannedPlayersIni = {} SPAWNPROTECT = true
WhiteListIni = {} PROTECTRADIUS = 20
BackCoords = {} LOGTOFILE = false
Messages = {} --END VARIABLES
LimitWorldsCuboid = {}
--COMMENCE AWESOMENESS!
function Initialize(Plugin)
PLUGIN = Plugin
function Initialize(Plugin) Plugin:SetName("Core")
PLUGIN = Plugin Plugin:SetVersion(13)
Plugin:SetName("Core") --ADD HOOKS
Plugin:SetVersion(13) PluginManager = cRoot:Get():GetPluginManager()
PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_JOINED)
PluginManager = cRoot:Get():GetPluginManager() PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_BREAKING_BLOCK)
PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_JOINED) PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_PLACING_BLOCK)
PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_BREAKING_BLOCK) PluginManager:AddHook(Plugin, cPluginManager.HOOK_LOGIN)
PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_PLACING_BLOCK) PluginManager:AddHook(Plugin, cPluginManager.HOOK_KILLING)
PluginManager:AddHook(Plugin, cPluginManager.HOOK_LOGIN) PluginManager:AddHook(Plugin, cPluginManager.HOOK_CRAFTING_NO_RECIPE)
PluginManager:AddHook(Plugin, cPluginManager.HOOK_KILLING) PluginManager:AddHook(Plugin, cPluginManager.HOOK_CHAT) -- used in web_chat.lua
PluginManager:AddHook(Plugin, cPluginManager.HOOK_CRAFTING_NO_RECIPE) PluginManager:AddHook(Plugin, cPluginManager.HOOK_CHUNK_GENERATING)
PluginManager:AddHook(Plugin, cPluginManager.HOOK_CHAT) -- used in web_chat.lua PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_MOVING)
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("/listworlds", "core.listworlds", HandleListWorldsCommand, " - Shows a list of all the worlds"); PluginManager:BindCommand("/back", "core.back", HandleBackCommand, " - Return to your last position");
PluginManager:BindCommand("/listgroups", "core.listgroups", HandleListGroupsCommand, " - Shows a list of all the groups"); PluginManager:BindCommand("/ban", "core.ban", HandleBanCommand, " ~ Ban a player");
PluginManager:BindCommand("/toggledownfall", "core.toggledownfall", HandleToggleDownfallCommand, " - Toggles the weather"); PluginManager:BindCommand("/give", "core.give", HandleGiveCommand, " ~ Give yourself an item");
PluginManager:BindCommand("/back", "core.back", HandleBackCommand, " - Return to your last position"); PluginManager:BindCommand("/gm", "core.changegm", HandleChangeGMCommand, " ~ Change your gamemode");
PluginManager:BindCommand("/save-all", "core.save-all", HandleSaveAllCommand, " - Saves all your worlds"); PluginManager:BindCommand("/help", "core.help", HandleHelpCommand, " ~ Show available commands");
PluginManager:BindCommand("/help", "core.help", HandleHelpCommand, " [Page] - Show available commands"); PluginManager:BindCommand("/kick", "core.kick", HandleKickCommand, " ~ Kick a player");
PluginManager:BindCommand("/rank", "core.rank", HandleRankCommand, " [Player] [Rank] - to add someone to a group"); PluginManager:BindCommand("/list", "core.playerlist", HandlePlayerListCommand, " - Shows list of connected players");
PluginManager:BindCommand("/pluginlist", "core.pluginlist", HandlePluginListCommand, " - Show list of plugins"); PluginManager:BindCommand("/listgroups", "core.listgroups", HandleListGroupsCommand, " - Shows a list of all the groups");
PluginManager:BindCommand("/tp", "core.teleport", HandleTPCommand, " [Player] - Teleport yourself to a player"); PluginManager:BindCommand("/locate", "core.locate", HandleLocateCommand, " - Show your current server coordinates");
PluginManager:BindCommand("/item", "core.item", HandleItemCommand, " [ItemType/Name] <Amount> - Give yourself an item"); PluginManager:BindCommand("/motd", "core.motd", HandleMOTDCommand, " - Show message of the day");
PluginManager:BindCommand("/i", "core.item", HandleItemCommand, ""); PluginManager:BindCommand("/playerlist", "core.playerlist", HandlePlayerListCommand, " - Shows list of connected players");
PluginManager:BindCommand("/list", "core.playerlist", HandlePlayerListCommand, " - Shows list of connected players"); PluginManager:BindCommand("/plugins", "core.plugins", HandlePluginsCommand, " - Show list of plugins");
PluginManager:BindCommand("/who", "core.playerlist", HandlePlayerListCommand, " - Shows list of connected players"); PluginManager:BindCommand("/portal", "core.portal", HandlePortalCommand, " ~ Move to a different world");
PluginManager:BindCommand("/playerlist", "core.playerlist", HandlePlayerListCommand, " - Shows list of connected players"); PluginManager:BindCommand("/rank", "core.rank", HandleRankCommand, " ~ Add someone to a group");
PluginManager:BindCommand("/motd", "core.motd", HandleMOTDCommand, " - Show message of the day"); PluginManager:BindCommand("/regen", "core.regen", HandleRegenCommand, " ~ Regenerates a chunk, current or specified");
PluginManager:BindCommand("/reload", "core.reload", HandleReloadCommand, " - Reload all plugins"); PluginManager:BindCommand("/reload", "core.reload", HandleReloadCommand, " - Reload all plugins");
PluginManager:BindCommand("/stop", "core.stop", HandleStopCommand, " - Stops the server"); PluginManager:BindCommand("/save-all", "core.save-all", HandleSaveAllCommand, " - Saves all your worlds");
PluginManager:BindCommand("/time", "core.time", HandleTimeCommand, " [Day/Night] - Sets the time of day"); PluginManager:BindCommand("/spawn", "core.spawn", HandleSpawnCommand, " - Return to the spawn");
PluginManager:BindCommand("/spawn", "core.spawn", HandleSpawnCommand, " - Return to the spawn"); PluginManager:BindCommand("/stop", "core.stop", HandleStopCommand, " - Stops the server");
PluginManager:BindCommand("/kick", "core.kick", HandleKickCommand, " [Player] - Kick a player"); PluginManager:BindCommand("/time", "core.time", HandleTimeCommand, " ~ Sets the time of day");
PluginManager:BindCommand("/ban", "core.ban", HandleBanCommand, " [Player] - Ban a player"); PluginManager:BindCommand("/toggledownfall", "core.toggledownfall", HandleToggleDownfallCommand, " - Toggles the weather");
PluginManager:BindCommand("/unban", "core.unban", HandleUnbanCommand, " [Player] - Unban a player"); PluginManager:BindCommand("/top", "core.top", HandleTopCommand, " - Teleport yourself to the top most block");
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("/gm", "core.changegm", HandleChangeGMCommand, " [0|1] - Change your gamemode"); PluginManager:BindCommand("/tpa", "core.teleport", HandleTPACommand, " ~ Ask to teleport yourself to a player");
PluginManager:BindCommand("/gotoworld", "core.gotoworld", HandleGotoWorldCommand, " [WorldName] - Move to a different world!"); PluginManager:BindCommand("/tpaccept", "core.teleport", HandleTPAcceptCommand, " ~ Accept a teleportation request");
PluginManager:BindCommand("/coords", "core.coords", HandleCoordsCommand, " - Show your current server coordinates"); PluginManager:BindCommand("/unban", "core.unban", HandleUnbanCommand, " ~ Unban a player");
PluginManager:BindCommand("/regeneratechunk", "core.regeneratechunk", HandleRegenerateChunkCommand, " <[X] [Z]> - Regenerates a chunk, current or specified"); PluginManager:BindCommand("/viewdistance", "core.viewdistance", HandleViewDistanceCommand, " [".. cClientHandle.MIN_VIEW_DISTANCE .."-".. cClientHandle.MAX_VIEW_DISTANCE .."] - Change your view distance")
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();
InitConsoleCommands();
-- Load the settings
IniFile = cIniFile("Settings.ini") --LOAD SETTINGS
if ( IniFile:ReadFile() == true ) then IniFile = cIniFile("settings.ini")
HardCore = IniFile:GetValueSet("GameMode", "Hardcore", "false") if ( IniFile:ReadFile() == true ) then
LimitWorld = IniFile:GetValueSetB("Worlds", "LimitWorld", true) HardCore = IniFile:GetValueSet("GameMode", "Hardcore", "false")
LimitWorldWidth = IniFile:GetValueSetI("Worlds", "LimitWorldWidth", 10) LimitWorld = IniFile:GetValueSetB("Worlds", "LimitWorld", true)
SHOW_PLUGIN_NAMES = IniFile:GetValueSetB("HelpPlugin", "ShowPluginNames", true ) LimitWorldWidth = IniFile:GetValueSetI("Worlds", "LimitWorldWidth", 10)
IniFile:WriteFile() SPAWNPROTECT = IniFile:GetValueSetB("SpawnProtect", "Enable", true)
end PROTECTRADIUS = IniFile:GetValueSetI("SpawnProtect", "ProtectRadius", 20)
LOGTOFILE = IniFile:GetValueSetB("SpawnProtect", "LogToFile", false)
cRoot:Get():ForEachWorld( IniFile:WriteFile()
function( World ) end
LimitWorldsCuboid[World:GetName()] = cCuboid()
LimitWorldsCuboid[World:GetName()].p1 = Vector3i( math.floor(World:GetSpawnX() / 16) + LimitWorldWidth, 0, math.floor(World:GetSpawnZ() / 16) + LimitWorldWidth) if LimitWorldWidth ~= nil then
LimitWorldsCuboid[World:GetName()].p2 = Vector3i( math.floor(World:GetSpawnX() / 16) - LimitWorldWidth, 256, math.floor(World:GetSpawnZ() / 16) - LimitWorldWidth) cRoot:Get():ForEachWorld(
LimitWorldsCuboid[World:GetName()]:Sort() function( World )
end LimitWorldsCuboid[World:GetName()] = cCuboid()
) LimitWorldsCuboid[World:GetName()].p1 = Vector3i( math.floor(World:GetSpawnX() / 16) + LimitWorldWidth, 0, math.floor(World:GetSpawnZ() / 16) + LimitWorldWidth)
-- Load whitelist, and add default values and stuff LimitWorldsCuboid[World:GetName()].p2 = Vector3i( math.floor(World:GetSpawnX() / 16) - LimitWorldWidth, 256, math.floor(World:GetSpawnZ() / 16) - LimitWorldWidth)
WhiteListIni = cIniFile( Plugin:GetLocalDirectory() .. "/whitelist.ini" ) LimitWorldsCuboid[World:GetName()]:Sort()
if ( WhiteListIni:ReadFile() == true ) then end
if( WhiteListIni:GetValueB("WhiteListSettings", "WhiteListOn", false) == true ) then )
if( WhiteListIni:GetNumValues("WhiteList") > 0 ) then end
LOGINFO("Core: loaded " .. WhiteListIni:GetNumValues('WhiteList') .. " whitelisted players.") --LOAD WHITELIST
else WhiteListIni = cIniFile( Plugin:GetLocalDirectory() .. "/whitelist.ini" )
LOGWARN("WARNING: WhiteList is on, but there are no people in the whitelist!") if ( WhiteListIni:ReadFile() == true ) then
end if( WhiteListIni:GetValueB("WhiteListSettings", "WhiteListOn", false) == true ) then
end if( WhiteListIni:GetNumValues("WhiteList") > 0 ) then
else LOGINFO("Core: loaded " .. WhiteListIni:GetNumValues('WhiteList') .. " whitelisted players.")
WhiteListIni:SetValueB("WhiteListSettings", "WhiteListOn", false ) else
WhiteListIni:SetValue("WhiteList", "", "") -- So it adds an empty header LOGWARN("WARNING: WhiteList is on, but there are no people in the whitelist!")
WhiteListIni:DeleteValue("WhiteList", "") -- And remove the value end
WhiteListIni:KeyComment("WhiteList", "PlayerName=1") end
if( WhiteListIni:WriteFile() == false ) then else
LOGWARN("WARNING: Could not write to whitelist.ini") WhiteListIni:SetValueB("WhiteListSettings", "WhiteListOn", false )
end WhiteListIni:SetValue("WhiteList", "", "") -- So it adds an empty header
end WhiteListIni:DeleteValue("WhiteList", "") -- And remove the value
WhiteListIni:KeyComment("WhiteList", "PlayerName=1")
-- Load banned players, and add default values and stuff if( WhiteListIni:WriteFile() == false ) then
BannedPlayersIni = cIniFile( Plugin:GetLocalDirectory() .. "/banned.ini" ) LOGWARN("WARNING: Could not write to whitelist.ini")
if ( BannedPlayersIni:ReadFile() == true ) then end
if( BannedPlayersIni:GetNumValues("Banned") > 0 ) then end
LOGINFO("Core: loaded " .. BannedPlayersIni:GetNumValues("Banned") .. " banned players.")
end --LOAD BANNED (BAD LUCK, BRO)
else BannedPlayersIni = cIniFile( Plugin:GetLocalDirectory() .. "/banned.ini" )
BannedPlayersIni:SetValue("Banned", "", "") -- So it adds an empty header if ( BannedPlayersIni:ReadFile() == true ) then
BannedPlayersIni:DeleteValue("Banned", "") -- And remove the value if( BannedPlayersIni:GetNumValues("Banned") > 0 ) then
BannedPlayersIni:KeyComment("Banned", "PlayerName=1") LOGINFO("Core: loaded " .. BannedPlayersIni:GetNumValues("Banned") .. " banned players.")
if( BannedPlayersIni:WriteFile() == false ) then end
LOGWARN("WARNING: Could not write to banned.ini") else
end BannedPlayersIni:SetValue("Banned", "", "") -- So it adds an empty header
end BannedPlayersIni:DeleteValue("Banned", "") -- And remove the value
BannedPlayersIni:KeyComment("Banned", "PlayerName=1")
Plugin:AddWebTab("Manage Server", HandleRequest_ManageServer); if( BannedPlayersIni:WriteFile() == false ) then
Plugin:AddWebTab("Server Settings", HandleRequest_ServerSettings); LOGWARN("WARNING: Could not write to banned.ini")
Plugin:AddWebTab("Chat", HandleRequest_Chat); end
Plugin:AddWebTab("Playerlist", HandleRequest_PlayerList); end
Plugin:AddWebTab("Whitelist", HandleRequest_WhiteList);
Plugin:AddWebTab("Permissions", HandleRequest_Permissions); --ADD WEB INTERFACE TABULATES (CURRENTLY DEPRECATED DUE TO LIST FORMAT BREAKING CSS)
Plugin:AddWebTab("Manage Plugins", HandleRequest_ManagePlugins); Plugin:AddWebTab("Manage Server", HandleRequest_ManageServer);
Plugin:AddWebTab("Server Settings", HandleRequest_ServerSettings);
LoadMotd() Plugin:AddWebTab("Chat", HandleRequest_Chat);
LOG( "Initialized " .. Plugin:GetName() .. " v." .. Plugin:GetVersion() ) Plugin:AddWebTab("Playerlist", HandleRequest_PlayerList);
return true Plugin:AddWebTab("Whitelist", HandleRequest_WhiteList);
end 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)
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

@ -1,97 +1,97 @@
function HandleMOTDCommand( Split, Player ) function HandleMOTDCommand( Split, Player )
ShowMOTDTo( Player ) ShowMOTDTo( Player )
return true return true
end end
function LoadMotd() function LoadMotd()
local File = io.open("motd.txt", "r") local File = io.open("motd.txt", "r")
-- Check if the file 'motd.txt' exists, else create it. -- Check if the file 'motd.txt' exists, else create it.
if not File then if not File then
CreateFile = io.open("motd.txt", "w") 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:write("@6Welcome to the MCServer test server!\n@6http://www.mc-server.org/\n@6Type /help for all commands")
CreateFile:close() CreateFile:close()
else else
File:close() File:close()
end end
for line in io.lines("motd.txt") do for line in io.lines("motd.txt") do
local TempMessage = line local TempMessage = line
-- Do a for loop that goes to each char in the line. -- Do a for loop that goes to each char in the line.
for I=1, string.len(TempMessage) do for I=1, string.len(TempMessage) do
-- If the char is a '@' then check if the next char represents a color. -- If the char is a '@' then check if the next char represents a color.
if string.sub(TempMessage, I, I) == "@" then if string.sub(TempMessage, I, I) == "@" then
local Char = string.sub(TempMessage, I + 1, I + 1) local Char = string.sub(TempMessage, I + 1, I + 1)
local Color = ReturnColorFromChar(TempMessage, Char) local Color = ReturnColorFromChar(TempMessage, Char)
-- If the next char represented a color then put the color in the string. -- If the next char represented a color then put the color in the string.
if (Color ~= nil) then if (Color ~= nil) then
TempMessage = string.gsub(TempMessage, "@" .. Char, Color) TempMessage = string.gsub(TempMessage, "@" .. Char, Color)
end end
end end
end end
-- Add the message to the list of messages. -- Add the message to the list of messages.
Messages[#Messages + 1] = TempMessage Messages[#Messages + 1] = TempMessage
end end
end end
function ShowMOTDTo( Player ) function ShowMOTDTo( Player )
for I=1, #Messages do for I=1, #Messages do
Player:SendMessage(Messages[I]) Player:SendMessage(Messages[I])
end end
end end
function ReturnColorFromChar( Split, char ) function ReturnColorFromChar( Split, char )
-- Check if the char represents a color. Else return nil. -- Check if the char represents a color. Else return nil.
if char == "0" then if char == "0" then
return cChatColor.Black return cChatColor.Black
elseif char == "1" then elseif char == "1" then
return cChatColor.Navy return cChatColor.Navy
elseif char == "2" then elseif char == "2" then
return cChatColor.Green return cChatColor.Green
elseif char == "3" then elseif char == "3" then
return cChatColor.Blue return cChatColor.Blue
elseif char == "4" then elseif char == "4" then
return cChatColor.Red return cChatColor.Red
elseif char == "5" then elseif char == "5" then
return cChatColor.Purple return cChatColor.Purple
elseif char == "6" then elseif char == "6" then
return cChatColor.Gold return cChatColor.Gold
elseif char == "7" then elseif char == "7" then
return cChatColor.LightGray return cChatColor.LightGray
elseif char == "8" then elseif char == "8" then
return cChatColor.Gray return cChatColor.Gray
elseif char == "9" then elseif char == "9" then
return cChatColor.DarkPurple return cChatColor.DarkPurple
elseif char == "a" then elseif char == "a" then
return cChatColor.LightGreen return cChatColor.LightGreen
elseif char == "b" then elseif char == "b" then
return cChatColor.LightBlue return cChatColor.LightBlue
elseif char == "c" then elseif char == "c" then
return cChatColor.Rose return cChatColor.Rose
elseif char == "d" then elseif char == "d" then
return cChatColor.LightPurple return cChatColor.LightPurple
elseif char == "e" then elseif char == "e" then
return cChatColor.Yellow return cChatColor.Yellow
elseif char == "f" then elseif char == "f" then
return cChatColor.White return cChatColor.White
elseif char == "k" then elseif char == "k" then
return cChatColor.Random return cChatColor.Random
elseif char == "l" then elseif char == "l" then
return cChatColor.Bold return cChatColor.Bold
elseif char == "m" then elseif char == "m" then
return cChatColor.Strikethrough return cChatColor.Strikethrough
elseif char == "n" then elseif char == "n" then
return cChatColor.Underlined return cChatColor.Underlined
elseif char == "o" then elseif char == "o" then
return cChatColor.Italic return cChatColor.Italic
elseif char == "r" then elseif char == "r" then
return cChatColor.Plain return cChatColor.Plain
end end
end end

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

@ -1,20 +1,19 @@
function OnLogin(Client, ProtocolVersion, Username) function OnLogin(Client, ProtocolVersion, Username)
if( Username ~= "" ) then if( Username ~= "" ) then
if( BannedPlayersIni:GetValueB("Banned", Username, false) == true ) then if( BannedPlayersIni:GetValueB("Banned", Username, false) == true ) then
local Server = cRoot:Get():GetServer() local Server = cRoot:Get():GetServer()
Server:SendMessage( Username .. " tried to join, but is banned!" ) Server:SendMessage( Username .. " tried to join, but is banned!" )
LOGINFO( 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 return true -- Player is banned, return true to deny access
end end
if( WhiteListIni:GetValueB("WhiteListSettings", "WhiteListOn", false ) == true ) then if( WhiteListIni:GetValueB("WhiteListSettings", "WhiteListOn", false ) == true ) then
if( WhiteListIni:GetValueB("WhiteList", Username, false ) == false ) then -- not on whitelist if( WhiteListIni:GetValueB("WhiteList", Username, false ) == false ) then -- not on whitelist
local Server = cRoot:Get():GetServer() local Server = cRoot:Get():GetServer()
Server:SendMessage( Username .. " tried to join, but is not on the whitelist." ) Server:SendMessage( Username .. " tried to join, but is not on the whitelist." )
LOGINFO( 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 return true -- Deny access to the server
end end
end end
end end
return false
return false
end 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,5 +1,5 @@
function OnPlayerJoined(Player) function OnPlayerJoined(Player)
ShowMOTDTo( Player ) ShowMOTDTo( Player )
AddMessage( Player:GetName() .. " has joined the game", " " ) AddMessage( Player:GetName() .. " has joined the game", " " )
return false return false
end end

View File

@ -1,14 +1,14 @@
function HandlePlayerListCommand( Split, Player ) function HandlePlayerListCommand( Split, Player )
local PlayerTable = {} local PlayerTable = {}
local AppendToTable = function( Player ) local AppendToTable = function( Player )
table.insert(PlayerTable, Player:GetName() ) table.insert(PlayerTable, Player:GetName() )
end end
Player:GetWorld():ForEachPlayer( AppendToTable ) Player:GetWorld():ForEachPlayer( AppendToTable )
local Message = cChatColor.Green .. "Connected players: (".. cChatColor.White.. #PlayerTable .. cChatColor.Green .. ")" local Message = cChatColor.Green .. "Connected players: (".. cChatColor.White.. #PlayerTable .. cChatColor.Green .. ")"
Player:SendMessage( Message ) Player:SendMessage( Message )
Player:SendMessage( table.concat(PlayerTable, " ") ) Player:SendMessage( table.concat(PlayerTable, " ") )
return true return true
end end

View File

@ -1,15 +1,15 @@
function HandlePluginListCommand( Split, Player ) function HandlePluginsCommand( Split, Player )
local PluginManager = cRoot:Get():GetPluginManager() local PluginManager = cRoot:Get():GetPluginManager()
local PluginList = PluginManager:GetAllPlugins() local PluginList = PluginManager:GetAllPlugins()
local PluginTable = {} local PluginTable = {}
for k, Plugin in pairs( PluginList ) do for k, Plugin in pairs( PluginList ) do
if ( Plugin ) then if ( Plugin ) then
table.insert(PluginTable, Plugin:GetName() ) table.insert(PluginTable, Plugin:GetName() )
end end
end end
Player:SendMessage( cChatColor.Green .. "Loaded plugins: (" .. #PluginTable .. ")" ) Player:SendMessage( cChatColor.Green .. "Loaded plugins: (" .. #PluginTable .. ")" )
Player:SendMessage( cChatColor.Gold .. table.concat(PluginTable, cChatColor.Gold.." ") ) Player:SendMessage( cChatColor.Gold .. table.concat(PluginTable, cChatColor.Gold.." ") )
return true return true
end end

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

@ -1,33 +1,48 @@
function HandleRankCommand( Split, Player ) function HandleRankCommand( Split, Player )
if Split[2] == nil or Split[3] == nil then if Split[2] == nil or Split[3] == nil then
Player:SendMessage(cChatColor.Rose .. "Usage: /rank [Player] [Group]") Player:SendMessage(cChatColor.Rose .. "Usage: /rank [Player] [Group]")
return true return true
end end
local GroupsIni = cIniFile("groups.ini") local GroupsIni = cIniFile("groups.ini")
if( GroupsIni:ReadFile() == false ) then if( GroupsIni:ReadFile() == false ) then
LOG("Could not read groups.ini!") LOG("Could not read groups.ini!")
end end
if GroupsIni:FindKey(Split[3]) == -1 then if GroupsIni:FindKey(Split[3]) == -1 then
Player:SendMessage(cChatColor.Rose .. "Group does not exist") Player:SendMessage(cChatColor.Rose .. "Group does not exist")
return true return true
end end
local UsersIni = cIniFile("users.ini") local UsersIni = cIniFile("users.ini")
if( UsersIni:ReadFile() == false ) then if( UsersIni:ReadFile() == false ) then
LOG("Could not read users.ini!") LOG("Could not read users.ini!")
end end
UsersIni:DeleteKey(Split[2]) UsersIni:DeleteKey(Split[2])
UsersIni:GetValueSet(Split[2], "Groups", Split[3]) UsersIni:GetValueSet(Split[2], "Groups", Split[3])
UsersIni:WriteFile() UsersIni:WriteFile()
local loopPlayers = function( Player ) local loopPlayers = function( Player )
if Player:GetName() == Split[2] then if Player:GetName() == Split[2] then
Player:SendMessage( cChatColor.Green .. "You were moved to group " .. Split[3] ) Player:SendMessage( cChatColor.Green .. "You were moved to group " .. Split[3] )
Player:LoadPermissionsFromDisk() Player:LoadPermissionsFromDisk()
end end
end end
local loopWorlds = function ( World ) local loopWorlds = function ( World )
World:ForEachPlayer( loopPlayers ) World:ForEachPlayer( loopPlayers )
end end
cRoot:Get():ForEachWorld( loopWorlds ) cRoot:Get():ForEachWorld( loopWorlds )
Player:SendMessage(cChatColor.Green .. "Player " .. Split[2] .. " Was moved to " .. Split[3]) Player:SendMessage(cChatColor.Green .. "Player " .. Split[2] .. " Was moved to " .. Split[3])
return true 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 end

View File

@ -1,18 +1,18 @@
function HandleRegenerateChunkCommand(Split, Player) function HandleRegenCommand(Split, Player)
if ((#Split == 2) or (#Split > 3)) then if ((#Split == 2) or (#Split > 3)) then
Player:SendMessage( cChatColor.Green .. "Usage: '/regeneratechunk' or '/regeneratechunk [X] [Z]'"); Player:SendMessage( cChatColor.Green .. "Usage: '/regeneratechunk' or '/regeneratechunk [X] [Z]'");
return true; return true;
end end
local X = Player:GetChunkX(); local X = Player:GetChunkX();
local Z = Player:GetChunkZ(); local Z = Player:GetChunkZ();
if (#Split == 3) then if (#Split == 3) then
X = Split[2]; X = Split[2];
Z = Split[3]; Z = Split[3];
end end
Player:SendMessage(cChatColor.Green .. "Regenerating chunk ["..X..", "..Z.."]"); Player:SendMessage(cChatColor.Green .. "Regenerating chunk ["..X..", "..Z.."]");
Player:GetWorld():RegenerateChunk(X, Z); Player:GetWorld():RegenerateChunk(X, Z);
return true; return true;
end end

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,7 +1,7 @@
function HandleSpawnCommand(Split, Player) function HandleSpawnCommand(Split, Player)
World = Player:GetWorld() World = Player:GetWorld()
SetBackCoordinates(Player) SetBackCoordinates(Player)
Player:TeleportToCoords(World:GetSpawnX(), World:GetSpawnY(), World:GetSpawnZ()) Player:TeleportToCoords(World:GetSpawnX(), World:GetSpawnY(), World:GetSpawnZ())
LOGINFO(Player:GetName() .. " returned to spawn.") LOGINFO(Player:GetName() .. " returned to spawn.")
return true return true
end 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

@ -1,46 +1,80 @@
function HandleTPCommand(a_Split, a_Player) function HandleTPCommand(a_Split, a_Player)
if ((#a_Split == 2) or (#a_Split == 3)) then 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": -- 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")); TeleportToPlayer(a_Player, a_Split[2], (a_Split[3] ~= "-h"));
return true; return true;
elseif (#a_Split == 4) then elseif (#a_Split == 4) then
-- Teleport to XYZ coords specified in a_Split[2, 3, 4]: -- Teleport to XYZ coords specified in a_Split[2, 3, 4]:
SetBackCoordinates(a_Player); SetBackCoordinates(a_Player);
a_Player:TeleportToCoords(a_Split[2], a_Split[3], a_Split[4]); 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] .. "}"); a_Player:SendMessage(cChatColor.Green .. "You teleported to {" .. a_Split[2] .. ", " .. a_Split[3] .. ", " .. a_Split[4] .. "}");
return true; return true;
else 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 return true
end end
end end
function HandleTPACommand( Split, Player )
if Split[2] == nil then
Player:SendMessage( cChatColor.Green .. "Usage: /tpa [Player]" )
return true
-- Teleports a_SrcPlayer to a player named a_DstPlayerName; if a_TellDst is true, will send a notice to the destination player end
function TeleportToPlayer(a_SrcPlayer, a_DstPlayerName, a_TellDst) local loopPlayer = function( OtherPlayer )
local teleport = function(OtherPlayer) if OtherPlayer:GetName() == Split[2] then
if (OtherPlayer == a_SrcPlayer) then OtherPlayer:SendMessage( cChatColor.Green .. Player:GetName() .. " send a teleport request" )
-- Asked to teleport to self? Player:SendMessage( cChatColor.Green .. "You send a teleport request to " .. OtherPlayer:GetName() )
a_SrcPlayer:SendMessage(cChatColor.Green .. "Already there :)"); Destination[OtherPlayer:GetName()] = Player:GetName()
else end
SetBackCoordinates(a_SrcPlayer); end
a_SrcPlayer:TeleportToEntity(OtherPlayer); local loopWorlds = function( World )
a_SrcPlayer:SendMessage(cChatColor.Green .. "You teleported to " .. OtherPlayer:GetName() .. "!"); World:ForEachPlayer( loopPlayer )
if (a_TellDst) then end
OtherPlayer:SendMessage(cChatColor.Green .. Player:GetName().." teleported to you!"); cRoot:Get():ForEachWorld( loopWorlds )
end return true
end end
end
function HandleTPAcceptCommand( Split, Player )
local World = Player:GetWorld(); if Destination[Player:GetName()] == nil then
if (not(World:DoWithPlayer(s_DstPlayerName, teleport))) then Player:SendMessage( cChatColor.Green .. "Nobody has send you a teleport request" )
a_SrcPlayer:SendMessage(cChatColor.Green .. "Can't find player " .. a_DstPlayerName); return true
end end
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 .. "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

View File

@ -1,23 +1,23 @@
function HandleTimeCommand( Split, Player ) function HandleTimeCommand( Split, Player )
if Split[2] == nil then if Split[2] == nil then
Player:SendMessage( cChatColor.Green .. "Usage: /time [Day/Night/Set/Add]" ) Player:SendMessage( cChatColor.Green .. "Usage: /time [Day/Night/Set/Add]" )
return true return true
end end
local Server = cRoot:Get():GetServer() local Server = cRoot:Get():GetServer()
if( string.upper( Split[2] ) == "DAY") then if( string.upper( Split[2] ) == "DAY") then
Player:GetWorld():SetTimeOfDay( 0 ) Player:GetWorld():SetTimeOfDay( 0 )
Server:SendMessage( cChatColor.Green .. Player:GetName() .. " set the time to Day.") Server:SendMessage( cChatColor.Green .. Player:GetName() .. " set the time to Day.")
elseif( string.upper( Split[2] ) == "NIGHT") then elseif( string.upper( Split[2] ) == "NIGHT") then
Player:GetWorld():SetTimeOfDay( 12000 + 1000 ) Player:GetWorld():SetTimeOfDay( 12000 + 1000 )
Server:SendMessage( cChatColor.Green .. Player:GetName() .. " set the time to Night.") Server:SendMessage( cChatColor.Green .. Player:GetName() .. " set the time to Night.")
elseif( string.upper(Split[2]) == "SET" ) and ( tonumber(Split[3]) ~= nil) then elseif( string.upper(Split[2]) == "SET" ) and ( tonumber(Split[3]) ~= nil) then
Player:GetWorld():SetTimeOfDay( tonumber(Split[3]) ) Player:GetWorld():SetTimeOfDay( tonumber(Split[3]) )
Server:SendMessage( cChatColor.Green .. Player:GetName() .. " set the time to " .. 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 elseif( string.upper(Split[2]) == "ADD" ) and ( tonumber(Split[3]) ~= nil) then
Player:GetWorld():SetTimeOfDay( Player:GetWorld():GetTimeOfDay() + Split[3] ) Player:GetWorld():SetTimeOfDay( Player:GetWorld():GetTimeOfDay() + Split[3] )
Server:SendMessage( cChatColor.Green .. Player:GetName() .. " Added " .. Split[3] .. " to the time" ) Server:SendMessage( cChatColor.Green .. Player:GetName() .. " Added " .. Split[3] .. " to the time" )
else else
Player:SendMessage( cChatColor.Green .. "Usage: /time [Day/Night/Set/Add]" ) Player:SendMessage( cChatColor.Green .. "Usage: /time [Day/Night/Set/Add]" )
end end
return true return true
end end

View File

@ -1,11 +1,11 @@
function HandleTopCommand( Split, Player ) function HandleTopCommand( Split, Player )
local World = Player:GetWorld() local World = Player:GetWorld()
local PlayerPos = Player:GetPosition() local PlayerPos = Player:GetPosition()
local Height = World:GetHeight( math.floor(PlayerPos.x), math.floor(PlayerPos.z) ) local Height = World:GetHeight( math.floor(PlayerPos.x), math.floor(PlayerPos.z) )
SetBackCoordinates( Player ) SetBackCoordinates( Player )
Player:TeleportToCoords( PlayerPos.x, Height+1, PlayerPos.z ) Player:TeleportToCoords( PlayerPos.x, Height+1, PlayerPos.z )
Player:SendMessage("Teleported to the top block") Player:SendMessage("Teleported to the top block")
return true return true
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

@ -1,10 +1,10 @@
function HandleViewDistanceCommand( Split, Player ) function HandleViewDistanceCommand( Split, Player )
if( #Split ~= 2 ) then if( #Split ~= 2 ) then
Player:SendMessage( cChatColor.Green .. "Usage: /viewdistance [".. cClientHandle.MIN_VIEW_DISTANCE .."-".. cClientHandle.MAX_VIEW_DISTANCE .."]" ) Player:SendMessage( cChatColor.Green .. "Usage: /viewdistance [".. cClientHandle.MIN_VIEW_DISTANCE .."-".. cClientHandle.MAX_VIEW_DISTANCE .."]" )
return true return true
end end
Player:GetClientHandle():SetViewDistance( Split[2] ) Player:GetClientHandle():SetViewDistance( Split[2] )
Player:SendMessage(cChatColor.Green .. "Your viewdistance has been set to " .. Player:GetClientHandle():GetViewDistance() ) Player:SendMessage(cChatColor.Green .. "Your viewdistance has been set to " .. Player:GetClientHandle():GetViewDistance() )
return true return true
end end

View File

@ -1,10 +1,10 @@
function HandleToggleDownfallCommand( Split, Player ) function HandleToggleDownfallCommand( Split, Player )
World = Player:GetWorld() World = Player:GetWorld()
if World:GetWeather() == 0 then if World:GetWeather() == 0 then
World:SetWeather(1) World:SetWeather(1)
else else
World:SetWeather(0) World:SetWeather(0)
end end
Player:SendMessage( cChatColor.Green .. "Weather toggled") Player:SendMessage( cChatColor.Green .. "Weather toggled")
return true return true
end end

View File

@ -1,157 +1,157 @@
local CHAT_HISTORY = 50 local CHAT_HISTORY = 50
local LastMessageID = 0 local LastMessageID = 0
local JavaScript = [[ local JavaScript = [[
<script type="text/javascript"> <script type="text/javascript">
function createXHR() function createXHR()
{ {
var request = false; var request = false;
try { try {
request = new ActiveXObject('Msxml2.XMLHTTP'); request = new ActiveXObject('Msxml2.XMLHTTP');
} }
catch (err2) { catch (err2) {
try { try {
request = new ActiveXObject('Microsoft.XMLHTTP'); request = new ActiveXObject('Microsoft.XMLHTTP');
} }
catch (err3) { catch (err3) {
try { try {
request = new XMLHttpRequest(); request = new XMLHttpRequest();
} }
catch (err1) { catch (err1) {
request = false; request = false;
} }
} }
} }
return request; return request;
} }
function OpenPage( url, postParams, callback ) function OpenPage( url, postParams, callback )
{ {
var xhr = createXHR(); var xhr = createXHR();
xhr.onreadystatechange=function() xhr.onreadystatechange=function()
{ {
if (xhr.readyState == 4) if (xhr.readyState == 4)
{ {
callback( xhr ) callback( xhr )
} }
}; };
xhr.open( (postParams!=null)?"POST":"GET", url , true); xhr.open( (postParams!=null)?"POST":"GET", url , true);
if( postParams != null ) if( postParams != null )
{ {
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
} }
xhr.send(postParams); xhr.send(postParams);
} }
function LoadPageInto( url, postParams, storage ) function LoadPageInto( url, postParams, storage )
{ {
OpenPage( url, postParams, function( xhr ) OpenPage( url, postParams, function( xhr )
{ {
var ScrollBottom = storage.scrollTop + storage.offsetHeight; var ScrollBottom = storage.scrollTop + storage.offsetHeight;
var bAutoScroll = (ScrollBottom >= storage.scrollHeight); // Detect whether we scrolled to the bottom of the div var bAutoScroll = (ScrollBottom >= storage.scrollHeight); // Detect whether we scrolled to the bottom of the div
results = xhr.responseText.split("<<divider>>"); results = xhr.responseText.split("<<divider>>");
if( results[2] != LastMessageID ) return; // Check if this message was meant for us if( results[2] != LastMessageID ) return; // Check if this message was meant for us
LastMessageID = results[1]; LastMessageID = results[1];
if( results[0] != "" ) if( results[0] != "" )
{ {
storage.innerHTML += results[0]; storage.innerHTML += results[0];
if( bAutoScroll == true ) if( bAutoScroll == true )
{ {
storage.scrollTop = storage.scrollHeight; storage.scrollTop = storage.scrollHeight;
} }
} }
} ); } );
return false; return false;
} }
function SendChatMessage() function SendChatMessage()
{ {
var MessageContainer = document.getElementById('ChatMessage'); var MessageContainer = document.getElementById('ChatMessage');
if( MessageContainer.value == "" ) return; if( MessageContainer.value == "" ) return;
var postParams = "ChatMessage=" + MessageContainer.value; var postParams = "ChatMessage=" + MessageContainer.value;
OpenPage( "/~webadmin/Core/Chat/", postParams, function( xhr ) OpenPage( "/~webadmin/Core/Chat/", postParams, function( xhr )
{ {
RefreshChat(); RefreshChat();
} ); } );
MessageContainer.value = ""; MessageContainer.value = "";
} }
function RefreshChat() function RefreshChat()
{ {
var postParams = "JustChat=true&LastMessageID=" + LastMessageID; var postParams = "JustChat=true&LastMessageID=" + LastMessageID;
LoadPageInto("/~webadmin/Core/Chat/", postParams, document.getElementById('ChatDiv')); LoadPageInto("/~webadmin/Core/Chat/", postParams, document.getElementById('ChatDiv'));
} }
setInterval(RefreshChat, 1000); setInterval(RefreshChat, 1000);
window.onload = RefreshChat; window.onload = RefreshChat;
var LastMessageID = 0; var LastMessageID = 0;
</script> </script>
]] ]]
local ChatLogMessages = {} local ChatLogMessages = {}
function AddMessage( PlayerName, Message ) function AddMessage( PlayerName, Message )
LastMessageID = LastMessageID + 1 LastMessageID = LastMessageID + 1
table.insert( ChatLogMessages, { name = PlayerName, message = Message, id = LastMessageID } ) table.insert( ChatLogMessages, { name = PlayerName, message = Message, id = LastMessageID } )
while( #ChatLogMessages > CHAT_HISTORY ) do while( #ChatLogMessages > CHAT_HISTORY ) do
table.remove( ChatLogMessages, 1 ) table.remove( ChatLogMessages, 1 )
end end
end end
function OnChat( Player, Message ) function OnChat( Player, Message )
AddMessage( Player:GetName(), Message ) AddMessage( Player:GetName(), Message )
end end
function HandleRequest_Chat( Request ) function HandleRequest_Chat( Request )
if( Request.PostParams["JustChat"] ~= nil ) then if( Request.PostParams["JustChat"] ~= nil ) then
local LastIdx = 0 local LastIdx = 0
if( Request.PostParams["LastMessageID"] ~= nil ) then LastIdx = tonumber( Request.PostParams["LastMessageID"] ) end if( Request.PostParams["LastMessageID"] ~= nil ) then LastIdx = tonumber( Request.PostParams["LastMessageID"] ) end
local Content = "" local Content = ""
for key, value in pairs(ChatLogMessages) do for key, value in pairs(ChatLogMessages) do
if( value.id > LastIdx ) then if( value.id > LastIdx ) then
Content = Content .. "[" .. value.name .. "]: " .. value.message .. "<br>" Content = Content .. "[" .. value.name .. "]: " .. value.message .. "<br>"
end end
end end
Content = Content .. "<<divider>>" .. LastMessageID .. "<<divider>>" .. LastIdx Content = Content .. "<<divider>>" .. LastMessageID .. "<<divider>>" .. LastIdx
return Content return Content
end end
if( Request.PostParams["ChatMessage"] ~= nil ) then if( Request.PostParams["ChatMessage"] ~= nil ) then
if( Request.PostParams["ChatMessage"] == "/help" ) then if( Request.PostParams["ChatMessage"] == "/help" ) then
Commands = "Available commands" Commands = "Available commands"
AddMessage(Commands, "<br>" .. "/help, /reload" ) AddMessage(Commands, "<br>" .. "/help, /reload" )
return Commands return Commands
elseif( Request.PostParams["ChatMessage"] == "/reload" ) then elseif( Request.PostParams["ChatMessage"] == "/reload" ) then
Server = cRoot:Get():GetServer() Server = cRoot:Get():GetServer()
Server:SendMessage( cChatColor.Green .. "Reloading all plugins." ) Server:SendMessage( cChatColor.Green .. "Reloading all plugins." )
AddMessage("Reloading all plugins", "") AddMessage("Reloading all plugins", "")
cRoot:Get():GetPluginManager():ReloadPlugins() cRoot:Get():GetPluginManager():ReloadPlugins()
return "" return ""
else else
cmd = Request.PostParams["ChatMessage"] cmd = Request.PostParams["ChatMessage"]
if string.sub(cmd,1,string.len("/")) == "/" then if string.sub(cmd,1,string.len("/")) == "/" then
AddMessage('Unknown Command "' .. Request.PostParams["ChatMessage"] .. '"', "") AddMessage('Unknown Command "' .. Request.PostParams["ChatMessage"] .. '"', "")
return "" return ""
end end
end end
local Message = "[WebAdmin]: " .. Request.PostParams["ChatMessage"] local Message = "[WebAdmin]: " .. Request.PostParams["ChatMessage"]
cRoot:Get():GetServer():SendMessage( Message ) cRoot:Get():GetServer():SendMessage( Message )
AddMessage("WebAdmin", Request.PostParams["ChatMessage"] ) AddMessage("WebAdmin", Request.PostParams["ChatMessage"] )
return "" return ""
end end
local Content = JavaScript local Content = JavaScript
Content = Content .. [[ Content = Content .. [[
<div style="font-family: Courier; border: 1px solid #DDD; padding: 10px; width: 97%; height: 200px; overflow: scroll;" id="ChatDiv"></div> <div style="font-family: Courier; border: 1px solid #DDD; padding: 10px; width: 97%; height: 200px; overflow: scroll;" id="ChatDiv"></div>
<input type="text" id="ChatMessage" onKeyPress="if (event.keyCode == 13) { SendChatMessage(); }"><input type="submit" value="Submit" onClick="SendChatMessage();"> <input type="text" id="ChatMessage" onKeyPress="if (event.keyCode == 13) { SendChatMessage(); }"><input type="submit" value="Submit" onClick="SendChatMessage();">
]] ]]
return Content return Content
end end

View File

@ -1,157 +1,157 @@
local function Button_RemovePlugin( Name, Index ) local function Button_RemovePlugin( Name, Index )
return "<form method='POST'><input type='hidden' name='PluginName' value='"..Name.."'><input type='hidden' name='PluginIndex' value='"..Index.."'><input type='submit' name='RemovePlugin' value='Remove'></form>" return "<form method='POST'><input type='hidden' name='PluginName' value='"..Name.."'><input type='hidden' name='PluginIndex' value='"..Index.."'><input type='submit' name='RemovePlugin' value='Remove'></form>"
end end
local function Button_EnablePlugin( Name ) local function Button_EnablePlugin( Name )
return [[<form method="POST"><input type="hidden" name="PluginName", value="]].. Name ..[["><input type="submit" name="EnablePlugin" value="Enable"></form>]] return [[<form method="POST"><input type="hidden" name="PluginName", value="]].. Name ..[["><input type="submit" name="EnablePlugin" value="Enable"></form>]]
end end
local function Button_DisablePlugin( Name ) local function Button_DisablePlugin( Name )
return [[<form method="POST"><input type="hidden" name="PluginName", value="]].. Name ..[["><input type="submit" name="DisablePlugin" value="Disable"></form>]] return [[<form method="POST"><input type="hidden" name="PluginName", value="]].. Name ..[["><input type="submit" name="DisablePlugin" value="Disable"></form>]]
end end
local function FindPluginID( SettingsIni, PluginName ) local function FindPluginID( SettingsIni, PluginName )
local KeyIdx = SettingsIni:FindKey("Plugins") local KeyIdx = SettingsIni:FindKey("Plugins")
local NumValues = SettingsIni:GetNumValues( KeyIdx ) local NumValues = SettingsIni:GetNumValues( KeyIdx )
for i = 0, NumValues-1 do for i = 0, NumValues-1 do
LOGINFO( SettingsIni:GetValue(KeyIdx, i) ) LOGINFO( SettingsIni:GetValue(KeyIdx, i) )
if( SettingsIni:GetValue(KeyIdx, i) == PluginName ) then if( SettingsIni:GetValue(KeyIdx, i) == PluginName ) then
return i return i
end end
end end
return nil return nil
end end
local function RemovePluginFromIni( SettingsIni, PluginName ) local function RemovePluginFromIni( SettingsIni, PluginName )
local KeyIdx = SettingsIni:FindKey("Plugins") local KeyIdx = SettingsIni:FindKey("Plugins")
local PluginIdx = FindPluginID( SettingsIni, PluginName ) local PluginIdx = FindPluginID( SettingsIni, PluginName )
if( PluginIdx == nil ) then if( PluginIdx == nil ) then
LOGINFO("Got nil! NOOOO") LOGINFO("Got nil! NOOOO")
return false return false
end end
local Name = SettingsIni:GetValue( KeyIdx, PluginIdx ) local Name = SettingsIni:GetValue( KeyIdx, PluginIdx )
if( Name ~= PluginName ) then if( Name ~= PluginName ) then
LOGINFO("not the same name T_T '" .. Name .. "' '" .. PluginName .. "'") LOGINFO("not the same name T_T '" .. Name .. "' '" .. PluginName .. "'")
end end
if( (Name == PluginName) and (SettingsIni:DeleteValueByID( KeyIdx, PluginIdx ) == true) ) then if( (Name == PluginName) and (SettingsIni:DeleteValueByID( KeyIdx, PluginIdx ) == true) ) then
return SettingsIni:WriteFile() return SettingsIni:WriteFile()
end end
return false return false
end end
local function AddPluginToIni( SettingsIni, PluginName ) local function AddPluginToIni( SettingsIni, PluginName )
RemovePluginFromIni( SettingsIni, PluginName ) -- Make sure there are no duplicates RemovePluginFromIni( SettingsIni, PluginName ) -- Make sure there are no duplicates
if( SettingsIni:SetValue("Plugins", "Plugin", PluginName, true ) == true ) then if( SettingsIni:SetValue("Plugins", "Plugin", PluginName, true ) == true ) then
return SettingsIni:WriteFile() return SettingsIni:WriteFile()
end end
return false return false
end end
local function HandlePluginListChanges( Request, SettingsIni ) local function HandlePluginListChanges( Request, SettingsIni )
local Content = "" local Content = ""
if( Request.PostParams["EnablePlugin"] ~= nil if( Request.PostParams["EnablePlugin"] ~= nil
and Request.PostParams["PluginName"] ~= nil ) then and Request.PostParams["PluginName"] ~= nil ) then
local PluginName = Request.PostParams["PluginName"] local PluginName = Request.PostParams["PluginName"]
local PM = cRoot:Get():GetPluginManager() local PM = cRoot:Get():GetPluginManager()
if( PM:LoadPlugin( PluginName ) == false ) then if( PM:LoadPlugin( PluginName ) == false ) then
Content = "Could not enable '".. PluginName .."'!" Content = "Could not enable '".. PluginName .."'!"
end end
if( AddPluginToIni( SettingsIni, PluginName ) == true ) then if( AddPluginToIni( SettingsIni, PluginName ) == true ) then
Content = "Enabled plugin '".. PluginName .."'" Content = "Enabled plugin '".. PluginName .."'"
else else
Content = "Enabled plugin '".. PluginName .."' but could not add it to settings.ini" Content = "Enabled plugin '".. PluginName .."' but could not add it to settings.ini"
end end
elseif( Request.PostParams["DisablePlugin"] ~= nil elseif( Request.PostParams["DisablePlugin"] ~= nil
and Request.PostParams["PluginName"] ~= nil ) then and Request.PostParams["PluginName"] ~= nil ) then
local PluginName = Request.PostParams["PluginName"] local PluginName = Request.PostParams["PluginName"]
local PM = cRoot:Get():GetPluginManager() local PM = cRoot:Get():GetPluginManager()
PM:DisablePlugin( PluginName ) PM:DisablePlugin( PluginName )
if( RemovePluginFromIni( SettingsIni, PluginName ) == true ) then if( RemovePluginFromIni( SettingsIni, PluginName ) == true ) then
Content = "Disabled plugin '".. PluginName .."'" Content = "Disabled plugin '".. PluginName .."'"
else else
Content = "Disabled plugin '".. PluginName .."' but could not remove it from settings.ini" Content = "Disabled plugin '".. PluginName .."' but could not remove it from settings.ini"
end end
end end
if( #Content > 0 ) then if( #Content > 0 ) then
return "<p><font color='red'><strong>INFO: " .. Content .. "</strong></font></p>" return "<p><font color='red'><strong>INFO: " .. Content .. "</strong></font></p>"
else else
return "" return ""
end end
end end
function HandleRequest_ManagePlugins( Request ) function HandleRequest_ManagePlugins( Request )
local Content = "" local Content = ""
if( Request.PostParams["reload"] ~= nil ) then if( Request.PostParams["reload"] ~= nil ) then
Content = Content .. "<head><meta http-equiv=\"refresh\" content=\"2;\"></head>" Content = Content .. "<head><meta http-equiv=\"refresh\" content=\"2;\"></head>"
Content = Content .. "<p>Reloading plugins... This can take a while depending on the plugins you're using.</p>" Content = Content .. "<p>Reloading plugins... This can take a while depending on the plugins you're using.</p>"
cRoot:Get():GetPluginManager():ReloadPlugins() cRoot:Get():GetPluginManager():ReloadPlugins()
return Content return Content
end end
local SettingsIni = cIniFile("settings.ini") local SettingsIni = cIniFile("settings.ini")
if( SettingsIni:ReadFile() == true ) then if( SettingsIni:ReadFile() == true ) then
Content = Content .. HandlePluginListChanges( Request, SettingsIni ) Content = Content .. HandlePluginListChanges( Request, SettingsIni )
else else
Content = Content .. "Cannot find/modify settings.ini" Content = Content .. "Cannot find/modify settings.ini"
end end
local PluginManager = cRoot:Get():GetPluginManager() local PluginManager = cRoot:Get():GetPluginManager()
PluginManager:FindPlugins() -- Refreshes the plugin list PluginManager:FindPlugins() -- Refreshes the plugin list
local PluginList = PluginManager:GetAllPlugins() local PluginList = PluginManager:GetAllPlugins()
Content = Content .. "<h4>Currently installed plugins</h4>" Content = Content .. "<h4>Currently installed plugins</h4>"
Content = Content .. "<table>" Content = Content .. "<table>"
ActivePluginsName = {} ActivePluginsName = {}
ActivePluginVersion = {} ActivePluginVersion = {}
InactivePlugins = {} InactivePlugins = {}
for k, Plugin in pairs(PluginList) do for k, Plugin in pairs(PluginList) do
if( Plugin ) then if( Plugin ) then
table.insert( ActivePluginsName, k ) table.insert( ActivePluginsName, k )
table.insert( ActivePluginVersion, Plugin:GetVersion() ) table.insert( ActivePluginVersion, Plugin:GetVersion() )
else else
table.insert( InactivePlugins, k ) table.insert( InactivePlugins, k )
end end
end end
table.sort( ActivePluginsName ) table.sort( ActivePluginsName )
table.sort( InactivePlugins ) table.sort( InactivePlugins )
for i = 1, #ActivePluginsName do for i = 1, #ActivePluginsName do
Content = Content .. "<tr><td>".. ActivePluginsName[i] .."</td>" Content = Content .. "<tr><td>".. ActivePluginsName[i] .."</td>"
Content = Content .. "<td>" .. ActivePluginsName[i] .. " V. " .. ActivePluginVersion[i] .. "</td><td>" .. Button_DisablePlugin(ActivePluginsName[i]) .. "</td>" Content = Content .. "<td>" .. ActivePluginsName[i] .. " V. " .. ActivePluginVersion[i] .. "</td><td>" .. Button_DisablePlugin(ActivePluginsName[i]) .. "</td>"
Content = Content .. "</tr>" Content = Content .. "</tr>"
end end
for i = 1, #InactivePlugins do for i = 1, #InactivePlugins do
Content = Content .. "<tr><td>".. InactivePlugins[i] .."</td>" Content = Content .. "<tr><td>".. InactivePlugins[i] .."</td>"
Content = Content .. "<td></td><td>" .. Button_EnablePlugin(InactivePlugins[i]) .. "</td>" Content = Content .. "<td></td><td>" .. Button_EnablePlugin(InactivePlugins[i]) .. "</td>"
Content = Content .. "</tr>" Content = Content .. "</tr>"
end end
Content = Content .. "</table>" Content = Content .. "</table>"
Content = Content .. "<h4>Reload</h4>" Content = Content .. "<h4>Reload</h4>"
Content = Content .. "<form method='POST'>" Content = Content .. "<form method='POST'>"
Content = Content .. "<p>Click the reload button to reload all plugins according to <strong>settings.ini</strong>!" Content = Content .. "<p>Click the reload button to reload all plugins according to <strong>settings.ini</strong>!"
Content = Content .. "<input type='submit' name='reload' value='Reload!'></p>" Content = Content .. "<input type='submit' name='reload' value='Reload!'></p>"
Content = Content .. "</form>" Content = Content .. "</form>"
return Content return Content
end end

View File

@ -1,134 +1,134 @@
local function HTML_Option( value, text, selected ) local function HTML_Option( value, text, selected )
if( selected == true ) then if( selected == true ) then
return [[<option value="]] .. value .. [[" selected>]] .. text .. [[</option>]] return [[<option value="]] .. value .. [[" selected>]] .. text .. [[</option>]]
else else
return [[<option value="]] .. value .. [[">]] .. text .. [[</option>"]] return [[<option value="]] .. value .. [[">]] .. text .. [[</option>"]]
end end
end end
local function ShowUsersTable() local function ShowUsersTable()
local Content = "<h4>Users</h4>" local Content = "<h4>Users</h4>"
local NumUsers = UsersIni:GetNumKeys() local NumUsers = UsersIni:GetNumKeys()
Content = Content .. "<table>" Content = Content .. "<table>"
if( NumUsers > 0 ) then if( NumUsers > 0 ) then
Content = Content .. "<tr><th></th><th>User</th><th>Groups</th></tr>" Content = Content .. "<tr><th></th><th>User</th><th>Groups</th></tr>"
for i=0, NumUsers-1 do for i=0, NumUsers-1 do
local UserName = UsersIni:GetKeyName( i ) local UserName = UsersIni:GetKeyName( i )
Content = Content .. "<tr>" Content = Content .. "<tr>"
Content = Content .. "<td style='width: 10px;'>" .. i .. ".</td>" Content = Content .. "<td style='width: 10px;'>" .. i .. ".</td>"
Content = Content .. "<td>" .. UserName .. "</td>" Content = Content .. "<td>" .. UserName .. "</td>"
Content = Content .. "<td>" Content = Content .. "<td>"
Content = Content .. UsersIni:GetValue( UserName, "Groups", "-" ) Content = Content .. UsersIni:GetValue( UserName, "Groups", "-" )
Content = Content .. "</td>" Content = Content .. "</td>"
Content = Content .. "</tr>" Content = Content .. "</tr>"
end end
else else
Content = Content .. "<tr><td>None</td></tr>" Content = Content .. "<tr><td>None</td></tr>"
end end
Content = Content .. "</table>" Content = Content .. "</table>"
return Content return Content
end end
local function ShowGroupsTable() local function ShowGroupsTable()
local Content = "<h4>Groups</h4>" local Content = "<h4>Groups</h4>"
local NumGroups = GroupsIni:GetNumKeys() local NumGroups = GroupsIni:GetNumKeys()
Content = Content .. "<table>" Content = Content .. "<table>"
if( NumGroups > 0 ) then if( NumGroups > 0 ) then
Content = Content .. "<tr><th></th><th>Name</th><th>Permissions</th><th>Color</th></tr>" Content = Content .. "<tr><th></th><th>Name</th><th>Permissions</th><th>Color</th></tr>"
for i=0, NumGroups-1 do for i=0, NumGroups-1 do
local GroupName = GroupsIni:GetKeyName( i ) local GroupName = GroupsIni:GetKeyName( i )
Content = Content .. "<tr>" Content = Content .. "<tr>"
Content = Content .. "<td style='width: 10px;'>" .. i .. ".</td>" Content = Content .. "<td style='width: 10px;'>" .. i .. ".</td>"
Content = Content .. "<td>" .. GroupName .. "</td>" Content = Content .. "<td>" .. GroupName .. "</td>"
Content = Content .. "<td>" Content = Content .. "<td>"
Content = Content .. GroupsIni:GetValue( GroupName, "Permissions", "-" ) Content = Content .. GroupsIni:GetValue( GroupName, "Permissions", "-" )
Content = Content .. "</td>" Content = Content .. "</td>"
Content = Content .. "<td>" Content = Content .. "<td>"
Content = Content .. GroupsIni:GetValue( GroupName, "Color", "-" ) Content = Content .. GroupsIni:GetValue( GroupName, "Color", "-" )
Content = Content .. "</td>" Content = Content .. "</td>"
Content = Content .. "</tr>" Content = Content .. "</tr>"
end end
else else
Content = Content .. "<tr><td>None</td></tr>" Content = Content .. "<tr><td>None</td></tr>"
end end
Content = Content .. "</table>" Content = Content .. "</table>"
return Content return Content
end end
local function HTML_Select_Group( name, defaultValue ) local function HTML_Select_Group( name, defaultValue )
Groups = "" Groups = ""
for I=0, GroupsIni:GetNumKeys() - 1 do for I=0, GroupsIni:GetNumKeys() - 1 do
Groups = Groups .. Groups = Groups ..
HTML_Option(GroupsIni:KeyName(I), GroupsIni:KeyName(I), defaultValue == GroupsIni:KeyName(I) ) HTML_Option(GroupsIni:KeyName(I), GroupsIni:KeyName(I), defaultValue == GroupsIni:KeyName(I) )
end end
return [[<select name="]] .. name .. [[">]] .. Groups .. [[</select>]] return [[<select name="]] .. name .. [[">]] .. Groups .. [[</select>]]
end end
local function AddPlayers( Request ) local function AddPlayers( Request )
local Content = "<h4>Add or change Players</h4>" local Content = "<h4>Add or change Players</h4>"
if( Request.PostParams["AddPlayerToGroup"] ~= nil ) then if( Request.PostParams["AddPlayerToGroup"] ~= nil ) then
if Request.PostParams["AddPlayer"] ~= "" then if Request.PostParams["AddPlayer"] ~= "" then
if Request.PostParams["AddGroups"] ~= "" then if Request.PostParams["AddGroups"] ~= "" then
if GroupsIni:FindKey(Request.PostParams["AddGroup"]) == -1 then if GroupsIni:FindKey(Request.PostParams["AddGroup"]) == -1 then
return "Group does not exist" return "Group does not exist"
end end
UsersIni:DeleteKey(Request.PostParams["AddPlayer"]) UsersIni:DeleteKey(Request.PostParams["AddPlayer"])
UsersIni:GetValueSet(Request.PostParams["AddPlayer"], "Groups", Request.PostParams["AddGroup"]) UsersIni:GetValueSet(Request.PostParams["AddPlayer"], "Groups", Request.PostParams["AddGroup"])
UsersIni:WriteFile() UsersIni:WriteFile()
local loopPlayers = function( Player ) local loopPlayers = function( Player )
if Player:GetName() == Request.PostParams["AddPlayer"] then if Player:GetName() == Request.PostParams["AddPlayer"] then
Player:SendMessage( cChatColor.Green .. "You were moved to group " .. Request.PostParams["AddGroup"] ) Player:SendMessage( cChatColor.Green .. "You were moved to group " .. Request.PostParams["AddGroup"] )
Player:LoadPermissionsFromDisk() Player:LoadPermissionsFromDisk()
end end
end end
local loopWorlds = function ( World ) local loopWorlds = function ( World )
World:ForEachPlayer( loopPlayers ) World:ForEachPlayer( loopPlayers )
end end
cRoot:Get():ForEachWorld( loopWorlds ) cRoot:Get():ForEachWorld( loopWorlds )
end end
end end
end end
Content = Content .. [[ Content = Content .. [[
<form method="POST"> <form method="POST">
<table> <table>
<tr><td style="width: 20%;">Player:</td> <tr><td style="width: 20%;">Player:</td>
<td><input type="text" name="AddPlayer" value=""></td></tr><br> <td><input type="text" name="AddPlayer" value=""></td></tr><br>
<tr><td style="width: 20%;">Group:</td> <tr><td style="width: 20%;">Group:</td>
<td>]] .. HTML_Select_Group("AddGroup", GroupsIni:KeyName(0) ) .. [[</td></tr> <td>]] .. HTML_Select_Group("AddGroup", GroupsIni:KeyName(0) ) .. [[</td></tr>
</table> </table>
<input type="submit" value="Add Player" name="AddPlayerToGroup">]] <input type="submit" value="Add Player" name="AddPlayerToGroup">]]
return Content return Content
end end
function HandleRequest_Permissions( Request ) function HandleRequest_Permissions( Request )
GroupsIni = cIniFile("groups.ini") GroupsIni = cIniFile("groups.ini")
if( GroupsIni:ReadFile() == false ) then if( GroupsIni:ReadFile() == false ) then
return "Could not read groups.ini!" return "Could not read groups.ini!"
end end
UsersIni = cIniFile("users.ini") UsersIni = cIniFile("users.ini")
if( UsersIni:ReadFile() == false ) then if( UsersIni:ReadFile() == false ) then
return "Could not read users.ini!" return "Could not read users.ini!"
end end
local Content = "" local Content = ""
Content = Content .. AddPlayers( Request ) Content = Content .. AddPlayers( Request )
Content = Content .. ShowGroupsTable() Content = Content .. ShowGroupsTable()
Content = Content .. ShowUsersTable() Content = Content .. ShowUsersTable()
return Content return Content
end end

View File

@ -1,38 +1,38 @@
function HandleRequest_PlayerList( Request ) function HandleRequest_PlayerList( Request )
local World = cRoot:Get():GetDefaultWorld() local World = cRoot:Get():GetDefaultWorld()
local Content = "" local Content = ""
if( Request.Params["playerlist-kick"] ~= nil ) then if( Request.Params["playerlist-kick"] ~= nil ) then
local KickPlayerName = Request.Params["playerlist-kick"] local KickPlayerName = Request.Params["playerlist-kick"]
local FoundPlayerCallback = function( Player ) local FoundPlayerCallback = function( Player )
if( Player:GetName() == KickPlayerName ) then if( Player:GetName() == KickPlayerName ) then
Player:GetClientHandle():Kick("You were kicked from the game!") Player:GetClientHandle():Kick("You were kicked from the game!")
Content = Content .. "<p>" .. KickPlayerName .. " has been kicked from the game!</p>" Content = Content .. "<p>" .. KickPlayerName .. " has been kicked from the game!</p>"
end end
end end
if( World:DoWithPlayer( KickPlayerName, FoundPlayerCallback ) == false ) then if( World:DoWithPlayer( KickPlayerName, FoundPlayerCallback ) == false ) then
Content = Content .. "<p>Could not find player " .. KickPlayerName .. " !</p>" Content = Content .. "<p>Could not find player " .. KickPlayerName .. " !</p>"
end end
end end
Content = Content .. "<p>Connected Players: <b>" .. World:GetNumPlayers() .. "</b></p>" Content = Content .. "<p>Connected Players: <b>" .. World:GetNumPlayers() .. "</b></p>"
Content = Content .. "<table>" Content = Content .. "<table>"
local PlayerNum = 0 local PlayerNum = 0
local AddPlayerToTable = function( Player ) local AddPlayerToTable = function( Player )
PlayerNum = PlayerNum + 1 PlayerNum = PlayerNum + 1
Content = Content .. "<tr>" Content = Content .. "<tr>"
Content = Content .. "<td style='width: 10px;'>" .. PlayerNum .. ".</td>" Content = Content .. "<td style='width: 10px;'>" .. PlayerNum .. ".</td>"
Content = Content .. "<td>" .. Player:GetName() .. "</td>" Content = Content .. "<td>" .. Player:GetName() .. "</td>"
Content = Content .. "<td><a href='?playerlist-kick=" .. Player:GetName() .. "'>Kick</a></td>" Content = Content .. "<td><a href='?playerlist-kick=" .. Player:GetName() .. "'>Kick</a></td>"
Content = Content .. "</tr>" Content = Content .. "</tr>"
end end
cRoot:Get():ForEachPlayer( AddPlayerToTable ) cRoot:Get():ForEachPlayer( AddPlayerToTable )
if( PlayerNum == 0 ) then if( PlayerNum == 0 ) then
Content = Content .. "<tr><td>None</td></tr>" Content = Content .. "<tr><td>None</td></tr>"
end end
Content = Content .. "</table>" Content = Content .. "</table>"
Content = Content .. "<br>" Content = Content .. "<br>"
return Content return Content
end end

File diff suppressed because it is too large Load Diff

View File

@ -1,79 +1,79 @@
local function HTMLDeleteButton( name ) local function HTMLDeleteButton( name )
return "<form method=\"POST\"><input type=\"hidden\" name=\"whitelist-delete\" value=\"".. name .."\"><input type=\"submit\" value=\"Remove from whitelist\"></form>" return "<form method=\"POST\"><input type=\"hidden\" name=\"whitelist-delete\" value=\"".. name .."\"><input type=\"submit\" value=\"Remove from whitelist\"></form>"
end end
function HandleRequest_WhiteList( Request ) function HandleRequest_WhiteList( Request )
local UpdateMessage = "" local UpdateMessage = ""
if( Request.PostParams["whitelist-add"] ~= nil ) then if( Request.PostParams["whitelist-add"] ~= nil ) then
local PlayerName = Request.PostParams["whitelist-add"] local PlayerName = Request.PostParams["whitelist-add"]
if( WhiteListIni:GetValueB("WhiteList", PlayerName, false) == true ) then if( WhiteListIni:GetValueB("WhiteList", PlayerName, false) == true ) then
UpdateMessage = "<b>".. PlayerName.."</b> is already on the whitelist" UpdateMessage = "<b>".. PlayerName.."</b> is already on the whitelist"
else else
WhiteListIni:SetValueB("WhiteList", PlayerName, true ) WhiteListIni:SetValueB("WhiteList", PlayerName, true )
UpdateMessage = "Added <b>" .. PlayerName .. "</b> to whitelist." UpdateMessage = "Added <b>" .. PlayerName .. "</b> to whitelist."
WhiteListIni:WriteFile() WhiteListIni:WriteFile()
end end
elseif( Request.PostParams["whitelist-delete"] ~= nil ) then elseif( Request.PostParams["whitelist-delete"] ~= nil ) then
local PlayerName = Request.PostParams["whitelist-delete"] local PlayerName = Request.PostParams["whitelist-delete"]
WhiteListIni:DeleteValue( "WhiteList", PlayerName ) WhiteListIni:DeleteValue( "WhiteList", PlayerName )
UpdateMessage = "Removed <b>" .. PlayerName .. "</b> from whitelist." UpdateMessage = "Removed <b>" .. PlayerName .. "</b> from whitelist."
WhiteListIni:WriteFile() WhiteListIni:WriteFile()
elseif( Request.PostParams["whitelist-reload"] ~= nil ) then elseif( Request.PostParams["whitelist-reload"] ~= nil ) then
WhiteListIni:Erase() -- Empty entire loaded ini first, otherwise weird shit goes down WhiteListIni:Erase() -- Empty entire loaded ini first, otherwise weird shit goes down
WhiteListIni:ReadFile() WhiteListIni:ReadFile()
UpdateMessage = "Loaded from disk" UpdateMessage = "Loaded from disk"
elseif( Request.Params["whitelist-setenable"] ~= nil ) then elseif( Request.Params["whitelist-setenable"] ~= nil ) then
local Enabled = Request.Params["whitelist-setenable"] local Enabled = Request.Params["whitelist-setenable"]
local CreateNewValue = false local CreateNewValue = false
if( WhiteListIni:FindValue( WhiteListIni:FindKey("WhiteListSettings"), "WhiteListOn" ) == cIniFile.noID ) then -- Find out whether the value is in the ini if( WhiteListIni:FindValue( WhiteListIni:FindKey("WhiteListSettings"), "WhiteListOn" ) == cIniFile.noID ) then -- Find out whether the value is in the ini
CreateNewValue = true CreateNewValue = true
end end
if( Enabled == "1" ) then if( Enabled == "1" ) then
WhiteListIni:SetValueB("WhiteListSettings", "WhiteListOn", true, CreateNewValue ) WhiteListIni:SetValueB("WhiteListSettings", "WhiteListOn", true, CreateNewValue )
else else
WhiteListIni:SetValueB("WhiteListSettings", "WhiteListOn", false, CreateNewValue ) WhiteListIni:SetValueB("WhiteListSettings", "WhiteListOn", false, CreateNewValue )
end end
WhiteListIni:WriteFile() WhiteListIni:WriteFile()
end end
local Content = "" local Content = ""
local WhiteListEnabled = WhiteListIni:GetValueB("WhiteListSettings", "WhiteListOn", false) local WhiteListEnabled = WhiteListIni:GetValueB("WhiteListSettings", "WhiteListOn", false)
if( WhiteListEnabled == false ) then if( WhiteListEnabled == false ) then
Content = Content .. "<p>Whitelist is currently disabled! Click <a href='?whitelist-setenable=1'>here</a> to enable.</p>" Content = Content .. "<p>Whitelist is currently disabled! Click <a href='?whitelist-setenable=1'>here</a> to enable.</p>"
end end
Content = Content .. "<h4>Whitelisted players</h4>" Content = Content .. "<h4>Whitelisted players</h4>"
Content = Content .. "<table>" Content = Content .. "<table>"
local KeyNum = WhiteListIni:FindKey("WhiteList") local KeyNum = WhiteListIni:FindKey("WhiteList")
local NumValues = WhiteListIni:GetNumValues(KeyNum) local NumValues = WhiteListIni:GetNumValues(KeyNum)
if( NumValues > 0 ) then if( NumValues > 0 ) then
for Num = 0, NumValues-1 do for Num = 0, NumValues-1 do
if( WhiteListIni:GetValue(KeyNum, Num, "0") == "1" ) then if( WhiteListIni:GetValue(KeyNum, Num, "0") == "1" ) then
local PlayerName = WhiteListIni:GetValueName(KeyNum, Num ) local PlayerName = WhiteListIni:GetValueName(KeyNum, Num )
Content = Content .. "<tr><td>" .. PlayerName .. "</td><td>" .. HTMLDeleteButton( PlayerName ) .. "</td></tr>" Content = Content .. "<tr><td>" .. PlayerName .. "</td><td>" .. HTMLDeleteButton( PlayerName ) .. "</td></tr>"
end end
end end
else else
Content = Content .. "<tr><td>None</td></tr>" Content = Content .. "<tr><td>None</td></tr>"
end end
Content = Content .. "</table>" Content = Content .. "</table>"
Content = Content .. "<br><h4>Add player to whitelist</h4>" Content = Content .. "<br><h4>Add player to whitelist</h4>"
Content = Content .. "<form method=\"POST\">" Content = Content .. "<form method=\"POST\">"
Content = Content .. "<input type=\"text\" name=\"whitelist-add\"><input type=\"submit\" value=\"Add player\">" Content = Content .. "<input type=\"text\" name=\"whitelist-add\"><input type=\"submit\" value=\"Add player\">"
Content = Content .. "</form>" Content = Content .. "</form>"
Content = Content .. "<form method=\"POST\">" Content = Content .. "<form method=\"POST\">"
Content = Content .. "<input type=\"submit\" name=\"whitelist-reload\" value=\"Reload from disk\">" Content = Content .. "<input type=\"submit\" name=\"whitelist-reload\" value=\"Reload from disk\">"
Content = Content .. "</form>" Content = Content .. "</form>"
Content = Content .. "<br>"..UpdateMessage Content = Content .. "<br>"..UpdateMessage
if( WhiteListEnabled == true ) then if( WhiteListEnabled == true ) then
Content = Content .. "<br><br><p>Whitelist is currently enabled, click <a href='?whitelist-setenable=0'>here</a> to disable.</p>" Content = Content .. "<br><br><p>Whitelist is currently enabled, click <a href='?whitelist-setenable=0'>here</a> to disable.</p>"
end end
return Content return Content
end end

View File

@ -1,21 +1,21 @@
function OnPlayerMoving( Player ) function OnPlayerMoving( Player )
if LimitWorld == true then if LimitWorld == true then
local World = Player:GetWorld() local World = Player:GetWorld()
local SpawnX = math.floor(World:GetSpawnX() / 16) local SpawnX = math.floor(World:GetSpawnX() / 16)
local SpawnZ = math.floor(World:GetSpawnZ() / 16) local SpawnZ = math.floor(World:GetSpawnZ() / 16)
local X = math.floor(Player:GetPosX() / 16) local X = math.floor(Player:GetPosX() / 16)
local Z = math.floor(Player:GetPosZ() / 16) local Z = math.floor(Player:GetPosZ() / 16)
if ( (SpawnX + LimitWorldWidth - 1) < X ) then if ( (SpawnX + LimitWorldWidth - 1) < X ) then
Player:TeleportToCoords(Player:GetPosX() - 1, Player:GetPosY(), Player:GetPosZ()) Player:TeleportToCoords(Player:GetPosX() - 1, Player:GetPosY(), Player:GetPosZ())
end end
if ( (SpawnX - LimitWorldWidth + 1) > X ) then if ( (SpawnX - LimitWorldWidth + 1) > X ) then
Player:TeleportToCoords(Player:GetPosX() + 1, Player:GetPosY(), Player:GetPosZ()) Player:TeleportToCoords(Player:GetPosX() + 1, Player:GetPosY(), Player:GetPosZ())
end end
if ( (SpawnZ + LimitWorldWidth - 1) < Z ) then if ( (SpawnZ + LimitWorldWidth - 1) < Z ) then
Player:TeleportToCoords(Player:GetPosX(), Player:GetPosY(), Player:GetPosZ() - 1) Player:TeleportToCoords(Player:GetPosX(), Player:GetPosY(), Player:GetPosZ() - 1)
end end
if ( (SpawnZ - LimitWorldWidth + 1) > Z ) then if ( (SpawnZ - LimitWorldWidth + 1) > Z ) then
Player:TeleportToCoords(Player:GetPosX(), Player:GetPosY(), Player:GetPosZ() + 1) Player:TeleportToCoords(Player:GetPosX(), Player:GetPosY(), Player:GetPosZ() + 1)
end end
end end
end end