Skip to content

Commit

Permalink
Remove darkrp from ingame docs when not in darkrp (#1943)
Browse files Browse the repository at this point in the history
* Remove darkrp from ingame docs when not in darkrp

* Fix
  • Loading branch information
thegrb93 authored Dec 29, 2024
1 parent 5039b75 commit be9f6ff
Show file tree
Hide file tree
Showing 4 changed files with 253 additions and 198 deletions.
59 changes: 57 additions & 2 deletions lua/starfall/libs_sh/darkrp2.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,61 @@ local checkpattern = SF.CheckPattern
local registerprivilege = SF.Permissions.registerPrivilege
local IsValid = FindMetaTable("Entity").IsValid

hook.Add("StarfallProcessDocs", "DarkRP", function(docs)
if DarkRP then return end
docs.Libraries.darkrp = nil

local ent_methods = docs.Types.Entity.methods
ent_methods.doorIndex = nil
ent_methods.isLocked = nil
ent_methods.getDoorOwner = nil
ent_methods.getKeysTitle = nil
ent_methods.isDoor = nil
ent_methods.isKeysOwned = nil
ent_methods.isKeysOwnedBy = nil
ent_methods.isMoneyBag = nil
ent_methods.getMoneyAmount = nil
ent_methods.getShipmentCount = nil
ent_methods.getShipmentContentsIndex = nil
ent_methods.getShipmentContents = nil

local ply_methods = docs.Types.Player.methods
ply_methods.keysUnOwnAll = nil
ply_methods.teamBanTimeLeft = nil
ply_methods.requestMoney = nil
ply_methods.giveMoney = nil
ply_methods.isInRoom = nil
ply_methods.canAfford = nil
ply_methods.canKeysLock = nil
ply_methods.canKeysUnlock = nil
ply_methods.getDarkRPVar = nil
ply_methods.getJobTable = nil
ply_methods.getPocketItems = nil
ply_methods.getWantedReason = nil
ply_methods.hasDarkRPPrivilege = nil
ply_methods.isArrested = nil
ply_methods.isChief = nil
ply_methods.isCook = nil
ply_methods.isCP = nil
ply_methods.isHitman = nil
ply_methods.isMayor = nil
ply_methods.isMedic = nil
ply_methods.isWanted = nil
ply_methods.getMoney = nil

docs.Hooks.moneyPrinterCatchFire = nil
docs.Hooks.moneyPrinterPrinted = nil
docs.Hooks.moneyPrinterPrintMoney = nil
docs.Hooks.playerWalletChanged = nil
docs.Hooks.lockdownEnded = nil
docs.Hooks.lockdownStarted = nil
docs.Hooks.addLaw = nil
docs.Hooks.removeLaw = nil
docs.Hooks.resetLaws = nil
docs.Hooks.lockpickStarted = nil
docs.Hooks.onLockpickCompleted = nil
end)

-- Under normal circumstances, an API change could introduce security
-- vulnerabilities. Suppose a DarkRP function changes to also return a Player
-- or Entity object, whereas before it only returned safe types like numbers
Expand Down Expand Up @@ -870,15 +925,15 @@ end
--- Get the amount of money in a "money bag" or cheque, or number of items in a dropped item stack. DarkRP only.
-- Equivalent to GLua Entity:Getamount.
-- @return number? Amount of money or number of items
function ents_methods:getAmount()
function ents_methods:getMoneyAmount()
self = getent(self)
return self.Getamount and assertsafety(self:Getamount()) or nil
end

--- Get the number of items remaining in a shipment. DarkRP only.
-- Equivalent to GLua Entity:Getcount.
-- @return number? Number of items remaining, or nil if not a shipment
function ents_methods:getCount()
function ents_methods:getShipmentCount()
self = getent(self)
return self.Getcount and assertsafety(self:Getcount()) or nil
end
Expand Down
2 changes: 1 addition & 1 deletion lua/starfall/permissions/core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ function P.loadPermissionsSafe()
end

-- Find and include all provider files.
do
function P.includePermissions()
local sv_dir = "starfall/permissions/providers_sv/"
local sv_files = file.Find(sv_dir.."*.lua", "LUA")
local sh_dir = "starfall/permissions/providers_sh/"
Expand Down
Loading

0 comments on commit be9f6ff

Please sign in to comment.