summaryrefslogtreecommitdiffstats
path: root/MCServer
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-02-01 20:55:42 +0100
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-02-01 20:55:42 +0100
commit019c8b5bc71708e2d895a95757643406f75b4149 (patch)
tree47c5e399e562384a255d5d789d761d8857dff6af /MCServer
parentRenamed HOOK_KILLED to HOOK_KILLING to match naming conventions. (diff)
downloadcuberite-019c8b5bc71708e2d895a95757643406f75b4149.tar
cuberite-019c8b5bc71708e2d895a95757643406f75b4149.tar.gz
cuberite-019c8b5bc71708e2d895a95757643406f75b4149.tar.bz2
cuberite-019c8b5bc71708e2d895a95757643406f75b4149.tar.lz
cuberite-019c8b5bc71708e2d895a95757643406f75b4149.tar.xz
cuberite-019c8b5bc71708e2d895a95757643406f75b4149.tar.zst
cuberite-019c8b5bc71708e2d895a95757643406f75b4149.zip
Diffstat (limited to 'MCServer')
-rw-r--r--MCServer/Plugins/Core/help.lua76
-rw-r--r--MCServer/Plugins/Core/main.lua75
-rw-r--r--MCServer/Plugins/Core/regeneratechunk.lua24
3 files changed, 71 insertions, 104 deletions
diff --git a/MCServer/Plugins/Core/help.lua b/MCServer/Plugins/Core/help.lua
index 800a65924..68cdeca66 100644
--- a/MCServer/Plugins/Core/help.lua
+++ b/MCServer/Plugins/Core/help.lua
@@ -1,56 +1,40 @@
-function HandleHelpCommand( Split, Player )
+function HandleHelpCommand(Split, Player)
local PluginManager = cRoot:Get():GetPluginManager()
- local LinesPerPage = 9
- local CurrentPage = 1
- local CurrentLine = 0
+ local LinesPerPage = 9;
+ local CurrentPage = 1;
+ local CurrentLine = 0;
+ local PageRequested = 1;
+ local Output = {};
- if( #Split == 2 ) then
- CurrentPage = tonumber(Split[2])
+ if (#Split == 2) then
+ PageRequested = tonumber(Split[2]);
end
- local Pages = {}
+ local Process = function(Command, Permission, HelpString)
+ if not(Player:HasPermission(Permission)) then
+ return false;
+ end;
+ if (HelpString == "") then
+ return false;
+ end;
- local PluginList = PluginManager:GetAllPlugins()
- for k, Plugin in pairs(PluginList) do
- if( Plugin ) then
- local Commands = Plugin:GetCommands()
- for i, v in ipairs( Commands ) do
- if( Player:HasPermission( v.Permission ) ) then
- local PageNum = math.floor( CurrentLine/LinesPerPage )+1
- if( Pages[ PageNum ] == nil ) then Pages[ PageNum ] = {} end -- Create page
-
- if( Pages[ PageNum ].ShownName ~= Plugin:GetName() and SHOW_PLUGIN_NAMES == true ) then
- if( CurrentLine == LinesPerPage * PageNum -1 ) then -- Don't add if it's the last line of the page, it looks silly
- -- Add it to the next page instead
- CurrentLine = CurrentLine+1
- PageNum = math.floor( CurrentLine/LinesPerPage )+1
-
- if( Pages[ PageNum ] == nil ) then Pages[ PageNum ] = {} end -- Create page
- table.insert( Pages[ PageNum ], cChatColor.Gold .. Plugin:GetName() )
- else
- Pages[ PageNum ].ShownName = Plugin:GetName()
- table.insert( Pages[ PageNum ], cChatColor.Gold .. Plugin:GetName() )
- end
- CurrentLine = CurrentLine+1
- PageNum = math.floor( CurrentLine/LinesPerPage )+1
- if( Pages[ PageNum ] == nil ) then Pages[ PageNum ] = {} end -- Create page
- end
- local Message = cChatColor.Blue .. v.Command .. v.Description;
- table.insert( Pages[ PageNum ], Message )
- CurrentLine = CurrentLine+1
- end
- end
- end
- end
-
- Player:SendMessage( cChatColor.Purple .. "- All commands - " .. cChatColor.Gold .. "[Page " .. (CurrentPage) .."/"..#Pages.."]" )
-
- if( Pages[CurrentPage] ~= nil ) then
- for i, v in ipairs(Pages[CurrentPage]) do
- Player:SendMessage( v )
- end
+ CurrentLine = CurrentLine + 1;
+ CurrentPage = math.floor(CurrentLine / LinesPerPage) + 1;
+ if (CurrentPage ~= PageRequested) then
+ return false;
+ end;
+ table.insert(Output, cChatColor.Blue .. Command .. HelpString);
end
+
+ PluginManager:ForEachCommand(Process);
+
+ -- CurrentPage now contains the total number of pages, and Output has the individual help lines to be sent
+
+ Player:SendMessage(cChatColor.Purple .. "- All commands - " .. cChatColor.Gold .. "[Page " .. PageRequested .. " / " .. CurrentPage .. "]");
+ for idx, msg in ipairs(Output) do
+ Player:SendMessage(msg);
+ end;
return true
end \ No newline at end of file
diff --git a/MCServer/Plugins/Core/main.lua b/MCServer/Plugins/Core/main.lua
index 2dfbfb407..4682333fd 100644
--- a/MCServer/Plugins/Core/main.lua
+++ b/MCServer/Plugins/Core/main.lua
@@ -8,11 +8,15 @@ PLUGIN = {} -- Reference to own plugin object
BannedPlayersIni = {}
WhiteListIni = {}
-function Initialize( Plugin )
+
+
+
+
+function Initialize(Plugin)
PLUGIN = Plugin
- Plugin:SetName( "Core" )
- Plugin:SetVersion(9)
+ Plugin:SetName("Core")
+ Plugin:SetVersion(10)
PluginManager = cRoot:Get():GetPluginManager()
PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_JOINED)
@@ -22,50 +26,29 @@ function Initialize( Plugin )
PluginManager:AddHook(Plugin, cPluginManager.HOOK_KILLING)
PluginManager:AddHook(Plugin, cPluginManager.HOOK_CRAFTING_NO_RECIPE)
PluginManager:AddHook(Plugin, cPluginManager.HOOK_CHAT) -- used in web_chat.lua
-
- Plugin:AddCommand("/help", " - [Page] Show this message", "core.help")
- Plugin:AddCommand("/pluginlist", " - Show list of plugins", "core.pluginlist")
- Plugin:AddCommand("/tp", " - [Player] - Teleport yourself to a player", "core.teleport")
- Plugin:AddCommand("/item", " - [ItemType/Name] <Amount> - Give yourself an item", "core.item")
- Plugin:AddCommand("/list", " - Shows list of connected players", "core.playerlist")
- Plugin:AddCommand("/motd", " - Show message of the day", "core.motd")
- Plugin:AddCommand("/reload", " - Reload all plugins", "core.reload")
- Plugin:AddCommand("/stop", " - Stops the server", "core.stop")
- Plugin:AddCommand("/time", " - [Day/Night] - Sets the time of day", "core.time")
- Plugin:AddCommand("/spawn", " - Return to the spawn", "core.spawn")
- Plugin:AddCommand("/kick", " - [Player] - Kick a player", "core.kick")
- Plugin:AddCommand("/ban", " - [Player] - Ban a player", "core.ban")
- Plugin:AddCommand("/unban", " - [Player] - Unban a player", "core.unban")
- Plugin:AddCommand("/top", " - Teleport yourself to the top most block", "core.top")
- Plugin:AddCommand("/gm", " - [Gamemode (0|1)] - Change your gamemode", "core.changegm")
- Plugin:AddCommand("/gotoworld", " - Move to a different world!", "core.gotoworld")
- Plugin:AddCommand("/coords", " - Show your current server coordinates", "core.coords")
- Plugin:AddCommand("/viewdistance", " - [".. cClientHandle.MIN_VIEW_DISTANCE .."-".. cClientHandle.MAX_VIEW_DISTANCE .."] - Change your view distance", "core.viewdistance")
- Plugin:AddCommand("/regeneratechunk", " - <X [Z]> - Regenerates a chunk", "core.regeneratechunk")
-
- Plugin:BindCommand( "/help", "core.help", HandleHelpCommand )
- Plugin:BindCommand( "/pluginlist", "core.pluginlist", HandlePluginListCommand )
- Plugin:BindCommand( "/tp", "core.teleport", HandleTPCommand )
- Plugin:BindCommand( "/item", "core.item", HandleItemCommand )
- Plugin:BindCommand( "/i", "core.item", HandleItemCommand )
- Plugin:BindCommand( "/list", "core.playerlist", HandlePlayerListCommand )
- Plugin:BindCommand( "/who", "core.playerlist", HandlePlayerListCommand )
- Plugin:BindCommand( "/playerlist", "core.playerlist", HandlePlayerListCommand )
- Plugin:BindCommand( "/motd", "core.motd", HandleMOTDCommand )
- Plugin:BindCommand( "/reload", "core.reload", HandleReloadCommand )
- Plugin:BindCommand( "/stop", "core.stop", HandleStopCommand )
- Plugin:BindCommand( "/time", "core.time", HandleTimeCommand )
- Plugin:BindCommand( "/spawn", "core.spawn", HandleSpawnCommand )
- Plugin:BindCommand( "/kick", "core.kick", HandleKickCommand )
- Plugin:BindCommand( "/ban", "core.ban", HandleBanCommand )
- Plugin:BindCommand( "/unban", "core.unban", HandleUnbanCommand )
- Plugin:BindCommand( "/top", "core.top", HandleTopCommand )
- Plugin:BindCommand( "/gm", "core.changegm", HandleChangeGMCommand )
- Plugin:BindCommand( "/gotoworld", "core.gotoworld", HandleGotoWorldCommand )
- Plugin:BindCommand( "/coords", "core.coords", HandleCoordsCommand )
- Plugin:BindCommand( "/viewdistance", "core.viewdistance", HandleViewDistanceCommand )
- Plugin:BindCommand( "/regeneratechunk", "core.regeneratechunk", HandleRegenerateChunkCommand )
+ PluginManager:BindCommand("/help", "core.help", HandleHelpCommand, " [Page] - Show available commands");
+ PluginManager:BindCommand("/pluginlist", "core.pluginlist", HandlePluginListCommand, " - Show list of plugins");
+ PluginManager:BindCommand("/tp", "core.teleport", HandleTPCommand, " [Player] - Teleport yourself to a player");
+ PluginManager:BindCommand("/item", "core.item", HandleItemCommand, " [ItemType/Name] <Amount> - Give yourself an item");
+ PluginManager:BindCommand("/list", "core.playerlist", HandlePlayerListCommand, " - Shows list of connected players");
+ PluginManager:BindCommand("/who", "core.playerlist", HandlePlayerListCommand, " - Shows list of connected players");
+ PluginManager:BindCommand("/playerlist", "core.playerlist", HandlePlayerListCommand, " - Shows list of connected players");
+ PluginManager:BindCommand("/motd", "core.motd", HandleMOTDCommand, " - Show message of the day");
+ PluginManager:BindCommand("/reload", "core.reload", HandleReloadCommand, " - Reload all plugins");
+ PluginManager:BindCommand("/stop", "core.stop", HandleStopCommand, " - Stops the server");
+ PluginManager:BindCommand("/time", "core.time", HandleTimeCommand, " [Day/Night] - Sets the time of day");
+ PluginManager:BindCommand("/spawn", "core.spawn", HandleSpawnCommand, " - Return to the spawn");
+ PluginManager:BindCommand("/kick", "core.kick", HandleKickCommand, " [Player] - Kick a player");
+ PluginManager:BindCommand("/ban", "core.ban", HandleBanCommand, " [Player] - Ban a player");
+ PluginManager:BindCommand("/unban", "core.unban", HandleUnbanCommand, " [Player] - Unban a player");
+ PluginManager:BindCommand("/top", "core.top", HandleTopCommand, " - Teleport yourself to the top most block");
+ PluginManager:BindCommand("/gm", "core.changegm", HandleChangeGMCommand, " [0|1] - Change your gamemode");
+ PluginManager:BindCommand("/gotoworld", "core.gotoworld", HandleGotoWorldCommand, " [WorldName] - Move to a different world!");
+ PluginManager:BindCommand("/coords", "core.coords", HandleCoordsCommand, " - Show your current server coordinates");
+ PluginManager:BindCommand("/regeneratechunk", "core.regeneratechunk", HandleRegenerateChunkCommand, " <[X] [Z]> - Regenerates a chunk, current or specified");
+ PluginManager:BindCommand("/viewdistance", "core.viewdistance", HandleViewDistanceCommand, " [".. cClientHandle.MIN_VIEW_DISTANCE .."-".. cClientHandle.MAX_VIEW_DISTANCE .."] - Change your view distance")
+
local IniFile = cIniFile("settings.ini")
if ( IniFile:ReadFile() == true ) then
SHOW_PLUGIN_NAMES = IniFile:GetValueB("HelpPlugin", "ShowPluginNames", true )
diff --git a/MCServer/Plugins/Core/regeneratechunk.lua b/MCServer/Plugins/Core/regeneratechunk.lua
index b4b2874fc..7f91f48c1 100644
--- a/MCServer/Plugins/Core/regeneratechunk.lua
+++ b/MCServer/Plugins/Core/regeneratechunk.lua
@@ -1,18 +1,18 @@
-function HandleRegenerateChunkCommand( Split, Player )
- if( (#Split == 2) or (#Split > 3) ) then
- Player:SendMessage( cChatColor.Green .. "Usage: /regeneratechunk <X [Z]>" )
- return true
+function HandleRegenerateChunkCommand(Split, Player)
+ if ((#Split == 2) or (#Split > 3)) then
+ Player:SendMessage( cChatColor.Green .. "Usage: '/regeneratechunk' or '/regeneratechunk [X] [Z]'");
+ return true;
end
- local X = Player:GetChunkX()
- local Z = Player:GetChunkZ()
+ local X = Player:GetChunkX();
+ local Z = Player:GetChunkZ();
- if( #Split == 3 ) then
- X = Split[2]
- Z = Split[3]
+ if (#Split == 3) then
+ X = Split[2];
+ Z = Split[3];
end
- Player:SendMessage(cChatColor.Green .. "Regenerating chunk ["..X..", "..Z.."]")
- Player:GetWorld():RegenerateChunk(X, Z)
- return true
+ Player:SendMessage(cChatColor.Green .. "Regenerating chunk ["..X..", "..Z.."]");
+ Player:GetWorld():RegenerateChunk(X, Z);
+ return true;
end \ No newline at end of file