@@ -7,14 +7,54 @@ local serverConfig = lib.require('config.server')
77local logs = lib .require (' modules.server.logs' )
88
99-- Localised Functions ----------------------------------------------
10- local AddEventHandler = AddEventHandler
10+ local string = string
11+ local gsub = string.gsub
12+ local match = string.match
1113local GetCurrentResourceName = GetCurrentResourceName
1214local TriggerClientEvent = TriggerClientEvent
15+ local GetResourceMetadata = GetResourceMetadata
16+ local AddEventHandler = AddEventHandler
1317
1418-- Local Variables ----------------------------------------------
1519local resourceName = GetCurrentResourceName ()
1620
1721-- Functions ------------------------------------------------------
22+ --- Checks resource metadata for cheeky gits
23+ local function checkResourceMeta ()
24+ local currentAuthor = GetResourceMetadata (resourceName , ' author' , 0 )
25+ assert (currentAuthor == ' MadCap' , locale (' not_author' , currentAuthor or ' unknown' ))
26+
27+ local currentResourceName = GetResourceMetadata (resourceName , ' name' , 0 )
28+ assert (currentResourceName == ' mad_goon' , locale (' resource_name_changed' , currentResourceName or ' unknown' ))
29+ end
30+
31+ --- Checks if the resource is a fork
32+ --- @return boolean isFork Whether the resource is a fork
33+ --- @return string repo The repository string (owner /repo )
34+ --- @return string owner The repository owner
35+ local function isFork ()
36+ local originalRepo = ' ThatMadCap/mad_goon'
37+
38+ local repo = GetResourceMetadata (resourceName , ' repository' , 0 ) or originalRepo
39+ repo = gsub (repo , ' https?://github%.com/' , ' ' )
40+
41+ local owner = match (repo , ' ^([^/]+)/' )
42+
43+ return repo ~= originalRepo , repo , owner
44+ end
45+
46+ --- Performs version check unless forked
47+ local function versionCheck ()
48+ local forked , repo , owner = isFork ()
49+
50+ if forked then
51+ lib .print .warn (locale (' fork_detected' , owner ))
52+ return
53+ end
54+
55+ lib .versionCheck (repo )
56+ end
57+
1858--- Broadcast speech to nearby players
1959--- @param src number Source player
2060--- @param data SpeechData
5898
5999-- Initialisation -----------------------------------------------------
60100local function init ()
101+ versionCheck ()
102+ checkResourceMeta ()
103+
61104 if not nlp .isModelReady () then
62105 nlp .initNLP ()
63106 end
@@ -69,8 +112,6 @@ local function init()
69112 commands .initCommands ()
70113end
71114
72- lib .versionCheck (' ThatMadCap/mad_goon' )
73-
74115-- Event Handlers --------------------------------------------------
75116AddEventHandler (' onResourceStart' , function (resName )
76117 if resourceName ~= resName then
0 commit comments