package team.unstudio.udpl.mapping;

import java.io.IOException;

import org.bukkit.Bukkit;

import team.unstudio.udpl.core.UDPLib;

public final class MappingHelper {
	
	private MappingHelper(){}
	
	private static final boolean DEBUG = UDPLib.isDebug();
	
	private static MemberMapping memberMapping;
	
	public static void loadMapping(){
		loadMapping(Bukkit.getBukkitVersion().substring(0, Bukkit.getBukkitVersion().indexOf("-")));
	}
	
	public static void loadMapping(String version){
		try {
			memberMapping = new MemberMapping(MappingHelper.class.getResourceAsStream("/mappings/"+version+"/members.csrg"));
		} catch (IOException e) {
			if(DEBUG)
				e.printStackTrace();
			memberMapping = null;
		}
	}

	public static MemberMapping getMemberMapping() {
		return memberMapping;
	}
	
	public static String getMemberDeobf(String className,String obf){
		if(memberMapping == null) 
			return "";
		
		return memberMapping.getDeobf(className,obf);
	}
	
	public static String getMemberObf(String className,String deobf){
		if(memberMapping == null) 
			return "";
		
		return memberMapping.getObf(className,deobf);
	}
}

@@ -886,105 +886,483 @@
  obf
-)%7B%0D%0A%09%09if(memberMapping == null) %0D%0A%09%09%09return %22%22;%0D%0A%09%09%0D%0A%09%09return memberMapping.getDeobf(className,ob
+,String def)%7B%0D%0A%09%09if(memberMapping == null) %0D%0A%09%09%09return def;%0D%0A%09%09%0D%0A%09%09return memberMapping.getDeobf(className,obf,def);%0D%0A%09%7D%0D%0A%09%0D%0A%09public static String getMemberDeobf(String className,String obf)%7B%0D%0A%09%09if(memberMapping == null) %0D%0A%09%09%09return %22%22;%0D%0A%09%09%0D%0A%09%09return memberMapping.getDeobf(className,obf);%0D%0A%09%7D%0D%0A%09%0D%0A%09public static String getMemberObf(String className,String deobf,String def)%7B%0D%0A%09%09if(memberMapping == null) %0D%0A%09%09%09return def;%0D%0A%09%09%0D%0A%09%09return memberMapping.getObf(className,deobf,de
 f);%0D

Update Mapping