Module:Downloadlinks

--	Create download links to replace the S3 links.

local p = {}

function p.downloadLinkConstructor( f ) local args = f	if f == mw.getCurrentFrame then args = require( 'Module:ProcessArgs' ).merge( true ) end local version = mw.text.trim( tostring( args.v ) or '' ):lower local variant = mw.text.trim( args.s or '' ):lower -- Load values from granules and define variables local versiondata = mw.loadData( 'Module:Downloadlinks/hashes' ).hash[version] local windowsServer = mw.loadData( 'Module:Downloadlinks/windows_server' )[version] local category = '' local dlink local dhash if (versiondata or windowsServer) and variant then if (variant:lower == 'client') and versiondata.clienthash then dhash = versiondata.clienthash dlink = 'https://launcher.mojang.com/v1/objects/' .. dhash .. '/client.jar' if versiondata.clienthash == nil then dlink = '— ' if not args.nocat and title.namespace == 0 and not title.isSubpage then category = '' end end elseif (variant:lower == 'server') and versiondata.serverhash then dhash = versiondata.serverhash dlink = 'https://launcher.mojang.com/v1/objects/' .. dhash .. '/server.jar' if versiondata.serverhash == nil then dlink = '— ' if not args.nocat and title.namespace == 0 and not title.isSubpage then category = '' end end elseif (variant:lower == 'json') and versiondata.jsonhash then dhash = versiondata.jsonhash dlink = 'https://launchermeta.mojang.com/v1/objects/' .. dhash .. '/' .. version .. '.json' if versiondata.jsonhash == nil then dlink = '— ' if not args.nocat and title.namespace == 0 and not title.isSubpage then category = '' end end elseif (variant:lower == 'windows') and windowsServer then dhash = windowsServer dlink = 'https://launcher.mojang.com/v1/objects/' .. dhash .. '/windows_server.exe' --				Although unlikely to get a Windowsversion 'nil' as				Value (just don't add), anyway added in case. if windowsServer == nil then dlink = '— ' if not args.nocat and title.namespace == 0 and not title.isSubpage then category = '' end end else dlink = 'missingno ' end else dlink = 'Parameterfout ' local title = mw.title.getCurrentTitle if not args.nocat and title.namespace == 0 and not title.isSubpage then category = '' end end -- Ability to add a description if args.description then local description = mw.text.trim( args.description ) dlink = '['	.. dlink .. ' ' .. description .. ']'	else dlink = dlink end return dlink .. category end

return p