diff --git a/Info.lua b/Info.lua index e9ffba9..bd82875 100644 --- a/Info.lua +++ b/Info.lua @@ -243,6 +243,20 @@ g_PluginInfo = HelpString = "Shows or sets a player's rank.", }, + ["/op"] = + { + Permission = "core.rank", + Handler = HandleOpCommand, + HelpString = "Add a player to the administrator rank.", + }, + + ["/deop"] = + { + Permission = "core.rank", + Handler = HandleDeOpCommand, + HelpString = "Add a player to the default rank.", + }, + ["/regen"] = { Permission = "core.regen", @@ -761,6 +775,20 @@ g_PluginInfo = Handler = HandleConsoleRank, HelpString = "Shows or sets a player's rank.", }, + + ["op"] = + { + Permission = "core.rank", + Handler = HandleConsoleOp, + HelpString = "Add a player to the Admin rank.", + }, + + ["deop"] = + { + Permission = "core.rank", + Handler = HandleConsoleDeOp, + HelpString = "Add a player to the Default rank.", + }, ["regen"] = { diff --git a/README.md b/README.md index e8f29bc..87375a2 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,7 @@ Implements some of the basic commands needed to run a simple server. | ------- | ---------- | ----------- | |/ban | core.ban | Bans a player.| |/clear | core.clear | Clears the inventory of a player.| +|/deop | core.rank | Add a player to the default rank.| |/difficulty | core.difficulty | Changes the difficulty level of the world you're located in.| |/do | core.do | Runs a command as a player.| |/effect | core.effect | Adds an effect to a player.| @@ -23,6 +24,7 @@ Implements some of the basic commands needed to run a simple server. |/listranks | core.listranks | Shows a list of the available ranks.| |/me | core.me | Broadcasts what you are doing.| |/motd | core.motd | Shows the message of the day.| +|/op | core.rank | Add a player to the administrator rank. | |/plugins | core.plugins | Shows a list of the plugins.| |/portal | core.portal | Moves your player to a different world.| |/r | core.tell | Replies to the latest private message you recieved.| @@ -85,7 +87,7 @@ Implements some of the basic commands needed to run a simple server. | core.motd | | `/motd` | | | core.plugins | | `/plugins` | | | core.portal | | `/portal` | | -| core.rank | | `/rank` | | +| core.rank | | `/rank`, `/op`, `/deop` | | | core.regen | | `/regen` | | | core.reload | | `/reload` | | | core.save-all | | `/save-all` | | diff --git a/console.lua b/console.lua index 5f113be..3516ca9 100644 --- a/console.lua +++ b/console.lua @@ -306,6 +306,45 @@ end +function HandleConsoleOp(a_Split) + -- Check the params: + if ((a_Split[2] == nil) or (a_Split[3] ~= nil)) then + -- Not enough or too many parameters + return true, "Usage: " .. a_Split[1] .. " " + end + + local PlayerName = a_Split[2] + local AdminRank = GetAdminRank() + + if not AdminRank then + SendMessage(a_Player, "No admin rank found, missing * permission") + return true + end + + return HandleConsoleRank({"rank", PlayerName, AdminRank}) +end + + + + + +function HandleConsoleDeOp(a_Split) + -- Check the params: + if ((a_Split[2] == nil) or (a_Split[3] ~= nil)) then + -- Not enough or too many parameters + return true, "Usage: " .. a_Split[1] .. " " + end + + local PlayerName = a_Split[2] + local DefaultRank = cRankManager:GetDefaultRank() + + return HandleConsoleRank({"rank", PlayerName, DefaultRank}) +end + + + + + function HandleConsoleSaveAll(Split) cRoot:Get():SaveAllChunks() return true diff --git a/functions.lua b/functions.lua index 8830583..c51ded1 100644 --- a/functions.lua +++ b/functions.lua @@ -182,3 +182,17 @@ function GetWorld( WorldName, Player ) return World end end + + +function GetAdminRank() + local AdminRank + local Ranks = cRankManager:GetAllRanks() + for _, Rank in ipairs(Ranks) do + local Permissions = cRankManager:GetRankPermissions(Rank) + for _, Permission in ipairs(Permissions) do + if Permission == "*" then + return Rank + end + end + end +end diff --git a/ranks.lua b/ranks.lua index 7608af0..4986a8f 100644 --- a/ranks.lua +++ b/ranks.lua @@ -75,3 +75,40 @@ end +function HandleOpCommand(a_Split, a_Player) + -- Check the params: + if ((a_Split[2] == nil) or (a_Split[3] ~= nil)) then + -- Too many or too few parameters, print the usage: + SendMessage(a_Player, "Usage: " .. a_Split[1] .. " ") + return true + end + + local PlayerName = a_Split[2] + local AdminRank = GetAdminRank() + + if not AdminRank then + SendMessage(a_Player, "No admin rank found, missing * permission") + return true + end + + return HandleRankCommand({"rank", PlayerName, AdminRank}, a_Player) +end + + + + + +function HandleDeOpCommand(a_Split, a_Player) + -- Check the params: + if ((a_Split[2] == nil) or (a_Split[3] ~= nil)) then + -- Too many or too few parameters, print the usage: + SendMessage(a_Player, "Usage: " .. a_Split[1] .. " ") + return true + end + + local PlayerName = a_Split[2] + local DefaultRank = cRankManager:GetDefaultRank() + + return HandleRankCommand({"rank", PlayerName, DefaultRank}, a_Player) +end +