Module:Version link

local p = {}

local function removePrefix( s, prefixes ) local final = s	for _, p in ipairs( prefixes ) do final = final:gsub( '^' .. p, '' ) end return mw.text.trim(final) end

local function getLast( prefix ) return function( s ) local last = mw.ustring.match( s, '^.+%s+(%S+)$' ) return prefix .. last end end

local function getJava( s ) return 'Java Edition ' .. removePrefix( s, { '[Jj]ava', ' [Ee]dition', '[Jj][Ee]' } ) end

local function getBedrock( s ) return 'Bedrock Edition ' .. removePrefix( s, { '[Bb]edrock', ' [Ee]dition', '[Bb][Ee]' } ) end

local function getPocket( s ) if(s:match('Alpha') and not s:match('Realms')) then return 'Pocket Edition ' .. mw.getCurrentFrame:preprocess('') end return 'Pocket Edition ' .. removePrefix( s, { '[Pp]ocket', ' [Ee]dition', '[Pp][Ee]' } ) end

local function getEducation( s ) return 'Minecraft Education ' .. removePrefix( s, { '[Ee]ducation', ' [Ee]dition', '[Ee][Dd][Uu]', '[Ee][Ee]' } ) end

local function getChinese return 'Minecraft China#History' end

local function getLauncher( s ) return 'Minecraft launcher#' .. removePrefix( s, { '[Ll]auncher' } ) end

local prefixFunctions = { java = getJava, je = getJava, ['pre-classic'] = getJava, classic = getJava, indev = getJava, infdev = getJava, alpha = getJava, beta = getJava, pe = getPocket, pocket = getPocket, be = getBedrock, bedrock = getBedrock, edu = getEducation, education = getEducation, ee = getEducation, ['3ds'] = getLast( 'New Nintendo 3DS Edition 版' ), new = getLast( 'New Nintendo 3DS Edition ' ), new3ds = getLast( 'New Nintendo 3DS Edition ' ), china = getChinese, chinese = getChinese, launcher = getLauncher, ps = getLast( 'PlayStation版' ), ['360'] = getLast( 'Xbox 360 Edition ' ), xbox = getLast( 'Xbox 360 Edition ' ), xbox360 = getLast( 'Xbox 360 Edition ' ), xbox = getLast( 'Xbox 360 Edition ' ), xbone = getLast( 'Xbox One Edition ' ), xb1 = getLast( 'Xbox One Edition ' ), xbox1 = getLast( 'Xbox One Edition ' ), ps3 = getLast( 'PlayStation 3 Edition ' ), ps4 = getLast( 'PlayStation 4 Edition ' ), playstation = getLast( 'PlayStation 4 Edition ' ), psv = getLast( 'PlayStation Vita Edition ' ), psvita = getLast( 'PlayStation Vita Edition ' ), wii = getLast( 'Wii U Edition Patch ' ), wiiu = getLast( 'Wii U Edition Patch ' ), switch = getLast( 'Nintendo Switch Edition ' ), nswitch = getLast( 'Nintendo Switch Edition ' ), realms = getLast( 'Realms#' ), earth = getLast( 'Minecraft Earth ' ) }

function p.version( s ) local v = s:gsub( '^[Mm]inecraft ', '' ) local prefix = mw.text.split( v, '%s' )[1]:lower local func = prefixFunctions[prefix] if func then return func( v ) else return v	end end

function p.main( f ) local args = f	if f == mw.getCurrentFrame then args = require( Module:ProcessArgs ).merge( false ) end local text if args[2]=='' then text = mw.ustring.match( args[1], '^.+%s+(%S+)$' ) else text = args[2] or args[1] end return  .. text ..  end

return p