Minecraft Wiki

Minecraft Wiki ภาษาไทยกำลังจะย้ายออกจาก Fandom ตามภาษาอังกฤษในเร็ว ๆ นี้ ดูที่หน้านี้และ Discord สำหรับข้อมูลเพิ่มเติม

READ MORE

Minecraft Wiki
Advertisement
[สร้าง | ประวัติ | ล้างแคช]คู่มือการใช้งาน
This module has no documentation. If you know how to use this module, please create it.
local p = {}
function p.fixes( f )
	local args = require("Module:ProcessArgs").norm(f:getParent().args)
	local project = args.project or 'MC'
	
	local argLen = 0
	for i in ipairs( args ) do
		argLen = i
	end
	
	local parentVersion = f:callParserFunction( '#dplvar', 'parentVersion' )
	local parentMajorVersion = nil
	if parentVersion == '' then
		parentVersion = f:callParserFunction( '#var', 'title' )
	else
		parentMajorVersion = table.concat( mw.text.split( string.gsub( parentVersion, '%s', '' ), '[\.]' ), '.', 1, 2 )	
	end

	local headerAliases = {
		[';old'] = ';จากเวอร์ชันก่อนหน้า ' .. parentVersion,
		[';dev'] = ';จากเวอร์ชันที่พัฒนา ' .. parentVersion,
		[';previous'] = ';จากก่อนเวอร์ชันที่พัฒนา',
		[';prev'] = ';จากก่อนเวอร์ชันที่พัฒนา',
		[';hotfix'] = ';จากเวอร์ชันปัจจุบัน เพิ่งได้รับการแก้ไข',
		[';private'] = ';ปัญหาที่ป้องกันการเข้าถึงไว้',
		[';priv'] = ';ปัญหาที่ป้องกันการเข้าถึงไว้',
	}
	
	local sections = {}
	local headers = {}
	local section = {}
	local issues = 0
	local index = {}
	local i = 1
	while i < argLen do
		local this = args[i]
		if this:match( '^;' ) then
			if #section > 0 then
				table.insert( sections, section )
				section = {}
			end
			
			local header = mw.text.trim( this )
			headers[#sections + 1] = headerAliases[header:lower()] or header
		else
			local issue = tonumber( this:match( '%d+' ) )
			if issue then
				table.insert( section, issue )
				issues = issues + 1
				index[issue] = i
			end
			
			i = i + 1
		end
		
		i = i + 1
	end
	if #section > 0 then
		table.insert( sections, section )
	end
	
	local list = {}
	for i, section in ipairs( sections ) do
		local header = headers[i]
		if header and header ~= '' then
			table.insert( list, header )
		end
		
		table.sort( section )
		for _, issue in ipairs( section ) do
			local title = mw.text.trim( args[index[issue] + 1] or '' )
			table.insert( list, '* <span class="plainlinks">[https://bugs.mojang.com/browse/' .. project .. '-' .. issue .. ' ' .. project:upper() .. '-' .. issue ..  ']</span> – ' .. title )
		end
	end

	local prefix = ''
	if args.prefix then
		prefix = args.prefix .. ' '
	end
	
	local trackerQuery = {}
	local makeQuery = function( query, arg )
		if arg and arg ~= '' then
			local makeQuery_results = {}
			for v in mw.text.gsplit( arg, '%s*,%s*' ) do
				if v ~= '' then
					if mw.text.trim( string.lower( v ) ) == 'future' then
						if parentMajorVersion ~= nil then
							table.insert( makeQuery_results, '"Future Version - ' .. parentMajorVersion .. '+"' )
						end
					else
						table.insert( makeQuery_results, '"' .. prefix .. mw.text.trim(v) .. '"' )
					end
				end
			end
			table.insert( trackerQuery, query .. ' in (' .. table.concat( makeQuery_results, ',' ) .. ')' )
		end
	end
	makeQuery( 'fixVersion', args.fixedin )
	makeQuery( 'fixVersion not', args.notfixedin )
	makeQuery( 'affectedVersion', args.affected )

	if args.otherissuescount then issues = issues + args.otherissuescount end
	
	local text = issues .. ' ปัญหา' .. (args.planned and 'ที่วางแผนว่าจะ' or '') .. 'ได้รับการแก้ไข'
	if #trackerQuery > 0 then
		table.insert( trackerQuery, 'project = ' .. project:upper() )

		-- For the sake of [[1.9]]
		if not args.upcoming then
			table.insert( trackerQuery, 'resolution = Fixed' )
		end
		text = '[https://bugs.mojang.com/issues/?jql=' .. mw.uri.encode( table.concat( trackerQuery, ' AND ' ) .. ' ORDER BY key' ) .. ' ' .. text .. ']'
	end
	
	return ';' .. text .. '\n' .. table.concat( list, '\n' )
end
return p
Advertisement