Files

65 lines
2.1 KiB
Java
Raw Permalink Normal View History

2016-10-18 21:48:07 +08:00
package customskinloader.loader.jsonapi;
2016-11-12 19:33:01 +08:00
import java.io.File;
import java.util.List;
2016-11-12 19:33:01 +08:00
import java.util.UUID;
import com.google.common.collect.Lists;
2016-10-18 21:48:07 +08:00
import com.google.gson.Gson;
import customskinloader.CustomSkinLoader;
import customskinloader.config.SkinSiteProfile;
import customskinloader.loader.JsonAPILoader;
import customskinloader.plugin.ICustomSkinLoaderPlugin;
2016-10-18 21:48:07 +08:00
import customskinloader.utils.MinecraftUtil;
2021-04-24 10:33:18 +08:00
import org.apache.commons.io.FileUtils;
2016-10-18 21:48:07 +08:00
public class CustomSkinAPIPlus extends CustomSkinAPI {
2016-10-18 21:48:07 +08:00
2018-02-12 12:20:28 +08:00
private static String clientID=null;
public CustomSkinAPIPlus(){
File clientIDFile=new File(CustomSkinLoader.DATA_DIR,"CustomSkinAPIPlus-ClientID");
if(clientIDFile.isFile())
try{
2018-06-25 00:34:32 +08:00
clientID=FileUtils.readFileToString(clientIDFile, "UTF-8");
2018-02-12 12:20:28 +08:00
}catch(Exception e){
e.printStackTrace();
}
if(clientID==null){
clientID=UUID.randomUUID().toString();
try {
2018-06-25 00:34:32 +08:00
FileUtils.write(clientIDFile, clientID, "UTF-8");
2018-02-12 12:20:28 +08:00
} catch (Exception e) {
e.printStackTrace();
}
}
}
2016-10-18 21:48:07 +08:00
@Override
public List<ICustomSkinLoaderPlugin.IDefaultProfile> getDefaultProfiles(JsonAPILoader loader) {
return Lists.newArrayList();
}
2018-02-12 12:20:28 +08:00
@Override
public String getPayload(SkinSiteProfile ssp) {
2018-08-11 07:34:13 +08:00
return new Gson().toJson(new CustomSkinAPIPlusPayload());
2018-02-12 12:20:28 +08:00
}
2016-10-18 21:48:07 +08:00
2018-02-12 12:20:28 +08:00
@Override
public String getName() {
return "CustomSKinAPIPlus";
}
2016-10-18 21:48:07 +08:00
2018-02-12 12:20:28 +08:00
public static class CustomSkinAPIPlusPayload{
2018-08-11 07:34:13 +08:00
String gameVersion;//minecraft version
String modVersion;//mod version
String serverAddress;//ip:port
String clientID;//Minecraft Client ID
CustomSkinAPIPlusPayload(){
gameVersion = MinecraftUtil.getMinecraftMainVersion();
modVersion = CustomSkinLoader.CustomSkinLoader_VERSION;
serverAddress = MinecraftUtil.isLanServer() ? null : MinecraftUtil.getStandardServerAddress();
clientID = CustomSkinAPIPlus.clientID;
2018-02-12 12:20:28 +08:00
}
}
2016-10-18 21:48:07 +08:00
}