Minecraft Wiki

The Minecraft Wiki has moved from Fandom; see the linked discussion page for details.

READ MORE

Minecraft Wiki
Advertisement
[view | edit | history | purge]DocumentationJump to code ↴

Explanation

['<version>'] = {
	client = '<client_hash>',
	server = '<server_hash>',
	windows_server = '<windows_server_hash>',
	json = '<json_hash>',
	json_package = '<json_package_hash>'
},

In here, <version> is a version of Minecraft, for example 1.13.1-pre2. The hashes are as follows (order shouldn't matter, but it is best to keep a regular order; see notes when given):

<client_hash>
SHA-1 hash for the client JAR, e.g. 7eaeaa37e0c7642d519c39de70a630119ad4929a.
<server_hash>
SHA-1 hash for the server JAR, e.g. c2a4bcf3e244c46f13c39e31e7ef6030564fb6c2.
<windows_server_hash>
SHA-1 hash for the Windows server EXE. It seems there's no longer a separate Windows version since 16w04a (late-1.9 development) and therefore it is not included in the example.
<json>
SHA-1 hash for the downloaded JSON file, e.g. 4f2100e24eb32ab94447de5808b96fdade6badd3. Pretty much only used when in the template call |force_download= is set to 1 when json is used as variant parameter value.
<json_package>
SHA-1 hash for the in-browser JSON, e.g. 1594d6f7242d2065c2b61c242397f40677e5123c. Used when json variant parameter value is set without |force_download= set to 1 or when json_package itself is used as value for the variant parameter field.

Example

Using the values from above, the 1.13.1-pre2 hash table would look like this:

['1.13.1-pre2'] = {
	client = '7eaeaa37e0c7642d519c39de70a630119ad4929a',
	server = 'c2a4bcf3e244c46f13c39e31e7ef6030564fb6c2',
	json = '4f2100e24eb32ab94447de5808b96fdade6badd3',
	json_package = '1594d6f7242d2065c2b61c242397f40677e5123c'
},

Using these hashes, the main module will create links from them.

[view | edit | history | purge]The above documentation is transcluded from Module:Downloadlinks/hashes/doc.
--[[
	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/mc/game/' .. version .. '/client/' .. dhash .. '/client.jar'
			if versiondata.clienthash == nil then
				dlink = '<abbr title="There is no client version of ' ..  version .. '">—</abbr>'
				if not args.nocat and title.namespace == 0 and not title.isSubpage then
					category = '[[Category:Invalid download link|' .. title .. ']]'
				end
			end
		elseif (variant:lower() == 'server') and versiondata.serverhash then
			dhash = versiondata.serverhash
			dlink = 'https://launcher.mojang.com/mc/game/' .. version .. '/server/' .. dhash .. '/server.jar'
			if versiondata.serverhash == nil then
				dlink = '<abbr title="There is no server version of ' .. version .. '">—</abbr>'
				if not args.nocat and title.namespace == 0 and not title.isSubpage then
					category = '[[Category:Invalid download link|' .. title .. ']]'
				end
			end
		elseif (variant:lower() == 'json') and versiondata.jsonhash then
			dhash = versiondata.jsonhash
			dlink = 'https://launchermeta.mojang.com/mc/game/' .. dhash .. '/' .. version .. '.json'
			if versiondata.jsonhash == nil then
				dlink = '<abbr title="No JSON file exists for ' .. version .. '">—</abbr>'
				if not args.nocat and title.namespace == 0 and not title.isSubpage then
					category = '[[Category:Invalid download link|' .. title .. ']]'
				end
			end
		elseif (variant:lower() == 'windows') and windowsServer then
			dhash = windowsServer
			dlink = 'https://launcher.mojang.com/mc/game/' .. version .. '/windows_server/' .. 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 = '<abbr title="There is no Windowsserverversion of ' .. version .. '">—</abbr>'
				if not args.nocat and title.namespace == 0 and not title.isSubpage then
					category = '[[Category:Invalid download link|' .. title .. ']]'
				end
			end
		else
			dlink = '<abbr title="No valid version and/or variant specified. Check the parameters.">missingno</abbr>'
		end
	else
		dlink = '<abbr title="No valid parameters specified!">Parameterfout</abbr>'
		local title = mw.title.getCurrentTitle()
		if not args.nocat and title.namespace == 0 and not title.isSubpage then
			category = '[[Category:Invalid download link|' .. title .. ']]'
		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
Advertisement