Compare commits

...
71 Commits
Author SHA1 Message Date
xfl03 42c48c5c2e Bump 14.10a 2019-03-05 19:33:09 +08:00
xfl03 030daf12a2 Fix 1.8 forge support 2019-03-04 20:12:13 +08:00
xfl03 88763d64ef Bump 14.10 2019-03-03 12:20:28 +08:00
xfl03 4f2b5edf84 Fix incorrect response code judgement 2019-03-03 11:53:48 +08:00
xfl03 cbe07b9003 Fix http redirect to https 2019-03-03 11:34:54 +08:00
xfl03 b2867a0dbf Add support for 1.13.2 forge 2019-03-02 12:26:53 +08:00
xfl03 65dacd8527 Fix javascript cannot expand 2019-03-01 20:31:23 +08:00
xfl03 d2d425e96e Remove 1.13 & 1.13.1 in settings.gradle 2019-03-01 20:10:50 +08:00
xfl03 0762e3e339 Remove support for vanilla 1.13 & 1.13.1 2019-03-01 20:08:22 +08:00
xfl03 4cb1e348bb Try to support 1.13 forge 2019-03-01 14:59:02 +08:00
Alexander Xia 7bbfd19bfd Fix no content cache 2019-02-06 00:39:17 +08:00
Alexander Xia be8b80bd55 Tweak CircleCI Docker Image 2019-01-05 00:20:22 +08:00
Alexander Xia 47de6d3a89 Add workaround for #42 2019-01-05 00:12:42 +08:00
Alexander Xia f78a3b2565 Add disable cape feature 2018-11-26 15:16:07 +08:00
Alexander Xia 016249c6ca Fix version display again 2018-11-25 02:33:12 +08:00
Alexander Xia 860edd2e1a Fix version display 2018-11-25 02:13:55 +08:00
Alexander Xia 3e6e444857 Fix gradle script buid again 2018-11-25 02:08:54 +08:00
Alexander Xia d67b7c6296 Fix gradle script buid again 2018-11-25 02:04:36 +08:00
Alexander Xia 94f6044c9a Fix gradle script build error 2018-11-25 01:53:28 +08:00
Alexander Xia 6b3531964e Tweak version json name 2018-11-25 01:44:06 +08:00
Alexander Xia fbd06f147a Modify gradle script 2018-11-24 01:38:49 +08:00
Alexander Xia e3020dad00 Add Upload Version json to COS 2018-11-23 03:23:17 +08:00
Alexander Xia 49fb976a2c Fix COS upload path 2018-11-23 02:48:19 +08:00
Alexander Xia 78bc4b5f7e Try to upload file to COS 2018-11-23 02:43:30 +08:00
Alexander Xia 7a3dc4f9c2 Support for 1.13.2 2018-11-02 14:48:07 +08:00
Alexander Xia 2087f7bb94 Tweak: Change Profile.json mirror 2018-09-23 23:44:25 +08:00
Alexander Xia e95edb16ac Add: Vanilla Support for 1.13.1 2018-09-23 23:00:34 +08:00
Alexander Xia 3b07b5ccca Update config version checker
Update config output
Add enableCape in config
2018-09-02 15:57:08 +08:00
xfl03 a3fb3cd770 Fix Build 2018-08-26 07:16:37 +08:00
xfl03 b7b59c0b85 Support ModLauncher 2018-08-26 07:04:25 +08:00
Alexander Xia db6b54732e Update MCP map to stable 2018-08-22 03:42:50 +08:00
Alexander Xia 09e3b81552 Fix path for ForgePlugin.log 2018-08-20 19:23:47 +08:00
Alexander Xia 2f494d295e Update Forge Version 2018-08-13 05:15:32 +08:00
Alexander Xia e8e3a72ae7 Add Fingerprint Violation 2018-08-13 05:11:47 +08:00
Alexander Xia ca8bd4e83d Add Profile.json for vanilla edition
Remove CustomSkinAPIPlusPrivacy
Fix typo in ReadMe
Update mcp map
2018-08-11 07:34:13 +08:00
Alexander Xia d789119c8f Get Ready for Forge 1.13 2018-07-26 20:50:41 +08:00
Alexander Xia bfd1b41ecc Update ReadMe
Thanks for @HeartyYF
2018-07-26 13:19:33 +08:00
Alexander Xia 5807acb34a Bump 14.9 2018-07-25 21:16:59 +08:00
Alexander Xia f319d535ae Merge branch '1.13-dev' into csl-14 2018-07-25 21:08:10 +08:00
Alexander Xia f669d095b6 Add Support for 1.13!
Thanks for MinecraftForge/MCPConfig.
2018-07-25 21:06:16 +08:00
Alexander Xia ca8b0ba185 Add FakeImage 2018-07-25 15:55:03 +08:00
Alexander Xia 7acef4d987 Fix Support for Java9
Add ElyBy in default load list
2018-07-20 23:23:37 +08:00
Alexander Xia 79404f659c Merge pull request #36 from andylizi/pr-replace
Replace the unnecessary `replaceAll` calls with `replace`
2018-07-13 22:36:31 +08:00
andylizi 85c86ff375 Replace the unnecessary replaceAll calls with replace 2018-07-13 19:48:02 +08:00
Alexander Xia f4030701ee Fix Legacy Texture cannot refresh in cache 2018-07-12 15:18:13 +08:00
Alexander Xia a36eca2a53 Add ElyByAPI 2018-07-09 19:53:35 +08:00
Alexander Xia 6ffdf2aafb Fix Spectator Menu totally 2018-07-02 00:15:03 +08:00
Alexander Xia fba9f7ca28 Fix head in Spectator Menu 2018-07-01 23:25:57 +08:00
Alexander Xia 2d157e3d5b Fix head is not loaded first time open Spectator Menu 2018-07-01 23:15:06 +08:00
Alexander Xia 055aef17db Fix ForgePlugin log 2018-06-25 00:56:47 +08:00
Alexander Xia 622e834d26 Make Code Better 2018-06-25 00:34:32 +08:00
Alexander Xia 469c8b62a9 Fix Noname skull load 2018-06-24 23:07:51 +08:00
Alexander Xia 1558ec819a Fix Crash in Spectator Menu 2018-06-24 22:59:46 +08:00
Alexander Xia 883e7b45fc Add skin model auto judge 2018-05-18 21:06:28 +08:00
Alexander Xia f30d3319b0 Reuse Vanilla Code 2018-05-06 01:10:55 +08:00
Alexander Xia 58276a7a0c Reuse Vanilla Code 2018-05-06 01:09:48 +08:00
Alexander Xia 883fb39380 Update Gradle Script
Fix local jsonAPI bug
https://minecraft.curseforge.com/projects/customskinloader?comment=10
2018-05-05 23:07:20 +08:00
Alexander Xia 1358a99f51 Merge pull request #35 from tnqzh123/csl-14
Update LittleSkin's API root
2018-04-10 23:39:31 +08:00
LittleStudio-Little_Qiu 47ea01dc39 Update API root 2018-04-10 23:29:45 +08:00
LittleStudio-Little_Qiu ee36f2f42a Update README.md
change link
2018-04-10 23:28:27 +08:00
Alexander Xia 5868a39adb Bump 14.8 2018-03-13 16:48:31 +08:00
Alexander Xia f7e000cb82 Add Cache for MojangAPI 2018-02-12 15:02:12 +08:00
Alexander Xia c40bb38e20 Remove Tab 2018-02-12 12:20:28 +08:00
Alexander Xia 4449ccdd45 Fix Spectator and TabIcon for non-Forge 2018-02-11 15:36:40 +08:00
Alexander Xia 67e56957e7 Fix Spectator Menu 2018-02-11 12:44:41 +08:00
Alexander Xia ea432f2405 Add more debug log 2018-02-10 21:23:58 +08:00
Alexander Xia eee978fc83 Try to fix SpectatorMenu
Forge only
2018-02-10 20:21:26 +08:00
Alexander Xia 9698d4098a Add CurseForge Url 2018-02-07 19:36:02 +08:00
Alexander Xia 3f779c9028 Try CircleCI 2 2018-02-06 07:41:18 +08:00
Alexander Xia 3945599fb4 Try CircleCI 2018-02-06 06:03:54 +08:00
Alexander Xia b50e6a934f Use both UUID and Name as credential 2018-02-03 18:40:04 +08:00
74 changed files with 4149 additions and 2541 deletions

No files matched your search

+37
View File
@@ -0,0 +1,37 @@
# Java Gradle CircleCI 2.0 configuration file
version: 2
jobs:
build:
docker:
- image: circleci/openjdk@sha256:7be33522f6f0ca65c2e78b22b1ef3e6739038494c1de1b8fb6d96da400dccf53
working_directory: ~/repo
environment:
JVM_OPTS: -Xmx3200m
TERM: dumb
steps:
- checkout
- restore_cache:
keys:
- gradle-cache
# Gradle Wrapper
# - run: sudo chmod +x gradlew
# - run: ./gradlew --version
# - run: ./gradlew clean build
# Gradle
- run: gradle --version
- run: gradle clean build
- run: gradle upload
- store_artifacts:
path: ./build/libs
- save_cache:
paths:
- ~/.gradle
key: gradle-cache
+10 -3
View File
@@ -1,3 +1,4 @@
# Java
*.class *.class
# Mobile Tools for Java (J2ME) # Mobile Tools for Java (J2ME)
@@ -11,15 +12,21 @@
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid* hs_err_pid*
#VSCode # VSCode
.vscode/ .vscode/
#eclipse # eclipse
*/.classpath */.classpath
.classpath .classpath
*/.project */.project
.project .project
.settings/ .settings/
#gradle # gradle
.gradle/ .gradle/
build/
# IDEA
.idea/
*.iml
out/
-6
View File
@@ -1,6 +0,0 @@
minecraft_version=1.12
minecraft_full_versions=1.12
#forge gradle needs forge version
forge_mc_version=1.12
forge_version=14.21.1.2387
mappings_version=snapshot_20170813
@@ -1,90 +0,0 @@
package net.minecraft.client.resources;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.common.collect.Maps;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.minecraft.InsecureTextureException;
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
import com.mojang.authlib.minecraft.MinecraftSessionService;
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import javax.annotation.Nullable;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.IImageBuffer;
import net.minecraft.client.renderer.ImageBufferDownload;
import net.minecraft.client.renderer.ThreadDownloadImageData;
import net.minecraft.client.renderer.texture.ITextureObject;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.util.ResourceLocation;
public class SkinManager
{
private static final ExecutorService THREAD_POOL = new ThreadPoolExecutor(0, 2, 1L, TimeUnit.MINUTES, new LinkedBlockingQueue());
private final TextureManager textureManager;
private final File skinCacheDir;
private final MinecraftSessionService sessionService;
private final LoadingCache<GameProfile, Map<Type, MinecraftProfileTexture>> skinCacheLoader;
private customskinloader.fake.FakeSkinManager fakeManager;//Fake Skin Manager
public SkinManager(TextureManager textureManagerInstance, File skinCacheDirectory, MinecraftSessionService sessionService)
{
this.textureManager = textureManagerInstance;
this.skinCacheDir = skinCacheDirectory;
this.sessionService = sessionService;
this.skinCacheLoader = CacheBuilder.newBuilder().expireAfterAccess(15L, TimeUnit.SECONDS).<GameProfile, Map<Type, MinecraftProfileTexture>>build(new CacheLoader<GameProfile, Map<Type, MinecraftProfileTexture>>()
{
public Map<Type, MinecraftProfileTexture> load(GameProfile p_load_1_) throws Exception
{
try
{
return Minecraft.getMinecraft().getSessionService().getTextures(p_load_1_, false);
}
catch (Throwable var3)
{
return Maps.<Type, MinecraftProfileTexture>newHashMap();
}
}
});
this.fakeManager=new customskinloader.fake.FakeSkinManager(textureManagerInstance,skinCacheDirectory,sessionService);
}
/**
* Used in the Skull renderer to fetch a skin. May download the skin if it's not in the cache
*/
public ResourceLocation loadSkin(MinecraftProfileTexture profileTexture, Type textureType)
{
return this.loadSkin(profileTexture, textureType, (SkinManager.SkinAvailableCallback)null);
}
/**
* May download the skin if its not in the cache, can be passed a SkinManager#SkinAvailableCallback for handling
*/
public ResourceLocation loadSkin(final MinecraftProfileTexture profileTexture, final Type textureType, @Nullable final SkinManager.SkinAvailableCallback skinAvailableCallback)
{
return this.fakeManager.loadSkin(profileTexture, textureType, skinAvailableCallback);
}
public void loadProfileTextures(final GameProfile profile, final SkinManager.SkinAvailableCallback skinAvailableCallback, final boolean requireSecure)
{
this.fakeManager.loadProfileTextures(profile, skinAvailableCallback, requireSecure);
}
public Map<Type, MinecraftProfileTexture> loadSkinFromCache(GameProfile profile)
{
return this.fakeManager.loadSkinFromCache(profile);
}
public interface SkinAvailableCallback
{
void skinAvailable(Type typeIn, ResourceLocation location, MinecraftProfileTexture profileTexture);
}
}
-6
View File
@@ -1,6 +0,0 @@
minecraft_version=1.12.1
minecraft_full_versions=1.12.1
#forge gradle needs forge version
forge_mc_version=1.12.1
forge_version=14.22.0.2452
mappings_version=snapshot_20170813
+2
View File
@@ -0,0 +1,2 @@
/build/
/src/main/
+458
View File
@@ -0,0 +1,458 @@
CL: net/minecraft/util/ResourceLocation pc
CL: net/minecraft/util/ResourceLocation$Serializer pc$a
CL: net/minecraft/util/StringUtils xw
CL: net/minecraft/client/Minecraft cft
CL: net/minecraft/client/Minecraft$1 cft$1
CL: net/minecraft/client/Minecraft$2 cft$2
CL: net/minecraft/client/multiplayer/ServerData crj
CL: net/minecraft/client/multiplayer/ServerData$ServerResourceMode crj$a
CL: net/minecraft/client/renderer/IImageBuffer cub
CL: net/minecraft/client/renderer/ImageBufferDownload cug
CL: net/minecraft/client/renderer/ThreadDownloadImageData ddc
CL: net/minecraft/client/renderer/ThreadDownloadImageData$1 ddc$1
CL: net/minecraft/client/renderer/texture/NativeImage ddg
CL: net/minecraft/client/renderer/texture/NativeImage$1 ddg$1
CL: net/minecraft/client/renderer/texture/NativeImage$PixelFormat ddg$a
CL: net/minecraft/client/renderer/texture/NativeImage$PixelFormatGLCode ddg$b
CL: net/minecraft/client/renderer/texture/NativeImage$WriteCallback ddg$c
CL: net/minecraft/client/renderer/texture/SimpleTexture ddi
CL: net/minecraft/client/renderer/texture/TextureManager ddn
CL: net/minecraft/client/renderer/texture/ITextureObject ddo
CL: net/minecraft/client/resources/DefaultPlayerSkin dec
CL: net/minecraft/client/resources/SkinManager deh
CL: net/minecraft/client/resources/SkinManager$1 deh$1
CL: net/minecraft/client/resources/SkinManager$2 deh$2
CL: net/minecraft/client/resources/SkinManager$SkinAvailableCallback deh$a
FD: net/minecraft/util/ResourceLocation/field_110626_a pc/a
FD: net/minecraft/util/ResourceLocation/field_110625_b pc/b
FD: net/minecraft/util/ResourceLocation/field_200118_c pc/c
FD: net/minecraft/util/StringUtils/field_76339_a xw/a
FD: net/minecraft/client/Minecraft$1/field_74532_a cft$1/a
FD: net/minecraft/client/Minecraft$2/field_210222_a cft$2/a
FD: net/minecraft/client/Minecraft$2/field_210223_b cft$2/b
FD: net/minecraft/client/Minecraft/field_175612_E cft/D
FD: net/minecraft/client/Minecraft/field_195555_I cft/E
FD: net/minecraft/client/Minecraft/field_147123_G cft/F
FD: net/minecraft/client/Minecraft/field_211120_F cft/G
FD: net/minecraft/client/Minecraft/field_130070_K cft/H
FD: net/minecraft/client/Minecraft/field_181038_N cft/I
FD: net/minecraft/client/Minecraft/field_195556_O cft/J
FD: net/minecraft/client/Minecraft/field_71422_O cft/K
FD: net/minecraft/client/Minecraft/field_71446_o cft/L
FD: net/minecraft/client/Minecraft/field_71432_P cft/M
FD: net/minecraft/client/Minecraft/field_184131_U cft/N
FD: net/minecraft/client/Minecraft/field_195557_T cft/O
FD: net/minecraft/client/Minecraft/field_71434_R cft/P
FD: net/minecraft/client/Minecraft/field_71433_S cft/Q
FD: net/minecraft/client/Minecraft/field_181541_X cft/R
FD: net/minecraft/client/Minecraft/field_71428_T cft/S
FD: net/minecraft/client/Minecraft/field_71427_U cft/T
FD: net/minecraft/client/Minecraft/field_175616_W cft/U
FD: net/minecraft/client/Minecraft/field_175621_X cft/V
FD: net/minecraft/client/Minecraft/field_175620_Y cft/W
FD: net/minecraft/client/Minecraft/field_175622_Z cft/X
FD: net/minecraft/client/Minecraft/field_193995_ae cft/Y
FD: net/minecraft/client/Minecraft/field_71449_j cft/Z
FD: net/minecraft/client/Minecraft/field_142025_a cft/a
FD: net/minecraft/client/Minecraft/field_211502_b cft/b
FD: net/minecraft/client/Minecraft/field_71464_q cft/c
FD: net/minecraft/client/Minecraft/field_71444_a cft/d
FD: net/minecraft/client/Minecraft/field_71442_b cft/e
FD: net/minecraft/client/Minecraft/field_195558_d cft/f
FD: net/minecraft/client/Minecraft/field_71441_e cft/g
FD: net/minecraft/client/Minecraft/field_71438_f cft/h
FD: net/minecraft/client/Minecraft/field_71439_g cft/i
FD: net/minecraft/client/Minecraft/field_147125_j cft/j
FD: net/minecraft/client/Minecraft/field_71452_i cft/k
FD: net/minecraft/client/Minecraft/field_71466_p cft/l
FD: net/minecraft/client/Minecraft/field_71462_r cft/m
FD: net/minecraft/client/Minecraft/field_71460_t cft/n
FD: net/minecraft/client/Minecraft/field_184132_p cft/o
FD: net/minecraft/client/Minecraft/field_71429_W cft/p
FD: net/minecraft/client/Minecraft/field_71456_v cft/q
FD: net/minecraft/client/Minecraft/field_71454_w cft/r
FD: net/minecraft/client/Minecraft/field_71476_x cft/s
FD: net/minecraft/client/Minecraft/field_71474_y cft/t
FD: net/minecraft/client/Minecraft/field_71417_B cft/u
FD: net/minecraft/client/Minecraft/field_195559_v cft/v
FD: net/minecraft/client/Minecraft/field_71412_D cft/w
FD: net/minecraft/client/Minecraft/field_181542_y cft/x
FD: net/minecraft/client/Minecraft/field_71424_I cft/y
FD: net/minecraft/client/Minecraft/field_71426_K cft/z
FD: net/minecraft/client/Minecraft/field_147128_au cft/aA
FD: net/minecraft/client/Minecraft/field_147127_av cft/aB
FD: net/minecraft/client/Minecraft/field_147126_aw cft/aC
FD: net/minecraft/client/Minecraft/field_211501_aD cft/aD
FD: net/minecraft/client/Minecraft/field_152355_az cft/aE
FD: net/minecraft/client/Minecraft/field_152350_aA cft/aF
FD: net/minecraft/client/Minecraft/field_152351_aB cft/aG
FD: net/minecraft/client/Minecraft/field_152352_aC cft/aH
FD: net/minecraft/client/Minecraft/field_175617_aL cft/aI
FD: net/minecraft/client/Minecraft/field_175618_aM cft/aJ
FD: net/minecraft/client/Minecraft/field_193034_aS cft/aK
FD: net/minecraft/client/Minecraft/field_71425_J cft/aL
FD: net/minecraft/client/Minecraft/field_71419_L cft/aM
FD: net/minecraft/client/Minecraft/field_71420_M cft/aN
FD: net/minecraft/client/Minecraft/field_193035_aW cft/aO
FD: net/minecraft/client/Minecraft/field_71465_an cft/aP
FD: net/minecraft/client/Minecraft/field_71445_n cft/aa
FD: net/minecraft/client/Minecraft/field_193996_ah cft/ab
FD: net/minecraft/client/Minecraft/field_71437_Z cft/ac
FD: net/minecraft/client/Minecraft/field_191950_u cft/ad
FD: net/minecraft/client/Minecraft/field_110446_Y cft/ae
FD: net/minecraft/client/Minecraft/field_110447_Z cft/af
FD: net/minecraft/client/Minecraft/field_184130_ao cft/ag
FD: net/minecraft/client/Minecraft/field_110453_aa cft/ah
FD: net/minecraft/client/Minecraft/field_71469_aa cft/ai
FD: net/minecraft/client/Minecraft/field_71470_ab cft/aj
FD: net/minecraft/client/Minecraft/field_71467_ac cft/ak
FD: net/minecraft/client/Minecraft/field_71475_ae cft/al
FD: net/minecraft/client/Minecraft/field_71477_af cft/am
FD: net/minecraft/client/Minecraft/field_71457_ai cft/an
FD: net/minecraft/client/Minecraft/field_181543_z cft/ao
FD: net/minecraft/client/Minecraft/field_147129_ai cft/ap
FD: net/minecraft/client/Minecraft/field_71459_aj cft/aq
FD: net/minecraft/client/Minecraft/field_71453_ak cft/ar
FD: net/minecraft/client/Minecraft/field_71455_al cft/as
FD: net/minecraft/client/Minecraft/field_110451_am cft/at
FD: net/minecraft/client/Minecraft/field_195554_ax cft/au
FD: net/minecraft/client/Minecraft/field_110448_aq cft/av
FD: net/minecraft/client/Minecraft/field_135017_as cft/aw
FD: net/minecraft/client/Minecraft/field_184127_aH cft/ax
FD: net/minecraft/client/Minecraft/field_184128_aI cft/ay
FD: net/minecraft/client/Minecraft/field_147124_at cft/az
FD: net/minecraft/client/multiplayer/ServerData$ServerResourceMode/ENABLED crj$a/a
FD: net/minecraft/client/multiplayer/ServerData$ServerResourceMode/DISABLED crj$a/b
FD: net/minecraft/client/multiplayer/ServerData$ServerResourceMode/PROMPT crj$a/c
FD: net/minecraft/client/multiplayer/ServerData$ServerResourceMode/field_152594_d crj$a/d
FD: net/minecraft/client/multiplayer/ServerData$ServerResourceMode/$VALUES crj$a/e
FD: net/minecraft/client/multiplayer/ServerData/field_78847_a crj/a
FD: net/minecraft/client/multiplayer/ServerData/field_78845_b crj/b
FD: net/minecraft/client/multiplayer/ServerData/field_78846_c crj/c
FD: net/minecraft/client/multiplayer/ServerData/field_78843_d crj/d
FD: net/minecraft/client/multiplayer/ServerData/field_78844_e crj/e
FD: net/minecraft/client/multiplayer/ServerData/field_82821_f crj/f
FD: net/minecraft/client/multiplayer/ServerData/field_82822_g crj/g
FD: net/minecraft/client/multiplayer/ServerData/field_78841_f crj/h
FD: net/minecraft/client/multiplayer/ServerData/field_147412_i crj/i
FD: net/minecraft/client/multiplayer/ServerData/field_152587_j crj/j
FD: net/minecraft/client/multiplayer/ServerData/field_147411_m crj/k
FD: net/minecraft/client/multiplayer/ServerData/field_181042_l crj/l
FD: net/minecraft/client/renderer/ThreadDownloadImageData$1/field_110932_a ddc$1/a
FD: net/minecraft/client/renderer/ThreadDownloadImageData/field_147644_c ddc/g
FD: net/minecraft/client/renderer/ThreadDownloadImageData/field_147643_d ddc/h
FD: net/minecraft/client/renderer/ThreadDownloadImageData/field_152434_e ddc/i
FD: net/minecraft/client/renderer/ThreadDownloadImageData/field_110562_b ddc/j
FD: net/minecraft/client/renderer/ThreadDownloadImageData/field_110563_c ddc/k
FD: net/minecraft/client/renderer/ThreadDownloadImageData/field_110561_e ddc/l
FD: net/minecraft/client/renderer/ThreadDownloadImageData/field_110559_g ddc/m
FD: net/minecraft/client/renderer/texture/NativeImage$PixelFormat/RGBA ddg$a/a
FD: net/minecraft/client/renderer/texture/NativeImage$PixelFormat/RGB ddg$a/b
FD: net/minecraft/client/renderer/texture/NativeImage$PixelFormat/LUMINANCE_ALPHA ddg$a/c
FD: net/minecraft/client/renderer/texture/NativeImage$PixelFormat/LUMINANCE ddg$a/d
FD: net/minecraft/client/renderer/texture/NativeImage$PixelFormat/field_211659_e ddg$a/e
FD: net/minecraft/client/renderer/texture/NativeImage$PixelFormat/field_211660_f ddg$a/f
FD: net/minecraft/client/renderer/texture/NativeImage$PixelFormat/field_211661_g ddg$a/g
FD: net/minecraft/client/renderer/texture/NativeImage$PixelFormat/field_211662_h ddg$a/h
FD: net/minecraft/client/renderer/texture/NativeImage$PixelFormat/field_211663_i ddg$a/i
FD: net/minecraft/client/renderer/texture/NativeImage$PixelFormat/field_211664_j ddg$a/j
FD: net/minecraft/client/renderer/texture/NativeImage$PixelFormat/field_211665_k ddg$a/k
FD: net/minecraft/client/renderer/texture/NativeImage$PixelFormat/field_211666_l ddg$a/l
FD: net/minecraft/client/renderer/texture/NativeImage$PixelFormat/field_211667_m ddg$a/m
FD: net/minecraft/client/renderer/texture/NativeImage$PixelFormat/field_211668_n ddg$a/n
FD: net/minecraft/client/renderer/texture/NativeImage$PixelFormat/field_211669_o ddg$a/o
FD: net/minecraft/client/renderer/texture/NativeImage$PixelFormat/field_211670_p ddg$a/p
FD: net/minecraft/client/renderer/texture/NativeImage$PixelFormat/field_211671_q ddg$a/q
FD: net/minecraft/client/renderer/texture/NativeImage$PixelFormat/$VALUES ddg$a/r
FD: net/minecraft/client/renderer/texture/NativeImage$PixelFormatGLCode/RGBA ddg$b/a
FD: net/minecraft/client/renderer/texture/NativeImage$PixelFormatGLCode/RGB ddg$b/b
FD: net/minecraft/client/renderer/texture/NativeImage$PixelFormatGLCode/LUMINANCE_ALPHA ddg$b/c
FD: net/minecraft/client/renderer/texture/NativeImage$PixelFormatGLCode/LUMINANCE ddg$b/d
FD: net/minecraft/client/renderer/texture/NativeImage$PixelFormatGLCode/INTENSITY ddg$b/e
FD: net/minecraft/client/renderer/texture/NativeImage$PixelFormatGLCode/field_211673_f ddg$b/f
FD: net/minecraft/client/renderer/texture/NativeImage$PixelFormatGLCode/$VALUES ddg$b/g
FD: net/minecraft/client/renderer/texture/NativeImage$WriteCallback/field_209268_a ddg$c/a
FD: net/minecraft/client/renderer/texture/NativeImage$WriteCallback/field_209269_b ddg$c/b
FD: net/minecraft/client/renderer/texture/NativeImage/field_209272_a ddg/a
FD: net/minecraft/client/renderer/texture/NativeImage/field_211680_b ddg/b
FD: net/minecraft/client/renderer/texture/NativeImage/field_195719_a ddg/c
FD: net/minecraft/client/renderer/texture/NativeImage/field_195720_b ddg/d
FD: net/minecraft/client/renderer/texture/NativeImage/field_195721_c ddg/e
FD: net/minecraft/client/renderer/texture/NativeImage/field_195722_d ddg/f
FD: net/minecraft/client/renderer/texture/NativeImage/field_195723_e ddg/g
FD: net/minecraft/client/renderer/texture/SimpleTexture/field_110568_b ddi/f
FD: net/minecraft/client/renderer/texture/SimpleTexture/field_147639_c ddi/g
FD: net/minecraft/client/renderer/texture/TextureManager/field_194008_a ddn/a
FD: net/minecraft/client/renderer/texture/TextureManager/field_147646_a ddn/b
FD: net/minecraft/client/renderer/texture/TextureManager/field_110585_a ddn/c
FD: net/minecraft/client/renderer/texture/TextureManager/field_110583_b ddn/d
FD: net/minecraft/client/renderer/texture/TextureManager/field_110584_c ddn/e
FD: net/minecraft/client/renderer/texture/TextureManager/field_110582_d ddn/f
FD: net/minecraft/client/resources/DefaultPlayerSkin/field_177337_a dec/a
FD: net/minecraft/client/resources/DefaultPlayerSkin/field_177336_b dec/b
FD: net/minecraft/client/resources/SkinManager$1/field_152787_a deh$1/a
FD: net/minecraft/client/resources/SkinManager$2/field_152635_a deh$2/a
FD: net/minecraft/client/resources/SkinManager$2/field_152636_b deh$2/b
FD: net/minecraft/client/resources/SkinManager$2/field_152637_c deh$2/c
FD: net/minecraft/client/resources/SkinManager$2/field_152638_d deh$2/d
FD: net/minecraft/client/resources/SkinManager$2/field_177249_e deh$2/e
FD: net/minecraft/client/resources/SkinManager$2/field_152639_e deh$2/f
FD: net/minecraft/client/resources/SkinManager/field_152794_b deh/a
FD: net/minecraft/client/resources/SkinManager/field_152795_c deh/b
FD: net/minecraft/client/resources/SkinManager/field_152796_d deh/c
FD: net/minecraft/client/resources/SkinManager/field_152797_e deh/d
FD: net/minecraft/client/resources/SkinManager/field_152798_f deh/e
MD: net/minecraft/util/ResourceLocation$Serializer/deserialize (Lcom/google/gson/JsonElement;Ljava/lang/reflect/Type;Lcom/google/gson/JsonDeserializationContext;)Lnet/minecraft/util/ResourceLocation; pc$a/a (Lcom/google/gson/JsonElement;Ljava/lang/reflect/Type;Lcom/google/gson/JsonDeserializationContext;)Lpc;
MD: net/minecraft/util/ResourceLocation$Serializer/serialize (Lnet/minecraft/util/ResourceLocation;Ljava/lang/reflect/Type;Lcom/google/gson/JsonSerializationContext;)Lcom/google/gson/JsonElement; pc$a/a (Lpc;Ljava/lang/reflect/Type;Lcom/google/gson/JsonSerializationContext;)Lcom/google/gson/JsonElement;
MD: net/minecraft/util/ResourceLocation$Serializer/serialize (Ljava/lang/Object;Ljava/lang/reflect/Type;Lcom/google/gson/JsonSerializationContext;)Lcom/google/gson/JsonElement; pc$a/serialize (Ljava/lang/Object;Ljava/lang/reflect/Type;Lcom/google/gson/JsonSerializationContext;)Lcom/google/gson/JsonElement;
MD: net/minecraft/util/ResourceLocation$Serializer/deserialize (Lcom/google/gson/JsonElement;Ljava/lang/reflect/Type;Lcom/google/gson/JsonDeserializationContext;)Ljava/lang/Object; pc$a/deserialize (Lcom/google/gson/JsonElement;Ljava/lang/reflect/Type;Lcom/google/gson/JsonDeserializationContext;)Ljava/lang/Object;
MD: net/minecraft/util/ResourceLocation/func_110623_a ()Ljava/lang/String; pc/a ()Ljava/lang/String;
MD: net/minecraft/util/ResourceLocation/func_195824_a (C)Z pc/a (C)Z
MD: net/minecraft/util/ResourceLocation/func_195827_a (I)Z pc/a (I)Z
MD: net/minecraft/util/ResourceLocation/func_195826_a (Lcom/mojang/brigadier/StringReader;)Lnet/minecraft/util/ResourceLocation; pc/a (Lcom/mojang/brigadier/StringReader;)Lpc;
MD: net/minecraft/util/ResourceLocation/func_208304_a (Ljava/lang/String;)Lnet/minecraft/util/ResourceLocation; pc/a (Ljava/lang/String;)Lpc;
MD: net/minecraft/util/ResourceLocation/func_195828_a (Ljava/lang/String;C)Lnet/minecraft/util/ResourceLocation; pc/a (Ljava/lang/String;C)Lpc;
MD: net/minecraft/util/ResourceLocation/compareTo (Lnet/minecraft/util/ResourceLocation;)I pc/a (Lpc;)I
MD: net/minecraft/util/ResourceLocation/func_110624_b ()Ljava/lang/String; pc/b ()Ljava/lang/String;
MD: net/minecraft/util/ResourceLocation/func_195825_b (I)Z pc/b (I)Z
MD: net/minecraft/util/ResourceLocation/func_195823_b (Ljava/lang/String;C)[Ljava/lang/String; pc/b (Ljava/lang/String;C)[Ljava/lang/String;
MD: net/minecraft/util/ResourceLocation/equals (Ljava/lang/Object;)Z pc/equals (Ljava/lang/Object;)Z
MD: net/minecraft/util/ResourceLocation/hashCode ()I pc/hashCode ()I
MD: net/minecraft/util/ResourceLocation/toString ()Ljava/lang/String; pc/toString ()Ljava/lang/String;
MD: net/minecraft/util/ResourceLocation/compareTo (Ljava/lang/Object;)I pc/compareTo (Ljava/lang/Object;)I
MD: net/minecraft/util/StringUtils/func_76337_a (I)Ljava/lang/String; xw/a (I)Ljava/lang/String;
MD: net/minecraft/util/StringUtils/func_76338_a (Ljava/lang/String;)Ljava/lang/String; xw/a (Ljava/lang/String;)Ljava/lang/String;
MD: net/minecraft/util/StringUtils/func_151246_b (Ljava/lang/String;)Z xw/b (Ljava/lang/String;)Z
MD: net/minecraft/client/Minecraft$1/run ()V cft$1/run ()V
MD: net/minecraft/client/Minecraft/func_71378_E ()Lnet/minecraft/profiler/Snooper; cft/A ()Ladu;
MD: net/minecraft/client/Minecraft/func_110432_I ()Lnet/minecraft/util/Session; cft/B ()Lcga;
MD: net/minecraft/client/Minecraft/func_181037_M ()Lcom/mojang/authlib/properties/PropertyMap; cft/C ()Lcom/mojang/authlib/properties/PropertyMap;
MD: net/minecraft/client/Minecraft/func_110437_J ()Ljava/net/Proxy; cft/D ()Ljava/net/Proxy;
MD: net/minecraft/client/Minecraft/func_110434_K ()Lnet/minecraft/client/renderer/texture/TextureManager; cft/E ()Lddn;
MD: net/minecraft/client/Minecraft/func_195551_G ()Lnet/minecraft/resources/IResourceManager; cft/F ()Lvf;
MD: net/minecraft/client/Minecraft/func_195548_H ()Lnet/minecraft/resources/ResourcePackList; cft/G ()Lux;
MD: net/minecraft/client/Minecraft/func_195541_I ()Lnet/minecraft/client/resources/DownloadingPackFinder; cft/H ()Ldea;
MD: net/minecraft/client/Minecraft/func_195549_J ()Ljava/io/File; cft/I ()Ljava/io/File;
MD: net/minecraft/client/Minecraft/func_135016_M ()Lnet/minecraft/client/resources/LanguageManager; cft/J ()Ldel;
MD: net/minecraft/client/Minecraft/func_147117_R ()Lnet/minecraft/client/renderer/texture/TextureMap; cft/K ()Lddl;
MD: net/minecraft/client/Minecraft/func_147111_S ()Z cft/L ()Z
MD: net/minecraft/client/Minecraft/func_147113_T ()Z cft/M ()Z
MD: net/minecraft/client/Minecraft/func_147118_V ()Lnet/minecraft/client/audio/SoundHandler; cft/N ()Ldgt;
MD: net/minecraft/client/Minecraft/func_147109_W ()Lnet/minecraft/client/audio/MusicTicker$MusicType; cft/O ()Ldgq$a;
MD: net/minecraft/client/Minecraft/func_70002_Q ()Z cft/P ()Z
MD: net/minecraft/client/Minecraft/func_152347_ac ()Lcom/mojang/authlib/minecraft/MinecraftSessionService; cft/Q ()Lcom/mojang/authlib/minecraft/MinecraftSessionService;
MD: net/minecraft/client/Minecraft/func_152342_ad ()Lnet/minecraft/client/resources/SkinManager; cft/R ()Ldeh;
MD: net/minecraft/client/Minecraft/func_175606_aa ()Lnet/minecraft/entity/Entity; cft/S ()Laer;
MD: net/minecraft/client/Minecraft/func_175602_ab ()Lnet/minecraft/client/renderer/BlockRendererDispatcher; cft/T ()Lcuu;
MD: net/minecraft/client/Minecraft/func_175598_ae ()Lnet/minecraft/client/renderer/entity/RenderManager; cft/U ()Lcyo;
MD: net/minecraft/client/Minecraft/func_175599_af ()Lnet/minecraft/client/renderer/ItemRenderer; cft/V ()Lczg;
MD: net/minecraft/client/Minecraft/func_175597_ag ()Lnet/minecraft/client/renderer/FirstPersonRenderer; cft/W ()Lcuc;
MD: net/minecraft/client/Minecraft/func_175610_ah ()I cft/X ()I
MD: net/minecraft/client/Minecraft/func_181539_aj ()Lnet/minecraft/util/FrameTimer; cft/Y ()Lxi;
MD: net/minecraft/client/Minecraft/func_181540_al ()Z cft/Z ()Z
MD: net/minecraft/client/Minecraft/func_99999_d ()V cft/a ()V
MD: net/minecraft/client/Minecraft/func_71383_b (I)V cft/a (I)V
MD: net/minecraft/client/Minecraft/func_181536_a (IIIIIIIIII)V cft/a (IIIIIIIIII)V
MD: net/minecraft/client/Minecraft/func_195545_a (IJ)V cft/a (IJ)V
MD: net/minecraft/client/Minecraft/func_70000_a (Lnet/minecraft/profiler/Snooper;)V cft/a (Ladu;)V
MD: net/minecraft/client/Minecraft/func_175607_a (Lnet/minecraft/entity/Entity;)V cft/a (Laer;)V
MD: net/minecraft/client/Minecraft/func_193985_a (Lnet/minecraft/item/ItemStack;)Ljava/lang/Iterable; cft/a (Late;)Ljava/lang/Iterable;
MD: net/minecraft/client/Minecraft/func_184119_a (Lnet/minecraft/item/ItemStack;Lnet/minecraft/tileentity/TileEntity;)Lnet/minecraft/item/ItemStack; cft/a (Late;Lbji;)Late;
MD: net/minecraft/client/Minecraft/func_200237_a (Lnet/minecraft/item/crafting/IRecipe;)Lnet/minecraft/util/ResourceLocation; cft/a (Lavk;)Lpc;
MD: net/minecraft/client/Minecraft/func_71404_a (Lnet/minecraft/crash/CrashReport;)V cft/a (Lb;)V
MD: net/minecraft/client/Minecraft/func_212315_a (Lnet/minecraft/world/dimension/DimensionType;)V cft/a (Lbod;)V
MD: net/minecraft/client/Minecraft/access$000 (Lnet/minecraft/client/Minecraft;)Z cft/a (Lcft;)Z
MD: net/minecraft/client/Minecraft/func_147108_a (Lnet/minecraft/client/gui/GuiScreen;)V cft/a (Lckd;)V
MD: net/minecraft/client/Minecraft/func_193992_a (Lnet/minecraft/client/gui/recipebook/RecipeList;)Ljava/lang/Iterable; cft/a (Lcmk;)Ljava/lang/Iterable;
MD: net/minecraft/client/Minecraft/func_71403_a (Lnet/minecraft/client/multiplayer/WorldClient;)V cft/a (Lcrg;)V
MD: net/minecraft/client/Minecraft/func_205055_a (Lnet/minecraft/client/multiplayer/WorldClient;Lnet/minecraft/client/gui/GuiScreen;)V cft/a (Lcrg;Lckd;)V
MD: net/minecraft/client/Minecraft/func_71351_a (Lnet/minecraft/client/multiplayer/ServerData;)V cft/a (Lcrj;)V
MD: net/minecraft/client/Minecraft/func_193987_a (Lnet/minecraft/client/util/SearchTreeManager$Key;)Lnet/minecraft/client/util/ISearchTree; cft/a (Ldgc$a;)Ldgd;
MD: net/minecraft/client/Minecraft/func_209507_a (Lnet/minecraft/util/text/ITextComponent;)V cft/a (Lij;)V
MD: net/minecraft/client/Minecraft/func_211108_a (Ljava/lang/Integer;Ljava/lang/String;)V cft/a (Ljava/lang/Integer;Ljava/lang/String;)V
MD: net/minecraft/client/Minecraft/func_152344_a (Ljava/lang/Runnable;)Lcom/google/common/util/concurrent/ListenableFuture; cft/a (Ljava/lang/Runnable;)Lcom/google/common/util/concurrent/ListenableFuture;
MD: net/minecraft/client/Minecraft/func_200234_a (Ljava/lang/String;)Z cft/a (Ljava/lang/String;)Z
MD: net/minecraft/client/Minecraft/func_71371_a (Ljava/lang/String;Ljava/lang/String;Lnet/minecraft/world/WorldSettings;)V cft/a (Ljava/lang/String;Ljava/lang/String;Layd;)V
MD: net/minecraft/client/Minecraft/func_211818_a (Ljava/lang/String;ZLjava/util/function/Supplier;Lnet/minecraft/resources/IResourcePack;Lnet/minecraft/resources/data/PackMetadataSection;Lnet/minecraft/resources/ResourcePackInfo$Priority;)Lnet/minecraft/client/resources/ResourcePackInfoClient; cft/a (Ljava/lang/String;ZLjava/util/function/Supplier;Lul;Luq;Lva$a;)Ldei;
MD: net/minecraft/client/Minecraft/func_211100_a (Ljava/util/List;IJ)V cft/a (Ljava/util/List;IJ)V
MD: net/minecraft/client/Minecraft/func_152343_a (Ljava/util/concurrent/Callable;)Lcom/google/common/util/concurrent/ListenableFuture; cft/a (Ljava/util/concurrent/Callable;)Lcom/google/common/util/concurrent/ListenableFuture;
MD: net/minecraft/client/Minecraft/func_211809_a (Ljava/util/function/Supplier;)Lnet/minecraft/resources/IResourcePack; cft/a (Ljava/util/function/Supplier;)Lul;
MD: net/minecraft/client/Minecraft/func_181537_a (Z)V cft/a (Z)V
MD: net/minecraft/client/Minecraft/func_147110_a ()Lnet/minecraft/client/shader/Framebuffer; cft/b ()Lcul;
MD: net/minecraft/client/Minecraft/func_193988_b (Lnet/minecraft/item/ItemStack;)Ljava/lang/Iterable; cft/b (Late;)Ljava/lang/Iterable;
MD: net/minecraft/client/Minecraft/func_200240_b (Lnet/minecraft/item/crafting/IRecipe;)Ljava/util/stream/Stream; cft/b (Lavk;)Ljava/util/stream/Stream;
MD: net/minecraft/client/Minecraft/func_71396_d (Lnet/minecraft/crash/CrashReport;)Lnet/minecraft/crash/CrashReport; cft/b (Lb;)Lb;
MD: net/minecraft/client/Minecraft/func_193990_a (Lnet/minecraft/client/gui/recipebook/RecipeList;)Ljava/lang/Iterable; cft/b (Lcmk;)Ljava/lang/Iterable;
MD: net/minecraft/client/Minecraft/func_200235_b (Lnet/minecraft/util/text/ITextComponent;)Ljava/lang/String; cft/b (Lij;)Ljava/lang/String;
MD: net/minecraft/client/Minecraft/func_200241_b (Ljava/lang/String;)Z cft/b (Ljava/lang/String;)Z
MD: net/minecraft/client/Minecraft/func_175600_c ()Ljava/lang/String; cft/c ()Ljava/lang/String;
MD: net/minecraft/client/Minecraft/func_71377_b (Lnet/minecraft/crash/CrashReport;)V cft/c (Lb;)V
MD: net/minecraft/client/Minecraft/func_211817_c (Lnet/minecraft/util/text/ITextComponent;)Ljava/lang/String; cft/c (Lij;)Ljava/lang/String;
MD: net/minecraft/client/Minecraft/func_195542_b (Z)V cft/c (Z)V
MD: net/minecraft/client/Minecraft/func_184123_d ()Ljava/lang/String; cft/d ()Ljava/lang/String;
MD: net/minecraft/client/Minecraft/func_147115_a (Z)V cft/d (Z)V
MD: net/minecraft/client/Minecraft/func_211821_e ()Z cft/e ()Z
MD: net/minecraft/client/Minecraft/func_110436_a ()V cft/f ()V
MD: net/minecraft/client/Minecraft/func_71359_d ()Lnet/minecraft/world/storage/ISaveFormat; cft/g ()Lcce;
MD: net/minecraft/client/Minecraft/func_71405_e ()V cft/h ()V
MD: net/minecraft/client/Minecraft/func_71398_f ()V cft/i ()V
MD: net/minecraft/client/Minecraft/func_71400_g ()V cft/j ()V
MD: net/minecraft/client/Minecraft/func_71385_j ()V cft/k ()V
MD: net/minecraft/client/Minecraft/func_181535_r ()Lnet/minecraft/client/audio/MusicTicker; cft/l ()Ldgq;
MD: net/minecraft/client/Minecraft/func_71407_l ()V cft/m ()V
MD: net/minecraft/client/Minecraft/func_71355_q ()Z cft/n ()Z
MD: net/minecraft/client/Minecraft/func_147114_u ()Lnet/minecraft/client/network/NetHandlerPlayClient; cft/o ()Lcrd;
MD: net/minecraft/client/Minecraft/func_71382_s ()Z cft/p ()Z
MD: net/minecraft/client/Minecraft/func_71375_t ()Z cft/q ()Z
MD: net/minecraft/client/Minecraft/func_71379_u ()Z cft/r ()Z
MD: net/minecraft/client/Minecraft/func_71410_x ()Lnet/minecraft/client/Minecraft; cft/s ()Lcft;
MD: net/minecraft/client/Minecraft/func_175603_A ()Lcom/google/common/util/concurrent/ListenableFuture; cft/t ()Lcom/google/common/util/concurrent/ListenableFuture;
MD: net/minecraft/client/Minecraft/func_71369_N ()I cft/u ()I
MD: net/minecraft/client/Minecraft/func_147104_D ()Lnet/minecraft/client/multiplayer/ServerData; cft/v ()Lcrj;
MD: net/minecraft/client/Minecraft/func_71387_A ()Z cft/w ()Z
MD: net/minecraft/client/Minecraft/func_71356_B ()Z cft/x ()Z
MD: net/minecraft/client/Minecraft/func_71401_C ()Lnet/minecraft/server/integrated/IntegratedServer; cft/y ()Ldgh;
MD: net/minecraft/client/Minecraft/func_71363_D ()V cft/z ()V
MD: net/minecraft/client/Minecraft/func_211816_aA ()Ljava/lang/String; cft/aA ()Ljava/lang/String;
MD: net/minecraft/client/Minecraft/func_211112_aw ()Ljava/lang/String; cft/aB ()Ljava/lang/String;
MD: net/minecraft/client/Minecraft/func_211115_ay ()Ljava/lang/String; cft/aC ()Ljava/lang/String;
MD: net/minecraft/client/Minecraft/func_211117_az ()Ljava/lang/String; cft/aD ()Ljava/lang/String;
MD: net/minecraft/client/Minecraft/func_210110_az ()Ljava/lang/String; cft/aE ()Ljava/lang/String;
MD: net/minecraft/client/Minecraft/func_210108_aA ()Ljava/lang/String; cft/aF ()Ljava/lang/String;
MD: net/minecraft/client/Minecraft/func_212317_aG ()Z cft/aG ()Z
MD: net/minecraft/client/Minecraft/func_212316_aH ()V cft/aH ()V
MD: net/minecraft/client/Minecraft/func_211813_aH ()J cft/aI ()J
MD: net/minecraft/client/Minecraft/func_184126_aj ()Lcom/mojang/datafixers/DataFixer; cft/aa ()Lcom/mojang/datafixers/DataFixer;
MD: net/minecraft/client/Minecraft/func_184121_ak ()F cft/ab ()F
MD: net/minecraft/client/Minecraft/func_193989_ak ()F cft/ac ()F
MD: net/minecraft/client/Minecraft/func_184125_al ()Lnet/minecraft/client/renderer/color/BlockColors; cft/ad ()Lcgf;
MD: net/minecraft/client/Minecraft/func_189648_am ()Z cft/af ()Z
MD: net/minecraft/client/Minecraft/func_193033_an ()Lnet/minecraft/client/gui/toasts/GuiToast; cft/ag ()Lcib;
MD: net/minecraft/client/Minecraft/func_193032_ao ()Lnet/minecraft/client/tutorial/Tutorial; cft/ah ()Ldhe;
MD: net/minecraft/client/Minecraft/func_195544_aj ()Z cft/ai ()Z
MD: net/minecraft/client/Minecraft/func_199403_al ()Lnet/minecraft/client/settings/CreativeSettings; cft/aj ()Lcfn;
MD: net/minecraft/client/Minecraft/func_209506_al ()Lnet/minecraft/client/renderer/model/ModelManager; cft/ak ()Ldfd;
MD: net/minecraft/client/Minecraft/func_211500_ak ()Lnet/minecraft/client/gui/fonts/FontResourceManager; cft/al ()Lcif;
MD: net/minecraft/client/Minecraft/func_71384_a ()V cft/am ()V
MD: net/minecraft/client/Minecraft/func_211118_al ()V cft/an ()V
MD: net/minecraft/client/Minecraft/func_193986_ar ()V cft/ao ()V
MD: net/minecraft/client/Minecraft/func_147122_X ()Z cft/ap ()Z
MD: net/minecraft/client/Minecraft/func_71389_H ()V cft/aq ()V
MD: net/minecraft/client/Minecraft/func_195547_ap ()V cft/ar ()V
MD: net/minecraft/client/Minecraft/func_203410_as ()V cft/as ()V
MD: net/minecraft/client/Minecraft/func_147116_af ()V cft/at ()V
MD: net/minecraft/client/Minecraft/func_147121_ag ()V cft/au ()V
MD: net/minecraft/client/Minecraft/func_152345_ab ()Z cft/av ()Z
MD: net/minecraft/client/Minecraft/func_184117_aA ()V cft/aw ()V
MD: net/minecraft/client/Minecraft/func_147112_ai ()V cft/ax ()V
MD: net/minecraft/client/Minecraft/func_181538_aA ()Ljava/lang/String; cft/ay ()Ljava/lang/String;
MD: net/minecraft/client/Minecraft/func_211822_az ()Ljava/lang/String; cft/az ()Ljava/lang/String;
MD: net/minecraft/client/Minecraft/getFocused ()Lnet/minecraft/client/gui/IGuiEventListener; cft/getFocused ()Lchr;
MD: net/minecraft/client/multiplayer/ServerData$ServerResourceMode/func_152589_a ()Lnet/minecraft/util/text/ITextComponent; crj$a/a ()Lij;
MD: net/minecraft/client/multiplayer/ServerData$ServerResourceMode/values ()[Lnet/minecraft/client/multiplayer/ServerData$ServerResourceMode; crj$a/values ()[Lcrj$a;
MD: net/minecraft/client/multiplayer/ServerData$ServerResourceMode/valueOf (Ljava/lang/String;)Lnet/minecraft/client/multiplayer/ServerData$ServerResourceMode; crj$a/valueOf (Ljava/lang/String;)Lcrj$a;
MD: net/minecraft/client/multiplayer/ServerData/func_78836_a ()Lnet/minecraft/nbt/NBTTagCompound; crj/a ()Lgy;
MD: net/minecraft/client/multiplayer/ServerData/func_152584_a (Lnet/minecraft/client/multiplayer/ServerData$ServerResourceMode;)V crj/a (Lcrj$a;)V
MD: net/minecraft/client/multiplayer/ServerData/func_152583_a (Lnet/minecraft/client/multiplayer/ServerData;)V crj/a (Lcrj;)V
MD: net/minecraft/client/multiplayer/ServerData/func_78837_a (Lnet/minecraft/nbt/NBTTagCompound;)Lnet/minecraft/client/multiplayer/ServerData; crj/a (Lgy;)Lcrj;
MD: net/minecraft/client/multiplayer/ServerData/func_147407_a (Ljava/lang/String;)V crj/a (Ljava/lang/String;)V
MD: net/minecraft/client/multiplayer/ServerData/func_152586_b ()Lnet/minecraft/client/multiplayer/ServerData$ServerResourceMode; crj/b ()Lcrj$a;
MD: net/minecraft/client/multiplayer/ServerData/func_147409_e ()Ljava/lang/String; crj/c ()Ljava/lang/String;
MD: net/minecraft/client/multiplayer/ServerData/func_181041_d ()Z crj/d ()Z
MD: net/minecraft/client/renderer/IImageBuffer/func_152634_a ()V cub/a ()V
MD: net/minecraft/client/renderer/IImageBuffer/func_195786_a (Lnet/minecraft/client/renderer/texture/NativeImage;)Lnet/minecraft/client/renderer/texture/NativeImage; cub/a (Lddg;)Lddg;
MD: net/minecraft/client/renderer/ImageBufferDownload/func_152634_a ()V cug/a ()V
MD: net/minecraft/client/renderer/ImageBufferDownload/func_195786_a (Lnet/minecraft/client/renderer/texture/NativeImage;)Lnet/minecraft/client/renderer/texture/NativeImage; cug/a (Lddg;)Lddg;
MD: net/minecraft/client/renderer/ImageBufferDownload/func_195788_a (Lnet/minecraft/client/renderer/texture/NativeImage;IIII)V cug/a (Lddg;IIII)V
MD: net/minecraft/client/renderer/ImageBufferDownload/func_195787_b (Lnet/minecraft/client/renderer/texture/NativeImage;IIII)V cug/b (Lddg;IIII)V
MD: net/minecraft/client/renderer/ThreadDownloadImageData$1/func_195658_a (Lnet/minecraft/client/renderer/texture/NativeImage;)V ddc$1/a (Lddg;)V
MD: net/minecraft/client/renderer/ThreadDownloadImageData$1/func_195657_a (Ljava/io/InputStream;)V ddc$1/a (Ljava/io/InputStream;)V
MD: net/minecraft/client/renderer/ThreadDownloadImageData$1/run ()V ddc$1/run ()V
MD: net/minecraft/client/renderer/ThreadDownloadImageData/func_152433_a ()V ddc/a ()V
MD: net/minecraft/client/renderer/ThreadDownloadImageData/access$000 (Lnet/minecraft/client/renderer/ThreadDownloadImageData;)Ljava/lang/String; ddc/a (Lddc;)Ljava/lang/String;
MD: net/minecraft/client/renderer/ThreadDownloadImageData/func_195417_a (Lnet/minecraft/client/renderer/texture/NativeImage;)V ddc/a (Lddg;)V
MD: net/minecraft/client/renderer/ThreadDownloadImageData/func_195413_a (Lnet/minecraft/resources/IResourceManager;)V ddc/a (Lvf;)V
MD: net/minecraft/client/renderer/ThreadDownloadImageData/access$100 (Lnet/minecraft/client/renderer/ThreadDownloadImageData;)Ljava/io/File; ddc/b (Lddc;)Ljava/io/File;
MD: net/minecraft/client/renderer/ThreadDownloadImageData/func_195416_b (Lnet/minecraft/client/renderer/texture/NativeImage;)V ddc/b (Lddg;)V
MD: net/minecraft/client/renderer/ThreadDownloadImageData/access$300 (Lnet/minecraft/client/renderer/ThreadDownloadImageData;)Lnet/minecraft/client/renderer/IImageBuffer; ddc/c (Lddc;)Lcub;
MD: net/minecraft/client/renderer/ThreadDownloadImageData/access$200 ()Lorg/apache/logging/log4j/Logger; ddc/e ()Lorg/apache/logging/log4j/Logger;
MD: net/minecraft/client/renderer/texture/NativeImage$PixelFormat/func_211651_a ()I ddg$a/a ()I
MD: net/minecraft/client/renderer/texture/NativeImage$PixelFormat/func_211652_a (I)Lnet/minecraft/client/renderer/texture/NativeImage$PixelFormat; ddg$a/a (I)Lddg$a;
MD: net/minecraft/client/renderer/texture/NativeImage$PixelFormat/func_211655_a (Lnet/minecraft/client/renderer/texture/NativeImage$PixelFormat;)I ddg$a/a (Lddg$a;)I
MD: net/minecraft/client/renderer/texture/NativeImage$PixelFormat/func_211656_b ()V ddg$a/b ()V
MD: net/minecraft/client/renderer/texture/NativeImage$PixelFormat/func_211646_b (I)Lnet/minecraft/client/renderer/texture/NativeImage$PixelFormat; ddg$a/b (I)Lddg$a;
MD: net/minecraft/client/renderer/texture/NativeImage$PixelFormat/func_211658_c ()V ddg$a/c ()V
MD: net/minecraft/client/renderer/texture/NativeImage$PixelFormat/func_211650_d ()I ddg$a/d ()I
MD: net/minecraft/client/renderer/texture/NativeImage$PixelFormat/func_211645_i ()Z ddg$a/i ()Z
MD: net/minecraft/client/renderer/texture/NativeImage$PixelFormat/func_211648_n ()I ddg$a/n ()I
MD: net/minecraft/client/renderer/texture/NativeImage$PixelFormat/func_211653_r ()Z ddg$a/r ()Z
MD: net/minecraft/client/renderer/texture/NativeImage$PixelFormat/func_211647_v ()I ddg$a/v ()I
MD: net/minecraft/client/renderer/texture/NativeImage$PixelFormat/func_211654_w ()Z ddg$a/w ()Z
MD: net/minecraft/client/renderer/texture/NativeImage$PixelFormat/values ()[Lnet/minecraft/client/renderer/texture/NativeImage$PixelFormat; ddg$a/values ()[Lddg$a;
MD: net/minecraft/client/renderer/texture/NativeImage$PixelFormat/valueOf (Ljava/lang/String;)Lnet/minecraft/client/renderer/texture/NativeImage$PixelFormat; ddg$a/valueOf (Ljava/lang/String;)Lddg$a;
MD: net/minecraft/client/renderer/texture/NativeImage$PixelFormatGLCode/func_211672_a ()I ddg$b/a ()I
MD: net/minecraft/client/renderer/texture/NativeImage$PixelFormatGLCode/values ()[Lnet/minecraft/client/renderer/texture/NativeImage$PixelFormatGLCode; ddg$b/values ()[Lddg$b;
MD: net/minecraft/client/renderer/texture/NativeImage$PixelFormatGLCode/valueOf (Ljava/lang/String;)Lnet/minecraft/client/renderer/texture/NativeImage$PixelFormatGLCode; ddg$b/valueOf (Ljava/lang/String;)Lddg$b;
MD: net/minecraft/client/renderer/texture/NativeImage$WriteCallback/func_209267_a ()V ddg$c/a ()V
MD: net/minecraft/client/renderer/texture/NativeImage$WriteCallback/invoke (JJI)V ddg$c/invoke (JJI)V
MD: net/minecraft/client/renderer/texture/NativeImage/func_195702_a ()I ddg/a ()I
MD: net/minecraft/client/renderer/texture/NativeImage/func_195709_a (II)I ddg/a (II)I
MD: net/minecraft/client/renderer/texture/NativeImage/func_195700_a (III)V ddg/a (III)V
MD: net/minecraft/client/renderer/texture/NativeImage/func_195715_a (IIIII)V ddg/a (IIIII)V
MD: net/minecraft/client/renderer/texture/NativeImage/func_195706_a (IIIIIIIZ)V ddg/a (IIIIIIIZ)V
MD: net/minecraft/client/renderer/texture/NativeImage/func_195712_a (IIIIIIIZZZ)V ddg/a (IIIIIIIZZZ)V
MD: net/minecraft/client/renderer/texture/NativeImage/func_195699_a (IIIIIIZZ)V ddg/a (IIIIIIZZ)V
MD: net/minecraft/client/renderer/texture/NativeImage/func_195708_a (IIIILnet/minecraft/client/renderer/texture/NativeImage;)V ddg/a (IIIILddg;)V
MD: net/minecraft/client/renderer/texture/NativeImage/func_195697_a (IIIZ)V ddg/a (IIIZ)V
MD: net/minecraft/client/renderer/texture/NativeImage/func_195717_a (IZ)V ddg/a (IZ)V
MD: net/minecraft/client/renderer/texture/NativeImage/func_211679_a (Lnet/minecraft/client/renderer/texture/NativeImage$PixelFormat;Ljava/io/InputStream;)Lnet/minecraft/client/renderer/texture/NativeImage; ddg/a (Lddg$a;Ljava/io/InputStream;)Lddg;
MD: net/minecraft/client/renderer/texture/NativeImage/func_211677_a (Lnet/minecraft/client/renderer/texture/NativeImage$PixelFormat;Ljava/nio/ByteBuffer;)Lnet/minecraft/client/renderer/texture/NativeImage; ddg/a (Lddg$a;Ljava/nio/ByteBuffer;)Lddg;
MD: net/minecraft/client/renderer/texture/NativeImage/func_195703_a (Lnet/minecraft/client/renderer/texture/NativeImage;)V ddg/a (Lddg;)V
MD: net/minecraft/client/renderer/texture/NativeImage/func_209271_a (Ljava/io/File;)V ddg/a (Ljava/io/File;)V
MD: net/minecraft/client/renderer/texture/NativeImage/func_195713_a (Ljava/io/InputStream;)Lnet/minecraft/client/renderer/texture/NativeImage; ddg/a (Ljava/io/InputStream;)Lddg;
MD: net/minecraft/client/renderer/texture/NativeImage/func_195704_a (Ljava/nio/ByteBuffer;)Lnet/minecraft/client/renderer/texture/NativeImage; ddg/a (Ljava/nio/ByteBuffer;)Lddg;
MD: net/minecraft/client/renderer/texture/NativeImage/func_209270_a (Ljava/nio/file/Path;)V ddg/a (Ljava/nio/file/Path;)V
MD: net/minecraft/client/renderer/texture/NativeImage/func_211676_a (Lorg/lwjgl/stb/STBTTFontinfo;IIIFFFFII)V ddg/a (Lorg/lwjgl/stb/STBTTFontinfo;IIIFFFFII)V
MD: net/minecraft/client/renderer/texture/NativeImage/func_195701_a (Z)V ddg/a (Z)V
MD: net/minecraft/client/renderer/texture/NativeImage/func_195705_a (ZZ)V ddg/a (ZZ)V
MD: net/minecraft/client/renderer/texture/NativeImage/func_195714_b ()I ddg/b ()I
MD: net/minecraft/client/renderer/texture/NativeImage/func_195718_b (III)V ddg/b (III)V
MD: net/minecraft/client/renderer/texture/NativeImage/func_195707_b (Z)V ddg/b (Z)V
MD: net/minecraft/client/renderer/texture/NativeImage/func_211678_c ()Lnet/minecraft/client/renderer/texture/NativeImage$PixelFormat; ddg/c ()Lddg$a;
MD: net/minecraft/client/renderer/texture/NativeImage/func_195716_c ()[I ddg/d ()[I
MD: net/minecraft/client/renderer/texture/NativeImage/func_211675_e (II)B ddg/e (II)B
MD: net/minecraft/client/renderer/texture/NativeImage/func_195710_e ()V ddg/f ()V
MD: net/minecraft/client/renderer/texture/NativeImage/func_195711_f ()V ddg/g ()V
MD: net/minecraft/client/renderer/texture/NativeImage/func_195696_g ()V ddg/h ()V
MD: net/minecraft/client/renderer/texture/NativeImage/close ()V ddg/close ()V
MD: net/minecraft/client/renderer/texture/NativeImage/toString ()Ljava/lang/String; ddg/toString ()Ljava/lang/String;
MD: net/minecraft/client/renderer/texture/SimpleTexture/func_195413_a (Lnet/minecraft/resources/IResourceManager;)V ddi/a (Lvf;)V
MD: net/minecraft/client/renderer/texture/TextureManager/func_210123_a (Lnet/minecraft/client/renderer/texture/ITextureObject;)Ljava/lang/String; ddn/a (Lddo;)Ljava/lang/String;
MD: net/minecraft/client/renderer/texture/TextureManager/func_110578_a (Ljava/lang/String;Lnet/minecraft/client/renderer/texture/DynamicTexture;)Lnet/minecraft/util/ResourceLocation; ddn/a (Ljava/lang/String;Lddb;)Lpc;
MD: net/minecraft/client/renderer/texture/TextureManager/func_110577_a (Lnet/minecraft/util/ResourceLocation;)V ddn/a (Lpc;)V
MD: net/minecraft/client/renderer/texture/TextureManager/func_110579_a (Lnet/minecraft/util/ResourceLocation;Lnet/minecraft/client/renderer/texture/ITextureObject;)Z ddn/a (Lpc;Lddo;)Z
MD: net/minecraft/client/renderer/texture/TextureManager/func_110580_a (Lnet/minecraft/util/ResourceLocation;Lnet/minecraft/client/renderer/texture/ITickableTextureObject;)Z ddn/a (Lpc;Lddr;)Z
MD: net/minecraft/client/renderer/texture/TextureManager/func_195410_a (Lnet/minecraft/resources/IResourceManager;)V ddn/a (Lvf;)V
MD: net/minecraft/client/renderer/texture/TextureManager/func_110581_b (Lnet/minecraft/util/ResourceLocation;)Lnet/minecraft/client/renderer/texture/ITextureObject; ddn/b (Lpc;)Lddo;
MD: net/minecraft/client/renderer/texture/TextureManager/func_147645_c (Lnet/minecraft/util/ResourceLocation;)V ddn/c (Lpc;)V
MD: net/minecraft/client/renderer/texture/TextureManager/func_110550_d ()V ddn/e ()V
MD: net/minecraft/client/renderer/texture/ITextureObject/func_195413_a (Lnet/minecraft/resources/IResourceManager;)V ddo/a (Lvf;)V
MD: net/minecraft/client/renderer/texture/ITextureObject/func_174935_a ()V ddo/b ()V
MD: net/minecraft/client/renderer/texture/ITextureObject/func_174936_b (ZZ)V ddo/b (ZZ)V
MD: net/minecraft/client/renderer/texture/ITextureObject/func_110552_b ()I ddo/c ()I
MD: net/minecraft/client/renderer/texture/ITextureObject/func_195412_h ()V ddo/h ()V
MD: net/minecraft/client/resources/DefaultPlayerSkin/func_177335_a ()Lnet/minecraft/util/ResourceLocation; dec/a ()Lpc;
MD: net/minecraft/client/resources/DefaultPlayerSkin/func_177334_a (Ljava/util/UUID;)Lnet/minecraft/util/ResourceLocation; dec/a (Ljava/util/UUID;)Lpc;
MD: net/minecraft/client/resources/DefaultPlayerSkin/func_177332_b (Ljava/util/UUID;)Ljava/lang/String; dec/b (Ljava/util/UUID;)Ljava/lang/String;
MD: net/minecraft/client/resources/DefaultPlayerSkin/func_177333_c (Ljava/util/UUID;)Z dec/c (Ljava/util/UUID;)Z
MD: net/minecraft/client/resources/SkinManager$1/load (Lcom/mojang/authlib/GameProfile;)Ljava/util/Map; deh$1/a (Lcom/mojang/authlib/GameProfile;)Ljava/util/Map;
MD: net/minecraft/client/resources/SkinManager$1/load (Ljava/lang/Object;)Ljava/lang/Object; deh$1/load (Ljava/lang/Object;)Ljava/lang/Object;
MD: net/minecraft/client/resources/SkinManager$2/func_152634_a ()V deh$2/a ()V
MD: net/minecraft/client/resources/SkinManager$2/func_195786_a (Lnet/minecraft/client/renderer/texture/NativeImage;)Lnet/minecraft/client/renderer/texture/NativeImage; deh$2/a (Lddg;)Lddg;
MD: net/minecraft/client/resources/SkinManager$SkinAvailableCallback/func_180521_a (Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;Lnet/minecraft/util/ResourceLocation;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;)V deh$a/onSkinTextureAvailable (Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;Lpc;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;)V
MD: net/minecraft/client/resources/SkinManager/func_152788_a (Lcom/mojang/authlib/GameProfile;)Ljava/util/Map; deh/a (Lcom/mojang/authlib/GameProfile;)Ljava/util/Map;
MD: net/minecraft/client/resources/SkinManager/func_152790_a (Lcom/mojang/authlib/GameProfile;Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;Z)V deh/a (Lcom/mojang/authlib/GameProfile;Ldeh$a;Z)V
MD: net/minecraft/client/resources/SkinManager/func_210275_a (Lcom/mojang/authlib/GameProfile;ZLnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;)V deh/a (Lcom/mojang/authlib/GameProfile;ZLdeh$a;)V
MD: net/minecraft/client/resources/SkinManager/func_152792_a (Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;)Lnet/minecraft/util/ResourceLocation; deh/a (Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;)Lpc;
MD: net/minecraft/client/resources/SkinManager/func_152789_a (Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;)Lnet/minecraft/util/ResourceLocation; deh/a (Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;Ldeh$a;)Lpc;
MD: net/minecraft/client/resources/SkinManager/func_210276_a (Ljava/util/Map;Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;)V deh/a (Ljava/util/Map;Ldeh$a;)V
+7
View File
@@ -0,0 +1,7 @@
minecraft_version=1.13.2
minecraft_full_versions=1.13.2
#forge gradle needs forge version
forge_mc_version=1.12.2
forge_version=14.23.5.2768
mappings_version=stable_39
srg_notch_map=1.13.2.srg
+87
View File
@@ -0,0 +1,87 @@
/**
* Gradle Script for COS
* It can be used to upload or download file from Tencent Cloud COS.
* COS: https://cloud.tencent.com/document/product/436
*/
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.qcloud:cos_api:5.4.6'
}
}
import com.qcloud.cos.COSClient
import com.qcloud.cos.ClientConfig
import com.qcloud.cos.auth.BasicCOSCredentials
import com.qcloud.cos.auth.COSCredentials
import com.qcloud.cos.model.PutObjectRequest
import com.qcloud.cos.model.GetObjectRequest
import com.qcloud.cos.region.Region
String getMcVersion(String filename) {
if (filename.endsWith(".json"))
return filename.substring(0, filename.indexOf('-'))
return filename.substring(filename.indexOf('_') + 1, filename.indexOf('-'))
}
String getKey(String filename) {
String name = filename.substring(0, filename.lastIndexOf('.'))
if (filename.endsWith(".json"))
return String.format(
"versions/%s/%s",
name,
filename
)
if (filename.endsWith(".jar"))
return String.format(
"libraries/customskinloader/%s/%s/%s",
name.substring(0, name.indexOf('-')),
name.substring(name.indexOf('-') + 1),
filename
)
return filename
}
ext.bucketName = System.getenv("COS_BUCKET")
ext.cosUrl = "https://csl.littleservice.cn/"
ext.cosClient0 = null
COSClient getCosClient() {
if (cosClient0 != null) return cosClient0
COSCredentials cred = new BasicCOSCredentials(System.getenv("COS_SECRET_ID"), System.getenv("COS_SECRET_KEY"))
ClientConfig clientConfig = new ClientConfig(new Region("ap-shanghai"))
cosClient0 = new COSClient(cred, clientConfig)
}
void uploadFile(String key, File file) {
PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, key, file)
getCosClient().putObject(putObjectRequest)
}
void downloadFile(String key, File file) {
GetObjectRequest getObjectRequest = new GetObjectRequest(bucketName, key)
getCosClient().getObject(getObjectRequest, file)
}
void uploadArtifacts(String shortVersion) {
String cslversion = shortVersion.replace(".", "")
File dir = rootProject.file("build/libs")
if (!dir.isDirectory()) return
File[] files = dir.listFiles()
for (file in files) {
String key = getKey(file.getName())
uploadFile(key, file)
String url = cosUrl + key
String mcversion = getMcVersion(file.getName()).replace(".", "").toLowerCase()
println(String.format("csl-%s-%s\t%s", mcversion, cslversion, url))
}
}
ext {
uploadArtifacts = this.&uploadArtifacts
}
+62
View File
@@ -0,0 +1,62 @@
/**
* Gradle Script for Remap
* Designed for remapping jar.
* Remap Jar: mcp<->srg<->notch
*/
buildscript {
repositories {
mavenCentral()
maven {
name = "forge"
url = "http://files.minecraftforge.net/maven"
}
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
}
}
import net.md_5.specialsource.JarMapping
import net.md_5.specialsource.JarRemapper
import net.md_5.specialsource.provider.JarProvider
import net.md_5.specialsource.provider.JointProvider
void reobfSrgToNotch() {
def srgName = "${archivesBaseName}-${version}-srg.jar"
def notchName = srgName.replace('-srg', '')
if (config.srg_notch_map == null) {
//Default Map
def mcpName = srgName.replace('-srg', '-dev')
applySpecialSource(srgName, mcpName, getDefaultMap("srg-mcp"))
applySpecialSource(mcpName, notchName, getDefaultMap("mcp-notch"))
} else {
//Custom Map
applySpecialSource(srgName, notchName, config.srg_notch_map)
}
}
void applySpecialSource(String inputName, String outputName, String mapFile) {
def mapping = new JarMapping()
def srgFile = file(mapFile)
def inputFile = file("build/libs/${inputName}")
def outputFile = file("build/libs/${outputName}")
def remapper = new JarRemapper(null, mapping)
def inputJar = net.md_5.specialsource.Jar.init(inputFile)
def inheritanceProviders = new JointProvider()
def jarProvider = new JarProvider(inputJar)
inheritanceProviders.add(jarProvider)
mapping.loadMappings(srgFile)
mapping.setFallbackInheritanceProvider(inheritanceProviders)
remapper.remapJar(inputJar, outputFile)
}
String getDefaultMap(String srgType) {
def mcpVersion = minecraft.mappings.replace('_', "/")
return System.getProperty('user.home') + "/.gradle/caches/minecraft/de/oceanlabs/mcp/mcp_${mcpVersion}/${config.forge_mc_version}/srgs/${srgType}.srg"
}
ext {
reobfSrgToNotch = this.&reobfSrgToNotch
}
+35
View File
@@ -0,0 +1,35 @@
/**
* Gradle Script for Version
* Format Version String
*/
boolean isRelease() {
String s = rootProject.ext.config.snapshot
return s == null || s == "" || s == "0"
}
boolean isSnapshot() {
return !isRelease()
}
String getBuildNum() {
if (System.getenv("CIRCLE_BUILD_NUM") != null)
return System.getenv("CIRCLE_BUILD_NUM")
return "00"
}
//Example: 14.10a-SNAPSHOT-33
String getCSLVersion() {
return rootProject.ext.config.version + rootProject.ext.config.dev_version +
(isRelease() ? '' : ('-SNAPSHOT-' + getBuildNum()))
}
//Example: 14.10a-s33
String getShortVersion() {
return getCSLVersion().replace("SNAPSHOT-", "s")
}
ext {
getCSLVersion = this.&getCSLVersion
getShortVersion = this.&getShortVersion
}
+24
View File
@@ -0,0 +1,24 @@
{
"id": "${mcVersion}-CSL-${modShortFullVersion}",
"inheritsFrom": "${mcVersion}",
"jar": "${mcVersion}",
"releaseTime": "2013-01-02T21:10:00+08:00",
"time": "2013-01-02T21:10:00+08:00",
"type": "release",
"arguments": {
"game": [
"--tweakClass",
"customskinloader.tweaker.Tweaker"
]
},
"mainClass": "net.minecraft.launchwrapper.Launch",
"libraries": [
{
"name": "customskinloader:CustomSkinLoader_${mcVersion}:${modFullVersion}",
"url": "https://csl.littleservice.cn/libraries/"
},
{
"name": "net.minecraft:launchwrapper:1.12"
}
]
}
@@ -21,148 +21,160 @@ import customskinloader.utils.MinecraftUtil;
/** /**
* Custom skin loader mod for Minecraft. * Custom skin loader mod for Minecraft.
* @author (C) Jeremy Lam [JLChnToZ] 2013 & Alexander Xia [xfl03] 2014-2016 * @author (C) Jeremy Lam [JLChnToZ] 2013 & Alexander Xia [xfl03] 2014-2018
* @version @MOD_FULL_VERSION@ * @version @MOD_FULL_VERSION@
*/ */
public class CustomSkinLoader { public class CustomSkinLoader {
public static final String CustomSkinLoader_VERSION="@MOD_VERSION@"; public static final String CustomSkinLoader_VERSION="@MOD_VERSION@";
public static final String CustomSkinLoader_FULL_VERSION="@MOD_FULL_VERSION@"; public static final String CustomSkinLoader_FULL_VERSION="@MOD_FULL_VERSION@";
public static final File DATA_DIR=new File(MinecraftUtil.getMinecraftDataDir(),"CustomSkinLoader"), public static final File DATA_DIR=new File(MinecraftUtil.getMinecraftDataDir(),"CustomSkinLoader"),
LOG_FILE=new File(DATA_DIR,"CustomSkinLoader.log"), LOG_FILE=new File(DATA_DIR,"CustomSkinLoader.log"),
CONFIG_FILE=new File(DATA_DIR,"CustomSkinLoader.json"); CONFIG_FILE=new File(DATA_DIR,"CustomSkinLoader.json");
public static final SkinSiteProfile[] DEFAULT_LOAD_LIST={ public static final SkinSiteProfile[] DEFAULT_LOAD_LIST={
SkinSiteProfile.createMojangAPI("Mojang"), SkinSiteProfile.createMojangAPI("Mojang"),
SkinSiteProfile.createCustomSkinAPI("LittleSkin","https://mcskin.littleservice.cn/"), SkinSiteProfile.createCustomSkinAPI("LittleSkin","https://littleskin.cn/"),
SkinSiteProfile.createCustomSkinAPI("BlessingSkin","http://skin.prinzeugen.net/"), SkinSiteProfile.createCustomSkinAPI("BlessingSkin","http://skin.prinzeugen.net/"),
//OneSkin has been removed temporarily //OneSkin has been removed temporarily
//SkinSiteProfile.createCustomSkinAPI("OneSkin","http://fleey.cn/skin/skin_user/skin_json.php/"), //SkinSiteProfile.createCustomSkinAPI("OneSkin","http://fleey.cn/skin/skin_user/skin_json.php/"),
//Minecrack could not load skin correctly //Minecrack could not load skin correctly
//SkinSiteProfile.creatLegacy("Minecrack","http://minecrack.fr.nf/mc/skinsminecrackd/{USERNAME}.png","http://minecrack.fr.nf/mc/cloaksminecrackd/{USERNAME}.png",null), //SkinSiteProfile.creatLegacy("Minecrack","http://minecrack.fr.nf/mc/skinsminecrackd/{USERNAME}.png","http://minecrack.fr.nf/mc/cloaksminecrackd/{USERNAME}.png",null),
SkinSiteProfile.createUniSkinAPI("SkinMe","http://www.skinme.cc/uniskin/"), SkinSiteProfile.createElyByAPI("ElyBy"),
SkinSiteProfile.createLegacy("LocalSkin","LocalSkin/skins/{USERNAME}.png","LocalSkin/capes/{USERNAME}.png","LocalSkin/elytras/{USERNAME}.png")}; SkinSiteProfile.createUniSkinAPI("SkinMe","http://www.skinme.cc/uniskin/"),
SkinSiteProfile.createLegacy("LocalSkin","LocalSkin/skins/{USERNAME}.png","LocalSkin/capes/{USERNAME}.png","LocalSkin/elytras/{USERNAME}.png")};
public static final Gson GSON=new GsonBuilder().setPrettyPrinting().create(); public static final Gson GSON=new GsonBuilder().setPrettyPrinting().create();
public static final Logger logger=initLogger(); public static final Logger logger=initLogger();
public static final Config config=Config.loadConfig0(); public static final Config config=Config.loadConfig0();
private static final ProfileCache profileCache=new ProfileCache(); private static final ProfileCache profileCache=new ProfileCache();
private static final DynamicSkullManager dynamicSkullManager=new DynamicSkullManager(); private static final DynamicSkullManager dynamicSkullManager=new DynamicSkullManager();
//For User Skin //For User Skin
public static Map loadProfile(GameProfile gameProfile){ public static Map<Type, MinecraftProfileTexture> loadProfile(GameProfile gameProfile){
String username=gameProfile.getName(); String username=gameProfile.getName();
//Fix: http://hopper.minecraft.net/crashes/minecraft/MCX-2773713 String credential=MinecraftUtil.getCredential(gameProfile);
if(username==null){ //Fix: http://hopper.minecraft.net/crashes/minecraft/MCX-2773713
logger.warning("Could not load profile: username is null."); if(username==null){
return Maps.newHashMap(); logger.warning("Could not load profile: username is null.");
} return Maps.newHashMap();
String tempName=Thread.currentThread().getName(); }
Thread.currentThread().setName(username);//Change Thread Name String tempName=Thread.currentThread().getName();
UserProfile profile=null; Thread.currentThread().setName(username);//Change Thread Name
if(profileCache.isReady(username)){ UserProfile profile;
logger.info("Cached profile will be used."); if(profileCache.isReady(credential)){
profile=profileCache.getProfile(username); logger.info("Cached profile will be used.");
if(profile==null){ profile=profileCache.getProfile(credential);
logger.warning("(!Cached Profile is empty!) Expiry:"+profileCache.getExpiry(username)); if(profile==null){
if(profileCache.isExpired(username))//force load logger.warning("(!Cached Profile is empty!) Expiry:"+profileCache.getExpiry(credential));
profile=loadProfile0(gameProfile); if(profileCache.isExpired(credential))//force load
} profile=loadProfile0(gameProfile);
else }
logger.info(profile.toString(profileCache.getExpiry(username))); else
}else{ logger.info(profile.toString(profileCache.getExpiry(credential)));
profileCache.setLoading(username, true); }else{
profile=loadProfile0(gameProfile); profileCache.setLoading(credential, true);
} profile=loadProfile0(gameProfile);
Thread.currentThread().setName(tempName); }
return ModelManager0.fromUserProfile(profile); Thread.currentThread().setName(tempName);
} return ModelManager0.fromUserProfile(profile);
//Core }
public static UserProfile loadProfile0(GameProfile gameProfile){ //Core
String username=gameProfile.getName(); public static UserProfile loadProfile0(GameProfile gameProfile){
profileCache.setLoading(username, true); String username=gameProfile.getName();
logger.info("Loading "+username+"'s profile."); String credential=MinecraftUtil.getCredential(gameProfile);
if(config.loadlist==null||config.loadlist.isEmpty()){
logger.info("LoadList is Empty.");
return null;
}
UserProfile profile0=new UserProfile(); profileCache.setLoading(credential, true);
for(int i=0;i<config.loadlist.size();i++){ logger.info("Loading "+username+"'s profile.");
SkinSiteProfile ssp=config.loadlist.get(i); if(config.loadlist==null||config.loadlist.isEmpty()){
logger.info((i+1)+"/"+config.loadlist.size()+" Try to load profile from '"+ssp.name+"'."); logger.info("LoadList is Empty.");
ProfileLoader.IProfileLoader loader=ProfileLoader.LOADERS.get(ssp.type.toLowerCase()); return null;
if(loader==null){ }
logger.info("Type '"+ssp.type+"' is not defined.");
continue;
}
UserProfile profile=null;
try{
profile=loader.loadProfile(ssp, gameProfile);
}catch(Exception e){
logger.warning("Exception occurs while loading.");
logger.warning(e);
}
if(profile==null)
continue;
if(!config.forceLoadAllTextures){
profile0=profile;
break;
}
profile0.mix(profile);
if(profile0.isFull())
break;
}
if(!profile0.isEmpty()){
logger.info(username+"'s profile loaded.");
profileCache.updateCache(username, profile0);
profileCache.setLoading(username, false);
logger.info(profile0.toString(profileCache.getExpiry(username)));
return profile0;
}
logger.info(username+"'s profile not found in load list.");
if(config.enableLocalProfileCache){ UserProfile profile0=new UserProfile();
UserProfile profile=profileCache.getLocalProfile(username); for(int i=0;i<config.loadlist.size();i++){
if(profile==null) SkinSiteProfile ssp=config.loadlist.get(i);
logger.info(username+"'s LocalProfile not found."); logger.info((i+1)+"/"+config.loadlist.size()+" Try to load profile from '"+ssp.name+"'.");
else{ ProfileLoader.IProfileLoader loader=ProfileLoader.LOADERS.get(ssp.type.toLowerCase());
profileCache.updateCache(username, profile, false); if(loader==null){
profileCache.setLoading(username, false); logger.info("Type '"+ssp.type+"' is not defined.");
logger.info(username+"'s LocalProfile will be used."); continue;
logger.info(profile.toString(profileCache.getExpiry(username))); }
return profile; UserProfile profile=null;
} try{
} profile=loader.loadProfile(ssp, gameProfile);
profileCache.setLoading(username, false); }catch(Exception e){
return null; logger.warning("Exception occurs while loading.");
} logger.warning(e);
if(e.getCause()!=null) {
logger.warning("Caused By:");
logger.warning(e.getCause());
}
}
if(profile==null)
continue;
if(!config.forceLoadAllTextures){
profile0=profile;
break;
}
profile0.mix(profile);
if(profile0.isFull())
break;
}
if(!profile0.isEmpty()){
logger.info(username+"'s profile loaded.");
if(!config.enableCape)
profile0.capeUrl = null;
profileCache.updateCache(credential, profile0);
profileCache.setLoading(credential, false);
logger.info(profile0.toString(profileCache.getExpiry(credential)));
return profile0;
}
logger.info(username+"'s profile not found in load list.");
//For Skull if(config.enableLocalProfileCache){
public static Map<Type, MinecraftProfileTexture> loadProfileFromCache(final GameProfile gameProfile) { UserProfile profile=profileCache.getLocalProfile(credential);
String username=gameProfile.getName(); if(profile==null)
if(username==null) logger.info(username+"'s LocalProfile not found.");
return dynamicSkullManager.getTexture(gameProfile); else{
if(config.enableUpdateSkull?profileCache.isReady(username):profileCache.isExist(username)){ profileCache.updateCache(credential, profile, false);
UserProfile profile=profileCache.getProfile(username); profileCache.setLoading(credential, false);
return ModelManager0.fromUserProfile(profile); logger.info(username+"'s LocalProfile will be used.");
} logger.info(profile.toString(profileCache.getExpiry(credential)));
//profileCache.setLoading(username, true); return profile;
Thread loadThread=new Thread(){ }
public void run(){ }
loadProfile0(gameProfile);//Load in thread profileCache.setLoading(credential, false);
} return null;
}; }
loadThread.setName(username+"'s skull");
loadThread.start();
return Maps.newHashMap();
}
private static Logger initLogger() { //For Skull
Logger logger=new Logger(LOG_FILE); public static Map<Type, MinecraftProfileTexture> loadProfileFromCache(final GameProfile gameProfile) {
logger.info("CustomSkinLoader "+CustomSkinLoader_FULL_VERSION); String username=gameProfile.getName();
logger.info("DataDir: "+DATA_DIR.getAbsolutePath()); String credential=MinecraftUtil.getCredential(gameProfile);
logger.info("Minecraft: "+MinecraftUtil.getMinecraftMainVersion()+"("+MinecraftUtil.getMinecraftVersionText()+")");
return logger; if(username == null || credential == null)
} return dynamicSkullManager.getTexture(gameProfile);
if(config.enableUpdateSkull?profileCache.isReady(credential):profileCache.isExist(credential)){
UserProfile profile=profileCache.getProfile(credential);
return ModelManager0.fromUserProfile(profile);
}
//profileCache.setLoading(username, true);
Thread loadThread=new Thread(){
public void run(){
loadProfile0(gameProfile);//Load in thread
}
};
loadThread.setName(username+"'s skull");
loadThread.start();
return Maps.newHashMap();
}
private static Logger initLogger() {
Logger logger=new Logger(LOG_FILE);
logger.info("CustomSkinLoader "+CustomSkinLoader_FULL_VERSION);
logger.info("DataDir: "+DATA_DIR.getAbsolutePath());
logger.info("Minecraft: "+MinecraftUtil.getMinecraftMainVersion()+"("+MinecraftUtil.getMinecraftVersionText()+")");
return logger;
}
} }
+91 -80
View File
@@ -7,89 +7,100 @@ import java.io.OutputStreamWriter;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
@SuppressWarnings("ResultOfMethodCallIgnored")
public class Logger { public class Logger {
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
public enum Level{ public enum Level{
DEBUG("DEBUG",false), DEBUG("DEBUG",false),
INFO("INFO",true), INFO("INFO",true),
WARNING("WARNING",true); WARNING("WARNING",true);
String name; String name;
boolean display; boolean display;
Level(String name,boolean display){ Level(String name,boolean display){
this.name=name; this.name=name;
this.display=display; this.display=display;
} }
public String getName(){ public String getName(){
return name; return name;
} }
public boolean display(){ public boolean display(){
return display; return display;
} }
} }
private BufferedWriter writer=null; private BufferedWriter writer=null;
public Logger(){ public Logger(){
//Logger isn't created. //Logger isn't created.
} }
public Logger(File logFile){ public Logger(String logFile) {
try { this(new File(logFile));
if(!logFile.getParentFile().exists()){ }
logFile.getParentFile().mkdirs(); public Logger(File logFile){
} try {
if(!logFile.exists()) if(!logFile.getParentFile().exists()){
logFile.createNewFile(); logFile.getParentFile().mkdirs();
}
if(!logFile.exists())
logFile.createNewFile();
writer = new BufferedWriter(new OutputStreamWriter( writer = new BufferedWriter(new OutputStreamWriter(
new FileOutputStream(logFile), "UTF-8")); new FileOutputStream(logFile), "UTF-8"));
} catch (Exception e) {
e.printStackTrace();
}
}
public void close(){
if(writer!=null){
try {
writer.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
public void log(Level level,String msg){ System.out.println("Log Path: " + logFile.getAbsolutePath());
if(!level.display()&&writer==null) } catch (Exception e) {
return; e.printStackTrace();
StringBuilder sb=new StringBuilder(); }
sb.append("[").append(Thread.currentThread().getName()).append(" ").append(level.getName()).append("] "); }
sb.append(msg); public void close(){
if(level.display()) if(writer!=null){
System.out.println(sb.toString()); try {
if(writer==null) writer.close();
return; } catch (Exception e) {
try { e.printStackTrace();
StringBuilder sb2=new StringBuilder(); }
sb2.append("[").append(DATE_FORMAT.format(new Date())).append("] "); }
sb2.append(sb.toString()).append("\r\n"); }
writer.write(sb2.toString());
writer.flush(); public void log(Level level,String msg){
} catch (Exception e) { if(!level.display()&&writer==null)
e.printStackTrace(); return;
} String sb = String.format("[%s %s] %s", Thread.currentThread().getName(), level.getName(), msg);
} if(level.display())
public void debug(String msg){ System.out.println(sb);
log(Level.DEBUG,msg); if(writer==null)
} return;
public void info(String msg){ try {
log(Level.INFO,msg); String sb2 = String.format("[%s] %s\r\n", DATE_FORMAT.format(new Date()), sb);
} writer.write(sb2);
public void warning(String msg){ writer.flush();
log(Level.WARNING,msg); } catch (Exception e) {
} e.printStackTrace();
public void warning(Exception e){ }
log(Level.WARNING,"Exception: "+e.toString()); }
StackTraceElement[] stes=e.getStackTrace(); public void debug(String msg){
for(StackTraceElement ste : stes){ log(Level.DEBUG,msg);
log(Level.WARNING,ste.toString()); }
} public void debug(String format, Object... objs) {
} debug(String.format(format, objs));
}
public void info(String msg){
log(Level.INFO,msg);
}
public void info(String format, Object... objs){
info(String.format(format, objs));
}
public void warning(String msg){
log(Level.WARNING,msg);
}
public void warning(String format, Object... objs){
warning(String.format(format, objs));
}
public void warning(Throwable e){
log(Level.WARNING,"Exception: "+e.toString());
StackTraceElement[] stes=e.getStackTrace();
for(StackTraceElement ste : stes){
log(Level.WARNING,ste.toString());
}
}
} }
+161 -164
View File
@@ -1,11 +1,12 @@
package customskinloader.config; package customskinloader.config;
import java.io.File; import java.io.File;
import java.lang.reflect.Field;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import org.apache.commons.io.Charsets; import customskinloader.utils.Version;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import customskinloader.CustomSkinLoader; import customskinloader.CustomSkinLoader;
@@ -14,182 +15,178 @@ import customskinloader.utils.HttpRequestUtil;
import customskinloader.utils.HttpTextureUtil; import customskinloader.utils.HttpTextureUtil;
import customskinloader.utils.HttpUtil0; import customskinloader.utils.HttpUtil0;
@SuppressWarnings("ResultOfMethodCallIgnored")
public class Config { public class Config {
//Program //Program
public String version; public String version;
public List<SkinSiteProfile> loadlist; public List<SkinSiteProfile> loadlist;
//Function //Function
public boolean enableDynamicSkull=true; public boolean enableDynamicSkull=true;
public boolean enableTransparentSkin=true; public boolean enableTransparentSkin=true;
public boolean ignoreHttpsCertificate=false; public boolean ignoreHttpsCertificate=false;
public boolean forceLoadAllTextures=false; public boolean forceLoadAllTextures=false;
public boolean enableCape = true;
//Cache //Cache
public int cacheExpiry=10; public int cacheExpiry=30;
public boolean enableUpdateSkull=false; public boolean enableUpdateSkull=false;
public boolean enableLocalProfileCache=false; public boolean enableLocalProfileCache=false;
public boolean enableCacheAutoClean=false; public boolean enableCacheAutoClean=false;
//Init config
public Config(SkinSiteProfile[] loadlist){
this.version=CustomSkinLoader.CustomSkinLoader_VERSION;
this.loadlist=Arrays.asList(loadlist);
}
//Init config public static Config loadConfig0() {
public Config(SkinSiteProfile[] loadlist){ Config config=loadConfig();
this.version=CustomSkinLoader.CustomSkinLoader_VERSION;
this.loadlist=Arrays.asList(loadlist);
}
public static Config loadConfig0() { //LoadList null checker
Config config=loadConfig(); if(config.loadlist==null){
config.loadlist=new ArrayList<SkinSiteProfile>();
}else{
for(int i=0;i<config.loadlist.size();i++){
if(config.loadlist.get(i)==null)
config.loadlist.remove(i--);
}
}
//LoadList null checker //Init program
if(config.loadlist==null){ config.loadExtraList();
config.loadlist=new ArrayList<SkinSiteProfile>(); config.initLocalFolder();
}else{ if(config.ignoreHttpsCertificate)
for(int i=0;i<config.loadlist.size();i++){ HttpUtil0.ignoreHttpsCertificate();
if(config.loadlist.get(i)==null) if(config.enableCacheAutoClean && !config.enableLocalProfileCache){
config.loadlist.remove(i--); try{
} FileUtils.deleteDirectory(HttpRequestUtil.CACHE_DIR);
} FileUtils.deleteDirectory(HttpTextureUtil.getCacheDir());
CustomSkinLoader.logger.info("Successfully cleaned cache.");
}catch(Exception e){
CustomSkinLoader.logger.warning("Exception occurs while cleaning cache: "+e.toString());
}
}
//Init program //Check config version
config.loadExtraList(); Version configVersion = Version.of(config.version);
config.initLocalFolder(); if (configVersion.compareTo(CustomSkinLoader.CustomSkinLoader_VERSION) < 0) {
if(config.ignoreHttpsCertificate) CustomSkinLoader.logger.info("Config File is out of date: " + config.version);
HttpUtil0.ignoreHttpsCertificate(); config.version = CustomSkinLoader.CustomSkinLoader_VERSION;
if(config.enableCacheAutoClean && !config.enableLocalProfileCache){
try{
FileUtils.deleteDirectory(HttpRequestUtil.CACHE_DIR);
FileUtils.deleteDirectory(HttpTextureUtil.getCacheDir());
CustomSkinLoader.logger.info("Successfully cleaned cache.");
}catch(Exception e){
CustomSkinLoader.logger.warning("Exception occurs while cleaning cache: "+e.toString());
}
}
//Output config //Update some config
CustomSkinLoader.logger.info("EnableDynamicSkull:"+config.enableDynamicSkull+ if (configVersion.compareTo("14.10") < 0)//Lower than 14.10
", EnableTranSkin:"+config.enableTransparentSkin+ config.enableCape = true;
", IgnoreHttpsCertificate:"+config.ignoreHttpsCertificate+ writeConfig(config, true);
", CacheExpiry:"+config.cacheExpiry+ }
", EnableUpdateSkull:"+config.enableUpdateSkull+
", EnableLocalProfileCache:"+config.enableLocalProfileCache+
", EnableCacheAutoClean:"+config.enableCacheAutoClean+
", LoadList:"+(config.loadlist==null?0:config.loadlist.size()));
//Check config version //Output config
float floatVersion=0f; for (Field field : config.getClass().getDeclaredFields()) {
float configVersion=0f; try {
try{ Object value = field.get(config);
floatVersion=Float.parseFloat(CustomSkinLoader.CustomSkinLoader_VERSION); if (value instanceof String || value instanceof Integer || value instanceof Boolean)
configVersion=Float.parseFloat(config.version); CustomSkinLoader.logger.info(field.getName() + " : " + value);
if(configVersion==15.1f)//To avoid some bug } catch (Exception ignored) { }
configVersion=14.6f; }
}catch (Exception e){ CustomSkinLoader.logger.info("loadList : " + (config.loadlist == null ? 0 : config.loadlist.size()));
CustomSkinLoader.logger.warning("Exception occurs while parsing version: "+e.toString());
}
if(config.version==null || configVersion==0f || floatVersion > configVersion){
CustomSkinLoader.logger.info("Config File is out of date: "+config.version);
config.version=CustomSkinLoader.CustomSkinLoader_VERSION;
writeConfig(config,true);
}
return config; return config;
} }
private static Config loadConfig() { private static Config loadConfig() {
CustomSkinLoader.logger.info("Config File: "+CustomSkinLoader.CONFIG_FILE.getAbsolutePath()); CustomSkinLoader.logger.info("Config File: "+CustomSkinLoader.CONFIG_FILE.getAbsolutePath());
if(!CustomSkinLoader.CONFIG_FILE.exists()){ if(!CustomSkinLoader.CONFIG_FILE.exists()){
CustomSkinLoader.logger.info("Config file not found, use default instead."); CustomSkinLoader.logger.info("Config file not found, use default instead.");
return initConfig(); return initConfig();
} }
try { try {
CustomSkinLoader.logger.info("Try to load config."); CustomSkinLoader.logger.info("Try to load config.");
String json=FileUtils.readFileToString(CustomSkinLoader.CONFIG_FILE,Charsets.UTF_8); String json=FileUtils.readFileToString(CustomSkinLoader.CONFIG_FILE, "UTF-8");
Config config=CustomSkinLoader.GSON.fromJson(json, Config.class); Config config=CustomSkinLoader.GSON.fromJson(json, Config.class);
CustomSkinLoader.logger.info("Successfully load config."); CustomSkinLoader.logger.info("Successfully load config.");
return config; return config;
}catch (Exception e) { }catch (Exception e) {
CustomSkinLoader.logger.info("Failed to load config, use default instead.("+e.toString()+")"); CustomSkinLoader.logger.info("Failed to load config, use default instead.("+e.toString()+")");
File brokenFile=new File(CustomSkinLoader.DATA_DIR,"BROKEN-CustomSkinLoader.json"); File brokenFile=new File(CustomSkinLoader.DATA_DIR,"BROKEN-CustomSkinLoader.json");
if(brokenFile.exists()) if(brokenFile.exists())
brokenFile.delete(); brokenFile.delete();
CustomSkinLoader.CONFIG_FILE.renameTo(brokenFile); CustomSkinLoader.CONFIG_FILE.renameTo(brokenFile);
return initConfig(); return initConfig();
} }
} }
private void loadExtraList(){ private void loadExtraList(){
File listAddition=new File(CustomSkinLoader.DATA_DIR,"ExtraList"); File listAddition=new File(CustomSkinLoader.DATA_DIR,"ExtraList");
if(!listAddition.isDirectory()){ if(!listAddition.isDirectory()){
listAddition.mkdirs(); listAddition.mkdirs();
return; return;
} }
List<SkinSiteProfile> adds=new ArrayList<SkinSiteProfile>(); List<SkinSiteProfile> adds=new ArrayList<SkinSiteProfile>();
File[] files=listAddition.listFiles(); File[] files=listAddition.listFiles();
for(File file:files){ for(File file: files != null ? files : new File[0]){
if(!file.getName().toLowerCase().endsWith(".json")&&!file.getName().toLowerCase().endsWith(".txt")) if(!file.getName().toLowerCase().endsWith(".json")&&!file.getName().toLowerCase().endsWith(".txt"))
continue; continue;
try { try {
CustomSkinLoader.logger.info("Try to load Extra List.("+file.getName()+")"); CustomSkinLoader.logger.info("Try to load Extra List.("+file.getName()+")");
String json=FileUtils.readFileToString(file,Charsets.UTF_8); String json=FileUtils.readFileToString(file, "UTF-8");
SkinSiteProfile ssp=CustomSkinLoader.GSON.fromJson(json, SkinSiteProfile.class); SkinSiteProfile ssp=CustomSkinLoader.GSON.fromJson(json, SkinSiteProfile.class);
CustomSkinLoader.logger.info("Successfully load Extra List."); CustomSkinLoader.logger.info("Successfully load Extra List.");
file.delete(); file.delete();
ProfileLoader.IProfileLoader loader=ProfileLoader.LOADERS.get(ssp.type.toLowerCase()); ProfileLoader.IProfileLoader loader=ProfileLoader.LOADERS.get(ssp.type.toLowerCase());
if(loader==null){ if(loader==null){
CustomSkinLoader.logger.info("Extra List will be ignore: Type '"+ssp.type+"' is not defined."); CustomSkinLoader.logger.info("Extra List will be ignore: Type '"+ssp.type+"' is not defined.");
continue; continue;
} }
boolean duplicate=false; boolean duplicate=false;
for(SkinSiteProfile ssp0:this.loadlist){ for(SkinSiteProfile ssp0:this.loadlist){
if(!ssp0.type.equalsIgnoreCase(ssp.type)) if(!ssp0.type.equalsIgnoreCase(ssp.type))
continue; continue;
if(loader.compare(ssp0, ssp)){ if(loader.compare(ssp0, ssp)){
duplicate=true; duplicate=true;
break; break;
} }
} }
if(!duplicate){ if(!duplicate){
adds.add(ssp); adds.add(ssp);
CustomSkinLoader.logger.info("Successfully apply Extra List.("+ssp.name+")"); CustomSkinLoader.logger.info("Successfully apply Extra List.("+ssp.name+")");
}else{ }else{
CustomSkinLoader.logger.info("Extra List will be ignore: Duplicate.("+ssp.name+")"); CustomSkinLoader.logger.info("Extra List will be ignore: Duplicate.("+ssp.name+")");
} }
}catch (Exception e) { }catch (Exception e) {
CustomSkinLoader.logger.info("Failed to load Extra List.("+e.toString()+")"); CustomSkinLoader.logger.info("Failed to load Extra List.("+e.toString()+")");
} }
} }
if(adds.size()!=0){ if(adds.size()!=0){
adds.addAll(this.loadlist); adds.addAll(this.loadlist);
this.loadlist=adds; this.loadlist=adds;
writeConfig(this,true); writeConfig(this,true);
} }
} }
private void initLocalFolder(){ private void initLocalFolder(){
for(SkinSiteProfile ssp:this.loadlist){ for(SkinSiteProfile ssp:this.loadlist){
ProfileLoader.IProfileLoader loader=ProfileLoader.LOADERS.get(ssp.type.toLowerCase()); ProfileLoader.IProfileLoader loader=ProfileLoader.LOADERS.get(ssp.type.toLowerCase());
if(loader==null) if(loader==null)
continue; continue;
loader.initLocalFolder(ssp); loader.initLocalFolder(ssp);
} }
} }
private static Config initConfig() { private static Config initConfig() {
Config config=new Config(CustomSkinLoader.DEFAULT_LOAD_LIST); Config config=new Config(CustomSkinLoader.DEFAULT_LOAD_LIST);
writeConfig(config,false); writeConfig(config,false);
return config; return config;
} }
private static void writeConfig(Config config,boolean update){ private static void writeConfig(Config config,boolean update){
String json=CustomSkinLoader.GSON.toJson(config); String json=CustomSkinLoader.GSON.toJson(config);
if(CustomSkinLoader.CONFIG_FILE.exists()) if(CustomSkinLoader.CONFIG_FILE.exists())
CustomSkinLoader.CONFIG_FILE.delete(); CustomSkinLoader.CONFIG_FILE.delete();
try { try {
CustomSkinLoader.CONFIG_FILE.createNewFile(); CustomSkinLoader.CONFIG_FILE.createNewFile();
FileUtils.write(CustomSkinLoader.CONFIG_FILE, json, Charsets.UTF_8); FileUtils.write(CustomSkinLoader.CONFIG_FILE, json, "UTF-8");
CustomSkinLoader.logger.info("Successfully "+(update?"update":"create")+" config."); CustomSkinLoader.logger.info("Successfully "+(update?"update":"create")+" config.");
} catch (Exception e) { } catch (Exception e) {
CustomSkinLoader.logger.info("Failed to "+(update?"update":"create")+" config.("+e.toString()+")"); CustomSkinLoader.logger.info("Failed to "+(update?"update":"create")+" config.("+e.toString()+")");
} }
} }
} }
@@ -1,64 +1,61 @@
package customskinloader.config; package customskinloader.config;
import customskinloader.loader.jsonapi.CustomSkinAPIPlus.CustomSkinAPIPlusPrivacy;
public class SkinSiteProfile { public class SkinSiteProfile {
public String name; public String name;
public String type; public String type;
public String userAgent; public String userAgent;
public String root; public String root;
public CustomSkinAPIPlusPrivacy privacy;
public Boolean checkPNG;//Not suitable for local skin public Boolean checkPNG;//Not suitable for local skin
public String skin; public String skin;
public String model; public String model;
public String cape; public String cape;
public String elytra; public String elytra;
public static SkinSiteProfile createMojangAPI(String name){ public static SkinSiteProfile createMojangAPI(String name){
SkinSiteProfile ssp=new SkinSiteProfile(); SkinSiteProfile ssp=new SkinSiteProfile();
ssp.name=name; ssp.name=name;
ssp.type="MojangAPI"; ssp.type="MojangAPI";
return ssp; return ssp;
} }
public static SkinSiteProfile createCustomSkinAPI(String name,String root){ public static SkinSiteProfile createCustomSkinAPI(String name,String root){
SkinSiteProfile ssp=new SkinSiteProfile(); SkinSiteProfile ssp=new SkinSiteProfile();
ssp.name=name; ssp.name=name;
ssp.type="CustomSkinAPI"; ssp.type="CustomSkinAPI";
ssp.root=root; ssp.root=root;
return ssp; return ssp;
} }
public static SkinSiteProfile creatCustomSkinAPIPlus(String name,String root){ public static SkinSiteProfile creatCustomSkinAPIPlus(String name,String root){
SkinSiteProfile ssp=new SkinSiteProfile(); SkinSiteProfile ssp=new SkinSiteProfile();
ssp.name=name; ssp.name=name;
ssp.type="CustomSkinAPIPlus"; ssp.type="CustomSkinAPIPlus";
ssp.root=root; ssp.root=root;
ssp.privacy=new CustomSkinAPIPlusPrivacy(); return ssp;
return ssp; }
} public static SkinSiteProfile createUniSkinAPI(String name,String root){
public static SkinSiteProfile createUniSkinAPI(String name,String root){ SkinSiteProfile ssp=new SkinSiteProfile();
SkinSiteProfile ssp=new SkinSiteProfile(); ssp.name=name;
ssp.name=name; ssp.type="UniSkinAPI";
ssp.type="UniSkinAPI"; ssp.root=root;
ssp.root=root; return ssp;
return ssp; }
} public static SkinSiteProfile createLegacy(String name,String skin,String cape,String elytra){
public static SkinSiteProfile createLegacy(String name,String skin,String cape,String elytra){ SkinSiteProfile ssp=new SkinSiteProfile();
SkinSiteProfile ssp=new SkinSiteProfile(); ssp.name=name;
ssp.name=name; ssp.type="Legacy";
ssp.type="Legacy"; ssp.checkPNG=false;
ssp.checkPNG=false; ssp.skin=skin;
ssp.skin=skin; ssp.model="auto";
ssp.model="default"; ssp.cape=cape;
ssp.cape=cape; ssp.elytra=elytra;
ssp.elytra=elytra; return ssp;
return ssp; }
}
public static SkinSiteProfile createElfSkin(String name){ public static SkinSiteProfile createElyByAPI(String name) {
SkinSiteProfile ssp=new SkinSiteProfile(); SkinSiteProfile ssp = new SkinSiteProfile();
ssp.name=name; ssp.name = name;
ssp.type="ElfSkin"; ssp.type = "ElyByAPI";
return ssp; return ssp;
} }
} }
@@ -0,0 +1,89 @@
package customskinloader.fake;
import java.util.Map;
import java.util.UUID;
import com.google.common.collect.Maps;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
import customskinloader.CustomSkinLoader;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.ThreadDownloadImageData;
import net.minecraft.client.renderer.texture.ITextureObject;
import net.minecraft.client.renderer.texture.SimpleTexture;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.client.resources.DefaultPlayerSkin;
import net.minecraft.client.resources.SkinManager;
import net.minecraft.client.resources.SkinManager.SkinAvailableCallback;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StringUtils;
public class FakeClientPlayer {
//For Legacy Skin
public static ThreadDownloadImageData getDownloadImageSkin(ResourceLocation resourceLocationIn, String username) {
//CustomSkinLoader.logger.debug("FakeClientPlayer/getDownloadImageSkin "+username);
TextureManager textman = Minecraft.getMinecraft().getTextureManager();
ITextureObject ito = textman.getTexture(resourceLocationIn);
if (ito == null || !(ito instanceof ThreadDownloadImageData)) {
//if Legacy Skin for username not loaded yet
SkinManager skinman = Minecraft.getMinecraft().getSkinManager();
UUID offlineUUID = getOfflineUUID(username);
GameProfile offlineProfile = new GameProfile(offlineUUID, username);
//Load Default Skin
ResourceLocation defaultSkin = DefaultPlayerSkin.getDefaultSkin(offlineUUID);
ITextureObject defaultSkinObj = new SimpleTexture(defaultSkin);
textman.loadTexture(resourceLocationIn, defaultSkinObj);
//Load Skin from SkinManager
skinman.loadProfileTextures(offlineProfile, new LegacyBuffer(resourceLocationIn), false);
}
if (ito instanceof ThreadDownloadImageData)
return (ThreadDownloadImageData) ito;
else
return null;
}
public static ResourceLocation getLocationSkin(String username) {
//CustomSkinLoader.logger.debug("FakeClientPlayer/getLocationSkin "+username);
return new ResourceLocation("skins/legacy-" + StringUtils.stripControlCodes(username));
}
public static UUID getOfflineUUID(String username)
{
return UUID.nameUUIDFromBytes(("OfflinePlayer:" + username).getBytes());
}
public static Map<ResourceLocation, ITextureObject> textureCache = Maps.newHashMap();
public static class LegacyBuffer implements SkinAvailableCallback {
ResourceLocation resourceLocationIn;
boolean loaded = false;
public LegacyBuffer(ResourceLocation resourceLocationIn) {
CustomSkinLoader.logger.debug("Loading Legacy Texture (" + resourceLocationIn + ")");
this.resourceLocationIn = resourceLocationIn;
}
@Override
public void skinAvailable(Type typeIn, ResourceLocation location, MinecraftProfileTexture profileTexture) {
if (typeIn != Type.SKIN || loaded)
return;
TextureManager textman = Minecraft.getMinecraft().getTextureManager();
ITextureObject ito = textman.getTexture(location);
if (ito == null)
ito = textureCache.get(location);
if (ito == null)
return;
loaded = true;
textman.loadTexture(resourceLocationIn, ito);
CustomSkinLoader.logger.debug("Legacy Texture (" + resourceLocationIn + ") Loaded as " +
ito.toString() + " (" + location + ")");
}
}
}
@@ -1,117 +1,151 @@
package customskinloader.fake; package customskinloader.fake;
import java.awt.Color; import customskinloader.CustomSkinLoader;
import java.awt.Graphics; import customskinloader.fake.texture.FakeBufferedImage;
import customskinloader.fake.texture.FakeImage;
import customskinloader.fake.texture.FakeNativeImage;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.awt.image.DataBufferInt;
import java.awt.image.ImageObserver;
public class FakeSkinBuffer implements net.minecraft.client.renderer.IImageBuffer { public class FakeSkinBuffer implements net.minecraft.client.renderer.IImageBuffer {
private int[] imageData; private int ratio = 1;
private int ratio=1; private FakeImage image = null;
@Override //parseUserSkin for 1.13+
public BufferedImage parseUserSkin(BufferedImage image) { public net.minecraft.client.renderer.texture.NativeImage func_195786_a(net.minecraft.client.renderer.texture.NativeImage image) {
if(image==null) if (image == null)
return null; return null;
ratio = image.getWidth() / 64;
BufferedImage bufferedimage = new BufferedImage(64 * ratio, 64 * ratio, 2);
Graphics graphics = bufferedimage.getGraphics();
graphics.setColor(new Color(0,0,0,0));
graphics.fillRect(0,0,64,64);
graphics.drawImage(image,0,0,(ImageObserver)null);
if (image.getHeight() == 32 * ratio){//Single Layer
//Revert to original algorithm
//Right Leg -> Left Leg
graphics.drawImage(bufferedimage, 24 * ratio, 48 * ratio, 20 * ratio, 52 * ratio, 4 * ratio, 16 * ratio, 8 * ratio, 20 * ratio, (ImageObserver)null);//Top
graphics.drawImage(bufferedimage, 28 * ratio, 48 * ratio, 24 * ratio, 52 * ratio, 8 * ratio, 16 * ratio, 12 * ratio, 20 * ratio, (ImageObserver)null);//Bottom
graphics.drawImage(bufferedimage, 20 * ratio, 52 * ratio, 16 * ratio, 64 * ratio, 8 * ratio, 20 * ratio, 12 * ratio, 32 * ratio, (ImageObserver)null);//Left
graphics.drawImage(bufferedimage, 24 * ratio, 52 * ratio, 20 * ratio, 64 * ratio, 4 * ratio, 20 * ratio, 8 * ratio, 32 * ratio, (ImageObserver)null);//Front
graphics.drawImage(bufferedimage, 28 * ratio, 52 * ratio, 24 * ratio, 64 * ratio, 0 * ratio, 20 * ratio, 4 * ratio, 32 * ratio, (ImageObserver)null);//Right
graphics.drawImage(bufferedimage, 32 * ratio, 52 * ratio, 28 * ratio, 64 * ratio, 12 * ratio, 20 * ratio, 16 * ratio, 32 * ratio, (ImageObserver)null);//Back
//Right Arm -> Left Arm
graphics.drawImage(bufferedimage, 40 * ratio, 48 * ratio, 36 * ratio, 52 * ratio, 44 * ratio, 16 * ratio, 48 * ratio, 20 * ratio, (ImageObserver)null);//Top
graphics.drawImage(bufferedimage, 44 * ratio, 48 * ratio, 40 * ratio, 52 * ratio, 48 * ratio, 16 * ratio, 52 * ratio, 20 * ratio, (ImageObserver)null);//Bottom
graphics.drawImage(bufferedimage, 36 * ratio, 52 * ratio, 32 * ratio, 64 * ratio, 48 * ratio, 20 * ratio, 52 * ratio, 32 * ratio, (ImageObserver)null);//Left
graphics.drawImage(bufferedimage, 40 * ratio, 52 * ratio, 36 * ratio, 64 * ratio, 44 * ratio, 20 * ratio, 48 * ratio, 32 * ratio, (ImageObserver)null);//Front
graphics.drawImage(bufferedimage, 44 * ratio, 52 * ratio, 40 * ratio, 64 * ratio, 40 * ratio, 20 * ratio, 44 * ratio, 32 * ratio, (ImageObserver)null);//Right
graphics.drawImage(bufferedimage, 48 * ratio, 52 * ratio, 44 * ratio, 64 * ratio, 52 * ratio, 20 * ratio, 56 * ratio, 32 * ratio, (ImageObserver)null);//Back
}
graphics.dispose();
this.imageData = ((DataBufferInt)bufferedimage.getRaster().getDataBuffer()).getData();
setAreaDueToConfig( 0 * ratio, 0 * ratio,32 * ratio,16 * ratio);//Head - 1 FakeImage img = parseUserSkin(new FakeNativeImage(image));
setAreaTransparent(32 * ratio, 0 * ratio,64 * ratio,16 * ratio);//Head - 2 if (img instanceof FakeNativeImage)
return ((FakeNativeImage) img).getImage();
setAreaDueToConfig( 0 * ratio,16 * ratio,16 * ratio,32 * ratio);//Right Leg - 1 CustomSkinLoader.logger.warning("Failed to parseUserSkin(func_195786_a).");
setAreaDueToConfig(16 * ratio,16 * ratio,40 * ratio,32 * ratio);//Body - 1 return null;
setAreaDueToConfig(40 * ratio,16 * ratio,56 * ratio,32 * ratio);//Right Arm - 1 }
setAreaTransparent( 0 * ratio,32 * ratio,16 * ratio,48 * ratio);//Right Leg - 2 //parseUserSkin for 1.12.2-
setAreaTransparent(16 * ratio,32 * ratio,40 * ratio,48 * ratio);//Body - 2 public BufferedImage parseUserSkin(BufferedImage image) {
setAreaTransparent(40 * ratio,32 * ratio,56 * ratio,48 * ratio);//Right Arm - 2 if (image == null)
return null;
setAreaTransparent( 0 * ratio,48 * ratio,16 * ratio,64 * ratio);//Left Leg - 2 FakeImage img = parseUserSkin(new FakeBufferedImage(image));
setAreaDueToConfig(16 * ratio,48 * ratio,32 * ratio,64 * ratio);//Left Leg - 1 if (img instanceof FakeBufferedImage)
setAreaDueToConfig(32 * ratio,48 * ratio,48 * ratio,64 * ratio);//Left Arm - 1 return ((FakeBufferedImage) img).getImage();
setAreaTransparent(48 * ratio,48 * ratio,64 * ratio,64 * ratio);//Left Arm - 2
return bufferedimage; CustomSkinLoader.logger.warning("Failed to parseUserSkin.");
} return null;
}
/* 2^24-1 public FakeImage parseUserSkin(FakeImage image) {
* 00000000 11111111 11111111 11111111 */ if (image == null) return null;
private static final int A=16777215; this.ratio = image.getWidth() / 64;
private static final int WHITE=getARGB(255,255,255,255);
private static final int BLACK=getARGB(255,0,0,0);
private boolean isFilled(int x0,int y0,int x1,int y1){
int data=this.imageData[getPosition(x0,y0)];
if(data!=WHITE && data!=BLACK)
return false;
for (int x=x0;x<x1;++x)
for (int y=y0;y<y1;++y)
if(this.imageData[getPosition(x,y)]!=data)
return false;
return true;
}
private void setAreaTransparent(int x0,int y0,int x1,int y1){
if(!isFilled(x0,y0,x1,y1))
return;
for (int x=x0;x<x1;++x)
for (int y=y0;y<y1;++y)
this.imageData[getPosition(x,y)] &= A;
}
/* -2^24 if (image.getHeight() != image.getWidth()) {//Single Layer
* 00000001 00000000 00000000 00000000 -> //Create a new image and copy origin image data
* 11111110 11111111 11111111 11111111 -> FakeImage img = image.createImage(64 * ratio, 64 * ratio);
* 11111111 00000000 00000000 00000000 */ img.copyImageData(image); image.close(); image = img;
private static final int B=-16777216; image.fillArea(0 * ratio, 32 * ratio, 64 * ratio, 32 * ratio);
private void setAreaOpaque(int x0,int y0,int x1,int y1){
for (int x=x0;x<x1;++x)
for (int y=y0;y<y1;++y)
this.imageData[getPosition(x,y)] |= B;
}
private void setAreaDueToConfig(int x0,int y0,int x1,int y1){ //Right Leg -> Left Leg
if(customskinloader.CustomSkinLoader.config.enableTransparentSkin) image.copyArea( 4 * ratio, 16 * ratio, 16 * ratio, 32 * ratio, 4 * ratio, 4 * ratio, true, false);//Top
setAreaTransparent(x0,y0,x1,y1); image.copyArea( 8 * ratio, 16 * ratio, 16 * ratio, 32 * ratio, 4 * ratio, 4 * ratio, true, false);//Bottom
else image.copyArea( 0 * ratio, 20 * ratio, 24 * ratio, 32 * ratio, 4 * ratio, 12 * ratio, true, false);//Right
setAreaOpaque(x0,y0,x1,y1); image.copyArea( 4 * ratio, 20 * ratio, 16 * ratio, 32 * ratio, 4 * ratio, 12 * ratio, true, false);//Front
} image.copyArea( 8 * ratio, 20 * ratio, 8 * ratio, 32 * ratio, 4 * ratio, 12 * ratio, true, false);//Left
image.copyArea(12 * ratio, 20 * ratio, 16 * ratio, 32 * ratio, 4 * ratio, 12 * ratio, true, false);//Back
//Right Arm -> Left Arm
image.copyArea(44 * ratio, 16 * ratio, -8 * ratio, 32 * ratio, 4 * ratio, 4 * ratio, true, false);//Top
image.copyArea(48 * ratio, 16 * ratio, -8 * ratio, 32 * ratio, 4 * ratio, 4 * ratio, true, false);//Bottom
image.copyArea(40 * ratio, 20 * ratio, 0 * ratio, 32 * ratio, 4 * ratio, 12 * ratio, true, false);//Right
image.copyArea(44 * ratio, 20 * ratio, -8 * ratio, 32 * ratio, 4 * ratio, 12 * ratio, true, false);//Front
image.copyArea(48 * ratio, 20 * ratio,-16 * ratio, 32 * ratio, 4 * ratio, 12 * ratio, true, false);//Left
image.copyArea(52 * ratio, 20 * ratio, -8 * ratio, 32 * ratio, 4 * ratio, 12 * ratio, true, false);//Back
}
this.image = image;
setAreaDueToConfig( 0 * ratio, 0 * ratio, 32 * ratio, 16 * ratio);//Head - 1
setAreaTransparent(32 * ratio, 0 * ratio, 64 * ratio, 16 * ratio);//Head - 2
setAreaDueToConfig(16 * ratio, 16 * ratio, 40 * ratio, 32 * ratio);//Body - 1
setAreaTransparent(16 * ratio, 32 * ratio, 40 * ratio, 48 * ratio);//Body - 2
@Override setAreaDueToConfig(40 * ratio, 16 * ratio, 56 * ratio, 32 * ratio);//Right Arm - 1
public void skinAvailable(){ setAreaTransparent(40 * ratio, 32 * ratio, 56 * ratio, 48 * ratio);//Right Arm - 2
//A callback when skin loaded setAreaDueToConfig( 0 * ratio, 16 * ratio, 16 * ratio, 32 * ratio);//Right Leg - 1
} setAreaTransparent( 0 * ratio, 32 * ratio, 16 * ratio, 48 * ratio);//Right Leg - 2
private static int getARGB(int a,int r,int g,int b){ setAreaDueToConfig(32 * ratio, 48 * ratio, 48 * ratio, 64 * ratio);//Left Arm - 1
return (a << 24) | (r << 16) | (g << 8) | b; setAreaTransparent(48 * ratio, 48 * ratio, 64 * ratio, 64 * ratio);//Left Arm - 2
} setAreaDueToConfig(16 * ratio, 48 * ratio, 32 * ratio, 64 * ratio);//Left Leg - 1
setAreaTransparent( 0 * ratio, 48 * ratio, 16 * ratio, 64 * ratio);//Left Leg - 2
return image;
}
private int getPosition(int x,int y){ /**
return x+y*64*ratio; * Judge the type of skin
} * Must be called after parseUserSkin
*
* @return type of skin (slim / default)
* @since 14.9
*/
public String judgeType() {
if (this.image == null)
return null;
if (((image.getRGBA(55, 20) & B) >>> 24) == 0)//if (55,20) is transparent
return "slim";
return "default";
}
/* 2^24-1
* 00000000 11111111 11111111 11111111 */
private static final int A = 16777215;
private static final int WHITE = getARGB(255, 255, 255, 255);
private static final int BLACK = getARGB(255, 0, 0, 0);
private boolean isFilled(int x0, int y0, int x1, int y1) {
int data = image.getRGBA(x0, y0);
if (data != WHITE && data != BLACK)
return false;
for (int x = x0; x < x1; ++x)
for (int y = y0; y < y1; ++y)
if (image.getRGBA(x, y) != data)
return false;
return true;
}
private void setAreaTransparent(int x0, int y0, int x1, int y1) {
if (!isFilled(x0, y0, x1, y1))
return;
for (int x = x0; x < x1; ++x)
for (int y = y0; y < y1; ++y)
image.setRGBA(x, y, image.getRGBA(x,y) & A);
}
/* -2^24
* 00000001 00000000 00000000 00000000 ->
* 11111110 11111111 11111111 11111111 ->
* 11111111 00000000 00000000 00000000 */
private static final int B = -16777216;
private void setAreaOpaque(int x0, int y0, int x1, int y1) {
for (int x = x0; x < x1; ++x)
for (int y = y0; y < y1; ++y)
image.setRGBA(x, y, image.getRGBA(x,y) | B);
}
private void setAreaDueToConfig(int x0, int y0, int x1, int y1) {
if (customskinloader.CustomSkinLoader.config.enableTransparentSkin)
setAreaTransparent(x0, y0, x1, y1);
else
setAreaOpaque(x0, y0, x1, y1);
}
public void skinAvailable() {
//A callback when skin loaded, nothing to do
}
private static int getARGB(int a, int r, int g, int b) {
return (a << 24) | (r << 16) | (g << 8) | b;
}
} }
@@ -28,81 +28,92 @@ import net.minecraft.client.resources.SkinManager.SkinAvailableCallback;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
public class FakeSkinManager{ public class FakeSkinManager{
private static final ExecutorService THREAD_POOL = new ThreadPoolExecutor(0, 2, 1L, TimeUnit.MINUTES, new LinkedBlockingQueue()); private static final ExecutorService THREAD_POOL = new ThreadPoolExecutor(0, 2, 1L, TimeUnit.MINUTES, new LinkedBlockingQueue<Runnable>());
private final TextureManager textureManager; private final TextureManager textureManager;
public FakeSkinManager(TextureManager textureManagerInstance, File skinCacheDirectory, MinecraftSessionService sessionService) { public FakeSkinManager(TextureManager textureManagerInstance, File skinCacheDirectory, MinecraftSessionService sessionService) {
this.textureManager=textureManagerInstance; this.textureManager=textureManagerInstance;
HttpTextureUtil.defaultCacheDir=skinCacheDirectory; HttpTextureUtil.defaultCacheDir=skinCacheDirectory;
} }
public ResourceLocation loadSkin(MinecraftProfileTexture profileTexture, Type textureType){ public ResourceLocation loadSkin(MinecraftProfileTexture profileTexture, Type textureType){
return this.loadSkin(profileTexture, textureType, null); return this.loadSkin(profileTexture, textureType, null);
} }
public ResourceLocation loadSkin(final MinecraftProfileTexture profileTexture, final Type textureType, final SkinAvailableCallback skinAvailableCallback){ public ResourceLocation loadSkin(final MinecraftProfileTexture profileTexture, final Type textureType, final SkinAvailableCallback skinAvailableCallback){
HttpTextureInfo info=HttpTextureUtil.toHttpTextureInfo(profileTexture.getUrl()); HttpTextureInfo info=HttpTextureUtil.toHttpTextureInfo(profileTexture.getUrl());
final ResourceLocation resourcelocation = new ResourceLocation("skins/" + info.hash); final ResourceLocation resourcelocation = new ResourceLocation("skins/" + info.hash);
ITextureObject itextureobject = this.textureManager.getTexture(resourcelocation); ITextureObject itextureobject = this.textureManager.getTexture(resourcelocation);
if (itextureobject != null)//Have already loaded if (itextureobject != null)//Have already loaded
makeCallback(skinAvailableCallback,textureType, resourcelocation, profileTexture); makeCallback(skinAvailableCallback,textureType, resourcelocation, profileTexture);
else{ else{
ThreadDownloadImageData threaddownloadimagedata = new ThreadDownloadImageData(info.cacheFile, info.url, DefaultPlayerSkin.getDefaultSkinLegacy(), ThreadDownloadImageData threaddownloadimagedata = new ThreadDownloadImageData(info.cacheFile, info.url, DefaultPlayerSkin.getDefaultSkinLegacy(),
new BaseBuffer(skinAvailableCallback, textureType, resourcelocation, profileTexture)); new BaseBuffer(skinAvailableCallback, textureType, resourcelocation, profileTexture));
this.textureManager.loadTexture(resourcelocation, threaddownloadimagedata); if(skinAvailableCallback instanceof FakeClientPlayer.LegacyBuffer)//Cache for client player
} FakeClientPlayer.textureCache.put(resourcelocation,threaddownloadimagedata);
return resourcelocation; this.textureManager.loadTexture(resourcelocation, threaddownloadimagedata);
} }
public void loadProfileTextures(final GameProfile profile, final SkinAvailableCallback skinAvailableCallback, final boolean requireSecure){ return resourcelocation;
THREAD_POOL.submit(new Runnable(){ }
public void run(){ public void loadProfileTextures(final GameProfile profile, final SkinAvailableCallback skinAvailableCallback, final boolean requireSecure){
final Map<Type, MinecraftProfileTexture> map = Maps.<Type, MinecraftProfileTexture>newHashMap(); THREAD_POOL.submit(new Runnable(){
map.putAll(customskinloader.CustomSkinLoader.loadProfile(profile)); public void run(){
final Map<Type, MinecraftProfileTexture> map = Maps.newHashMap();
map.putAll(customskinloader.CustomSkinLoader.loadProfile(profile));
Minecraft.getMinecraft().addScheduledTask(new Runnable(){ Minecraft.getMinecraft().addScheduledTask(new Runnable(){
public void run(){ public void run(){
for(Type type:Type.values()) for(Type type:Type.values())
if(map.containsKey(type)) if(map.containsKey(type))
FakeSkinManager.this.loadSkin((MinecraftProfileTexture)map.get(type), type, skinAvailableCallback); FakeSkinManager.this.loadSkin(map.get(type), type, skinAvailableCallback);
} }
}); });
} }
}); });
} }
public Map<Type, MinecraftProfileTexture> loadSkinFromCache(GameProfile profile){ public Map<Type, MinecraftProfileTexture> loadSkinFromCache(GameProfile profile){
return CustomSkinLoader.loadProfileFromCache(profile); return CustomSkinLoader.loadProfileFromCache(profile);
} }
private static void makeCallback(SkinAvailableCallback callback,Type type, ResourceLocation location, MinecraftProfileTexture texture){ private static void makeCallback(SkinAvailableCallback callback,Type type, ResourceLocation location, MinecraftProfileTexture texture){
if(callback!=null) if(callback!=null)
callback.skinAvailable(type, location, texture); callback.skinAvailable(type, location, texture);
} }
private class BaseBuffer implements IImageBuffer{ private class BaseBuffer implements IImageBuffer{
private IImageBuffer buffer; private IImageBuffer buffer;
private SkinAvailableCallback callback; private SkinAvailableCallback callback;
private Type type; private Type type;
private ResourceLocation location; private ResourceLocation location;
private MinecraftProfileTexture texture; private MinecraftProfileTexture texture;
public BaseBuffer(SkinAvailableCallback callback,Type type,ResourceLocation location,MinecraftProfileTexture texture){ public BaseBuffer(SkinAvailableCallback callback,Type type,ResourceLocation location,MinecraftProfileTexture texture){
this.buffer=(type==Type.SKIN?new FakeSkinBuffer():null); this.buffer=(type==Type.SKIN?new FakeSkinBuffer():null);
this.callback=callback; this.callback=callback;
this.type=type; this.type=type;
this.location=location; this.location=location;
this.texture=texture; this.texture=texture;
} }
public BufferedImage parseUserSkin(BufferedImage image){ public net.minecraft.client.renderer.texture.NativeImage func_195786_a(net.minecraft.client.renderer.texture.NativeImage image){
return buffer==null?image:buffer.parseUserSkin(image); return buffer instanceof FakeSkinBuffer ? ((FakeSkinBuffer) buffer).func_195786_a(image) : image;
} }
public void skinAvailable(){ public BufferedImage parseUserSkin(BufferedImage image){
if (buffer != null) return buffer==null?image:buffer.parseUserSkin(image);
buffer.skinAvailable(); }
public void skinAvailable(){
FakeSkinManager.makeCallback(callback,type, location, texture); if (buffer != null){
} buffer.skinAvailable();
} if ("auto".equals(texture.getMetadata("model")) && buffer instanceof FakeSkinBuffer){
//Auto judge skin type
Map<String, String> metadata = Maps.newHashMap();
metadata.put("model", ((FakeSkinBuffer) buffer).judgeType());
texture = new MinecraftProfileTexture(texture.getUrl(), metadata);
}
}
FakeSkinManager.makeCallback(callback,type, location, texture);
}
}
} }
@@ -0,0 +1,67 @@
package customskinloader.fake.texture;
import java.awt.*;
import java.awt.image.BufferedImage;
public class FakeBufferedImage implements FakeImage {
private BufferedImage image;
private Graphics graphics;
public FakeBufferedImage(int width, int height) {
this(new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB));
}
public FakeBufferedImage(BufferedImage image) {
this.image = image;
graphics = image.getGraphics();
}
public BufferedImage getImage() {
graphics.dispose();
return image;
}
public FakeImage createImage(int width, int height) {
return new FakeBufferedImage(width, height);
}
public int getWidth() {
return image.getWidth();
}
public int getHeight() {
return image.getHeight();
}
public int getRGBA(int x, int y) {
return image.getRGB(x, y);
}
public void setRGBA(int x, int y, int rgba) {
image.setRGB(x, y, rgba);
}
public void copyImageData(FakeImage image) {
if (!(image instanceof FakeBufferedImage)) return;
BufferedImage img = ((FakeBufferedImage) image).getImage();
graphics.drawImage(img, 0, 0, null);
}
public void fillArea(int x0, int y0, int width, int height) {
graphics.setColor(new Color(0, 0, 0, 0));
graphics.fillRect(x0, y0, width, height);
}
public void copyArea(int x0, int y0, int dx, int dy, int width, int height, boolean reversex, boolean reversey) {
int x1 = x0 + width, x2 = x0 + dx, x3 = x2 + width;
int y1 = y0 + height, y2 = y0 + dy, y3 = y2 + height;
graphics.drawImage(image,
reversex ? x3 : x2, reversey ? y3 : y2,
reversex ? x2 : x3, reversey ? y2 : y3,
x0, y0, x1, y1, null);
}
public void close() {
graphics.dispose();
}
}
@@ -0,0 +1,21 @@
package customskinloader.fake.texture;
public interface FakeImage {
FakeImage createImage(int width, int height);
int getWidth();
int getHeight();
int getRGBA(int x, int y);
void setRGBA(int x, int y, int rgba);
void copyImageData(FakeImage image);
void fillArea(int x0, int y0, int width, int height);
void copyArea(int x0, int y0, int dx, int dy, int width, int height, boolean reversex, boolean reversey);
void close();
}
@@ -0,0 +1,55 @@
package customskinloader.fake.texture;
import net.minecraft.client.renderer.texture.NativeImage;
public class FakeNativeImage implements FakeImage {
private NativeImage image;
public FakeNativeImage(int width, int height) {
this(new NativeImage(width, height, true));
}
public FakeNativeImage(NativeImage image) {
this.image = image;
}
public NativeImage getImage() {
return image;
}
public FakeImage createImage(int width, int height) {
return new FakeNativeImage(width, height);
}
public int getWidth() {
return image.func_195702_a();
}
public int getHeight() {
return image.func_195714_b();
}
public int getRGBA(int x, int y) {
return image.func_195709_a(x, y);
}
public void setRGBA(int x, int y, int rgba) {
image.func_195700_a(x, y, rgba);
}
public void copyImageData(FakeImage image) {
if (!(image instanceof FakeNativeImage)) return;
this.image.func_195703_a(((FakeNativeImage) image).getImage());
}
public void fillArea(int x0, int y0, int width, int height) {
image.func_195715_a(x0, y0, width, height, 0);
}
public void copyArea(int x0, int y0, int dx, int dy, int width, int height, boolean reversex, boolean reversey) {
image.func_195699_a(x0, y0, dx, dy, width, height, reversex, reversey);
}
public void close() {
}
}
@@ -19,83 +19,87 @@ import customskinloader.utils.HttpRequestUtil.HttpResponce;
public class JsonAPILoader implements ProfileLoader.IProfileLoader { public class JsonAPILoader implements ProfileLoader.IProfileLoader {
public interface IJsonAPI { public interface IJsonAPI {
public String toJsonUrl(String root,String username); String toJsonUrl(String root, String username);
public String getPayload(SkinSiteProfile ssp); String getPayload(SkinSiteProfile ssp);
public UserProfile toUserProfile(String root,String json,boolean local); UserProfile toUserProfile(String root, String json, boolean local);
public String getName(); String getName();
} }
public static class ErrorProfile{ public static class ErrorProfile{
public int errno; public int errno;
public String msg; public String msg;
} }
public static enum Type{ public enum Type{
CustomSkinAPI(new CustomSkinAPI()),CustomSkinAPIPlus(new CustomSkinAPIPlus()),UniSkinAPI(new UniSkinAPI()); CustomSkinAPI(new CustomSkinAPI()),
public IJsonAPI jsonAPI; CustomSkinAPIPlus(new CustomSkinAPIPlus()),
private Type(IJsonAPI jsonAPI){ UniSkinAPI(new UniSkinAPI()),
this.jsonAPI=jsonAPI; ElyByAPI(new ElyByAPI());
} public IJsonAPI jsonAPI;
} Type(IJsonAPI jsonAPI){
this.jsonAPI=jsonAPI;
}
}
private Type type; private Type type;
public JsonAPILoader(Type type){ public JsonAPILoader(Type type){
this.type=type; this.type=type;
} }
@Override @Override
public UserProfile loadProfile(SkinSiteProfile ssp, GameProfile gameProfile) throws Exception { public UserProfile loadProfile(SkinSiteProfile ssp, GameProfile gameProfile) throws Exception {
String username=gameProfile.getName(); String username=gameProfile.getName();
boolean local=HttpUtil0.isLocal(ssp.root); if(StringUtils.isEmpty(ssp.root) && type!=Type.ElyByAPI){
if(ssp.root==null||ssp.root.equals("")){ CustomSkinLoader.logger.info("Root not defined.");
CustomSkinLoader.logger.info("Root not defined."); return null;
return null; }
} boolean local = HttpUtil0.isLocal(ssp.root);
String jsonUrl=type.jsonAPI.toJsonUrl(ssp.root, username); String jsonUrl=type.jsonAPI.toJsonUrl(ssp.root, username);
String json; String json;
if(local){ if(local){
File jsonFile=new File(jsonUrl); File jsonFile = new File(CustomSkinLoader.DATA_DIR, jsonUrl);
if(!jsonFile.exists()){ if(!jsonFile.exists()){
CustomSkinLoader.logger.info("Profile File not found."); CustomSkinLoader.logger.info("Profile File not found.");
return null; return null;
} }
json=IOUtils.toString(new FileInputStream(jsonFile)); json=IOUtils.toString(new FileInputStream(jsonFile), "UTF-8");
}else{ }else{
HttpResponce responce=HttpRequestUtil.makeHttpRequest(new HttpRequest(jsonUrl).setCacheTime(60).setUserAgent(ssp.userAgent).setPayload(type.jsonAPI.getPayload(ssp))); HttpResponce responce=HttpRequestUtil.makeHttpRequest(new HttpRequest(jsonUrl).setCacheTime(90).setUserAgent(ssp.userAgent).setPayload(type.jsonAPI.getPayload(ssp)));
json=responce.content; json=responce.content;
} }
if(json==null||json.equals("")){ if(json==null||json.equals("")){
CustomSkinLoader.logger.info("Profile not found."); CustomSkinLoader.logger.info("Profile not found.");
return null; return null;
} }
ErrorProfile profile=CustomSkinLoader.GSON.fromJson(json, ErrorProfile.class); ErrorProfile profile=CustomSkinLoader.GSON.fromJson(json, ErrorProfile.class);
if(profile.errno!=0){ if(profile.errno!=0){
CustomSkinLoader.logger.info("Error "+profile.errno+": "+profile.msg); CustomSkinLoader.logger.info("Error "+profile.errno+": "+profile.msg);
return null; return null;
} }
UserProfile p=type.jsonAPI.toUserProfile(ssp.root, json, local); UserProfile p=type.jsonAPI.toUserProfile(ssp.root, json, local);
if(p==null||p.isEmpty()){ if(p==null||p.isEmpty()){
CustomSkinLoader.logger.info("Both skin and cape not found."); CustomSkinLoader.logger.info("Both skin and cape not found.");
return null; return null;
}else{ }else{
return p; return p;
} }
} }
@Override @Override
public boolean compare(SkinSiteProfile ssp0, SkinSiteProfile ssp1) { public boolean compare(SkinSiteProfile ssp0, SkinSiteProfile ssp1) {
return StringUtils.isNoneEmpty(ssp0.root)?ssp0.root.equalsIgnoreCase(ssp1.root):true; return !StringUtils.isNoneEmpty(ssp0.root) || ssp0.root.equalsIgnoreCase(ssp1.root);
} }
@Override @Override
public String getName() { public String getName() {
return type.jsonAPI.getName(); return type.jsonAPI.getName();
} }
@Override @SuppressWarnings("ResultOfMethodCallIgnored")
public void initLocalFolder(SkinSiteProfile ssp) { @Override
if(HttpUtil0.isLocal(ssp.root)){ public void initLocalFolder(SkinSiteProfile ssp) {
File f=new File(ssp.root); if(HttpUtil0.isLocal(ssp.root)){
if(!f.exists()) File f=new File(ssp.root);
f.mkdirs(); if(!f.exists())
} f.mkdirs();
} }
}
} }
@@ -17,78 +17,79 @@ import customskinloader.utils.HttpTextureUtil;
import customskinloader.utils.HttpUtil0; import customskinloader.utils.HttpUtil0;
public class LegacyLoader implements ProfileLoader.IProfileLoader { public class LegacyLoader implements ProfileLoader.IProfileLoader {
public static final String USERNAME_REGEX="\\{USERNAME\\}"; public static final String USERNAME_PLACEHOLDER="{USERNAME}";
@Override @Override
public UserProfile loadProfile(SkinSiteProfile ssp, GameProfile gameProfile) throws Exception { public UserProfile loadProfile(SkinSiteProfile ssp, GameProfile gameProfile) throws Exception {
String username=gameProfile.getName(); String username=gameProfile.getName();
UserProfile profile=new UserProfile(); UserProfile profile=new UserProfile();
if(StringUtils.isNoneEmpty(ssp.skin)){ if(StringUtils.isNoneEmpty(ssp.skin)){
String skin=ssp.skin.replaceAll(USERNAME_REGEX, username); String skin=ssp.skin.replace(USERNAME_PLACEHOLDER, username);
if(HttpUtil0.isLocal(ssp.skin)){ if(HttpUtil0.isLocal(ssp.skin)){
File skinFile=new File(CustomSkinLoader.DATA_DIR,skin); File skinFile=new File(CustomSkinLoader.DATA_DIR,skin);
if(skinFile.exists()&&skinFile.isFile()) if(skinFile.exists()&&skinFile.isFile())
profile.skinUrl=HttpTextureUtil.getLocalLegacyFakeUrl(skin, HttpTextureUtil.getHash(skin, skinFile.length(), skinFile.lastModified())); profile.skinUrl=HttpTextureUtil.getLocalLegacyFakeUrl(skin, HttpTextureUtil.getHash(skin, skinFile.length(), skinFile.lastModified()));
}else{ }else{
HttpResponce responce=HttpRequestUtil.makeHttpRequest(new HttpRequest(skin).setUserAgent(ssp.userAgent).setCheckPNG(ssp.checkPNG!=null&&ssp.checkPNG!=false).setLoadContent(false).setCacheTime(60)); HttpResponce responce = HttpRequestUtil.makeHttpRequest(new HttpRequest(skin).setUserAgent(ssp.userAgent).setCheckPNG(ssp.checkPNG!=null && ssp.checkPNG).setLoadContent(false).setCacheTime(90));
if(responce.success) if(responce.success)
profile.skinUrl=HttpTextureUtil.getLegacyFakeUrl(skin); profile.skinUrl=HttpTextureUtil.getLegacyFakeUrl(skin);
} }
profile.model=profile.hasSkinUrl()?ssp.model:null; profile.model=profile.hasSkinUrl()?ssp.model:null;
} }
if(StringUtils.isNoneEmpty(ssp.cape)){ if(StringUtils.isNoneEmpty(ssp.cape)){
String cape=ssp.cape.replaceAll(USERNAME_REGEX, username); String cape=ssp.cape.replace(USERNAME_PLACEHOLDER, username);
if(HttpUtil0.isLocal(ssp.cape)){ if(HttpUtil0.isLocal(ssp.cape)){
File capeFile=new File(CustomSkinLoader.DATA_DIR,cape); File capeFile=new File(CustomSkinLoader.DATA_DIR,cape);
if(capeFile.exists()&&capeFile.isFile()) if(capeFile.exists()&&capeFile.isFile())
profile.capeUrl=HttpTextureUtil.getLocalLegacyFakeUrl(cape, HttpTextureUtil.getHash(cape, capeFile.length(), capeFile.lastModified())); profile.capeUrl=HttpTextureUtil.getLocalLegacyFakeUrl(cape, HttpTextureUtil.getHash(cape, capeFile.length(), capeFile.lastModified()));
}else{ }else{
HttpResponce responce=HttpRequestUtil.makeHttpRequest(new HttpRequest(cape).setUserAgent(ssp.userAgent).setCheckPNG(ssp.checkPNG!=null&&ssp.checkPNG!=false).setLoadContent(false).setCacheTime(60)); HttpResponce responce = HttpRequestUtil.makeHttpRequest(new HttpRequest(cape).setUserAgent(ssp.userAgent).setCheckPNG(ssp.checkPNG!=null && ssp.checkPNG).setLoadContent(false).setCacheTime(90));
if(responce.success) if(responce.success)
profile.capeUrl=HttpTextureUtil.getLegacyFakeUrl(cape); profile.capeUrl=HttpTextureUtil.getLegacyFakeUrl(cape);
} }
} }
if(ModelManager0.isElytraSupported()&&StringUtils.isNoneEmpty(ssp.elytra)){ if(ModelManager0.isElytraSupported()&&StringUtils.isNoneEmpty(ssp.elytra)){
String elytra=ssp.elytra.replaceAll(USERNAME_REGEX, username); String elytra=ssp.elytra.replace(USERNAME_PLACEHOLDER, username);
if(HttpUtil0.isLocal(ssp.elytra)){ if(HttpUtil0.isLocal(ssp.elytra)){
File elytraFile=new File(CustomSkinLoader.DATA_DIR,elytra); File elytraFile=new File(CustomSkinLoader.DATA_DIR,elytra);
if(elytraFile.exists()&&elytraFile.isFile()) if(elytraFile.exists()&&elytraFile.isFile())
profile.elytraUrl=HttpTextureUtil.getLocalLegacyFakeUrl(elytra, HttpTextureUtil.getHash(elytra, elytraFile.length(), elytraFile.lastModified())); profile.elytraUrl=HttpTextureUtil.getLocalLegacyFakeUrl(elytra, HttpTextureUtil.getHash(elytra, elytraFile.length(), elytraFile.lastModified()));
}else{ }else{
HttpResponce responce=HttpRequestUtil.makeHttpRequest(new HttpRequest(elytra).setUserAgent(ssp.userAgent).setCheckPNG(ssp.checkPNG!=null&&ssp.checkPNG!=false).setLoadContent(false).setCacheTime(60)); HttpResponce responce=HttpRequestUtil.makeHttpRequest(new HttpRequest(elytra).setUserAgent(ssp.userAgent).setCheckPNG(ssp.checkPNG!=null && ssp.checkPNG).setLoadContent(false).setCacheTime(90));
if(responce.success) if(responce.success)
profile.elytraUrl=HttpTextureUtil.getLegacyFakeUrl(elytra); profile.elytraUrl=HttpTextureUtil.getLegacyFakeUrl(elytra);
} }
} }
if(profile.isEmpty()){ if(profile.isEmpty()){
CustomSkinLoader.logger.info("Both skin and cape not found."); CustomSkinLoader.logger.info("Both skin and cape not found.");
return null; return null;
} }
return profile; return profile;
} }
@Override @Override
public boolean compare(SkinSiteProfile ssp0, SkinSiteProfile ssp1) { public boolean compare(SkinSiteProfile ssp0, SkinSiteProfile ssp1) {
return (StringUtils.isNoneEmpty(ssp0.skin)?ssp0.skin.equalsIgnoreCase(ssp1.skin):true) || (StringUtils.isNoneEmpty(ssp0.cape)?ssp0.cape.equalsIgnoreCase(ssp1.cape):true); return (!StringUtils.isNoneEmpty(ssp0.skin) || ssp0.skin.equalsIgnoreCase(ssp1.skin)) || (!StringUtils.isNoneEmpty(ssp0.cape) || ssp0.cape.equalsIgnoreCase(ssp1.cape));
} }
@Override @Override
public String getName() { public String getName() {
return "Legacy"; return "Legacy";
} }
@Override @Override
public void initLocalFolder(SkinSiteProfile ssp) { public void initLocalFolder(SkinSiteProfile ssp) {
if(HttpUtil0.isLocal(ssp.skin)) if(HttpUtil0.isLocal(ssp.skin))
initFolder(ssp.skin); initFolder(ssp.skin);
if(HttpUtil0.isLocal(ssp.cape)) if(HttpUtil0.isLocal(ssp.cape))
initFolder(ssp.cape); initFolder(ssp.cape);
if(HttpUtil0.isLocal(ssp.elytra)) if(HttpUtil0.isLocal(ssp.elytra))
initFolder(ssp.elytra); initFolder(ssp.elytra);
} }
private void initFolder(String target){ @SuppressWarnings("ResultOfMethodCallIgnored")
String file=target.replaceAll(USERNAME_REGEX, "init"); private void initFolder(String target){
File folder=new File(CustomSkinLoader.DATA_DIR,file).getParentFile(); String file=target.replace(USERNAME_PLACEHOLDER, "init");
if(folder!=null&&!folder.exists()) File folder=new File(CustomSkinLoader.DATA_DIR,file).getParentFile();
folder.mkdirs(); if(folder!=null&&!folder.exists())
} folder.mkdirs();
}
} }
@@ -1,9 +1,9 @@
package customskinloader.loader; package customskinloader.loader;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
import com.google.common.collect.Maps;
import org.apache.commons.codec.Charsets; import org.apache.commons.codec.Charsets;
import org.apache.commons.codec.binary.Base64; import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@@ -15,6 +15,8 @@ import com.mojang.authlib.GameProfile;
import com.mojang.authlib.minecraft.MinecraftProfileTexture; import com.mojang.authlib.minecraft.MinecraftProfileTexture;
import com.mojang.authlib.minecraft.MinecraftSessionService; import com.mojang.authlib.minecraft.MinecraftSessionService;
import com.mojang.authlib.properties.Property; import com.mojang.authlib.properties.Property;
import com.mojang.authlib.properties.PropertyMap;
import com.mojang.authlib.yggdrasil.response.MinecraftProfilePropertiesResponse;
import com.mojang.authlib.yggdrasil.response.MinecraftTexturesPayload; import com.mojang.authlib.yggdrasil.response.MinecraftTexturesPayload;
import com.mojang.util.UUIDTypeAdapter; import com.mojang.util.UUIDTypeAdapter;
@@ -29,66 +31,91 @@ import customskinloader.utils.MinecraftUtil;
public class MojangAPILoader implements ProfileLoader.IProfileLoader { public class MojangAPILoader implements ProfileLoader.IProfileLoader {
public static final MinecraftSessionService defaultSessionService=MinecraftUtil.getSessionService(); public static final MinecraftSessionService defaultSessionService=MinecraftUtil.getSessionService();
@Override @Override
public UserProfile loadProfile(SkinSiteProfile ssp, GameProfile gameProfile) throws Exception { public UserProfile loadProfile(SkinSiteProfile ssp, GameProfile gameProfile) throws Exception {
Map<MinecraftProfileTexture.Type,MinecraftProfileTexture> map=getTextures(gameProfile); Map<MinecraftProfileTexture.Type,MinecraftProfileTexture> map=getTextures(gameProfile);
if(!map.isEmpty()){ if(!map.isEmpty()){
CustomSkinLoader.logger.info("Default profile will be used."); CustomSkinLoader.logger.info("Default profile will be used.");
return ModelManager0.toUserProfile(map); return ModelManager0.toUserProfile(map);
} }
String username=gameProfile.getName(); String username=gameProfile.getName();
GameProfile newGameProfile=loadGameProfile(username); GameProfile newGameProfile=loadGameProfile(username);
if(newGameProfile==null){ if(newGameProfile==null){
CustomSkinLoader.logger.info("Profile not found.("+username+"'s profile not found.)"); CustomSkinLoader.logger.info("Profile not found.("+username+"'s profile not found.)");
return null; return null;
} }
newGameProfile=defaultSessionService.fillProfileProperties(newGameProfile, false); newGameProfile=fillGameProfile(newGameProfile);
map=getTextures(newGameProfile); map=getTextures(newGameProfile);
if(!map.isEmpty()){ if(!map.isEmpty()){
gameProfile.getProperties().putAll(newGameProfile.getProperties()); gameProfile.getProperties().putAll(newGameProfile.getProperties());
return ModelManager0.toUserProfile(map); return ModelManager0.toUserProfile(map);
} }
CustomSkinLoader.logger.info("Profile not found.("+username+" doesn't have skin/cape.)"); CustomSkinLoader.logger.info("Profile not found.("+username+" doesn't have skin/cape.)");
return null; return null;
} }
public static GameProfile loadGameProfile(String username) throws Exception{ //Username -> UUID
//Doc (http://wiki.vg/Mojang_API#Username_-.3E_UUID_at_time) public static GameProfile loadGameProfile(String username) {
HttpResponce responce=HttpRequestUtil.makeHttpRequest(new HttpRequest("https://api.mojang.com/users/profiles/minecraft/"+username).setCacheTime(0)); //Doc (http://wiki.vg/Mojang_API#Username_-.3E_UUID_at_time)
if(StringUtils.isEmpty(responce.content)) HttpResponce responce=HttpRequestUtil.makeHttpRequest(new HttpRequest("https://api.mojang.com/users/profiles/minecraft/"+username).setCacheTime(0));
return null; if(StringUtils.isEmpty(responce.content))
Gson gson=new GsonBuilder().registerTypeAdapter(UUID.class, new UUIDTypeAdapter()).create(); return null;
GameProfile gameProfile=gson.fromJson(responce.content, GameProfile.class);
if(gameProfile.getId()==null)
return null;
return new GameProfile(gameProfile.getId(),gameProfile.getName());
}
public static Map<MinecraftProfileTexture.Type,MinecraftProfileTexture> getTextures(GameProfile gameProfile) throws Exception{
Property textureProperty=(Property)Iterables.getFirst(gameProfile.getProperties().get("textures"), null);
if (textureProperty==null)
return new HashMap();
String value=textureProperty.getValue();
if(StringUtils.isBlank(value))
return new HashMap();
String json=new String(Base64.decodeBase64(value),Charsets.UTF_8);
Gson gson=new GsonBuilder().registerTypeAdapter(UUID.class,new UUIDTypeAdapter()).create();
MinecraftTexturesPayload result=gson.fromJson(json,MinecraftTexturesPayload.class);
if (result==null||result.getTextures()==null)
return new HashMap();
return result.getTextures();
}
@Override Gson gson=new GsonBuilder().registerTypeAdapter(UUID.class, new UUIDTypeAdapter()).create();
public boolean compare(SkinSiteProfile ssp0, SkinSiteProfile ssp1) { GameProfile gameProfile=gson.fromJson(responce.content, GameProfile.class);
return true;
}
@Override
public String getName() {
return "MojangAPI";
}
@Override if(gameProfile.getId()==null)
public void initLocalFolder(SkinSiteProfile ssp) { return null;
} return new GameProfile(gameProfile.getId(),gameProfile.getName());
}
//UUID -> Profile
public static GameProfile fillGameProfile(GameProfile profile) {
//Doc (http://wiki.vg/Mojang_API#UUID_-.3E_Profile_.2B_Skin.2FCape)
HttpResponce responce = HttpRequestUtil.makeHttpRequest(
new HttpRequest("https://sessionserver.mojang.com/session/minecraft/profile/"
+ UUIDTypeAdapter.fromUUID(profile.getId())).setCacheTime(90));
if(StringUtils.isEmpty(responce.content))
return profile;
Gson gson=new GsonBuilder()
.registerTypeAdapter(UUID.class, new UUIDTypeAdapter())
.registerTypeAdapter(PropertyMap.class, new PropertyMap.Serializer())
.create();
MinecraftProfilePropertiesResponse propertiesResponce=gson.fromJson(responce.content, MinecraftProfilePropertiesResponse.class);
GameProfile newGameProfile=new GameProfile(propertiesResponce.getId(),propertiesResponce.getName());
newGameProfile.getProperties().putAll(propertiesResponce.getProperties());
return newGameProfile;
}
public static Map<MinecraftProfileTexture.Type,MinecraftProfileTexture> getTextures(GameProfile gameProfile) {
if(gameProfile==null)
return Maps.newHashMap();
Property textureProperty=Iterables.getFirst(gameProfile.getProperties().get("textures"), null);
if (textureProperty==null)
return Maps.newHashMap();
String value=textureProperty.getValue();
if(StringUtils.isBlank(value))
return Maps.newHashMap();
@SuppressWarnings("deprecation") String json = new String(Base64.decodeBase64(value), Charsets.UTF_8);
Gson gson=new GsonBuilder().registerTypeAdapter(UUID.class,new UUIDTypeAdapter()).create();
MinecraftTexturesPayload result=gson.fromJson(json,MinecraftTexturesPayload.class);
if (result==null||result.getTextures()==null)
return Maps.newHashMap();
return result.getTextures();
}
@Override
public boolean compare(SkinSiteProfile ssp0, SkinSiteProfile ssp1) {
return true;
}
@Override
public String getName() {
return "MojangAPI";
}
@Override
public void initLocalFolder(SkinSiteProfile ssp) {
}
} }
@@ -8,27 +8,28 @@ import customskinloader.config.SkinSiteProfile;
import customskinloader.profile.UserProfile; import customskinloader.profile.UserProfile;
public class ProfileLoader { public class ProfileLoader {
private static final IProfileLoader[] DEFAULT_LOADERS={ private static final IProfileLoader[] DEFAULT_LOADERS={
new MojangAPILoader(), new MojangAPILoader(),
new JsonAPILoader(JsonAPILoader.Type.CustomSkinAPI), new JsonAPILoader(JsonAPILoader.Type.CustomSkinAPI),
new JsonAPILoader(JsonAPILoader.Type.CustomSkinAPIPlus), new JsonAPILoader(JsonAPILoader.Type.CustomSkinAPIPlus),
new LegacyLoader(), new JsonAPILoader(JsonAPILoader.Type.UniSkinAPI),
new JsonAPILoader(JsonAPILoader.Type.UniSkinAPI)}; new JsonAPILoader(JsonAPILoader.Type.ElyByAPI),
new LegacyLoader()};
public static final HashMap<String,IProfileLoader> LOADERS=initLoaders(); public static final HashMap<String,IProfileLoader> LOADERS=initLoaders();
private static HashMap<String, IProfileLoader> initLoaders() { private static HashMap<String, IProfileLoader> initLoaders() {
HashMap<String, IProfileLoader> loaders=new HashMap<String, IProfileLoader>(); HashMap<String, IProfileLoader> loaders=new HashMap<String, IProfileLoader>();
for(IProfileLoader loader:DEFAULT_LOADERS){ for(IProfileLoader loader:DEFAULT_LOADERS){
loaders.put(loader.getName().toLowerCase(), loader); loaders.put(loader.getName().toLowerCase(), loader);
} }
return loaders; return loaders;
} }
public interface IProfileLoader { public interface IProfileLoader {
public UserProfile loadProfile(SkinSiteProfile ssp,GameProfile gameProfile) throws Exception; UserProfile loadProfile(SkinSiteProfile ssp,GameProfile gameProfile) throws Exception;
public boolean compare(SkinSiteProfile ssp0,SkinSiteProfile ssp1); boolean compare(SkinSiteProfile ssp0,SkinSiteProfile ssp1);
public String getName(); String getName();
public void initLocalFolder(SkinSiteProfile ssp); void initLocalFolder(SkinSiteProfile ssp);
} }
} }
@@ -14,77 +14,77 @@ import customskinloader.profile.UserProfile;
import customskinloader.utils.HttpTextureUtil; import customskinloader.utils.HttpTextureUtil;
public class CustomSkinAPI implements IJsonAPI { public class CustomSkinAPI implements IJsonAPI {
private static final String TEXTURES="textures/"; private static final String TEXTURES="textures/";
private static final String SUFFIX=".json"; private static final String SUFFIX=".json";
@Override @Override
public String toJsonUrl(String root, String username) { public String toJsonUrl(String root, String username) {
return new StringBuilder().append(root).append(username).append(SUFFIX).toString(); return root + username + SUFFIX;
} }
@Override @Override
public UserProfile toUserProfile(String root, String json, boolean local) { public UserProfile toUserProfile(String root, String json, boolean local) {
CustomSkinAPIProfile profile=CustomSkinLoader.GSON.fromJson(json, CustomSkinAPIProfile.class); CustomSkinAPIProfile profile=CustomSkinLoader.GSON.fromJson(json, CustomSkinAPIProfile.class);
UserProfile p=new UserProfile(); UserProfile p=new UserProfile();
if(StringUtils.isNotBlank(profile.skin)){ if(StringUtils.isNotBlank(profile.skin)){
p.skinUrl=root+TEXTURES+profile.skin; p.skinUrl=root+TEXTURES+profile.skin;
if(local) if(local)
p.skinUrl=HttpTextureUtil.getLocalFakeUrl(p.skinUrl); p.skinUrl=HttpTextureUtil.getLocalFakeUrl(p.skinUrl);
} }
if(StringUtils.isNotBlank(profile.cape)){ if(StringUtils.isNotBlank(profile.cape)){
p.capeUrl=root+TEXTURES+profile.cape; p.capeUrl=root+TEXTURES+profile.cape;
if(local) if(local)
p.capeUrl=HttpTextureUtil.getLocalFakeUrl(p.capeUrl); p.capeUrl=HttpTextureUtil.getLocalFakeUrl(p.capeUrl);
} }
if(StringUtils.isNotBlank(profile.elytra)){ if(StringUtils.isNotBlank(profile.elytra)){
p.elytraUrl=root+TEXTURES+profile.elytra; p.elytraUrl=root+TEXTURES+profile.elytra;
if(local) if(local)
p.elytraUrl=HttpTextureUtil.getLocalFakeUrl(p.elytraUrl); p.elytraUrl=HttpTextureUtil.getLocalFakeUrl(p.elytraUrl);
} }
Map<String,String> textures=new LinkedHashMap<String,String>(); Map<String,String> textures=new LinkedHashMap<String,String>();
if(profile.skins!=null) if(profile.skins!=null)
textures.putAll(profile.skins); textures.putAll(profile.skins);
if(profile.textures!=null) if(profile.textures!=null)
textures.putAll(profile.textures); textures.putAll(profile.textures);
if(textures.isEmpty()) if(textures.isEmpty())
return p; return p;
boolean hasSkin=false; boolean hasSkin=false;
for(String model:textures.keySet()){ for(String model:textures.keySet()){
Model enumModel=ModelManager0.getEnumModel(model); Model enumModel=ModelManager0.getEnumModel(model);
if(enumModel==null||StringUtils.isEmpty(textures.get(model))) if(enumModel==null||StringUtils.isEmpty(textures.get(model)))
continue; continue;
if(ModelManager0.isSkin(enumModel)) if(ModelManager0.isSkin(enumModel))
if(hasSkin) if(hasSkin)
continue; continue;
else else
hasSkin=true; hasSkin=true;
String url=root+TEXTURES+textures.get(model); String url=root+TEXTURES+textures.get(model);
if(local) if(local)
url=HttpTextureUtil.getLocalFakeUrl(url); url=HttpTextureUtil.getLocalFakeUrl(url);
p.put(enumModel, url); p.put(enumModel, url);
} }
return p; return p;
} }
private class CustomSkinAPIProfile{ private class CustomSkinAPIProfile{
public String username; public String username;
public Map<String,String> textures; public LinkedHashMap<String,String> textures;
public Map<String,String> skins; public LinkedHashMap<String,String> skins;
public String skin; public String skin;
public String cape; public String cape;
public String elytra; public String elytra;
} }
@Override @Override
public String getPayload(SkinSiteProfile ssp) { public String getPayload(SkinSiteProfile ssp) {
return null; return null;
} }
@Override @Override
public String getName() { public String getName() {
return "CustomSkinAPI"; return "CustomSkinAPI";
} }
} }
@@ -16,67 +16,55 @@ import customskinloader.utils.MinecraftUtil;
public class CustomSkinAPIPlus implements IJsonAPI { public class CustomSkinAPIPlus implements IJsonAPI {
private static String clientID=null; private static String clientID=null;
public CustomSkinAPIPlus(){ public CustomSkinAPIPlus(){
File clientIDFile=new File(CustomSkinLoader.DATA_DIR,"CustomSkinAPIPlus-ClientID"); File clientIDFile=new File(CustomSkinLoader.DATA_DIR,"CustomSkinAPIPlus-ClientID");
if(clientIDFile.isFile()) if(clientIDFile.isFile())
try{ try{
clientID=FileUtils.readFileToString(clientIDFile); clientID=FileUtils.readFileToString(clientIDFile, "UTF-8");
}catch(Exception e){ }catch(Exception e){
e.printStackTrace(); e.printStackTrace();
} }
if(clientID==null){ if(clientID==null){
clientID=UUID.randomUUID().toString(); clientID=UUID.randomUUID().toString();
try { try {
FileUtils.write(clientIDFile, clientID); FileUtils.write(clientIDFile, clientID, "UTF-8");
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
} }
@Override @Override
public String toJsonUrl(String root, String username) { public String toJsonUrl(String root, String username) {
return JsonAPILoader.Type.CustomSkinAPI.jsonAPI.toJsonUrl(root, username); return JsonAPILoader.Type.CustomSkinAPI.jsonAPI.toJsonUrl(root, username);
} }
@Override @Override
public String getPayload(SkinSiteProfile ssp) { public String getPayload(SkinSiteProfile ssp) {
if(ssp.privacy==null) return new Gson().toJson(new CustomSkinAPIPlusPayload());
ssp.privacy=new CustomSkinAPIPlusPrivacy(); }
return new Gson().toJson(new CustomSkinAPIPlusPayload(ssp.privacy));
}
@Override @Override
public UserProfile toUserProfile(String root, String json, boolean local) { public UserProfile toUserProfile(String root, String json, boolean local) {
return JsonAPILoader.Type.CustomSkinAPI.jsonAPI.toUserProfile(root, json, local); return JsonAPILoader.Type.CustomSkinAPI.jsonAPI.toUserProfile(root, json, local);
} }
@Override @Override
public String getName() { public String getName() {
return "CustomSKinAPIPlus"; return "CustomSKinAPIPlus";
} }
public static class CustomSkinAPIPlusPayload{ public static class CustomSkinAPIPlusPayload{
public String gameVersion;//minecraft version String gameVersion;//minecraft version
public String modVersion;//mod version String modVersion;//mod version
public String serverAddress;//ip:port String serverAddress;//ip:port
public String clientID;//Minecraft Client ID String clientID;//Minecraft Client ID
public CustomSkinAPIPlusPayload(CustomSkinAPIPlusPrivacy privacy){ CustomSkinAPIPlusPayload(){
if(privacy.gameVersion) gameVersion = MinecraftUtil.getMinecraftMainVersion();
gameVersion=MinecraftUtil.getMinecraftMainVersion(); modVersion = CustomSkinLoader.CustomSkinLoader_VERSION;
if(privacy.modVersion) serverAddress = MinecraftUtil.isLanServer() ? null : MinecraftUtil.getStandardServerAddress();
modVersion=CustomSkinLoader.CustomSkinLoader_VERSION; clientID = CustomSkinAPIPlus.clientID;
if(privacy.serverAddress) }
serverAddress=MinecraftUtil.isLanServer()?null:MinecraftUtil.getStandardServerAddress(); }
if(privacy.clientID)
clientID=CustomSkinAPIPlus.clientID;
}
}
public static class CustomSkinAPIPlusPrivacy{
public boolean gameVersion=true;
public boolean modVersion=true;
public boolean serverAddress=true;
public boolean clientID=true;
}
} }
@@ -0,0 +1,50 @@
package customskinloader.loader.jsonapi;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
import customskinloader.config.SkinSiteProfile;
import customskinloader.loader.JsonAPILoader;
import customskinloader.profile.ModelManager0;
import customskinloader.profile.UserProfile;
import customskinloader.utils.MinecraftUtil;
import java.net.URI;
import java.util.Map;
public class ElyByAPI implements JsonAPILoader.IJsonAPI {
@Override
public String toJsonUrl(String root, String username) {
return "http://skinsystem.ely.by/textures/" + username + "?version=2&minecraft_version=" + MinecraftUtil.getMinecraftMainVersion();
}
@Override
public UserProfile toUserProfile(String root, String json, boolean local) {
Map<Type, MinecraftProfileTexture> result = new Gson().fromJson(json, new TypeToken<Map<Type, MinecraftProfileTexture>>() {
}.getType());
if (!result.containsKey(Type.SKIN))
return null;
//Check URL
try {
URI uri = new URI(result.get(Type.SKIN).getUrl());
if (!uri.getHost().endsWith("ely.by"))
return null;
} catch (Exception e) {
return null;
}
return ModelManager0.toUserProfile(result);
}
@Override
public String getPayload(SkinSiteProfile ssp) {
return null;
}
@Override
public String getName() {
return "ElyByAPI";
}
}
@@ -14,67 +14,67 @@ import customskinloader.profile.ModelManager0.Model;
import customskinloader.utils.HttpTextureUtil; import customskinloader.utils.HttpTextureUtil;
public class UniSkinAPI implements IJsonAPI { public class UniSkinAPI implements IJsonAPI {
private static final String TEXTURES="textures/"; private static final String TEXTURES="textures/";
private static final String SUFFIX=".json"; private static final String SUFFIX=".json";
@Override @Override
public String toJsonUrl(String root, String username) { public String toJsonUrl(String root, String username) {
return new StringBuilder().append(root).append(username).append(SUFFIX).toString(); return root + username + SUFFIX;
} }
@Override @Override
public UserProfile toUserProfile(String root, String json, boolean local) { public UserProfile toUserProfile(String root, String json, boolean local) {
UniSkinAPIProfile profile=CustomSkinLoader.GSON.fromJson(json, UniSkinAPIProfile.class); UniSkinAPIProfile profile=CustomSkinLoader.GSON.fromJson(json, UniSkinAPIProfile.class);
UserProfile p=new UserProfile(); UserProfile p=new UserProfile();
if(StringUtils.isNotBlank(profile.cape)){ if(StringUtils.isNotBlank(profile.cape)){
p.capeUrl=root+TEXTURES+profile.cape; p.capeUrl=root+TEXTURES+profile.cape;
if(local) if(local)
p.capeUrl=HttpTextureUtil.getLocalFakeUrl(p.capeUrl); p.capeUrl=HttpTextureUtil.getLocalFakeUrl(p.capeUrl);
} }
if(profile.skins==null||profile.skins.isEmpty()) if(profile.skins==null||profile.skins.isEmpty())
return p; return p;
if(profile.model_preference==null||profile.model_preference.isEmpty()) if(profile.model_preference==null||profile.model_preference.isEmpty())
return p; return p;
boolean hasSkin=false; boolean hasSkin=false;
for(String model:profile.model_preference){ for(String model:profile.model_preference){
Model enumModel=ModelManager0.getEnumModel(model); Model enumModel=ModelManager0.getEnumModel(model);
if(enumModel==null||StringUtils.isEmpty(profile.skins.get(model))) if(enumModel==null||StringUtils.isEmpty(profile.skins.get(model)))
continue; continue;
if(ModelManager0.isSkin(enumModel)) if(ModelManager0.isSkin(enumModel))
if(hasSkin) if(hasSkin)
continue; continue;
else else
hasSkin=true; hasSkin=true;
String url=root+TEXTURES+profile.skins.get(model); String url=root+TEXTURES+profile.skins.get(model);
if(local) if(local)
url=HttpTextureUtil.getLocalFakeUrl(url); url=HttpTextureUtil.getLocalFakeUrl(url);
p.put(enumModel, url); p.put(enumModel, url);
} }
return p; return p;
} }
/** /**
* Json profile for UniSkinAPI * Json profile for UniSkinAPI
* Source Code: https://github.com/RecursiveG/UniSkinMod/blob/master/src/main/java/org/devinprogress/uniskinmod/UniSkinApiProfile.java#L18-L22 * Source Code: https://github.com/RecursiveG/UniSkinMod/blob/master/src/main/java/org/devinprogress/uniskinmod/UniSkinApiProfile.java#L18-L22
* @author RecursiveG * @author RecursiveG
*/ */
private class UniSkinAPIProfile{ private class UniSkinAPIProfile{
public String player_name; public String player_name;
public long last_update; public long last_update;
public List<String> model_preference; public List<String> model_preference;
public Map<String,String> skins; public Map<String,String> skins;
public String cape; public String cape;
} }
@Override @Override
public String getPayload(SkinSiteProfile ssp) { public String getPayload(SkinSiteProfile ssp) {
return null; return null;
} }
@Override @Override
public String getName() { public String getName() {
return "UniSkinAPI"; return "UniSkinAPI";
} }
} }
@@ -1,12 +1,9 @@
package customskinloader.profile; package customskinloader.profile;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import com.google.common.collect.Lists;
import org.apache.commons.codec.Charsets; import org.apache.commons.codec.Charsets;
import org.apache.commons.codec.binary.Base64; import org.apache.commons.codec.binary.Base64;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
@@ -31,133 +28,132 @@ import customskinloader.utils.HttpTextureUtil;
import customskinloader.utils.HttpUtil0; import customskinloader.utils.HttpUtil0;
public class DynamicSkullManager { public class DynamicSkullManager {
public static class SkullTexture{ public static class SkullTexture{
public Map<Type,MinecraftProfileTexture> textures; public Map<Type,MinecraftProfileTexture> textures;
public String index;//Index File public String index;//Index File
public ArrayList<String> skins; public ArrayList<String> skins;
public int interval; public int interval;
public boolean fromZero; public boolean fromZero;
//For program //For program
public long startTime; public long startTime;
public int period; public int period;
} }
private Map<GameProfile,SkullTexture> dynamicTextures=new HashMap<GameProfile,SkullTexture>(); private Map<GameProfile,SkullTexture> dynamicTextures=new HashMap<GameProfile,SkullTexture>();
private Map<GameProfile,Map<Type,MinecraftProfileTexture>> staticTextures=new HashMap<GameProfile,Map<Type,MinecraftProfileTexture>>(); private Map<GameProfile,Map<Type,MinecraftProfileTexture>> staticTextures=new HashMap<GameProfile,Map<Type,MinecraftProfileTexture>>();
private List<GameProfile> loadingList=new ArrayList<GameProfile>(); private List<GameProfile> loadingList=new ArrayList<GameProfile>();
private void parseGameProfile(GameProfile profile){ private void parseGameProfile(GameProfile profile){
Property textureProperty=(Property)Iterables.getFirst(profile.getProperties().get("textures"), null); Property textureProperty = Iterables.getFirst(profile.getProperties().get("textures"), null);
if (textureProperty==null){ if (textureProperty==null){
staticTextures.put(profile, new HashMap()); staticTextures.put(profile, Maps.<Type, MinecraftProfileTexture>newHashMap());
return; return;
} }
String value=textureProperty.getValue(); String value=textureProperty.getValue();
if(StringUtils.isBlank(value)){ if(StringUtils.isBlank(value)){
staticTextures.put(profile, new HashMap()); staticTextures.put(profile, Maps.<Type, MinecraftProfileTexture>newHashMap());
return; return;
} }
String json=new String(Base64.decodeBase64(value),Charsets.UTF_8); @SuppressWarnings("deprecation") String json = new String(Base64.decodeBase64(value), Charsets.UTF_8);
Gson gson=new GsonBuilder().registerTypeAdapter(UUID.class,new UUIDTypeAdapter()).create(); Gson gson=new GsonBuilder().registerTypeAdapter(UUID.class,new UUIDTypeAdapter()).create();
SkullTexture result=gson.fromJson(json,SkullTexture.class); SkullTexture result=gson.fromJson(json,SkullTexture.class);
if(result==null){ if(result==null){
staticTextures.put(profile, new HashMap()); staticTextures.put(profile, Maps.<Type, MinecraftProfileTexture>newHashMap());
return; return;
} }
staticTextures.put(profile, (result.textures==null||!result.textures.containsKey(Type.SKIN))?new HashMap():parseTextures(result.textures)); staticTextures.put(profile, (result.textures==null || !result.textures.containsKey(Type.SKIN)) ?
Maps.<Type, MinecraftProfileTexture>newHashMap() : parseTextures(result.textures));
if(StringUtils.isNotEmpty(result.index)){ if(StringUtils.isNotEmpty(result.index)){
File indexFile=new File(CustomSkinLoader.DATA_DIR,result.index); File indexFile=new File(CustomSkinLoader.DATA_DIR,result.index);
try{ try{
String index=FileUtils.readFileToString(indexFile, Charsets.UTF_8); String index=FileUtils.readFileToString(indexFile, "UTF-8");
if(StringUtils.isNotEmpty(index)){ if(StringUtils.isNotEmpty(index)){
ArrayList<String> skins=CustomSkinLoader.GSON.fromJson(index, ArrayList.class); String[] skins = CustomSkinLoader.GSON.fromJson(index, String[].class);
if(skins!=null&&!skins.isEmpty()) if(skins != null && skins.length != 0)
result.skins=skins; result.skins = Lists.newArrayList(skins);
} }
}catch(Exception e){ }catch(Exception e){
CustomSkinLoader.logger.warning("Exception occurs while parsing index file: "+e.toString()); CustomSkinLoader.logger.warning("Exception occurs while parsing index file: "+e.toString());
} }
} }
if(!CustomSkinLoader.config.enableDynamicSkull||result.skins==null||result.skins.isEmpty()) if(!CustomSkinLoader.config.enableDynamicSkull||result.skins==null||result.skins.isEmpty())
return; return;
CustomSkinLoader.logger.info("Try to load Dynamic Skull: "+json); CustomSkinLoader.logger.info("Try to load Dynamic Skull: "+json);
for(int i=0;i<result.skins.size();i++){//check and cache skins for(int i=0;i<result.skins.size();i++){//check and cache skins
String skin=result.skins.get(i); String skin=result.skins.get(i);
if(HttpUtil0.isLocal(skin)){ if(HttpUtil0.isLocal(skin)){
//Local Skin //Local Skin
File skinFile=new File(CustomSkinLoader.DATA_DIR,skin); File skinFile=new File(CustomSkinLoader.DATA_DIR,skin);
if(skinFile.isFile()&&skinFile.length()>0){ if(skinFile.isFile()&&skinFile.length()>0){
//Skin found //Skin found
String fakeUrl=HttpTextureUtil.getLocalFakeUrl(skin); String fakeUrl=HttpTextureUtil.getLocalFakeUrl(skin);
result.skins.set(i, fakeUrl); result.skins.set(i, fakeUrl);
}else{ }else{
//Could not find skin //Could not find skin
result.skins.remove(i--); result.skins.remove(i--);
continue; }
} }else{
}else{ //Online Skin
//Online Skin HttpResponce responce=HttpRequestUtil.makeHttpRequest(new HttpRequest(skin).setCacheFile(HttpTextureUtil.getCacheFile(FilenameUtils.getBaseName(skin))).setCacheTime(0).setLoadContent(false));
HttpResponce responce=HttpRequestUtil.makeHttpRequest(new HttpRequest(skin).setCacheFile(HttpTextureUtil.getCacheFile(FilenameUtils.getBaseName(skin))).setCacheTime(0).setLoadContent(false)); if(!responce.success){
if(!responce.success){ //Could not load skin
//Could not load skin result.skins.remove(i--);
result.skins.remove(i--); }
continue; }
} }
}
}
if(result.skins.isEmpty()){//Nothing loaded if(result.skins.isEmpty()){//Nothing loaded
CustomSkinLoader.logger.info("Failed: Nothing loaded."); CustomSkinLoader.logger.info("Failed: Nothing loaded.");
return; return;
} }
result.interval=Math.max(result.interval, 50); result.interval=Math.max(result.interval, 50);
if(result.fromZero) if(result.fromZero)
result.startTime=System.currentTimeMillis(); result.startTime=System.currentTimeMillis();
result.period=result.interval*result.skins.size(); result.period=result.interval*result.skins.size();
CustomSkinLoader.logger.info("Successfully loaded Dynamic Skull: "+new Gson().toJson(result)); CustomSkinLoader.logger.info("Successfully loaded Dynamic Skull: "+new Gson().toJson(result));
dynamicTextures.put(profile, result); dynamicTextures.put(profile, result);
staticTextures.remove(profile); staticTextures.remove(profile);
} }
//Support local skin for skull //Support local skin for skull
public Map<Type, MinecraftProfileTexture> parseTextures(Map<Type, MinecraftProfileTexture> textures) { public Map<Type, MinecraftProfileTexture> parseTextures(Map<Type, MinecraftProfileTexture> textures) {
MinecraftProfileTexture skin=textures.get(Type.SKIN); MinecraftProfileTexture skin=textures.get(Type.SKIN);
String skinUrl=skin.getUrl(); String skinUrl=skin.getUrl();
if(!HttpUtil0.isLocal(skinUrl)) if(!HttpUtil0.isLocal(skinUrl))
return textures; return textures;
File skinFile=new File(CustomSkinLoader.DATA_DIR,skinUrl); File skinFile=new File(CustomSkinLoader.DATA_DIR,skinUrl);
if(!skinFile.isFile()) if(!skinFile.isFile())
return new HashMap(); return Maps.newHashMap();
textures.put(Type.SKIN, ModelManager0.getProfileTexture(HttpTextureUtil.getLocalFakeUrl(skinUrl), null)); textures.put(Type.SKIN, ModelManager0.getProfileTexture(HttpTextureUtil.getLocalFakeUrl(skinUrl), null));
return textures; return textures;
} }
public Map<Type,MinecraftProfileTexture> getTexture(final GameProfile profile){ public Map<Type,MinecraftProfileTexture> getTexture(final GameProfile profile){
if(staticTextures.get(profile)!=null) if(staticTextures.get(profile)!=null)
return staticTextures.get(profile); return staticTextures.get(profile);
if(loadingList.contains(profile)) if(loadingList.contains(profile))
return new HashMap(); return Maps.newHashMap();
if(dynamicTextures.containsKey(profile)){ if(dynamicTextures.containsKey(profile)){
SkullTexture texture=dynamicTextures.get(profile); SkullTexture texture=dynamicTextures.get(profile);
long time=System.currentTimeMillis()-texture.startTime; long time=System.currentTimeMillis()-texture.startTime;
int index=(int)Math.floor((time%texture.period)/texture.interval); int index=(int)Math.floor((time%texture.period)/texture.interval);
Map<Type,MinecraftProfileTexture> map=Maps.newHashMap(); Map<Type,MinecraftProfileTexture> map=Maps.newHashMap();
map.put(Type.SKIN, ModelManager0.getProfileTexture(texture.skins.get(index), null)); map.put(Type.SKIN, ModelManager0.getProfileTexture(texture.skins.get(index), null));
return map; return map;
} }
loadingList.add(profile); loadingList.add(profile);
Thread loadThread=new Thread(){ Thread loadThread=new Thread(){
public void run(){ public void run(){
parseGameProfile(profile);//Load in thread parseGameProfile(profile);//Load in thread
loadingList.remove(profile); loadingList.remove(profile);
} }
}; };
loadThread.setName("Skull "+profile.hashCode()); loadThread.setName("Skull "+profile.hashCode());
loadThread.start(); loadThread.start();
return new HashMap(); return Maps.newHashMap();
} }
} }
@@ -16,106 +16,106 @@ import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
* @since 13.1 * @since 13.1
*/ */
public class ModelManager0 { public class ModelManager0 {
public static enum Model{ public enum Model{
SKIN_DEFAULT, SKIN_DEFAULT,
SKIN_SLIM, SKIN_SLIM,
CAPE, CAPE,
ELYTRA ELYTRA
} }
private static HashMap<String,Model> models=new HashMap<String,Model>(); private static HashMap<String,Model> models=new HashMap<String,Model>();
private static Type typeElytra=null; private static Type typeElytra=null;
static{ static{
for(Type type:Type.values()){ for(Type type:Type.values()){
if(type.ordinal()==2)//ELYTRA if(type.ordinal()==2)//ELYTRA
typeElytra=type; typeElytra=type;
} }
models.put("default", Model.SKIN_DEFAULT); models.put("default", Model.SKIN_DEFAULT);
models.put("slim", Model.SKIN_SLIM); models.put("slim", Model.SKIN_SLIM);
models.put("cape", Model.CAPE); models.put("cape", Model.CAPE);
if(typeElytra!=null) if(typeElytra!=null)
models.put("elytra", Model.ELYTRA); models.put("elytra", Model.ELYTRA);
} }
/** /**
* Get enum for the model. * Get enum for the model.
* @param model - string model * @param model - string model
* @since 14.5 * @since 14.5
*/ */
public static Model getEnumModel(String model){ public static Model getEnumModel(String model){
return models.get(model); return models.get(model);
} }
/** /**
* Check if model is skin. * Check if model is skin.
* @since 14.5 * @since 14.5
* */ * */
public static boolean isSkin(Model model){ public static boolean isSkin(Model model){
return model==Model.SKIN_DEFAULT||model==Model.SKIN_SLIM; return model==Model.SKIN_DEFAULT||model==Model.SKIN_SLIM;
} }
/** /**
* Check if elytra is supported. * Check if elytra is supported.
* @since 14.5 * @since 14.5
*/ */
public static boolean isElytraSupported(){ public static boolean isElytraSupported(){
return typeElytra!=null; return typeElytra!=null;
} }
/** /**
* Parse hashMapProfile to UserProfile * Parse hashMapProfile to UserProfile
* @param profile - hashMapProfile (HashMap<String,MinecraftProfileTexture>) * @param profile - hashMapProfile (HashMap<String,MinecraftProfileTexture>)
* @return profile - UserProfile instance * @return profile - UserProfile instance
* @since 13.1 * @since 13.1
*/ */
public static UserProfile toUserProfile(Map profile){ public static UserProfile toUserProfile(Map<Type, MinecraftProfileTexture> profile){
UserProfile userProfile=new UserProfile(); UserProfile userProfile=new UserProfile();
if(profile==null) if(profile==null)
return userProfile; return userProfile;
MinecraftProfileTexture skin=(MinecraftProfileTexture)profile.get(Type.SKIN); MinecraftProfileTexture skin = profile.get(Type.SKIN);
userProfile.skinUrl= skin==null?null:skin.getUrl();//Avoid NullPointerException userProfile.skinUrl= skin==null?null:skin.getUrl();//Avoid NullPointerException
userProfile.model= skin==null?null:skin.getMetadata("model"); userProfile.model= skin==null?null:skin.getMetadata("model");
if(StringUtils.isEmpty(userProfile.model)) if(StringUtils.isEmpty(userProfile.model))
userProfile.model="default"; userProfile.model="default";
MinecraftProfileTexture cape=(MinecraftProfileTexture)profile.get(Type.CAPE); MinecraftProfileTexture cape = profile.get(Type.CAPE);
userProfile.capeUrl= cape==null?null:cape.getUrl(); userProfile.capeUrl= cape==null?null:cape.getUrl();
return userProfile; return userProfile;
} }
/** /**
* Parse UserProfile to hashMapProfile * Parse UserProfile to hashMapProfile
* @param profile - UserProfile instance * @param profile - UserProfile instance
* @return profile - hashMapProfile (HashMap<String,MinecraftProfileTexture>) * @return profile - hashMapProfile (HashMap<String,MinecraftProfileTexture>)
* @since 13.1 * @since 13.1
*/ */
public static Map fromUserProfile(UserProfile profile){ public static Map<Type, MinecraftProfileTexture> fromUserProfile(UserProfile profile){
Map map=Maps.newHashMap(); Map<Type, MinecraftProfileTexture> map=Maps.newHashMap();
if(profile==null) if(profile==null)
return map; return map;
if(profile.skinUrl!=null){ if(profile.skinUrl!=null){
Map metadata=null; Map<String,String> metadata = null;
if(profile.model!=null&&profile.model.equals("slim")){ if("slim".equals(profile.model) || "auto".equals(profile.model)){
metadata = Maps.newHashMap(); metadata = Maps.newHashMap();
metadata.put("model", "slim"); metadata.put("model", profile.model);
} }
map.put(Type.SKIN, getProfileTexture(profile.skinUrl,metadata)); map.put(Type.SKIN, getProfileTexture(profile.skinUrl,metadata));
} }
if(profile.capeUrl!=null) if(profile.capeUrl!=null)
map.put(Type.CAPE, getProfileTexture(profile.capeUrl,null)); map.put(Type.CAPE, getProfileTexture(profile.capeUrl,null));
if(typeElytra!=null && profile.elytraUrl!=null) if(typeElytra!=null && profile.elytraUrl!=null)
map.put(typeElytra, getProfileTexture(profile.elytraUrl,null)); map.put(typeElytra, getProfileTexture(profile.elytraUrl,null));
return map; return map;
} }
/** /**
* Parse url to MinecraftProfileTexture * Parse url to MinecraftProfileTexture
* *
* @param url - textureUrl * @param url - textureUrl
* metadata - metadata * metadata - metadata
* @return MinecraftProfileTexture * @return MinecraftProfileTexture
* @since 14.5 * @since 14.5
*/ */
public static MinecraftProfileTexture getProfileTexture(String url,Map metadata){ public static MinecraftProfileTexture getProfileTexture(String url,Map<String,String> metadata){
return new MinecraftProfileTexture(url,metadata); return new MinecraftProfileTexture(url,metadata);
} }
} }
@@ -1,106 +1,105 @@
package customskinloader.profile; package customskinloader.profile;
import java.io.File; import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.HashMap; import java.util.HashMap;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.FileUtils;
import customskinloader.CustomSkinLoader; import customskinloader.CustomSkinLoader;
import customskinloader.utils.TimeUtil; import customskinloader.utils.TimeUtil;
public class ProfileCache { public class ProfileCache {
public static File PROFILE_CACHE_DIR=new File(CustomSkinLoader.DATA_DIR,"ProfileCache"); public static File PROFILE_CACHE_DIR=new File(CustomSkinLoader.DATA_DIR,"ProfileCache");
private HashMap<String,CachedProfile> cachedProfiles=new HashMap<String,CachedProfile>(); private HashMap<String,CachedProfile> cachedProfiles=new HashMap<String,CachedProfile>();
private HashMap<String,UserProfile> localProfiles=new HashMap<String,UserProfile>(); private HashMap<String,UserProfile> localProfiles=new HashMap<String,UserProfile>();
public ProfileCache(){ @SuppressWarnings("ResultOfMethodCallIgnored")
if(!PROFILE_CACHE_DIR.exists()) public ProfileCache(){
PROFILE_CACHE_DIR.mkdir(); if(!PROFILE_CACHE_DIR.exists())
} PROFILE_CACHE_DIR.mkdir();
}
public boolean isExist(String username){ public boolean isExist(String username){
return cachedProfiles.containsKey(username.toLowerCase()); return cachedProfiles.containsKey(username.toLowerCase());
} }
public boolean isReady(String username){ public boolean isReady(String username){
CachedProfile cp=cachedProfiles.get(username.toLowerCase()); CachedProfile cp=cachedProfiles.get(username.toLowerCase());
return cp==null?false:(cp.loading||cp.expiryTime>TimeUtil.getCurrentUnixTimestamp()); return cp != null && (cp.loading || cp.expiryTime > TimeUtil.getCurrentUnixTimestamp());
} }
public boolean isExpired(String username){ public boolean isExpired(String username){
CachedProfile cp=cachedProfiles.get(username.toLowerCase()); CachedProfile cp=cachedProfiles.get(username.toLowerCase());
return cp==null?true:(cp.expiryTime<=TimeUtil.getCurrentUnixTimestamp()); return cp == null || (cp.expiryTime <= TimeUtil.getCurrentUnixTimestamp());
} }
public UserProfile getProfile(String username){ public UserProfile getProfile(String username){
return getCachedProfile(username).profile; return getCachedProfile(username).profile;
} }
public long getExpiry(String username){ public long getExpiry(String username){
return getCachedProfile(username).expiryTime; return getCachedProfile(username).expiryTime;
} }
public UserProfile getLocalProfile(String username){ public UserProfile getLocalProfile(String username){
if(localProfiles.containsKey(username.toLowerCase())) if(localProfiles.containsKey(username.toLowerCase()))
return localProfiles.get(username.toLowerCase()); return localProfiles.get(username.toLowerCase());
return loadLocalProfile(username); return loadLocalProfile(username);
} }
public void setLoading(String username,boolean loading){ public void setLoading(String username,boolean loading){
getCachedProfile(username).loading=loading; getCachedProfile(username).loading=loading;
} }
public void updateCache(String username,UserProfile profile){ public void updateCache(String username,UserProfile profile){
updateCache(username,profile,CustomSkinLoader.config.enableLocalProfileCache); updateCache(username,profile,CustomSkinLoader.config.enableLocalProfileCache);
} }
public void updateCache(String username,UserProfile profile,boolean saveLocalProfile){ public void updateCache(String username,UserProfile profile,boolean saveLocalProfile){
CachedProfile cp=getCachedProfile(username); CachedProfile cp=getCachedProfile(username);
cp.profile=profile; cp.profile=profile;
cp.expiryTime=TimeUtil.getUnixTimestampRandomDelay(CustomSkinLoader.config.cacheExpiry); cp.expiryTime=TimeUtil.getUnixTimestampRandomDelay(CustomSkinLoader.config.cacheExpiry);
if(!saveLocalProfile) if(!saveLocalProfile)
return; return;
saveLocalProfile(username,profile); saveLocalProfile(username,profile);
} }
private CachedProfile getCachedProfile(String username){ private CachedProfile getCachedProfile(String username){
CachedProfile cp=cachedProfiles.get(username.toLowerCase()); CachedProfile cp=cachedProfiles.get(username.toLowerCase());
if(cp!=null) if(cp!=null)
return cp; return cp;
cp=new CachedProfile(); cp=new CachedProfile();
cachedProfiles.put(username.toLowerCase(), cp); cachedProfiles.put(username.toLowerCase(), cp);
return cp; return cp;
} }
private UserProfile loadLocalProfile(String username){ private UserProfile loadLocalProfile(String username){
File localProfile=new File(PROFILE_CACHE_DIR,username.toLowerCase()+".json"); File localProfile=new File(PROFILE_CACHE_DIR,username.toLowerCase()+".json");
if(!localProfile.exists()){ if(!localProfile.exists()){
localProfiles.put(username.toLowerCase(), null); localProfiles.put(username.toLowerCase(), null);
} }
try{ try{
String json=IOUtils.toString(new FileInputStream(localProfile)); String json = FileUtils.readFileToString(localProfile, "UTF-8");
UserProfile profile=CustomSkinLoader.GSON.fromJson(json, UserProfile.class); UserProfile profile=CustomSkinLoader.GSON.fromJson(json, UserProfile.class);
localProfiles.put(username.toLowerCase(), profile); localProfiles.put(username.toLowerCase(), profile);
CustomSkinLoader.logger.info("Successfully load LocalProfile."); CustomSkinLoader.logger.info("Successfully load LocalProfile.");
return profile; return profile;
}catch(Exception e){ }catch(Exception e){
CustomSkinLoader.logger.info("Failed to load LocalProfile.("+e.toString()+")"); CustomSkinLoader.logger.info("Failed to load LocalProfile.("+e.toString()+")");
localProfiles.put(username.toLowerCase(), null); localProfiles.put(username.toLowerCase(), null);
} }
return null; return null;
} }
private void saveLocalProfile(String username,UserProfile profile){ @SuppressWarnings("ResultOfMethodCallIgnored")
String json=CustomSkinLoader.GSON.toJson(profile); private void saveLocalProfile(String username, UserProfile profile){
File localProfile=new File(PROFILE_CACHE_DIR,username.toLowerCase()+".json"); String json=CustomSkinLoader.GSON.toJson(profile);
if(localProfile.exists()) File localProfile=new File(PROFILE_CACHE_DIR,username+".json");
localProfile.delete(); if(localProfile.exists())
try { localProfile.delete();
localProfile.createNewFile(); try {
IOUtils.write(json, new FileOutputStream(localProfile)); FileUtils.write(localProfile, json, "UTF-8");
CustomSkinLoader.logger.info("Successfully save LocalProfile."); CustomSkinLoader.logger.info("Successfully save LocalProfile.");
} catch (Exception e) { } catch (Exception e) {
CustomSkinLoader.logger.info("Failed to save LocalProfile.("+e.toString()+")"); CustomSkinLoader.logger.info("Failed to save LocalProfile.("+e.toString()+")");
} }
} }
} }
class CachedProfile{ class CachedProfile{
public UserProfile profile; public UserProfile profile;
public long expiryTime=0; public long expiryTime=0;
public boolean loading=false; public boolean loading=false;
} }
@@ -10,93 +10,94 @@ import customskinloader.profile.ModelManager0.Model;
*/ */
public class UserProfile { public class UserProfile {
/** /**
* Direct url for skin. * Direct url for skin.
* @since 13.1 * @since 13.1
*/ */
public String skinUrl=null; public String skinUrl=null;
/** /**
* Model for skin. * Model for skin.
* default/slim * default/slim
* @since 13.1 * @since 13.1
*/ */
public String model=null; public String model=null;
/** /**
* Direct url for cape. * Direct url for cape.
* @since 13.1 * @since 13.1
*/ */
public String capeUrl=null; public String capeUrl=null;
/** /**
* Direct url for elytra. * Direct url for elytra.
* @since 14.5 * @since 14.5
*/ */
public String elytraUrl=null; public String elytraUrl=null;
public void put(Model model,String url){ public void put(Model model,String url){
if(model==null||StringUtils.isEmpty(url)) if(model==null||StringUtils.isEmpty(url))
return; return;
switch(model){ switch(model){
case SKIN_DEFAULT: case SKIN_DEFAULT:
this.skinUrl=url; this.skinUrl=url;
this.model="default"; this.model="default";
return; return;
case SKIN_SLIM: case SKIN_SLIM:
this.skinUrl=url; this.skinUrl=url;
this.model="slim"; this.model="slim";
return; return;
case CAPE: case CAPE:
this.capeUrl=url; this.capeUrl=url;
return; return;
case ELYTRA: case ELYTRA:
this.capeUrl=url; this.capeUrl=url;
return; }
} }
}
/** /**
* Get parsed String to output the instance. * Get parsed String to output the instance.
*/ */
@Override @Override
public String toString(){ public String toString(){
return toString(0); return toString(0);
} }
public String toString(long expiry){ public String toString(long expiry){
return "(SkinUrl: "+skinUrl+ return "(SkinUrl: "+skinUrl+
" , Model: "+model+ " , Model: "+model+
" , CapeUrl: "+capeUrl+ " , CapeUrl: "+capeUrl+
(StringUtils.isBlank(elytraUrl)?" ":" , ElytraUrl: "+elytraUrl)+ (StringUtils.isBlank(elytraUrl)?" ":" , ElytraUrl: "+elytraUrl)+
(expiry==0?"":(" , Expiry: "+expiry))+")"; (expiry==0?"":(" , Expiry: "+expiry))+")";
} }
/** /**
* Check if the instance is empty. * Check if the instance is empty.
* @return status (true - empty) * @return status (true - empty)
*/ */
public boolean isEmpty(){ public boolean isEmpty(){
return StringUtils.isEmpty(skinUrl) && StringUtils.isEmpty(capeUrl) && StringUtils.isEmpty(elytraUrl); return StringUtils.isEmpty(skinUrl) && StringUtils.isEmpty(capeUrl) && StringUtils.isEmpty(elytraUrl);
} }
/** /**
* Check if the instance is full(Both skin and cape). * Check if the instance is full(Both skin and cape).
* @return status (true - full) * @return status (true - full)
* @since 14.7 * @since 14.7
*/ */
public boolean isFull(){ public boolean isFull(){
return StringUtils.isNoneBlank(skinUrl,capeUrl); return StringUtils.isNoneBlank(skinUrl,capeUrl);
} }
public boolean hasSkinUrl(){ public boolean hasSkinUrl(){
return StringUtils.isNotEmpty(skinUrl); return StringUtils.isNotEmpty(skinUrl);
} }
public void mix(UserProfile profile){ public void mix(UserProfile profile){
if(profile==null) if(profile==null)
return; return;
if(StringUtils.isEmpty(this.skinUrl)) if(StringUtils.isEmpty(this.skinUrl)) {
this.skinUrl=profile.skinUrl; this.skinUrl = profile.skinUrl;
if(StringUtils.isEmpty(this.capeUrl)) this.model = profile.model;
this.capeUrl=profile.capeUrl; }
if(StringUtils.isEmpty(this.elytraUrl)) if(StringUtils.isEmpty(this.capeUrl))
this.elytraUrl=profile.elytraUrl; this.capeUrl=profile.capeUrl;
} if(StringUtils.isEmpty(this.elytraUrl))
this.elytraUrl=profile.elytraUrl;
}
} }
@@ -1,125 +0,0 @@
package customskinloader.tweaker;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import org.apache.commons.io.IOUtils;
import customskinloader.utils.MinecraftUtil;
import net.minecraft.launchwrapper.IClassTransformer;
public class ClassTransformer implements IClassTransformer {
private ZipFile zipFile = null;
private ArrayList<String> classes=new ArrayList<String>();
public ClassTransformer() {
ModSystemTweaker.logger.info("ClassTransformer Begin");
try {
URLClassLoader ucl = (URLClassLoader)this.getClass().getClassLoader();
URL urls[] = ucl.getURLs();
for (URL url : urls) {
if(MinecraftUtil.isCoreFile(url)){
ModSystemTweaker.logger.debug(url.toString()+" : SKIP (core file).");
continue;
}
if(MinecraftUtil.isLibraryFile(url)){
ModSystemTweaker.logger.debug(url.toString()+" : SKIP (library file).");
continue;
}
File file = new File(url.toURI());
if(file==null||!file.isFile()){
ModSystemTweaker.logger.info(url.toString()+" : EXCEPTION (file not found).");
continue;
}
ZipFile tempZipFile = getZipFile(file);
if(tempZipFile==null){
ModSystemTweaker.logger.info(url.toString()+" : EXCEPTION (^ Message ^).");
continue;
}
if (tempZipFile.getEntry("customskinloader/tweaker/ClassTransformer.class") == null){
tempZipFile.close();
ModSystemTweaker.logger.debug(url.toString()+" : FINISH (not target).");
continue;
}
zipFile = tempZipFile;
Enumeration<ZipEntry> entries=(Enumeration<ZipEntry>) zipFile.entries();
StringBuilder sb=new StringBuilder();
while(entries.hasMoreElements()){
ZipEntry entry=entries.nextElement();
String name=entry.getName();
if(name.endsWith(".class")&&(!name.contains("/")||name.startsWith("net"))){
classes.add(name);
sb.append(" ");
sb.append(name);
}
}
ModSystemTweaker.logger.info(url.toString()+" : CHOOSE.");
ModSystemTweaker.logger.info("Classes:" + sb.toString());
break;
}
} catch (Exception e) {
ModSystemTweaker.logger.warning(e);
}
if (zipFile == null) {
ModSystemTweaker.logger.info("Can not find JAR in the classpath.");
}
}
private static ZipFile getZipFile(File file)
{
ZipFile zipFile0=null;
try {
zipFile0 = new ZipFile(file);
return zipFile0;
} catch (Exception e) {
ModSystemTweaker.logger.warning(e);
}
return null;
}
public byte[] transform(String name, String transformedName, byte bytes[]) {
if (zipFile == null)
return bytes;
String fullName = new StringBuilder().append(name.startsWith("net") ? name.replaceAll("\\.", "\\/") : name).append(".class").toString();//Notch(Run)/MCP(Dev) Class Name
if(!classes.contains(fullName)){//Check Name
if(name.equals(transformedName))
return bytes;
fullName = new StringBuilder().append(transformedName.replaceAll("\\.", "\\/")).append(".class").toString();//MCP Class Name
if(!classes.contains(fullName))//check Again
return bytes;
}
ZipEntry ze = zipFile.getEntry(fullName);
if (ze == null)
return bytes;
byte diBytes[] = getClass(ze);
if (diBytes != null) {
ModSystemTweaker.logger.info("Class '" + name + "'("+transformedName+") transformed.");
return diBytes;
}
else
return bytes;
}
private byte[] getClass(ZipEntry ze) {
try {
InputStream is = zipFile.getInputStream(ze);
byte[] bytes = IOUtils.toByteArray(is);
if ((long)bytes.length == ze.getSize())
return bytes;
ModSystemTweaker.logger.info("Failed: " + ze.getName() + " " + bytes.length + " / " + ze.getSize());
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
}
@@ -1,38 +0,0 @@
package customskinloader.tweaker;
import customskinloader.Logger;
import java.io.File;
import java.util.List;
import net.minecraft.launchwrapper.ITweaker;
import net.minecraft.launchwrapper.LaunchClassLoader;
public class ModSystemTweaker implements ITweaker {
public static Logger logger = new Logger();
public void acceptOptions(List args, File gameDir, File assetsDir, String profile) {
File tweakerLogFile = new File(gameDir,"CustomSkinLoader/Tweaker.log");
logger = new Logger(tweakerLogFile);
logger.info("Using ModSystemTweaker");
logger.info("ModSystemTweaker: acceptOptions");
}
public void injectIntoClassLoader(LaunchClassLoader classLoader) {
logger.info("ModSystemTweaker: injectIntoClassLoader");
classLoader.registerTransformer("customskinloader.tweaker.ClassTransformer");
logger.info("ClassTransformer Registered");
}
public String getLaunchTarget() {
logger.info("ModSystemTweaker: getLaunchTarget");
return "net.minecraft.client.main.Main";
}
public String[] getLaunchArguments() {
logger.info("ModSystemTweaker: getLaunchArguments");
return new String[0];
}
}
@@ -1,44 +0,0 @@
package customskinloader.tweaker;
import customskinloader.Logger;
import java.io.File;
import java.util.List;
import org.apache.commons.lang3.ArrayUtils;
import net.minecraft.launchwrapper.ITweaker;
import net.minecraft.launchwrapper.LaunchClassLoader;
public class Tweaker implements ITweaker {
private String[] args;
public static Logger logger = new Logger();
public void acceptOptions(List<String> args, File gameDir, File assetsDir, String profile) {
File tweakerLogFile = new File(gameDir,"CustomSkinLoader/Tweaker.log");
logger = new Logger(tweakerLogFile);
logger.info("Using Tweaker");
logger.info("Tweaker: acceptOptions");
String[] temp={"--gameDir",gameDir.getAbsolutePath(),"--assetsDir",assetsDir.getAbsolutePath(),"--version",profile};
this.args=ArrayUtils.addAll(args.toArray(new String[args.size()]), temp);
}
public void injectIntoClassLoader(LaunchClassLoader classLoader) {
logger.info("Tweaker: injectIntoClassLoader");
logger.info("Loaded as a library.");
}
public String getLaunchTarget() {
logger.info("Tweaker: getLaunchTarget");
return "net.minecraft.client.main.Main";
}
public String[] getLaunchArguments() {
logger.info("Tweaker: getLaunchArguments");
return args;
}
}
@@ -20,193 +20,214 @@ import org.apache.commons.lang3.StringUtils;
import customskinloader.CustomSkinLoader; import customskinloader.CustomSkinLoader;
public class HttpRequestUtil { public class HttpRequestUtil {
public static class HttpRequest{ public static class HttpRequest{
public String url; public String url;
public String userAgent=null; public String userAgent=null;
public String payload=null; public String payload=null;
public boolean loadContent=true; public boolean loadContent=true;
public boolean checkPNG=false; public boolean checkPNG=false;
public int cacheTime=600;//-1=No Cache 0=Always Cache t=Default Cache Time(second) public int cacheTime=600;//-1=No Cache 0=Always Cache t=Default Cache Time(second)
public File cacheFile=null;//Default Cache File public File cacheFile=null;//Default Cache File
public HttpRequest(String url){ public HttpRequest(String url){
this.url=url; this.url=url;
} }
public HttpRequest setUserAgent(String userAgent){ public HttpRequest setUserAgent(String userAgent){
this.userAgent=userAgent; this.userAgent=userAgent;
return this; return this;
} }
public HttpRequest setPayload(String payload){ public HttpRequest setPayload(String payload){
this.payload=payload; this.payload=payload;
return this; return this;
} }
public HttpRequest setLoadContent(boolean loadContent){ public HttpRequest setLoadContent(boolean loadContent){
this.loadContent=loadContent; this.loadContent=loadContent;
return this; return this;
} }
public HttpRequest setCheckPNG(boolean checkPNG){ public HttpRequest setCheckPNG(boolean checkPNG){
this.checkPNG=checkPNG; this.checkPNG=checkPNG;
return this; return this;
} }
public HttpRequest setCacheTime(int cacheTime){ public HttpRequest setCacheTime(int cacheTime){
this.cacheTime=cacheTime; this.cacheTime=cacheTime;
return this; return this;
} }
public HttpRequest setCacheFile(File cacheFile){ public HttpRequest setCacheFile(File cacheFile){
this.cacheFile=cacheFile; this.cacheFile=cacheFile;
return this; return this;
} }
} }
public static class HttpResponce{ public static class HttpResponce{
public String content=null; public String content=null;
public int responceCode=-1; public int responceCode=-1;
public boolean success=false; public boolean success=false;
public boolean fromCache=false; public boolean fromCache=false;
} }
public static class CacheInfo{ public static class CacheInfo{
public String url; public String url;
public String etag=null; public String etag=null;
public long lastModified=-1;//ms public long lastModified=-1;//ms
public long expire=-1;//UNIX timestamp public long expire=-1;//UNIX timestamp
} }
public static final File CACHE_DIR=new File(CustomSkinLoader.DATA_DIR,"caches"); public static final File CACHE_DIR=new File(CustomSkinLoader.DATA_DIR,"caches");
public static HttpResponce makeHttpRequest(HttpRequest request){ public static HttpResponce makeHttpRequest(HttpRequest request){
try{ return makeHttpRequest(request, 0);
CustomSkinLoader.logger.info("Try to request '"+request.url+(request.userAgent==null?"'.":"' with user agent '"+request.userAgent+"'.")); }
//Check Cache
if(StringUtils.isNotEmpty(request.payload))
request.cacheTime=-1;//No Cache
File cacheInfoFile=null;
CacheInfo cacheInfo=new CacheInfo();
if(request.cacheFile==null && request.cacheTime>=0){
String hash=DigestUtils.sha1Hex(request.url);
request.cacheFile=new File(CACHE_DIR,hash);
cacheInfoFile=new File(CACHE_DIR,hash+".json");
}
if(request.cacheTime==0 && request.cacheFile.isFile())
return loadFromCache(request,new HttpResponce());
if(cacheInfoFile!=null&&cacheInfoFile.isFile()){
String json=FileUtils.readFileToString(cacheInfoFile);
if(StringUtils.isNotEmpty(json))
cacheInfo=CustomSkinLoader.GSON.fromJson(json, CacheInfo.class);
if(cacheInfo==null)
cacheInfo=new CacheInfo();
if(cacheInfo.expire>=TimeUtil.getCurrentUnixTimestamp())
return loadFromCache(request,new HttpResponce(),cacheInfo.expire);
}
//Init Connection public static HttpResponce makeHttpRequest(HttpRequest request, int redirectTime){
String url=new URI(request.url).toASCIIString(); try{
if(!url.equalsIgnoreCase(request.url)) CustomSkinLoader.logger.debug("Try to request '"+request.url+(request.userAgent==null?"'.":"' with user agent '"+request.userAgent+"'."));
CustomSkinLoader.logger.info("Encoded URL: "+url); //Check Cache
HttpURLConnection c = (HttpURLConnection) (new URL(url)).openConnection(); if(StringUtils.isNotEmpty(request.payload))
c.setReadTimeout(1000 * 10); request.cacheTime=-1;//No Cache
c.setConnectTimeout(1000 * 10); File cacheInfoFile=null;
c.setDoInput(true); CacheInfo cacheInfo=new CacheInfo();
c.setUseCaches(false); if(request.cacheFile==null && request.cacheTime>=0){
c.setInstanceFollowRedirects(true); String hash=DigestUtils.sha1Hex(request.url);
request.cacheFile=new File(CACHE_DIR,hash);
cacheInfoFile=new File(CACHE_DIR,hash+".json");
}
if(request.cacheTime==0 && request.cacheFile.isFile())
return loadFromCache(request,new HttpResponce());
if(cacheInfoFile!=null&&cacheInfoFile.isFile()){
String json=FileUtils.readFileToString(cacheInfoFile, "UTF-8");
if(StringUtils.isNotEmpty(json))
cacheInfo=CustomSkinLoader.GSON.fromJson(json, CacheInfo.class);
if(cacheInfo==null)
cacheInfo=new CacheInfo();
if(cacheInfo.expire>=TimeUtil.getCurrentUnixTimestamp())
return loadFromCache(request,new HttpResponce(),cacheInfo.expire);
}
//Make Connection //Init Connection
if(cacheInfo.lastModified>=0) String url=new URI(request.url).toASCIIString();
c.setIfModifiedSince(cacheInfo.lastModified); if(!url.equalsIgnoreCase(request.url))
if(cacheInfo.etag!=null) CustomSkinLoader.logger.debug("Encoded URL: "+url);
c.setRequestProperty("If-None-Match",cacheInfo.etag); HttpURLConnection c = (HttpURLConnection) (new URL(url)).openConnection();
c.setRequestProperty("Accept-Encoding","gzip"); c.setReadTimeout(1000 * 10);
if(request.userAgent!=null) c.setConnectTimeout(1000 * 10);
c.setRequestProperty("User-Agent",request.userAgent); c.setDoInput(true);
if(StringUtils.isNotEmpty(request.payload)){ c.setUseCaches(false);
CustomSkinLoader.logger.info("Payload: "+request.payload); c.setInstanceFollowRedirects(true);
c.setDoOutput(true);
OutputStream os=c.getOutputStream();
IOUtils.write(request.payload, os);
IOUtils.closeQuietly(os);
}
c.connect();
//Check Connection //Make Connection
HttpResponce responce=new HttpResponce(); if(cacheInfo.lastModified>=0)
responce.responceCode=c.getResponseCode(); c.setIfModifiedSince(cacheInfo.lastModified);
int res=c.getResponseCode()/100; if(cacheInfo.etag!=null)
if(res==4||res==5){//Failed c.setRequestProperty("If-None-Match",cacheInfo.etag);
CustomSkinLoader.logger.info("Failed to request (Response Code: "+c.getResponseCode()+")"); c.setRequestProperty("Accept-Encoding","gzip");
return responce; if(request.userAgent!=null)
} c.setRequestProperty("User-Agent",request.userAgent);
responce.success=true; if(StringUtils.isNotEmpty(request.payload)){
CustomSkinLoader.logger.info("Successfully request (Response Code: "+c.getResponseCode()+" , Content Length: "+c.getContentLength()+")"); CustomSkinLoader.logger.info("Payload: "+request.payload);
if(responce.responceCode==HttpURLConnection.HTTP_NOT_MODIFIED) c.setDoOutput(true);
return loadFromCache(request,responce); OutputStream os=c.getOutputStream();
IOUtils.write(request.payload, os, "UTF-8");
IOUtils.closeQuietly(os);
}
c.connect();
//Load Content //Check Connection
InputStream is="gzip".equals(c.getContentEncoding())?new GZIPInputStream(c.getInputStream()):c.getInputStream(); HttpResponce responce=new HttpResponce();
byte [] bytes = IOUtils.toByteArray(is); responce.responceCode=c.getResponseCode();
if(request.checkPNG&&(bytes.length<=4||bytes[1]!=(byte)'P'||bytes[2]!=(byte)'N'||bytes[3]!=(byte)'G')){ int res = c.getResponseCode();
CustomSkinLoader.logger.info("Failed to request (Not Standard PNG)"); if (res / 100 == 4 || res / 100 == 5) {//Failed
responce.success=false; CustomSkinLoader.logger.debug("Failed to request (Response Code: " + res + ")");
return responce; return responce;
} }
if(request.cacheFile!=null){ if (res == HttpURLConnection.HTTP_MOVED_PERM || res == HttpURLConnection.HTTP_MOVED_TEMP) {
FileUtils.writeByteArrayToFile(request.cacheFile, bytes); //Redirect
if(cacheInfoFile!=null){ if (redirectTime >= 4) {
cacheInfo.url=request.url; CustomSkinLoader.logger.debug("Failed to request (Too many redirection)");
cacheInfo.etag=c.getHeaderField("ETag"); return responce;
cacheInfo.lastModified=c.getLastModified(); }
cacheInfo.expire=getExpire(c,request.cacheTime); request.url = c.getHeaderField("Location");//Get redirecting location
FileUtils.write(cacheInfoFile, CustomSkinLoader.GSON.toJson(cacheInfo)); if (request.url == null) {
} CustomSkinLoader.logger.debug("Failed to request (Redirecting location not found)");
CustomSkinLoader.logger.info("Saved to cache (Length: "+request.cacheFile.length()+" , Path: '"+request.cacheFile.getAbsolutePath()+"' , Expire: "+cacheInfo.expire+")"); return responce;
} }
if(!request.loadContent) CustomSkinLoader.logger.debug("Redirect to: " + request.url);
return responce; return makeHttpRequest(request, redirectTime + 1);//Recursion
responce.content=new String(bytes,Charsets.UTF_8); }
CustomSkinLoader.logger.info("Content: "+responce.content); responce.success=true;
return responce; CustomSkinLoader.logger.debug("Successfully request (Response Code: " + res + " , Content Length: " + c.getContentLength() + ")");
if(responce.responceCode==HttpURLConnection.HTTP_NOT_MODIFIED)
return loadFromCache(request,responce);
if (responce.responceCode == HttpURLConnection.HTTP_NO_CONTENT)
request.cacheTime = 3600;
}catch(Exception e){ //Load Content
CustomSkinLoader.logger.info("Failed to request (Exception: "+e.toString()+")"); InputStream is="gzip".equals(c.getContentEncoding())?new GZIPInputStream(c.getInputStream()):c.getInputStream();
return loadFromCache(request,new HttpResponce()); byte [] bytes = IOUtils.toByteArray(is);
} if(request.checkPNG&&(bytes.length<=4||bytes[1]!=(byte)'P'||bytes[2]!=(byte)'N'||bytes[3]!=(byte)'G')){
} CustomSkinLoader.logger.debug("Failed to request (Not Standard PNG)");
responce.success=false;
return responce;
}
if(request.cacheFile!=null){
FileUtils.writeByteArrayToFile(request.cacheFile, bytes);
if(cacheInfoFile!=null){
cacheInfo.url=request.url;
cacheInfo.etag=c.getHeaderField("ETag");
cacheInfo.lastModified=c.getLastModified();
cacheInfo.expire=getExpire(c,request.cacheTime);
FileUtils.write(cacheInfoFile, CustomSkinLoader.GSON.toJson(cacheInfo), "UTF-8");
}
CustomSkinLoader.logger.debug("Saved to cache (Length: "+request.cacheFile.length()+" , Path: '"+request.cacheFile.getAbsolutePath()+"' , Expire: "+cacheInfo.expire+")");
}
if(!request.loadContent)
return responce;
responce.content=new String(bytes, "UTF-8");
CustomSkinLoader.logger.debug("Content: "+responce.content);
return responce;
public static File getCacheFile(String hash){ }catch(Exception e){
return new File(CACHE_DIR,hash); CustomSkinLoader.logger.debug("Failed to request (Exception: "+e.toString()+")");
} return loadFromCache(request,new HttpResponce());
private static HttpResponce loadFromCache(HttpRequest request,HttpResponce responce){ }
return loadFromCache(request,responce,0); }
}
private static HttpResponce loadFromCache(HttpRequest request,HttpResponce responce,long expireTime){
if(request.cacheFile==null||!request.cacheFile.isFile())
return responce;
CustomSkinLoader.logger.info("Cache file found (Length: "+request.cacheFile.length()+" , Path: '"+request.cacheFile.getAbsolutePath()+"' , Expire: "+expireTime+"')");
responce.fromCache=true;
responce.success=true;
if(!request.loadContent)
return responce;
CustomSkinLoader.logger.info("Try to load from cache '"+request.cacheFile.getAbsolutePath()+"'."); public static File getCacheFile(String hash){
try { return new File(CACHE_DIR,hash);
responce.content=FileUtils.readFileToString(request.cacheFile); }
CustomSkinLoader.logger.info("Successfully to load from cache"); private static HttpResponce loadFromCache(HttpRequest request,HttpResponce responce){
} catch (IOException e) { return loadFromCache(request,responce,0);
CustomSkinLoader.logger.info("Failed to load from cache (Exception: "+e.toString()+")"); }
responce.success=false; private static HttpResponce loadFromCache(HttpRequest request,HttpResponce responce,long expireTime){
} if(request.cacheFile==null||!request.cacheFile.isFile())
return responce; return responce;
} CustomSkinLoader.logger.debug("Cache file found (Length: "+request.cacheFile.length()+" , Path: '"+request.cacheFile.getAbsolutePath()+"' , Expire: "+expireTime+"')");
private final static Pattern MAX_AGE_PATTERN = Pattern.compile(".*?max-age=(\\d+).*?"); responce.fromCache=true;
private static long getExpire(HttpURLConnection connection,int cacheTime){ responce.success=true;
String cacheControl=connection.getHeaderField("Cache-Control"); if(!request.loadContent)
if(StringUtils.isNotEmpty(cacheControl)){ return responce;
Matcher m=MAX_AGE_PATTERN.matcher(cacheControl);
if(m!=null && m.matches())
return TimeUtil.getUnixTimestamp(Long.parseLong(m.group(m.groupCount())));
}
long expires=connection.getExpiration();
if(expires>0)
return expires/1000;
return TimeUtil.getUnixTimestampRandomDelay(cacheTime==0 ? 86400 : cacheTime);
} CustomSkinLoader.logger.info("Try to load from cache '"+request.cacheFile.getAbsolutePath()+"'.");
try {
responce.content=FileUtils.readFileToString(request.cacheFile, "UTF-8");
CustomSkinLoader.logger.debug("Successfully load from cache");
CustomSkinLoader.logger.debug("Content: "+responce.content);
} catch (IOException e) {
CustomSkinLoader.logger.debug("Failed to load from cache (Exception: "+e.toString()+")");
responce.success=false;
}
return responce;
}
private final static Pattern MAX_AGE_PATTERN = Pattern.compile(".*?max-age=(\\d+).*?");
private static long getExpire(HttpURLConnection connection,int cacheTime){
String cacheControl=connection.getHeaderField("Cache-Control");
if(StringUtils.isNotEmpty(cacheControl)){
Matcher m=MAX_AGE_PATTERN.matcher(cacheControl);
if(m.matches())
return TimeUtil.getUnixTimestamp(Long.parseLong(m.group(m.groupCount())));
}
long expires=connection.getExpiration();
if(expires>0)
return expires/1000;
return TimeUtil.getUnixTimestampRandomDelay(cacheTime==0 ? 86400 : cacheTime);
}
} }
@@ -8,75 +8,76 @@ import org.apache.commons.io.FilenameUtils;
import customskinloader.CustomSkinLoader; import customskinloader.CustomSkinLoader;
public class HttpTextureUtil { public class HttpTextureUtil {
public static class HttpTextureInfo{ public static class HttpTextureInfo{
public String url=""; public String url="";
public File cacheFile; public File cacheFile;
public String hash; public String hash;
} }
private static final String private static final String
LEGACY_MARK="(LEGACY)", LEGACY_MARK="(LEGACY)",
LOCAL_MARK="(LOCAL)", LOCAL_MARK="(LOCAL)",
LOCAL_LEGACY_MARK="(LOCAL_LEGACY)"; LOCAL_LEGACY_MARK="(LOCAL_LEGACY)";
public static File defaultCacheDir; public static File defaultCacheDir;
public static void cleanCacheDir(){ @SuppressWarnings("ResultOfMethodCallIgnored")
if(defaultCacheDir!=null){ public static void cleanCacheDir(){
defaultCacheDir.delete(); if(defaultCacheDir!=null){
defaultCacheDir.mkdirs(); defaultCacheDir.delete();
} defaultCacheDir.mkdirs();
} }
public static File getCacheDir(){ }
return defaultCacheDir==null?new File(MinecraftUtil.getMinecraftDataDir(),"assets/skins"):defaultCacheDir; public static File getCacheDir(){
} return defaultCacheDir==null?new File(MinecraftUtil.getMinecraftDataDir(),"assets/skins"):defaultCacheDir;
}
public static HttpTextureInfo toHttpTextureInfo(String fakeUrl){ public static HttpTextureInfo toHttpTextureInfo(String fakeUrl){
HttpTextureInfo info=new HttpTextureInfo(); HttpTextureInfo info=new HttpTextureInfo();
if(fakeUrl.startsWith("http")){ if(fakeUrl.startsWith("http")){
info.url=fakeUrl; info.url=fakeUrl;
info.hash=FilenameUtils.getBaseName(fakeUrl); info.hash=FilenameUtils.getBaseName(fakeUrl);
info.cacheFile=getCacheFile(info.hash); info.cacheFile=getCacheFile(info.hash);
return info; return info;
} }
if(fakeUrl.startsWith(LOCAL_LEGACY_MARK)){ if(fakeUrl.startsWith(LOCAL_LEGACY_MARK)){
fakeUrl=fakeUrl.replace(LOCAL_LEGACY_MARK, ""); fakeUrl=fakeUrl.replace(LOCAL_LEGACY_MARK, "");
String[] t=fakeUrl.split(",",2); String[] t=fakeUrl.split(",",2);
if(t.length!=2) if(t.length!=2)
return info; return info;
info.cacheFile=new File(CustomSkinLoader.DATA_DIR,t[1]); info.cacheFile=new File(CustomSkinLoader.DATA_DIR,t[1]);
info.hash=t[0]; info.hash=t[0];
return info; return info;
} }
if(fakeUrl.startsWith(LOCAL_MARK)){ if(fakeUrl.startsWith(LOCAL_MARK)){
fakeUrl=fakeUrl.replace(LOCAL_MARK, ""); fakeUrl=fakeUrl.replace(LOCAL_MARK, "");
info.cacheFile=new File(CustomSkinLoader.DATA_DIR,fakeUrl); info.cacheFile=new File(CustomSkinLoader.DATA_DIR,fakeUrl);
info.hash=FilenameUtils.getBaseName(fakeUrl); info.hash=FilenameUtils.getBaseName(fakeUrl);
return info; return info;
} }
if(fakeUrl.startsWith(LEGACY_MARK)){ if(fakeUrl.startsWith(LEGACY_MARK)){
fakeUrl=fakeUrl.replace(LEGACY_MARK, ""); fakeUrl=fakeUrl.replace(LEGACY_MARK, "");
info.url=fakeUrl; info.url=fakeUrl;
info.hash=DigestUtils.sha1Hex(info.url);; info.hash=DigestUtils.sha1Hex(info.url);
info.cacheFile=HttpTextureUtil.getCacheFile(info.hash); info.cacheFile = HttpRequestUtil.getCacheFile(info.hash);
return info; return info;
} }
return info; return info;
} }
public static String getLegacyFakeUrl(String url){ public static String getLegacyFakeUrl(String url){
return LEGACY_MARK+url; return LEGACY_MARK+url;
} }
public static String getLocalFakeUrl(String path){ public static String getLocalFakeUrl(String path){
return LOCAL_MARK+path; return LOCAL_MARK+path;
} }
public static String getLocalLegacyFakeUrl(String path,String hash){ public static String getLocalLegacyFakeUrl(String path,String hash){
return LOCAL_LEGACY_MARK+hash+","+path; return LOCAL_LEGACY_MARK+hash+","+path;
} }
public static String getHash(String url,long size,long lastModified){ public static String getHash(String url,long size,long lastModified){
return DigestUtils.sha1Hex(size+url+lastModified); return DigestUtils.sha1Hex(size+url+lastModified);
} }
public static File getCacheFile(String hash){ public static File getCacheFile(String hash){
return getCacheFile(defaultCacheDir,hash); return getCacheFile(defaultCacheDir,hash);
} }
public static File getCacheFile(File cacheDir,String hash){ public static File getCacheFile(File cacheDir,String hash){
return new File(new File(cacheDir,hash.length()>2?hash.substring(0,2):"xx"), hash); return new File(new File(cacheDir,hash.length()>2?hash.substring(0,2):"xx"), hash);
} }
} }
@@ -1,79 +1,122 @@
package customskinloader.utils; package customskinloader.utils;
import java.io.IOException;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.Socket;
import java.net.UnknownHostException; import java.net.UnknownHostException;
import java.security.cert.X509Certificate; import java.security.cert.X509Certificate;
import javax.net.ssl.HostnameVerifier; import javax.net.ssl.*;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
public class HttpUtil0 { public class HttpUtil0 {
public static boolean isLocal(String url){ public static boolean isLocal(String url){
return url==null? false : !url.startsWith("http"); return url != null && !url.startsWith("http");
} }
//From: http://blog.csdn.net/xiyushiyi/article/details/46685387 //From: http://blog.csdn.net/xiyushiyi/article/details/46685387
public static void ignoreHttpsCertificate(){ public static void ignoreHttpsCertificate(){
HostnameVerifier doNotVerify = new HostnameVerifier() { HostnameVerifier doNotVerify = new HostnameVerifier() {
public boolean verify(String hostname, SSLSession session) { public boolean verify(String hostname, SSLSession session) {
return true; return true;
} }
}; };
TrustManager[] trustAllCerts = new TrustManager[] {new X509TrustManager() { TrustManager[] trustAllCerts = new TrustManager[] {new X509TrustManager() {
public X509Certificate[] getAcceptedIssuers() { public X509Certificate[] getAcceptedIssuers() {
return new X509Certificate[] {}; return new X509Certificate[] {};
} }
public void checkClientTrusted(X509Certificate[] chain, String authType){} public void checkClientTrusted(X509Certificate[] chain, String authType){}
public void checkServerTrusted(X509Certificate[] chain, String authType){} public void checkServerTrusted(X509Certificate[] chain, String authType){}
}}; }};
try { try {
SSLContext sc = SSLContext.getInstance("TLS"); SSLContext sc = SSLContext.getInstance("TLS");
sc.init(null, trustAllCerts, new java.security.SecureRandom()); sc.init(null, trustAllCerts, new java.security.SecureRandom());
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); //HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
HttpsURLConnection.setDefaultHostnameVerifier(doNotVerify); HttpsURLConnection.setDefaultSSLSocketFactory(new SSLSocketFactoryFacade());
} catch (Exception e) { HttpsURLConnection.setDefaultHostnameVerifier(doNotVerify);
e.printStackTrace(); } catch (Exception e) {
} e.printStackTrace();
} }
}
public static String parseAddress(String address) { public static String parseAddress(String address) {
if(StringUtils.isEmpty(address)) if(StringUtils.isEmpty(address))
return null; return null;
String[] addresses=address.split(":"); String[] addresses=address.split(":");
InetAddress add; InetAddress add;
try { try {
add = InetAddress.getByName(addresses[0]); add = InetAddress.getByName(addresses[0]);
} catch (UnknownHostException e) { } catch (UnknownHostException e) {
e.printStackTrace(); e.printStackTrace();
return null; return null;
} }
return add.getHostAddress()+(addresses.length==2 ? addresses[1] : "25565"); return add.getHostAddress()+(addresses.length==2 ? addresses[1] : "25565");
} }
public static boolean isLanServer(String standardAddress){ public static boolean isLanServer(String standardAddress){
if(StringUtils.isEmpty(standardAddress)) if(StringUtils.isEmpty(standardAddress))
return true; return true;
String[] addresses=standardAddress.split(":"); String[] addresses=standardAddress.split(":");
int numIp=getNumIp(addresses[0]); int numIp=getNumIp(addresses[0]);
return numIp==0||numIp==getNumIp("127.0.0.1")|| return numIp==0||numIp==getNumIp("127.0.0.1")||
(numIp>=getNumIp("192.168.0.0")&&numIp<=getNumIp("192.168.255.255"))|| (numIp>=getNumIp("192.168.0.0")&&numIp<=getNumIp("192.168.255.255"))||
(numIp>=getNumIp("10.0.0.0")&&numIp<=getNumIp("10.255.255.255"))|| (numIp>=getNumIp("10.0.0.0")&&numIp<=getNumIp("10.255.255.255"))||
(numIp>=getNumIp("172.16.0.0")&&numIp<=getNumIp("172.31.255.255")); (numIp>=getNumIp("172.16.0.0")&&numIp<=getNumIp("172.31.255.255"));
} }
public static int getNumIp(String ip){ public static int getNumIp(String ip){
int num=0; int num=0;
String[] ips=ip.split("\\."); String[] ips=ip.split("\\.");
if(ips.length!=4) if(ips.length!=4)
return 0; return 0;
for(int i=0;i<4;i++) for(int i=0;i<4;i++)
num+=Integer.parseInt(ips[i])*(256^(3-i)); num+=Integer.parseInt(ips[i])*(256^(3-i));
return num; return num;
} }
//https://stackoverflow.com/questions/30817934/extended-server-name-sni-extension-not-sent-with-jdk1-8-0-but-send-with-jdk1-7
public static class SSLSocketFactoryFacade extends SSLSocketFactory {
SSLSocketFactory sslsf;
public SSLSocketFactoryFacade() {
sslsf = (SSLSocketFactory) SSLSocketFactory.getDefault();;
}
@Override
public String[] getDefaultCipherSuites() {
return sslsf.getDefaultCipherSuites();
}
@Override
public String[] getSupportedCipherSuites() {
return sslsf.getSupportedCipherSuites();
}
@Override
public Socket createSocket(Socket socket, String s, int i, boolean b) throws IOException {
return sslsf.createSocket(socket, s, i, b);
}
@Override
public Socket createSocket(String s, int i) throws IOException, UnknownHostException {
return sslsf.createSocket(s, i);
}
@Override
public Socket createSocket(String s, int i, InetAddress inetAddress, int i1) throws IOException, UnknownHostException {
return sslsf.createSocket(s, i, inetAddress, i1);
}
@Override
public Socket createSocket(InetAddress inetAddress, int i) throws IOException {
return createSocket(inetAddress, i);
}
@Override
public Socket createSocket(InetAddress inetAddress, int i, InetAddress inetAddress1, int i1) throws IOException {
return createSocket(inetAddress, i, inetAddress1, i1);
}
}
} }
@@ -0,0 +1,34 @@
package customskinloader.utils;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.LinkedList;
public class JavaUtil {
public static URL[] getClasspath() {
if (JavaUtil.class.getClassLoader() instanceof URLClassLoader) {
//Java 8-
//Use URLClassLoader Directly
URLClassLoader ucl = (URLClassLoader) JavaUtil.class.getClassLoader();
return ucl.getURLs();
} else {
//Java 9+
//It uses APPClassLoader instead of URLClassLoader
//Get Classpath from properties and parse it to URL array
String classpath = System.getProperty("java.class.path");
String[] elements = classpath.split(File.pathSeparator);
if (elements.length == 0)
return new URL[0];
LinkedList<URL> urls = new LinkedList<URL>();
for (String ele : elements) {
try {
urls.add(new URL(ele));
} catch (Exception ignored) {
}
}
return (URL[]) urls.toArray();
}
}
}
@@ -2,7 +2,6 @@ package customskinloader.utils;
import java.io.File; import java.io.File;
import java.net.URL; import java.net.URL;
import java.net.URLClassLoader;
import java.net.URLDecoder; import java.net.URLDecoder;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.regex.Matcher; import java.util.regex.Matcher;
@@ -10,8 +9,10 @@ import java.util.regex.Pattern;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.minecraft.MinecraftSessionService; import com.mojang.authlib.minecraft.MinecraftSessionService;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.client.renderer.texture.TextureManager;
/** /**
@@ -20,105 +21,105 @@ import net.minecraft.client.renderer.texture.TextureManager;
* *
*/ */
public class MinecraftUtil { public class MinecraftUtil {
public static File getMinecraftDataDir(){ public static File getMinecraftDataDir(){
return net.minecraft.client.Minecraft.getMinecraft().mcDataDir; return Minecraft.getMinecraft().gameDir;
} }
public static MinecraftSessionService getSessionService(){ public static MinecraftSessionService getSessionService(){
return net.minecraft.client.Minecraft.getMinecraft().getSessionService(); return Minecraft.getMinecraft().getSessionService();
} }
public static TextureManager getTextureManager(){ public static TextureManager getTextureManager(){
return net.minecraft.client.Minecraft.getMinecraft().getTextureManager(); return Minecraft.getMinecraft().getTextureManager();
} }
private static ArrayList<String> minecraftVersion=new ArrayList<String>(); private static ArrayList<String> minecraftVersion=new ArrayList<String>();
private static String minecraftMainVersion=null; private static String minecraftMainVersion=null;
private final static Pattern MINECRAFT_VERSION_PATTERN = Pattern.compile(".*?(\\d+\\.\\d+[\\.]?\\d*).*?"); private final static Pattern MINECRAFT_VERSION_PATTERN = Pattern.compile(".*?(\\d+\\.\\d+[\\.]?\\d*).*?");
public static ArrayList<String> getMinecraftVersions(){ public static ArrayList<String> getMinecraftVersions(){
if(minecraftVersion!=null&&!minecraftVersion.isEmpty()) if(minecraftVersion!=null&&!minecraftVersion.isEmpty())
return minecraftVersion; return minecraftVersion;
testProbe(); testProbe();
return minecraftVersion; return minecraftVersion;
} }
public static String getMinecraftVersionText(){ public static String getMinecraftVersionText(){
StringBuilder sb=new StringBuilder(); StringBuilder sb=new StringBuilder();
for(String version:getMinecraftVersions()) for(String version:getMinecraftVersions())
sb.append(version).append(" "); sb.append(version).append(" ");
return StringUtils.trim(sb.toString()); return StringUtils.trim(sb.toString());
} }
public static String getMinecraftMainVersion(){ public static String getMinecraftMainVersion(){
if(minecraftMainVersion!=null) if(minecraftMainVersion!=null)
return minecraftMainVersion; return minecraftMainVersion;
for(String version:getMinecraftVersions()){ for(String version:getMinecraftVersions()){
Matcher m = null; Matcher m = null;
try{ try{
m=MINECRAFT_VERSION_PATTERN.matcher(version); m=MINECRAFT_VERSION_PATTERN.matcher(version);
}catch(Exception e){ }catch(Exception e){
e.printStackTrace(); e.printStackTrace();
} }
if(m==null || !m.matches()) if(m==null || !m.matches())
continue; continue;
minecraftMainVersion=m.group(m.groupCount()); minecraftMainVersion=m.group(m.groupCount());
break; break;
} }
return minecraftMainVersion; return minecraftMainVersion;
} }
// (domain|ip)(:port) // (domain|ip)(:port)
public static String getServerAddress(){ public static String getServerAddress(){
net.minecraft.client.multiplayer.ServerData data=net.minecraft.client.Minecraft.getMinecraft().getCurrentServerData(); net.minecraft.client.multiplayer.ServerData data = Minecraft.getMinecraft().getCurrentServerData();
if(data==null)//Single Player if(data==null)//Single Player
return null; return null;
return data.serverIP; return data.serverIP;
} }
// ip:port // ip:port
public static String getStandardServerAddress(){ public static String getStandardServerAddress(){
return HttpUtil0.parseAddress(getServerAddress()); return HttpUtil0.parseAddress(getServerAddress());
} }
public static boolean isLanServer(){ public static boolean isLanServer(){
return HttpUtil0.isLanServer(getStandardServerAddress()); return HttpUtil0.isLanServer(getStandardServerAddress());
} }
public static String getCurrentUsername(){ public static String getCurrentUsername(){
return net.minecraft.client.Minecraft.getMinecraft().getSession().getProfile().getName(); return Minecraft.getMinecraft().getSession().getProfile().getName();
} }
private final static Pattern MINECRAFT_CORE_FILE_PATTERN = Pattern.compile("^(.*?)/versions/([^\\/\\\\]*?)/([^\\/\\\\]*?).jar$"); private final static Pattern MINECRAFT_CORE_FILE_PATTERN = Pattern.compile("^(.*?)/versions/([^\\/\\\\]*?)/([^\\/\\\\]*?).jar$");
private static void testProbe(){ private static void testProbe(){
minecraftVersion.clear(); minecraftVersion.clear();
URLClassLoader ucl = (URLClassLoader)new MinecraftUtil().getClass().getClassLoader(); URL urls[] = JavaUtil.getClasspath();
URL urls[] = ucl.getURLs(); for(URL url:urls){
for(URL url:urls){ Matcher m = null;
Matcher m = null; try{
try{ m=MINECRAFT_CORE_FILE_PATTERN.matcher(URLDecoder.decode(url.getPath(),"UTF-8"));
m=MINECRAFT_CORE_FILE_PATTERN.matcher(URLDecoder.decode(url.getPath(),"UTF-8")); }catch(Exception e){
}catch(Exception e){ e.printStackTrace();
e.printStackTrace(); }
} if(m==null || !m.matches())
if(m==null || !m.matches()) continue;
continue; minecraftVersion.add(m.group(2));
minecraftVersion.add(m.group(2)); }
} }
}
public static boolean isCoreFile(URL url){ public static boolean isCoreFile(URL url) {
Matcher m = null; return regexMatch(url, MINECRAFT_CORE_FILE_PATTERN);
try{ }
m=MINECRAFT_CORE_FILE_PATTERN.matcher(URLDecoder.decode(url.getPath(),"UTF-8"));
}catch(Exception e){
e.printStackTrace();
return false;
}
return m!=null && m.matches();
}
private final static Pattern LIBRARY_FILE_PATTERN = Pattern.compile("^(.*?)/libraries/(.*?)/([^\\/\\\\]*?).jar$"); private final static Pattern LIBRARY_FILE_PATTERN = Pattern.compile("^(.*?)/libraries/(.*?)/([^\\/\\\\]*?).jar$");
public static boolean isLibraryFile(URL url){ public static boolean isLibraryFile(URL url) {
Matcher m = null; return regexMatch(url, LIBRARY_FILE_PATTERN);
try{ }
m=LIBRARY_FILE_PATTERN.matcher(URLDecoder.decode(url.getPath(),"UTF-8")); private static boolean regexMatch(URL url, Pattern p) {
}catch(Exception e){ Matcher m;
e.printStackTrace(); try {
return false; m=p.matcher(URLDecoder.decode(url.getPath(), "UTF-8"));
} } catch (Exception e) {
return m!=null && m.matches(); e.printStackTrace();
} return false;
}
return m.matches();
}
public static String getCredential(GameProfile profile) {
return (profile==null || profile.hashCode()==0) ? null :
(profile.getId()==null ? profile.getName() : String.format("%s-%s", profile.getName(),profile.getId()));
}
} }
@@ -1,17 +1,17 @@
package customskinloader.utils; package customskinloader.utils;
public class TimeUtil { public class TimeUtil {
public static long getCurrentUnixTimestamp(){ public static long getCurrentUnixTimestamp(){
return System.currentTimeMillis()/1000l; return System.currentTimeMillis() / 1000L;
} }
public static long getUnixTimestamp(long offset){ public static long getUnixTimestamp(long offset){
return getCurrentUnixTimestamp()+offset; return getCurrentUnixTimestamp()+offset;
} }
public static long getUnixTimestampRandomDelay(long offset){ public static long getUnixTimestampRandomDelay(long offset){
return getCurrentUnixTimestamp()+offset+random(0,5); return getCurrentUnixTimestamp()+offset+random(0,5);
} }
private static int random(int min,int max){ private static int random(int min,int max){
return (int)(Math.random()*(max-min+1))+min; return (int)(Math.random()*(max-min+1))+min;
} }
} }
@@ -0,0 +1,50 @@
package customskinloader.utils;
import org.apache.commons.lang3.StringUtils;
public class Version implements Comparable {
private String version;
private int sub[];
public Version(String version) {
if (version == null) version = "";
this.version = version;
//Parse Subversion
String[] split = version.split("\\.");
sub = new int[split.length];
for (int i = 0; i < split.length; i++) {
if (StringUtils.isNumeric(split[i]))
sub[i] = Integer.parseInt(split[i]);
}
}
public static Version of(String version) {
return new Version(version);
}
public static int compare(String version, String anotherVersion) {
return Version.of(version).compareTo(anotherVersion);
}
@Override
public String toString() {
return version;
}
@Override
public int compareTo(Object o) {
if (o instanceof String) o = Version.of((String) o);//Parse String version
if (!(o instanceof Version)) throw new IllegalArgumentException(String.format("'%s' is not a Version.", o));
Version v = (Version) o;
int i = 0;
//Skip same subversion
while (i < sub.length && i < v.sub.length && sub[i] == v.sub[i]) i++;
//Compare first non-equal number
if (i < sub.length && i < v.sub.length)
return (sub[i] < v.sub[i]) ? -1 : ((sub[i] == v.sub[i]) ? 0 : 1); //Integer.compare(sub[i], v.sub[i]);
//Compare length if all subversion is same
return Integer.signum(sub.length - v.sub.length);
}
}
@@ -0,0 +1,57 @@
package net.minecraft.client.renderer.texture;
/**
* Empty stack for NativeImage
*/
public class NativeImage {
public NativeImage(int p_i48122_1_, int p_i48122_2_, boolean p_i48122_3_) {
}
/**
* getWidth
*/
public int func_195702_a() {
return 0;
}
/**
* getHeight
*/
public int func_195714_b() {
return 0;
}
/**
* copyImage image
*/
public void func_195703_a(NativeImage p_195703_1_) {
}
/**
* fillAreaRGBA x0 y0 weight height rgba
*/
public void func_195715_a(int p_195715_1_, int p_195715_2_, int p_195715_3_, int p_195715_4_, int p_195715_5_) {
}
/**
* copyAreaRGBA x0 y0 dx dy weight height reversex reversey
*/
public void func_195699_a(int p_195699_1_, int p_195699_2_, int p_195699_3_, int p_195699_4_, int p_195699_5_, int p_195699_6_, boolean p_195699_7_, boolean p_195699_8_) {
}
/**
* getPixelRGBA x y
*/
public int func_195709_a(int p_195709_1_, int p_195709_2_) {
return 0;
}
/**
* setPixelRGBA x y rgba
*/
public void func_195700_a(int p_195700_1_, int p_195700_2_, int p_195700_3_) {
}
public void close() {
}
}
+3
View File
@@ -0,0 +1,3 @@
/bin/
/build/
/run/
Binary file not shown.
+71 -63
View File
@@ -1,11 +1,11 @@
buildscript { buildscript {
repositories { repositories {
/*maven { mavenCentral()
name = "fmm"
url = "http://forgemavenmirror.sinaapp.com/maven"
}*/
jcenter() jcenter()
maven { url = "http://files.minecraftforge.net/maven" } maven {
name = "forge"
url = "http://files.minecraftforge.net/maven"
}
} }
dependencies { dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT' classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
@@ -13,44 +13,61 @@ buildscript {
} }
apply plugin: 'net.minecraftforge.gradle.forge' apply plugin: 'net.minecraftforge.gradle.forge'
ext.MINECRAFT_VERSION="1.12" ext.MINECRAFT_VERSION = "1.12.2"
ext.FORGE_VERSION="14.21.1.2387" ext.FORGE_VERSION = "14.23.5.2768"
ext.MAPPING_VERSION="snapshot_20170813" ext.MAPPING_VERSION = "stable_39"
ext.MINECRAFT_FULL_VERSIONS="1.8,1.8.8,1.8.9,1.9,1.9.4,1.10,1.10.2,1.11,1.11.2,1.12,1.12.1" ext.MINECRAFT_FULL_VERSIONS = "1.8,1.8.8,1.8.9,1.9,1.9.4,1.10,1.10.2,1.11,1.11.2,1.12,1.12.1,1.12.2"
ext.snapshot = !(rootProject.ext.config.snapshot==""||rootProject.ext.config.snapshot=="0"||rootProject.ext.config.snapshot==0) apply from: rootProject.file("BuildScripts/version.gradle")
archivesBaseName = "CustomSkinLoader_Forge" archivesBaseName = "CustomSkinLoader_Forge"
version = rootProject.ext.config.version + rootProject.ext.config.dev_version + (snapshot?"-SNAPSHOT-"+System.getenv("BUILD_NUMBER"):"") version = getCSLVersion()
group = "customskinloader" group = "customskinloader"
sourceCompatibility = targetCompatibility = "1.6" sourceCompatibility = targetCompatibility = 1.6
compileJava { compileJava {
sourceCompatibility = targetCompatibility = "1.6" sourceCompatibility = targetCompatibility = 1.6
} }
jar { jar {
manifest { manifest {
attributes 'FMLCorePlugin': 'customskinloader.forge.ForgePlugin' attributes([
attributes 'FMLCorePluginContainsFMLMod': true "FMLCorePlugin" : "customskinloader.forge.ForgePlugin",
"FMLCorePluginContainsFMLMod": true,
"Specification-Title" : "CustomSkinLoader",
"Specification-Vendor" : "xfl03",
"Specification-Version" : "1",
"Implementation-Title" : "CustomSkinLoader",
"Implementation-Version" : "${version}",
"Implementation-Vendor" : "xfl03",
"Implementation-Timestamp" : new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
])
} }
exclude 'net/minecraft/client/renderer/texture/NativeImage.class'
exclude 'net/minecraftforge/fml/common/Mod.class'
} }
sourceSets { sourceSets {
main { main {
java { java {
srcDir 'MergedSource'//Merge source //Common
srcDir '../Common/source'
//Forge
srcDir 'source'
} }
resources { resources {
srcDir 'MergedResource' //Common
srcDir '../Common/resource'
exclude 'Profile.json'
//Forge
srcDir 'resource'
} }
} }
} }
minecraft { minecraft {
version = MINECRAFT_VERSION+"-"+FORGE_VERSION version = MINECRAFT_VERSION + "-" + FORGE_VERSION
runDir = "run" runDir = "run"
mappings = MAPPING_VERSION mappings = MAPPING_VERSION
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable. clientJvmArgs += "-Dfml.coreMods.load=customskinloader.forge.ForgePlugin"
replace '@MOD_VERSION@', rootProject.ext.config.version replace '@MOD_VERSION@', rootProject.ext.config.version
replace '@MOD_FULL_VERSION@', project.version replace '@MOD_FULL_VERSION@', project.version
@@ -58,51 +75,42 @@ minecraft {
replaceIn 'ForgeMod.java' replaceIn 'ForgeMod.java'
} }
task mergeSource { doLast { processResources {
copy { filesNotMatching("**/*.js"){
from '../Common/source' expand([
exclude '**/tweaker/**' modVersion : rootProject.ext.config.version,
from 'source' modFullVersion: project.version,
into 'MergedSource' mcVersion : MINECRAFT_VERSION,
} mcFullVersions: MINECRAFT_FULL_VERSIONS,
}} forgeVersion : FORGE_VERSION,
sourceMainJava.dependsOn mergeSource gitVersion : System.getenv("CIRCLE_SHA1"),
buildUrl : System.getenv("CIRCLE_BUILD_URL")
task mergeResources { doLast { ])}
copy {
from '../Common/resource'
from 'resource'
into 'MergedResource'
}
}}
processResources.dependsOn mergeResources
processResources
{
expand ([
modVersion :rootProject.ext.config.version,
modFullVersion :project.version,
mcVersion :MINECRAFT_VERSION,
mcFullVersions :MINECRAFT_FULL_VERSIONS,
forgeVersion :FORGE_VERSION,
gitVersion :System.getenv("GIT_COMMIT"),
buildUrl :System.getenv("BUILD_URL")
])
} }
task afterBuild { doLast { task signJar(type: SignJar, dependsOn: reobfJar) {
//Clean Up onlyIf { System.getenv("KEY_PASS") != null }
def sourceDir = file("MergedSource") doLast { System.out.println("Jar will be signed.") }
sourceDir.deleteDir()
def resourceDir = file("MergedResource")
resourceDir.deleteDir()
//copyBuildFile inputFile = jar.archivePath
copy { outputFile = jar.archivePath
from 'build/libs'
into '../build/libs' keyStore = 'CustomSkinLoader.jks'
include '**/*.jar' alias = 'CustomSkinLoader'
exclude '**/*-sources.jar' storePass = System.getenv("KEY_PASS")
keyPass = System.getenv("KEY_PASS")
}
build.dependsOn signJar
task afterBuild {
doLast {
//copyBuildFile
copy {
from 'build/libs'
into '../build/libs'
include '**/*.jar'
exclude '**/*-sources.jar'
}
} }
}} }
build.finalizedBy afterBuild build.finalizedBy afterBuild
+3
View File
@@ -0,0 +1,3 @@
{
"transformers": "transformers.js"
}
+18
View File
@@ -0,0 +1,18 @@
modLoader="javafml"
loaderVersion="[25,)"
[[mods]]
modId="customskinloader"
version="${modFullVersion}"
displayName="CustomSkinLoader"
description='''
Custom Skin Loader for Minecraft
'''
issueTrackerURL="https://github.com/xfl03/MCCustomSkinLoader/issues"
displayURL="https://github.com/xfl03/MCCustomSkinLoader"
authors=["xfl03", "JLChnToZ"]
[[dependencies.customskinloader]]
modId="forge"
mandatory=true
versionRange="[25,)"
ordering="NONE"
side="CLIENT"
+8 -9
View File
@@ -1,11 +1,10 @@
[ [
{ {
"modid": "customskinloader", "modid": "customskinloader",
"name": "CustomSkinLoader", "name": "CustomSkinLoader",
"description": "Custom Skin Loader for Minecraft", "description": "Custom Skin Loader for Minecraft",
"version": "${modFullVersion}", "version": "${modFullVersion}",
"url": "https://github.com/xfl03/MCCustomSkinLoader", "url": "https://github.com/xfl03/MCCustomSkinLoader",
"authorList": ["xfl03"], "authorList": ["xfl03", "JLChnToZ"]
"credits": "GPLv3" }
}
] ]
+6
View File
@@ -0,0 +1,6 @@
{
"pack": {
"description": "CustomSkinLoader resources",
"pack_format": 4
}
}
+154
View File
@@ -0,0 +1,154 @@
var AbstractInsnNode = Java.type('org.objectweb.asm.tree.AbstractInsnNode');
var FieldInsnNode = Java.type('org.objectweb.asm.tree.FieldInsnNode');
var FieldNode = Java.type('org.objectweb.asm.tree.FieldNode');
var InsnNode = Java.type('org.objectweb.asm.tree.InsnNode');
var MethodInsnNode = Java.type('org.objectweb.asm.tree.MethodInsnNode');
var TypeInsnNode = Java.type('org.objectweb.asm.tree.TypeInsnNode');
var VarInsnNode = Java.type('org.objectweb.asm.tree.VarInsnNode');
var Opcodes = Java.type('org.objectweb.asm.Opcodes');
function SkinManagerTransformer() {
return {
'InitTransformer': function (cn, mn) {
cn.fields.add(new FieldNode(Opcodes.ACC_PRIVATE, "fakeManager", "Lcustomskinloader/fake/FakeSkinManager;", null, null));
mn.instructions.clear();
mn.instructions.add(new VarInsnNode(Opcodes.ALOAD, 0));
mn.instructions.add(new MethodInsnNode(Opcodes.INVOKESPECIAL, "java/lang/Object", "<init>", "()V", false));
mn.instructions.add(new VarInsnNode(Opcodes.ALOAD, 0));
mn.instructions.add(new TypeInsnNode(Opcodes.NEW, "customskinloader/fake/FakeSkinManager"));
mn.instructions.add(new InsnNode(Opcodes.DUP));
mn.instructions.add(new VarInsnNode(Opcodes.ALOAD, 1));
mn.instructions.add(new VarInsnNode(Opcodes.ALOAD, 2));
mn.instructions.add(new VarInsnNode(Opcodes.ALOAD, 3));
mn.instructions.add(new MethodInsnNode(Opcodes.INVOKESPECIAL, "customskinloader/fake/FakeSkinManager", "<init>",
"(Lnet/minecraft/client/renderer/texture/TextureManager;Ljava/io/File;Lcom/mojang/authlib/minecraft/MinecraftSessionService;)V", false));
mn.instructions.add(new FieldInsnNode(Opcodes.PUTFIELD, "net/minecraft/client/resources/SkinManager", "fakeManager", "Lcustomskinloader/fake/FakeSkinManager;"));
mn.instructions.add(new InsnNode(Opcodes.RETURN));
},
'LoadSkinTransformer': function (cn, mn) {
mn.instructions.clear();
mn.instructions.add(new VarInsnNode(Opcodes.ALOAD, 0));
mn.instructions.add(new FieldInsnNode(Opcodes.GETFIELD, "net/minecraft/client/resources/SkinManager", "fakeManager", "Lcustomskinloader/fake/FakeSkinManager;"));
mn.instructions.add(new VarInsnNode(Opcodes.ALOAD, 1));
mn.instructions.add(new VarInsnNode(Opcodes.ALOAD, 2));
mn.instructions.add(new VarInsnNode(Opcodes.ALOAD, 3));
mn.instructions.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, "customskinloader/fake/FakeSkinManager", "loadSkin",
"(Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;)Lnet/minecraft/util/ResourceLocation;", false));
mn.instructions.add(new InsnNode(Opcodes.ARETURN));
},
'LoadProfileTexturesTransformer': function (cn, mn) {
mn.instructions.clear();
mn.instructions.add(new VarInsnNode(Opcodes.ALOAD, 0));
mn.instructions.add(new FieldInsnNode(Opcodes.GETFIELD, "net/minecraft/client/resources/SkinManager", "fakeManager", "Lcustomskinloader/fake/FakeSkinManager;"));
mn.instructions.add(new VarInsnNode(Opcodes.ALOAD, 1));
mn.instructions.add(new VarInsnNode(Opcodes.ALOAD, 2));
mn.instructions.add(new VarInsnNode(Opcodes.ILOAD, 3));
mn.instructions.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, "customskinloader/fake/FakeSkinManager", "loadProfileTextures",
"(Lcom/mojang/authlib/GameProfile;Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;Z)V", false));
mn.instructions.add(new InsnNode(Opcodes.RETURN));
},
'LoadSkinFromCacheTransformer': function (cn, mn) {
mn.instructions.clear();
mn.instructions.add(new VarInsnNode(Opcodes.ALOAD, 0));
mn.instructions.add(new FieldInsnNode(Opcodes.GETFIELD, "net/minecraft/client/resources/SkinManager", "fakeManager", "Lcustomskinloader/fake/FakeSkinManager;"));
mn.instructions.add(new VarInsnNode(Opcodes.ALOAD, 1));
mn.instructions.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, "customskinloader/fake/FakeSkinManager", "loadSkinFromCache",
"(Lcom/mojang/authlib/GameProfile;)Ljava/util/Map;", false));
mn.instructions.add(new InsnNode(Opcodes.ARETURN));
}
};
}
function PlayerTabTransformer(cn, mn) {
var iterator = mn.instructions.iterator();
while (iterator.hasNext()) {
var node = iterator.next();
if (node instanceof VarInsnNode) {
var varNode = node;
if (varNode.getOpcode() === Opcodes.ISTORE && varNode.var === 11) {
mn.instructions.set(varNode.getPrevious(), new InsnNode(Opcodes.ICONST_1));
}
}
}
}
function FakeSkinManagerTransformer(cn, mn) {
var TARGET_CLASS = "net/minecraft/client/renderer/ThreadDownloadImageData";
var NEW_TARGET_CLASS = "net/minecraft/client/renderer/texture/ThreadDownloadImageData";
var CALLBACK_CLASS = "net/minecraft/client/resources/SkinManager$SkinAvailableCallback";
var il = mn.instructions;
var li = il.iterator();
while (li.hasNext()) {
var ain = li.next();
if (ain instanceof MethodInsnNode) {
var min = ain;
if (min.owner.equals(TARGET_CLASS)) {
min.owner = NEW_TARGET_CLASS;
//il.set(min, new MethodInsnNode(min.getOpcode(), NEW_TARGET_CLASS, min.name, min.desc, false));
}
if (min.owner.equals(CALLBACK_CLASS) && min.name.equals("func_180521_a")) {
min.name = "onSkinTextureAvailable";
//il.set(min, new MethodInsnNode(min.getOpcode(), min.owner, "onSkinTextureAvailable", min.desc, false));
}
} else if (ain instanceof TypeInsnNode) {
var tin = ain;
if (tin.desc.equals(TARGET_CLASS)) {
tin.desc = NEW_TARGET_CLASS;
}
}
}
}
function initializeCoreMod() {
return {
'SkinManagerTransformer': {
'target': {
'type': 'CLASS',
'name': 'net/minecraft/client/resources/SkinManager'
},
'transformer': function (cn) {
cn.methods.forEach(function (mn) {
if (mn.name === '<init>')
SkinManagerTransformer()['InitTransformer'](cn, mn);
else if(mn.name === 'func_152789_a')
SkinManagerTransformer()['LoadSkinTransformer'](cn, mn);
else if(mn.name === 'func_152790_a')
SkinManagerTransformer()['LoadProfileTexturesTransformer'](cn, mn);
else if(mn.name === 'func_152788_a')
SkinManagerTransformer()['LoadSkinFromCacheTransformer'](cn, mn);
});
return cn;
}
},
'PlayerTabTransformer': {
'target': {
'type': 'CLASS',
'name': 'net/minecraft/client/gui/GuiPlayerTabOverlay'
},
'transformer': function (cn) {
cn.methods.forEach(function (mn) {
if (mn.name === 'func_175249_a')
PlayerTabTransformer(cn, mn);
});
return cn;
}
},
'FakeSkinManagerTransformer': {
'target': {
'type': 'CLASS',
'name': 'customskinloader/fake/FakeSkinManager'
},
'transformer': function (cn) {
cn.methods.forEach(function (mn) {
//if (mn.name === '<init>')
FakeSkinManagerTransformer(cn, mn);
});
return cn;
}
}
};
}
@@ -1,12 +1,40 @@
package customskinloader.forge; package customskinloader.forge;
import customskinloader.CustomSkinLoader;
import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.event.FMLFingerprintViolationEvent;
@Mod(modid = "customskinloader", /**
name = "CustomSkinLoader", * Forge Mod Container
version = "@MOD_FULL_VERSION@", */
clientSideOnly=true, @Mod(
acceptedMinecraftVersions="[1.8,)") value = "customskinloader",
public class ForgeMod{ modid = "customskinloader",
name = "CustomSkinLoader",
version = "@MOD_FULL_VERSION@",
clientSideOnly = true,
acceptedMinecraftVersions = "[1.8,)",
certificateFingerprint = "52885f395e68f42e9b3b629ba56ecf606f7d4269"
)//1.13-
public class ForgeMod {
@EventHandler
public void fingerprintError(FMLFingerprintViolationEvent event) {
if (event.isDirectory()) return;//Development Environment
CustomSkinLoader.logger.warning("!!!Fingerprint ERROR!!!");
CustomSkinLoader.logger.warning("Failed to check fingerprint in file '" + event.getSource().getAbsolutePath() + "'.");
CustomSkinLoader.logger.warning("Excepted Fingerprint: " + event.getExpectedFingerprint());
if (event.getFingerprints().isEmpty()) {
CustomSkinLoader.logger.warning("No Fingerprint Founded.");
} else {
CustomSkinLoader.logger.warning("Founded Fingerprint: ");
for (String s : event.getFingerprints())
CustomSkinLoader.logger.warning(s);
}
throw new RuntimeException("Fingerprint ERROR, please **DO NOT MODIFY** any mod.");
}
} }
@@ -3,12 +3,14 @@ package customskinloader.forge;
import java.util.Map; import java.util.Map;
import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin; import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin;
import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin.Name;
@Name("CustomSkinLoader")
public class ForgePlugin implements IFMLLoadingPlugin { public class ForgePlugin implements IFMLLoadingPlugin {
@Override @Override
public String[] getASMTransformerClass() { public String[] getASMTransformerClass() {
return new String[] {TransformerManager.class.getName()}; return new String[]{"customskinloader.forge.loader.LaunchWrapper"};//LaunchWrapper
} }
@Override @Override
@@ -1,36 +0,0 @@
package customskinloader.forge;
import java.util.ListIterator;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.InsnNode;
import org.objectweb.asm.tree.MethodNode;
import org.objectweb.asm.tree.VarInsnNode;
import customskinloader.forge.TransformerManager.IMethodTransformer;
import customskinloader.forge.TransformerManager.TransformTarget;
public class PlayerTabTransformer {
@TransformTarget(className="net.minecraft.client.gui.GuiPlayerTabOverlay",
methodNames={"func_175249_a","renderPlayerlist"},
desc="(ILnet/minecraft/scoreboard/Scoreboard;Lnet/minecraft/scoreboard/ScoreObjective;)V")
public static class ScoreObjectiveTransformer implements IMethodTransformer{
//From: http://git.oschina.net/AsteriskTeam/TabIconHackForge/blob/master/src/main/java/kengxxiao/tabiconhack/coremod/TabIconHackForgeClassTransformer.java#L30-L43
@Override
public void transform(ClassNode cn, MethodNode mn) {
ListIterator<AbstractInsnNode> iterator = mn.instructions.iterator();
while (iterator.hasNext())
{
AbstractInsnNode node = iterator.next();
if (node instanceof VarInsnNode)
{
VarInsnNode varNode = (VarInsnNode) node;
if (varNode.getOpcode() == Opcodes.ISTORE && varNode.var == 11)
mn.instructions.set(varNode.getPrevious(), new InsnNode(Opcodes.ICONST_1));
}
}
}
}
}
@@ -1,88 +0,0 @@
package customskinloader.forge;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.FieldInsnNode;
import org.objectweb.asm.tree.FieldNode;
import org.objectweb.asm.tree.InsnNode;
import org.objectweb.asm.tree.MethodInsnNode;
import org.objectweb.asm.tree.MethodNode;
import org.objectweb.asm.tree.TypeInsnNode;
import org.objectweb.asm.tree.VarInsnNode;
import customskinloader.forge.TransformerManager.IMethodTransformer;
import customskinloader.forge.TransformerManager.TransformTarget;
public class SkinManagerTransformer {
@TransformTarget(className="net.minecraft.client.resources.SkinManager",
methodNames={"<init>"},
desc="(Lnet/minecraft/client/renderer/texture/TextureManager;Ljava/io/File;Lcom/mojang/authlib/minecraft/MinecraftSessionService;)V")
public static class InitTransformer implements IMethodTransformer{
@Override
public void transform(ClassNode cn,MethodNode mn) {
cn.fields.add(new FieldNode(Opcodes.ACC_PRIVATE, "fakeManager", "Lcustomskinloader/fake/FakeSkinManager;", null, null));
mn.instructions.clear();
mn.instructions.add(new VarInsnNode(Opcodes.ALOAD,0));
mn.instructions.add(new MethodInsnNode(Opcodes.INVOKESPECIAL,"java/lang/Object","<init>","()V", false));
mn.instructions.add(new VarInsnNode(Opcodes.ALOAD,0));
mn.instructions.add(new TypeInsnNode(Opcodes.NEW, "customskinloader/fake/FakeSkinManager"));
mn.instructions.add(new InsnNode(Opcodes.DUP));
mn.instructions.add(new VarInsnNode(Opcodes.ALOAD,1));
mn.instructions.add(new VarInsnNode(Opcodes.ALOAD,2));
mn.instructions.add(new VarInsnNode(Opcodes.ALOAD,3));
mn.instructions.add(new MethodInsnNode(Opcodes.INVOKESPECIAL,"customskinloader/fake/FakeSkinManager","<init>",
"(Lnet/minecraft/client/renderer/texture/TextureManager;Ljava/io/File;Lcom/mojang/authlib/minecraft/MinecraftSessionService;)V", false));
mn.instructions.add(new FieldInsnNode(Opcodes.PUTFIELD, "net/minecraft/client/resources/SkinManager", "fakeManager", "Lcustomskinloader/fake/FakeSkinManager;"));
mn.instructions.add(new InsnNode(Opcodes.RETURN));
}
}
@TransformTarget(className="net.minecraft.client.resources.SkinManager",
methodNames={"func_152789_a","loadSkin"},
desc="(Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;)Lnet/minecraft/util/ResourceLocation;")
public static class LoadSkinTransformer implements IMethodTransformer{
@Override
public void transform(ClassNode cn,MethodNode mn) {
mn.instructions.clear();
mn.instructions.add(new VarInsnNode(Opcodes.ALOAD,0));
mn.instructions.add(new FieldInsnNode(Opcodes.GETFIELD, "net/minecraft/client/resources/SkinManager", "fakeManager", "Lcustomskinloader/fake/FakeSkinManager;"));
mn.instructions.add(new VarInsnNode(Opcodes.ALOAD,1));
mn.instructions.add(new VarInsnNode(Opcodes.ALOAD,2));
mn.instructions.add(new VarInsnNode(Opcodes.ALOAD,3));
mn.instructions.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL,"customskinloader/fake/FakeSkinManager","loadSkin",
"(Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;)Lnet/minecraft/util/ResourceLocation;", false));
mn.instructions.add(new InsnNode(Opcodes.ARETURN));
}
}
@TransformTarget(className="net.minecraft.client.resources.SkinManager",
methodNames={"func_152790_a","loadProfileTextures"},
desc="(Lcom/mojang/authlib/GameProfile;Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;Z)V")
public static class LoadProfileTexturesTransformer implements IMethodTransformer{
@Override
public void transform(ClassNode cn,MethodNode mn) {
mn.instructions.clear();
mn.instructions.add(new VarInsnNode(Opcodes.ALOAD,0));
mn.instructions.add(new FieldInsnNode(Opcodes.GETFIELD, "net/minecraft/client/resources/SkinManager", "fakeManager", "Lcustomskinloader/fake/FakeSkinManager;"));
mn.instructions.add(new VarInsnNode(Opcodes.ALOAD,1));
mn.instructions.add(new VarInsnNode(Opcodes.ALOAD,2));
mn.instructions.add(new VarInsnNode(Opcodes.ILOAD,3));
mn.instructions.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL,"customskinloader/fake/FakeSkinManager","loadProfileTextures",
"(Lcom/mojang/authlib/GameProfile;Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;Z)V", false));
mn.instructions.add(new InsnNode(Opcodes.RETURN));
}
}
@TransformTarget(className="net.minecraft.client.resources.SkinManager",
methodNames={"func_152788_a","loadSkinFromCache"},
desc="(Lcom/mojang/authlib/GameProfile;)Ljava/util/Map;")
public static class LoadSkinFromCacheTransformer implements IMethodTransformer{
@Override
public void transform(ClassNode cn,MethodNode mn) {
mn.instructions.clear();
mn.instructions.add(new VarInsnNode(Opcodes.ALOAD,0));
mn.instructions.add(new FieldInsnNode(Opcodes.GETFIELD, "net/minecraft/client/resources/SkinManager", "fakeManager", "Lcustomskinloader/fake/FakeSkinManager;"));
mn.instructions.add(new VarInsnNode(Opcodes.ALOAD,1));
mn.instructions.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL,"customskinloader/fake/FakeSkinManager","loadSkinFromCache",
"(Lcom/mojang/authlib/GameProfile;)Ljava/util/Map;", false));
mn.instructions.add(new InsnNode(Opcodes.ARETURN));
}
}
}
@@ -1,95 +1,69 @@
package customskinloader.forge; package customskinloader.forge;
import java.io.File;
import java.lang.annotation.ElementType; import java.lang.annotation.ElementType;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; import java.lang.annotation.Target;
import java.util.ArrayList; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.tree.ClassNode; import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.MethodNode; import org.objectweb.asm.tree.MethodNode;
import net.minecraft.launchwrapper.IClassTransformer; import customskinloader.Logger;
import net.minecraftforge.fml.common.asm.transformers.deobf.FMLDeobfuscatingRemapper;
import net.minecraftforge.fml.relauncher.FMLRelaunchLog;
import customskinloader.forge.PlayerTabTransformer.ScoreObjectiveTransformer;
import customskinloader.forge.SkinManagerTransformer.*;
public class TransformerManager implements IClassTransformer { public class TransformerManager {
@Retention(RetentionPolicy.RUNTIME) public static Logger logger = new Logger(new File("./CustomSkinLoader/ForgePlugin.log"));
@Target(ElementType.TYPE)
public @interface TransformTarget{
public String className();
public String[] methodNames();
public String desc();
}
public interface IMethodTransformer{
public void transform(ClassNode cn,MethodNode mn);
}
private static final IMethodTransformer[] TRANFORMERS={
new InitTransformer(),
new LoadSkinTransformer(),
new LoadProfileTexturesTransformer(),
new LoadSkinFromCacheTransformer(),
new ScoreObjectiveTransformer()};
private Map<String, Map<String, IMethodTransformer>> map;
public TransformerManager(){
map = new HashMap<String, Map<String, IMethodTransformer>>();
for(IMethodTransformer t:TRANFORMERS){
FMLRelaunchLog.info("[CSL DEBUG] REGISTERING TRANSFORMER %s",t.getClass().getName());
if(!t.getClass().isAnnotationPresent(TransformTarget.class)){
FMLRelaunchLog.info("[CSL DEBUG] ERROR occurs while parsing Annotation.");
continue;
}
addMethodTransformer(t.getClass().getAnnotation(TransformTarget.class),t);
}
}
private void addMethodTransformer(TransformTarget target, IMethodTransformer transformer) {
if (!map.containsKey(target.className()))
map.put(target.className(), new HashMap<String, IMethodTransformer>());
for(String methodName:target.methodNames()){
map.get(target.className()).put(methodName + target.desc(), transformer);
FMLRelaunchLog.info("[CSL DEBUG] REGISTERING METHOD %s(%s)",target.className(),methodName + target.desc());
}
}
//From: https://github.com/RecursiveG/UniSkinMod/blob/1.9.4/src/main/java/org/devinprogress/uniskinmod/coremod/BaseAsmTransformer.java#L83-L114 @Retention(RetentionPolicy.RUNTIME)
@Override @Target(ElementType.TYPE)
public byte[] transform(String obfClassName, String className, byte[] bytes) { public @interface TransformTarget {
if (!map.containsKey(className)) return bytes; String className();
FMLRelaunchLog.info("[CSL DEBUG] CLASS %s will be transformed", className);
Map<String, IMethodTransformer> transMap = map.get(className);
ClassReader cr = new ClassReader(bytes); String[] methodNames();
ClassNode cn = new ClassNode();
cr.accept(cn, 0);
// NOTE: `map` = convert obfuscated name to srgName; String desc();
List<MethodNode> ml = new ArrayList<MethodNode>(); }
ml.addAll(cn.methods);
for (MethodNode mn : ml) {
String methodName = FMLDeobfuscatingRemapper.INSTANCE.mapMethodName(obfClassName, mn.name, mn.desc);
String methodDesc = FMLDeobfuscatingRemapper.INSTANCE.mapMethodDesc(mn.desc);
if (transMap.containsKey(methodName + methodDesc)) {
try {
FMLRelaunchLog.info("[CSL DEBUG] Transforming method %s in class %s(%s)", methodName + methodDesc, obfClassName, className);
transMap.get(methodName + methodDesc).transform(cn,mn);
FMLRelaunchLog.info("[CSL DEBUG] Successfully transformed method %s in class %s(%s)", methodName + methodDesc, obfClassName, className);
} catch (Exception e) {
FMLRelaunchLog.warning("[CSL DEBUG] An error happened when transforming method %s in class %s(%s). The whole class was not modified.", methodName + methodDesc, obfClassName, className);
e.printStackTrace();
return bytes;
}
}
}
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS); public interface IMethodTransformer {
cn.accept(cw); void transform(ClassNode cn, MethodNode mn);
return cw.toByteArray(); }
}
public Map<String, Map<String, IMethodTransformer>> map;
public TransformerManager(IMethodTransformer... transformers) {
map = new HashMap<String, Map<String, IMethodTransformer>>();
for (IMethodTransformer t : transformers) {
logger.info("[CSL DEBUG] REGISTERING TRANSFORMER %s", t.getClass().getName());
if (!t.getClass().isAnnotationPresent(TransformTarget.class)) {
logger.info("[CSL DEBUG] ERROR occurs while parsing Annotation.");
continue;
}
addMethodTransformer(t.getClass().getAnnotation(TransformTarget.class), t);
}
}
private void addMethodTransformer(TransformTarget target, IMethodTransformer transformer) {
if (!map.containsKey(target.className()))
map.put(target.className(), new HashMap<String, IMethodTransformer>());
for (String methodName : target.methodNames()) {
map.get(target.className()).put(methodName + target.desc(), transformer);
logger.info("[CSL DEBUG] REGISTERING METHOD %s(%s)", target.className(), methodName + target.desc());
}
}
public MethodNode transform(ClassNode classNode, MethodNode methodNode, String className, String methodName, String methodDesc) {
Map<String, IMethodTransformer> transMap = map.get(className);
String methodTarget = methodName + methodDesc;
if (transMap.containsKey(methodTarget)) {
try {
transMap.get(methodTarget).transform(classNode, methodNode);
logger.info("[CSL DEBUG] Successfully transformed method %s in class %s", methodName, className);
} catch (Exception e) {
logger.warning("[CSL DEBUG] An error happened when transforming method %s in class %s.", methodTarget, className);
logger.warning(e);
}
}
return methodNode;
}
} }
@@ -0,0 +1,49 @@
package customskinloader.forge.loader;
import customskinloader.forge.TransformerManager;
import customskinloader.forge.transformer.PlayerTabTransformer;
import customskinloader.forge.transformer.SkinManagerTransformer;
import customskinloader.forge.transformer.SpectatorMenuTransformer;
import net.minecraft.launchwrapper.IClassTransformer;
import net.minecraftforge.fml.common.asm.transformers.deobf.FMLDeobfuscatingRemapper;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.MethodNode;
//LaunchWrapper for 1.13-
public class LaunchWrapper implements IClassTransformer {
private static final TransformerManager.IMethodTransformer[] TRANFORMERS = {
new SkinManagerTransformer.InitTransformer(),
new SkinManagerTransformer.LoadSkinTransformer(),
new SkinManagerTransformer.LoadProfileTexturesTransformer(),
new SkinManagerTransformer.LoadSkinFromCacheTransformer(),
new PlayerTabTransformer.ScoreObjectiveTransformer(),
new SpectatorMenuTransformer.PlayerMenuObjectTransformer()
};
private TransformerManager transformerManager = new TransformerManager(TRANFORMERS);
//From: https://github.com/RecursiveG/UniSkinMod/blob/1.9.4/src/main/java/org/devinprogress/uniskinmod/coremod/BaseAsmTransformer.java#L83-L114
public byte[] transform(String obfClassName, String className, byte[] bytes) {
if (!transformerManager.map.containsKey(className)) return bytes;//Check if should be transformed
//Parse bytes to ClassNode
ClassReader cr = new ClassReader(bytes);
ClassNode cn = new ClassNode();
cr.accept(cn, 0);
//Transform ClassNode
for (MethodNode mn : cn.methods) {
String methodName = FMLDeobfuscatingRemapper.INSTANCE.mapMethodName(obfClassName, mn.name, mn.desc);
String methodDesc = FMLDeobfuscatingRemapper.INSTANCE.mapMethodDesc(mn.desc);
transformerManager.transform(cn, mn, className, methodName, methodDesc);
}
//Parse Class Node to bytes
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
cn.accept(cw);
return cw.toByteArray();
}
}
@@ -0,0 +1,49 @@
package customskinloader.forge.loader;
import customskinloader.forge.TransformerManager;
import customskinloader.forge.transformer.FakeSkinManagerTransformer;
import customskinloader.forge.transformer.PlayerTabTransformer;
import customskinloader.forge.transformer.SkinManagerTransformer;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.MethodNode;
/**
* ModLauncher for 1.13+
* @deprecated Use JavaScript Instead
*/
@Deprecated
public class ModLauncher {
private static final TransformerManager.IMethodTransformer[] TRANFORMERS = {
new SkinManagerTransformer.InitTransformer(),
new SkinManagerTransformer.LoadSkinTransformer(),
new SkinManagerTransformer.LoadProfileTexturesTransformer(),
new SkinManagerTransformer.LoadSkinFromCacheTransformer(),
new PlayerTabTransformer.ScoreObjectiveTransformer(),
new FakeSkinManagerTransformer.InitTransformer()
};
private TransformerManager transformerManager = new TransformerManager(TRANFORMERS);
public ClassNode transform(ClassNode input) {
for (MethodNode mn : input.methods) {
transformerManager.transform(input, mn, input.name, mn.name, mn.desc);
}
return input;
}
//Singleton
private volatile static ModLauncher INSTANCE = null;
public static ModLauncher instance() {
if (INSTANCE == null) {
synchronized (ModLauncher.class) {
if (INSTANCE == null) {
INSTANCE = new ModLauncher();
}
}
}
return INSTANCE;
}
}
@@ -0,0 +1,57 @@
package customskinloader.forge.transformer;
import customskinloader.forge.TransformerManager;
import customskinloader.forge.TransformerManager.IMethodTransformer;
import customskinloader.forge.TransformerManager.TransformTarget;
import org.objectweb.asm.tree.*;
import java.util.ListIterator;
/**
* Transformer of FakeSkinManager for 1.13+
* @deprecated Use JavaScript Instead
*/
@Deprecated
public class FakeSkinManagerTransformer {
private final static String TARGET_CLASS = "net/minecraft/client/renderer/ThreadDownloadImageData";
private final static String NEW_TARGET_CLASS = "net/minecraft/client/renderer/texture/ThreadDownloadImageData";
private final static String CALLBACK_CLASS = "net/minecraft/client/resources/SkinManager$SkinAvailableCallback";
@TransformTarget(className = "customskinloader.fake.FakeSkinManager",
methodNames = {"<init>"},
desc = "(Lnet/minecraft/client/renderer/texture/TextureManager;Ljava/io/File;Lcom/mojang/authlib/minecraft/MinecraftSessionService;)V")
public static class InitTransformer implements IMethodTransformer {
@Override
public void transform(ClassNode cn, MethodNode mn) {
TransformerManager.logger.info("1.13 detected, FakeSkinManager will be transformed.");
//ClassNameRemapper.remapClassName(cn, TARGET_CLASS, NEW_TARGET_CLASS);
//MethodNameRemapper.remapMethodName(cn, CALLBACK_CLASS, "func_180521_a", "onSkinTextureAvailable");
InsnList il = mn.instructions;
ListIterator<AbstractInsnNode> li = il.iterator();
while (li.hasNext()) {
AbstractInsnNode ain = li.next();
if (ain instanceof MethodInsnNode) {
MethodInsnNode min = (MethodInsnNode) ain;
if (min.owner.equals(TARGET_CLASS)) {
min.owner = NEW_TARGET_CLASS;
//il.set(min, new MethodInsnNode(min.getOpcode(), NEW_TARGET_CLASS, min.name, min.desc, false));
}
if (min.owner.equals(CALLBACK_CLASS) && min.name.equals("func_180521_a")) {
min.name = "onSkinTextureAvailable";
//il.set(min, new MethodInsnNode(min.getOpcode(), min.owner, "onSkinTextureAvailable", min.desc, false));
}
} else if (ain instanceof TypeInsnNode) {
TypeInsnNode tin = (TypeInsnNode) ain;
if (tin.desc.equals(TARGET_CLASS)) {
tin.desc = NEW_TARGET_CLASS;
}
}
}
}
}
}
@@ -0,0 +1,35 @@
package customskinloader.forge.transformer;
import java.util.ListIterator;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.InsnNode;
import org.objectweb.asm.tree.MethodNode;
import org.objectweb.asm.tree.VarInsnNode;
import customskinloader.forge.TransformerManager.IMethodTransformer;
import customskinloader.forge.TransformerManager.TransformTarget;
public class PlayerTabTransformer {
@TransformTarget(className = "net.minecraft.client.gui.GuiPlayerTabOverlay",
methodNames = {"func_175249_a", "renderPlayerlist"},
desc = "(ILnet/minecraft/scoreboard/Scoreboard;Lnet/minecraft/scoreboard/ScoreObjective;)V")
public static class ScoreObjectiveTransformer implements IMethodTransformer {
//From: http://git.oschina.net/AsteriskTeam/TabIconHackForge/blob/master/src/main/java/kengxxiao/tabiconhack/coremod/TabIconHackForgeClassTransformer.java#L30-L43
@Override
public void transform(ClassNode cn, MethodNode mn) {
ListIterator<AbstractInsnNode> iterator = mn.instructions.iterator();
while (iterator.hasNext()) {
AbstractInsnNode node = iterator.next();
if (node instanceof VarInsnNode) {
VarInsnNode varNode = (VarInsnNode) node;
if (varNode.getOpcode() == Opcodes.ISTORE && varNode.var == 11) {
mn.instructions.set(varNode.getPrevious(), new InsnNode(Opcodes.ICONST_1));
}
}
}
}
}
}
@@ -0,0 +1,88 @@
package customskinloader.forge.transformer;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.FieldInsnNode;
import org.objectweb.asm.tree.FieldNode;
import org.objectweb.asm.tree.InsnNode;
import org.objectweb.asm.tree.MethodInsnNode;
import org.objectweb.asm.tree.MethodNode;
import org.objectweb.asm.tree.TypeInsnNode;
import org.objectweb.asm.tree.VarInsnNode;
import customskinloader.forge.TransformerManager.IMethodTransformer;
import customskinloader.forge.TransformerManager.TransformTarget;
public class SkinManagerTransformer {
@TransformTarget(className="net.minecraft.client.resources.SkinManager",
methodNames={"<init>"},
desc="(Lnet/minecraft/client/renderer/texture/TextureManager;Ljava/io/File;Lcom/mojang/authlib/minecraft/MinecraftSessionService;)V")
public static class InitTransformer implements IMethodTransformer{
@Override
public void transform(ClassNode cn,MethodNode mn) {
cn.fields.add(new FieldNode(Opcodes.ACC_PRIVATE, "fakeManager", "Lcustomskinloader/fake/FakeSkinManager;", null, null));
mn.instructions.clear();
mn.instructions.add(new VarInsnNode(Opcodes.ALOAD,0));
mn.instructions.add(new MethodInsnNode(Opcodes.INVOKESPECIAL,"java/lang/Object","<init>","()V", false));
mn.instructions.add(new VarInsnNode(Opcodes.ALOAD,0));
mn.instructions.add(new TypeInsnNode(Opcodes.NEW, "customskinloader/fake/FakeSkinManager"));
mn.instructions.add(new InsnNode(Opcodes.DUP));
mn.instructions.add(new VarInsnNode(Opcodes.ALOAD,1));
mn.instructions.add(new VarInsnNode(Opcodes.ALOAD,2));
mn.instructions.add(new VarInsnNode(Opcodes.ALOAD,3));
mn.instructions.add(new MethodInsnNode(Opcodes.INVOKESPECIAL,"customskinloader/fake/FakeSkinManager","<init>",
"(Lnet/minecraft/client/renderer/texture/TextureManager;Ljava/io/File;Lcom/mojang/authlib/minecraft/MinecraftSessionService;)V", false));
mn.instructions.add(new FieldInsnNode(Opcodes.PUTFIELD, "net/minecraft/client/resources/SkinManager", "fakeManager", "Lcustomskinloader/fake/FakeSkinManager;"));
mn.instructions.add(new InsnNode(Opcodes.RETURN));
}
}
@TransformTarget(className="net.minecraft.client.resources.SkinManager",
methodNames={"func_152789_a","loadSkin"},
desc="(Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;)Lnet/minecraft/util/ResourceLocation;")
public static class LoadSkinTransformer implements IMethodTransformer{
@Override
public void transform(ClassNode cn,MethodNode mn) {
mn.instructions.clear();
mn.instructions.add(new VarInsnNode(Opcodes.ALOAD,0));
mn.instructions.add(new FieldInsnNode(Opcodes.GETFIELD, "net/minecraft/client/resources/SkinManager", "fakeManager", "Lcustomskinloader/fake/FakeSkinManager;"));
mn.instructions.add(new VarInsnNode(Opcodes.ALOAD,1));
mn.instructions.add(new VarInsnNode(Opcodes.ALOAD,2));
mn.instructions.add(new VarInsnNode(Opcodes.ALOAD,3));
mn.instructions.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL,"customskinloader/fake/FakeSkinManager","loadSkin",
"(Lcom/mojang/authlib/minecraft/MinecraftProfileTexture;Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;)Lnet/minecraft/util/ResourceLocation;", false));
mn.instructions.add(new InsnNode(Opcodes.ARETURN));
}
}
@TransformTarget(className="net.minecraft.client.resources.SkinManager",
methodNames={"func_152790_a","loadProfileTextures"},
desc="(Lcom/mojang/authlib/GameProfile;Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;Z)V")
public static class LoadProfileTexturesTransformer implements IMethodTransformer{
@Override
public void transform(ClassNode cn,MethodNode mn) {
mn.instructions.clear();
mn.instructions.add(new VarInsnNode(Opcodes.ALOAD,0));
mn.instructions.add(new FieldInsnNode(Opcodes.GETFIELD, "net/minecraft/client/resources/SkinManager", "fakeManager", "Lcustomskinloader/fake/FakeSkinManager;"));
mn.instructions.add(new VarInsnNode(Opcodes.ALOAD,1));
mn.instructions.add(new VarInsnNode(Opcodes.ALOAD,2));
mn.instructions.add(new VarInsnNode(Opcodes.ILOAD,3));
mn.instructions.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL,"customskinloader/fake/FakeSkinManager","loadProfileTextures",
"(Lcom/mojang/authlib/GameProfile;Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;Z)V", false));
mn.instructions.add(new InsnNode(Opcodes.RETURN));
}
}
@TransformTarget(className="net.minecraft.client.resources.SkinManager",
methodNames={"func_152788_a","loadSkinFromCache"},
desc="(Lcom/mojang/authlib/GameProfile;)Ljava/util/Map;")
public static class LoadSkinFromCacheTransformer implements IMethodTransformer{
@Override
public void transform(ClassNode cn,MethodNode mn) {
mn.instructions.clear();
mn.instructions.add(new VarInsnNode(Opcodes.ALOAD,0));
mn.instructions.add(new FieldInsnNode(Opcodes.GETFIELD, "net/minecraft/client/resources/SkinManager", "fakeManager", "Lcustomskinloader/fake/FakeSkinManager;"));
mn.instructions.add(new VarInsnNode(Opcodes.ALOAD,1));
mn.instructions.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL,"customskinloader/fake/FakeSkinManager","loadSkinFromCache",
"(Lcom/mojang/authlib/GameProfile;)Ljava/util/Map;", false));
mn.instructions.add(new InsnNode(Opcodes.ARETURN));
}
}
}
@@ -0,0 +1,56 @@
package customskinloader.forge.transformer;
import java.util.ListIterator;
import customskinloader.forge.TransformerManager;
import net.minecraftforge.fml.common.asm.transformers.deobf.FMLDeobfuscatingRemapper;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.InsnList;
import org.objectweb.asm.tree.MethodInsnNode;
import org.objectweb.asm.tree.MethodNode;
import customskinloader.forge.TransformerManager.IMethodTransformer;
import customskinloader.forge.TransformerManager.TransformTarget;
/**
* Transformer of Spectator Menu for 1.13-
*/
public class SpectatorMenuTransformer {
@TransformTarget(className = "net.minecraft.client.gui.spectator.PlayerMenuObject",
methodNames = {"<init>"},
desc = "(Lcom/mojang/authlib/GameProfile;)V")
public static class PlayerMenuObjectTransformer implements IMethodTransformer {
@Override
public void transform(ClassNode cn, MethodNode mn) {
InsnList il = mn.instructions;
ListIterator<AbstractInsnNode> li = il.iterator();
boolean flag = false;
while (li.hasNext()) {
AbstractInsnNode ain = li.next();
if (ain.getOpcode() != Opcodes.INVOKESTATIC)
continue;
if (!flag) {
//First InvokeStatic
il.set(ain, new MethodInsnNode(Opcodes.INVOKESTATIC,
"customskinloader/fake/FakeClientPlayer",
"getLocationSkin",
"(Ljava/lang/String;)Lnet/minecraft/util/ResourceLocation;", false));
flag = true;
} else {
//Second InvokeStatic
il.set(ain, new MethodInsnNode(Opcodes.INVOKESTATIC,
"customskinloader/fake/FakeClientPlayer",
"getDownloadImageSkin",
"(Lnet/minecraft/util/ResourceLocation;Ljava/lang/String;)Lnet/minecraft/client/renderer/ThreadDownloadImageData;", false));
break;
}
}
}
}
}
@@ -0,0 +1,32 @@
package net.minecraftforge.fml.common;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
//https://github.com/MinecraftForge/MinecraftForge/blob/1.13.x/src/main/java/net/minecraftforge/fml/common/Mod.java
//https://github.com/MinecraftForge/MinecraftForge/blob/1.12.x/src/main/java/net/minecraftforge/fml/common/Mod.java
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface Mod {
String value();
String modid();
String name() default "";
String version() default "";
boolean clientSideOnly() default false;
String acceptedMinecraftVersions() default "";
String certificateFingerprint() default "";
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@interface EventHandler {
}
}
+33 -27
View File
@@ -1,66 +1,70 @@
# CustomSkinLoader # CustomSkinLoader
## What's this? ## What's this?
Custom Skin Loader mod for Minecraft. Custom Skin Loader mod for Minecraft.
You can use it to load any skin from any website. It's a mod which can load skins and capes from any online source or from your local.
## Download ## Download
Build Server : [Infinity Studio CI](https://jenkins.mcdev.se/job/CustomSkinLoader/) Build Server : [CircleCI](https://circleci.com/gh/xfl03/MCCustomSkinLoader) & ~~[Infinity Studio CI](https://ci.infstudio.net/job/CustomSkinLoader/)~~
[![Build Status](https://jenkins.mcdev.se/job/CustomSkinLoader/badge/icon)](https://ci.infstudio.net/job/CustomSkinLoader/) Release Page : [MCBBS](http://www.mcbbs.net/thread-269807-1-1.html) & [GitHub](https://github.com/xfl03/MCCustomSkinLoader/releases) & [CurseForge](https://minecraft.curseforge.com/projects/customskinloader)
Release Page : [MCBBS](http://www.mcbbs.net/thread-269807-1-1.html)
## Feature ## Feature
### Plenty of Skin Load API Support and Customizable Skin Load List ### Support Plenty of Skin Load API and Customizable Skin Load List
Skin Load API Supported: Supported Skin Load APIs:
- [Mojang API](http://wiki.vg/Mojang_API) - [Mojang API](http://wiki.vg/Mojang_API)
- [CustomSkinAPI](https://github.com/xfl03/CustomSkinLoaderAPI/tree/master/CustomSkinAPI) - [CustomSkinAPI](https://github.com/xfl03/CustomSkinLoaderAPI/tree/master/CustomSkinAPI)
- CustomSkinAPIPlus (Test Only) - CustomSkinAPIPlus (Test Only)
- [UniSkinAPI](https://github.com/RecursiveG/UniSkinServer/tree/master/doc) - [UniSkinAPI](https://github.com/RecursiveG/UniSkinServer/tree/master/doc)
- [ElyByAPI](http://docs.ely.by/api.html)
- Legacy - Legacy
You can use this feature to customize your skin load list so as to load from any skin server you want. You can use this feature to customize your skin load list so as to load your skins from any skin server you want.
If you are the owner of skin server, you can use CustomSkinLoader to load skin from your server if one of the api has been actualized. If you are the owner of skin server, you can use CustomSkinLoader to load skins from your server if one of the APIs has been actualized by your server.
### HD Skins Support ### HD Skins Support
Even though there is no Optifine or MCPatcher, CustomSkinLoader has fix this problem. Even though you don't have OptiFine and MCPatcher, CustomSkinLoader can still load and render HD skins.
You can easily to get a better view in skin. You can easily to get a better view of skins.
### Skull Support ### Skull Support
Fixed skull load bug. Fixed skull loading bug, you can apply any skin to your skull now.
Dynamic skull supported. Dynamic skull supported.
### Profile Cache ### Profile Cache
- Decrease frenquency of using network. - Decrease the frenquency of using the network.
- Meanwhile,you can still load profile without network. - Meanwhile, you can still load profiles when network is unavailable.(*)
*Should be open in configratulation file. *Only when it is opened in configratulation.
### Local Skin ### Local Skin
Load skin without skin server. Load skins without a skin server.
Furthermore, by using this function you can preview your skin in game and even change default skin and model. Furthermore, by using this function you can preview your skins in game and even change the default skin and model.
You can load local skin by using any API(excluding MojangAPI). You can load local skins by using any API (excluding MojangAPI).
*While using default configratulation, just put skin into `.minecraft/CustomSkinLoader/LocalSkin/(skin|cape)s/{USERNAME}.png`. *While using default configratulation, just put your skins into `.minecraft/CustomSkinLoader/LocalSkin/(skin|cape)s/{USERNAME}.png`.
### Extra List ### Extra List
A json file generated by supported skin server. A json file generated by skin servers which supports this feature.
To add server to load list, users just need to put file into `.minecraft/CustomSkinLoader/ExtraList` . To add a server to your load list, users just need to put the file into `.minecraft/CustomSkinLoader/ExtraList` .
### Transparent Skin Support ### Transparent Skin Support
The problem of rendering incorrect texture has been fixed. The problem of incorrectly rendering textures has been fixed.
### Spectator Menu Fixed
By using this mod, you can see correct avatar of players in Spectator Menu rather than steve and alex.
## Default Load List ## Default Load List
- [Mojang](http://www.minecraft.net/) (Mojang API) - [Mojang](http://www.minecraft.net/) (Mojang API)
- [Little Skin](https://mcskin.littleservice.cn/) (CustomSkinAPI) - [LittleSkin](https://littleskin.cn/) (CustomSkinAPI)
- [Blessing Skin](http://skin.prinzeugen.net/) (CustomSkinAPI) - [Blessing Skin](http://skin.prinzeugen.net/) (CustomSkinAPI)
- [ElyBy](http://docs.ely.by/) (ElyByAPI)
- SkinMe (UniSkinAPI) - SkinMe (UniSkinAPI)
- LocalSkin (Legacy) - LocalSkin (Legacy)
If you want to apply to add other skin server to default list, please go to [issue](https://github.com/JLChnToZ/MCCustomSkinLoader/issues). If you want to apply to add other skin server to default list, please go to [issue](https://github.com/JLChnToZ/MCCustomSkinLoader/issues).
## To Skin Server Owner ## To Skin Server Owner
CustomSkinLoader is designed for loading from any server, which makes it complex. CustomSkinLoader is designed for loading from any server, which makes the mod complex.
It's not a good idea to refer to CustomSkinLoader's source code to develop your own skin mod. It's not a good idea to refer to CustomSkinLoader's source code to develop your own skin mod.
It's recommended to use CustomSkinLoader for your server directly. It's recommended to use CustomSkinLoader for your server directly.
Furthermore, you can add your server to 'Default Load List'. Furthermore, you can add your server to 'Default Load List'.
You also can use 'ExtraList' which makes it easier for user to adds your server into load list. You can also use 'ExtraList' which makes it easier for users to add your server into load list.
## Copyright & LICENSE ## Copyright & LICENSE
### Binary File ### Binary File
@@ -71,15 +75,17 @@ You could not repost this mod to any website without permission.
You could not earn money with this mod excluding modpack. You could not earn money with this mod excluding modpack.
### Source Code ### Source Code
#### Package 'customskinloader' #### Package 'customskinloader'
Including some code from Including some codes from
- [AsteriskTeam/TabIconHackForge](http://git.oschina.net/AsteriskTeam/TabIconHackForge) (GPLv3) - [AsteriskTeam/TabIconHackForge](http://git.oschina.net/AsteriskTeam/TabIconHackForge) (GPLv3)
- [RecursiveG/UniSkinMod](https://github.com/RecursiveG/UniSkinMod) (GPLv3) - [RecursiveG/UniSkinMod](https://github.com/RecursiveG/UniSkinMod) (GPLv3)
- [NekoCaffeine/Alchemy](https://github.com/NekoCaffeine/Alchemy) (GPLv3)
Copyright(C) 2013-2017 JLChnToZ xfl03 Copyright(C) 2013-2018 JLChnToZ xfl03
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
GPLv3: http://www.gnu.org/licenses/gpl.html GPLv3: http://www.gnu.org/licenses/gpl.html
You should change the name of package to avoid others' misunderstanding.
You should change the name of the package to avoid others' misunderstanding.
@@ -0,0 +1,124 @@
package customskinloader.tweaker;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import customskinloader.utils.JavaUtil;
import org.apache.commons.io.IOUtils;
import customskinloader.utils.MinecraftUtil;
import net.minecraft.launchwrapper.IClassTransformer;
public class ClassTransformer implements IClassTransformer {
private ZipFile zipFile = null;
private ArrayList<String> classes=new ArrayList<String>();
public ClassTransformer() {
ModSystemTweaker.logger.info("ClassTransformer Begin");
try {
URL urls[] = JavaUtil.getClasspath();
for (URL url : urls) {
if(MinecraftUtil.isCoreFile(url)){
ModSystemTweaker.logger.debug(url.toString()+" : SKIP (core file).");
continue;
}
if(MinecraftUtil.isLibraryFile(url)){
ModSystemTweaker.logger.debug(url.toString()+" : SKIP (library file).");
continue;
}
File file = new File(url.toURI());
if(!file.isFile()){
ModSystemTweaker.logger.info(url.toString()+" : EXCEPTION (file not found).");
continue;
}
ZipFile tempZipFile = getZipFile(file);
if(tempZipFile==null){
ModSystemTweaker.logger.info(url.toString()+" : EXCEPTION (^ Message ^).");
continue;
}
if (tempZipFile.getEntry("customskinloader/tweaker/ClassTransformer.class") == null){
tempZipFile.close();
ModSystemTweaker.logger.debug(url.toString()+" : FINISH (not target).");
continue;
}
zipFile = tempZipFile;
Enumeration<ZipEntry> entries=(Enumeration<ZipEntry>) zipFile.entries();
StringBuilder sb=new StringBuilder();
while(entries.hasMoreElements()){
ZipEntry entry=entries.nextElement();
String name=entry.getName();
if(name.endsWith(".class")&&(!name.contains("/")||name.startsWith("net"))){
classes.add(name);
sb.append(" ");
sb.append(name);
}
}
ModSystemTweaker.logger.info(url.toString()+" : CHOOSE.");
ModSystemTweaker.logger.info("Classes:" + sb.toString());
break;
}
} catch (Exception e) {
ModSystemTweaker.logger.warning(e);
}
if (zipFile == null) {
ModSystemTweaker.logger.info("Can not find JAR in the classpath.");
}
}
private static ZipFile getZipFile(File file)
{
ZipFile zipFile0;
try {
zipFile0 = new ZipFile(file);
return zipFile0;
} catch (Exception e) {
ModSystemTweaker.logger.warning(e);
}
return null;
}
public byte[] transform(String name, String transformedName, byte bytes[]) {
if (zipFile == null)
return bytes;
String fullName = (name.startsWith("net") ? name.replace('.', '/') : name) + ".class";//Notch(Run)/MCP(Dev) Class Name
if(!classes.contains(fullName)){//Check Name
if(name.equals(transformedName))
return bytes;
fullName = transformedName.replace('.', '/') + ".class";//MCP Class Name
if(!classes.contains(fullName))//check Again
return bytes;
}
ZipEntry ze = zipFile.getEntry(fullName);
if (ze == null)
return bytes;
byte diBytes[] = getClass(ze);
if (diBytes != null) {
ModSystemTweaker.logger.info("Class '" + name + "'("+transformedName+") transformed.");
return diBytes;
}
else
return bytes;
}
private byte[] getClass(ZipEntry ze) {
try {
InputStream is = zipFile.getInputStream(ze);
byte[] bytes = IOUtils.toByteArray(is);
if ((long)bytes.length == ze.getSize())
return bytes;
ModSystemTweaker.logger.info("Failed: " + ze.getName() + " " + bytes.length + " / " + ze.getSize());
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
}
@@ -0,0 +1,38 @@
package customskinloader.tweaker;
import customskinloader.Logger;
import java.io.File;
import java.util.List;
import net.minecraft.launchwrapper.ITweaker;
import net.minecraft.launchwrapper.LaunchClassLoader;
public class ModSystemTweaker implements ITweaker {
public static Logger logger = new Logger();
public void acceptOptions(List args, File gameDir, File assetsDir, String profile) {
File tweakerLogFile = new File(gameDir,"./CustomSkinLoader/Tweaker.log");
logger = new Logger(tweakerLogFile);
logger.info("Using ModSystemTweaker");
logger.info("ModSystemTweaker: acceptOptions");
}
public void injectIntoClassLoader(LaunchClassLoader classLoader) {
logger.info("ModSystemTweaker: injectIntoClassLoader");
classLoader.registerTransformer("customskinloader.tweaker.ClassTransformer");
logger.info("ClassTransformer Registered");
}
public String getLaunchTarget() {
logger.info("ModSystemTweaker: getLaunchTarget");
return "net.minecraft.client.main.Main";
}
public String[] getLaunchArguments() {
logger.info("ModSystemTweaker: getLaunchArguments");
return new String[0];
}
}
@@ -0,0 +1,44 @@
package customskinloader.tweaker;
import customskinloader.Logger;
import java.io.File;
import java.util.List;
import org.apache.commons.lang3.ArrayUtils;
import net.minecraft.launchwrapper.ITweaker;
import net.minecraft.launchwrapper.LaunchClassLoader;
public class Tweaker implements ITweaker {
private String[] args;
public static Logger logger = new Logger();
public void acceptOptions(List<String> args, File gameDir, File assetsDir, String profile) {
File tweakerLogFile = new File(gameDir,"./CustomSkinLoader/Tweaker.log");
logger = new Logger(tweakerLogFile);
logger.info("Using Tweaker");
logger.info("Tweaker: acceptOptions");
String[] temp={"--gameDir",gameDir.getAbsolutePath(),"--assetsDir",assetsDir.getAbsolutePath(),"--version",profile};
this.args=ArrayUtils.addAll(args.toArray(new String[args.size()]), temp);
}
public void injectIntoClassLoader(LaunchClassLoader classLoader) {
logger.info("Tweaker: injectIntoClassLoader");
logger.info("Loaded as a library.");
}
public String getLaunchTarget() {
logger.info("Tweaker: getLaunchTarget");
return "net.minecraft.client.main.Main";
}
public String[] getLaunchArguments() {
logger.info("Tweaker: getLaunchArguments");
return args;
}
}
@@ -71,7 +71,7 @@ public class SkinManager
*/ */
public ResourceLocation loadSkin(final MinecraftProfileTexture profileTexture, final Type textureType, @Nullable final SkinManager.SkinAvailableCallback skinAvailableCallback) public ResourceLocation loadSkin(final MinecraftProfileTexture profileTexture, final Type textureType, @Nullable final SkinManager.SkinAvailableCallback skinAvailableCallback)
{ {
return this.fakeManager.loadSkin(profileTexture, textureType, skinAvailableCallback); return this.fakeManager.loadSkin(profileTexture, textureType, skinAvailableCallback);
} }
public void loadProfileTextures(final GameProfile profile, final SkinManager.SkinAvailableCallback skinAvailableCallback, final boolean requireSecure) public void loadProfileTextures(final GameProfile profile, final SkinManager.SkinAvailableCallback skinAvailableCallback, final boolean requireSecure)
+13 -13
View File
@@ -2,28 +2,18 @@ apply plugin: 'base'
ext.configFile = file "build.properties" ext.configFile = file "build.properties"
configFile.withReader { configFile.withReader {
// read config. it shall from now on be referenced as simply config or as project.config
def prop = new Properties() def prop = new Properties()
prop.load(it) prop.load(it)
project.ext.config = new ConfigSlurper().parse prop project.ext.config = new ConfigSlurper().parse prop
} }
buildscript { buildscript {
repositories { repositories {
/* mavenCentral()
maven { jcenter()
name = "fmm"
url = "http://forgemavenmirror.sinaapp.com/maven"
}
*/
jcenter()
maven { maven {
name = "forge" name = "forge"
url = "http://files.minecraftforge.net/maven" url = "http://files.minecraftforge.net/maven"
} }
maven {
name = "sonatype"
url = "https://oss.sonatype.org/content/repositories/snapshots/"
}
} }
dependencies { dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT' classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
@@ -31,6 +21,16 @@ buildscript {
} }
subprojects { subprojects {
if(!project.name.toLowerCase().contains("forge")) if (!project.name.toLowerCase().contains("forge"))
apply from: rootProject.file('common.gradle') apply from: rootProject.file('common.gradle')
} }
apply from: rootProject.file('BuildScripts/cos.gradle')
apply from: rootProject.file('BuildScripts/version.gradle')
task upload {
onlyIf { System.getenv("COS_SECRET_KEY") != null }
doLast {
uploadArtifacts(getShortVersion())
}
}
+2 -2
View File
@@ -1,6 +1,6 @@
name=CustomSkinLoader name=CustomSkinLoader
group=customskinloader group=customskinloader
version=14.7 version=14.10
dev_version= dev_version=a
#RELEASE: snapshot=0 #RELEASE: snapshot=0
snapshot=0 snapshot=0
+72 -91
View File
@@ -1,20 +1,11 @@
buildscript { buildscript {
repositories { repositories {
/* mavenCentral()
maven {
name = "fmm"
url = "http://forgemavenmirror.sinaapp.com/maven"
}
*/
jcenter() jcenter()
maven { maven {
name = "forge" name = "forge"
url = "http://files.minecraftforge.net/maven" url = "http://files.minecraftforge.net/maven"
} }
maven {
name = "sonatype"
url = "https://oss.sonatype.org/content/repositories/snapshots/"
}
} }
dependencies { dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT' classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
@@ -24,18 +15,24 @@ apply plugin: 'net.minecraftforge.gradle.forge'
ext.configFile = file "build.properties" ext.configFile = file "build.properties"
configFile.withReader { configFile.withReader {
// read config. it shall from now on be referenced as simply config or as project.config
def prop = new Properties() def prop = new Properties()
prop.load(it) prop.load(it)
project.ext.config = new ConfigSlurper().parse prop project.ext.config = new ConfigSlurper().parse prop
} }
//Example: 14.4a-SNAPSHOT-20160820 apply from: rootProject.file("BuildScripts/version.gradle")
version = rootProject.ext.config.version + rootProject.ext.config.dev_version + ((rootProject.ext.config.snapshot==""||rootProject.ext.config.snapshot=="0"||rootProject.ext.config.snapshot==0)?'':('-SNAPSHOT-'+System.getenv("BUILD_NUMBER")))
version = getCSLVersion()
group = config.group group = config.group
archivesBaseName = rootProject.ext.config.name+"_"+config.minecraft_version archivesBaseName = rootProject.ext.config.name + "_" + config.minecraft_version
ext.shortVersion = getShortVersion()
sourceCompatibility = targetCompatibility = 1.6
compileJava {
sourceCompatibility = targetCompatibility = 1.6
}
minecraft { minecraft {
version = config.forge_mc_version+"-"+config.forge_version version = config.forge_mc_version + "-" + config.forge_version
runDir = "run" runDir = "run"
mappings = config.mappings_version mappings = config.mappings_version
@@ -46,97 +43,81 @@ minecraft {
jar { jar {
manifest { manifest {
attributes 'TweakClass' : 'customskinloader.tweaker.ModSystemTweaker' attributes 'TweakClass' : 'customskinloader.tweaker.ModSystemTweaker'
attributes 'TweakName' : rootProject.ext.config.name attributes 'TweakName' : rootProject.ext.config.name
attributes 'TweakAuthor' : 'xfl03,JLChnToZ' attributes 'TweakAuthor' : 'xfl03,JLChnToZ'
attributes 'TweakVersion' : version attributes 'TweakVersion': version
attributes 'TweakOrder' : '-10' attributes 'TweakOrder' : '-10'
} }
exclude 'net/minecraft/client/renderer/texture/NativeImage.class'
} }
task copySource << { sourceSets {
def outputFile = file("src/main/java") main {
outputFile.deleteDir() java {
copy { //Common
from '../Common/source' srcDir '../Common/source'
from 'src/minecraft/' //Vanilla
into 'src/main/java' srcDir '../Vanilla'
}
resources {
//Common
srcDir '../Common/resource'
}
} }
} }
sourceMainJava.dependsOn copySource
processResources { processResources {
expand ([ expand([
modVersion:rootProject.ext.config.version, modVersion : rootProject.ext.config.version,
modFullVersion:project.version, modFullVersion : project.version,
mcVersion:config.minecraft_version, modShortFullVersion: shortVersion,
mcFullVersions:config.minecraft_full_versions, mcVersion : config.minecraft_version,
forgeVersion:config.forge_version, mcFullVersions : config.minecraft_full_versions,
gitVersion:System.getenv("GIT_COMMIT"), forgeVersion : config.forge_version,
buildUrl:System.getenv("BUILD_URL") gitVersion : System.getenv("CIRCLE_SHA1"),
buildUrl : System.getenv("CIRCLE_BUILD_URL")
]) ])
} }
task copyResources << { task copyResources {
def outputFile = file("src/main/resources") doLast {
outputFile.deleteDir() def outputFile = file("src/main/resources")
copy { outputFile.deleteDir()
from '../Common/resource' copy {
into 'src/main/resources' from '../Common/resource'
into 'src/main/resources'
}
} }
} }
processResources.dependsOn copyResources processResources.dependsOn copyResources
task afterBuild << { apply from: rootProject.file("BuildScripts/remap.gradle")
//renameSrgJar task afterBuild {
def file0 = file("build/libs/${archivesBaseName}-${version}.jar") doLast {
def file1 = file("build/libs/${archivesBaseName}-${version}-srg.jar") //renameSrgJar
file0.renameTo(file1) def file0 = file("build/libs/${archivesBaseName}-${version}.jar")
def file1 = file("build/libs/${archivesBaseName}-${version}-srg.jar")
file0.renameTo(file1)
//reobfSrgToNotch //reobfSrgToNotch
reobfSrgToNotch() reobfSrgToNotch()
//copyBuildFile //copyBuildFile
copy { copy {
from 'build/libs' from 'build/libs'
into '../build/libs' into '../build/libs'
include '**/*.jar' include '**/*.jar'
exclude '**/*-srg.jar' exclude '**/*-srg.jar'
exclude '**/*-dev.jar' exclude '**/*-dev.jar'
exclude '**/*-sources.jar' exclude '**/*-sources.jar'
}
//copyProfileJson
File f = project.file("build/resources/main/Profile.json")
String of = String.format("build/libs/%s-CSL-%s.json", config.minecraft_version, shortVersion)
File off = rootProject.file(of)
off.parentFile.mkdirs()
f.renameTo(off)
} }
} }
build.finalizedBy afterBuild build.finalizedBy afterBuild
//notch pack
void reobfSrgToNotch(){
def srgName = "${archivesBaseName}-${version}-srg.jar"
def notchName = srgName.replace('-srg', '')
if(config.srg_notch_map==null||!(config.srg_notch_map instanceof String)||config.srg_notch_map==""){
//Default Map
def mcpName = srgName.replace('-srg', '-dev')
applySpecialSource(srgName,mcpName,getDefaultMap("srg-mcp"))
applySpecialSource(mcpName,notchName,getDefaultMap("mcp-notch"))
}else{
//Custom Map
applySpecialSource(srgName,notchName,config.srg_notch_map)
}
}
void applySpecialSource(String inputName,String outputName,String mapFile){
def mapping = new net.md_5.specialsource.JarMapping()
def srgFile = file(mapFile)
def inputFile = file("build/libs/${inputName}")
def outputFile = file("build/libs/${outputName}")
def remapper = new net.md_5.specialsource.JarRemapper(null, mapping)
def inputJar = net.md_5.specialsource.Jar.init(inputFile)
def inheritanceProviders = new net.md_5.specialsource.provider.JointProvider()
def jarProvider = new net.md_5.specialsource.provider.JarProvider(inputJar)
inheritanceProviders.add(jarProvider)
mapping.loadMappings(srgFile)
mapping.setFallbackInheritanceProvider(inheritanceProviders)
remapper.remapJar(inputJar, outputFile)
}
String getDefaultMap(String srgType){
def mcpVersion = minecraft.mappings.replace('_',"/")
return System.getProperty('user.home') + "/.gradle/caches/minecraft/de/oceanlabs/mcp/mcp_${mcpVersion}/${config.forge_mc_version}/srgs/${srgType}.srg"
}
+3 -3
View File
@@ -1,5 +1,5 @@
include "1.12-mcp940" //Special Vanilla Edition
include "1.12.1-test" include "1.13.2"
//Universial Forge Version for [1.8,) //Universal Forge Edition for [1.8,)
include "Forge" include "Forge"