mirror of
https://github.com/xfl03/MCCustomSkinLoader.git
synced 2026-11-25 04:04:25 +00:00
Compare commits
18
Commits
14.8
..
GUI-archive
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
546caf028a | ||
|
|
d27b24fbde | ||
|
|
3600a7c5bf | ||
|
|
504a598428 | ||
|
|
e6f7618071 | ||
|
|
20a2dda540 | ||
|
|
57725f2c7a | ||
|
|
dc057ae7af | ||
|
|
c2e4235227 | ||
|
|
d99e82224b | ||
|
|
bf69fb5d42 | ||
|
|
a7a89bb621 | ||
|
|
583c610c8d | ||
|
|
ff7fa75cfa | ||
|
|
0c9bb21145 | ||
|
|
72d381cb4f | ||
|
|
b5bce5c4be | ||
|
|
b9138676ca |
No files matched your search
@@ -1,36 +0,0 @@
|
|||||||
# Java Gradle CircleCI 2.0 configuration file
|
|
||||||
version: 2
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
docker:
|
|
||||||
- image: circleci/openjdk:8-jdk
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
- store_artifacts:
|
|
||||||
path: ./build/libs
|
|
||||||
|
|
||||||
- save_cache:
|
|
||||||
paths:
|
|
||||||
- ~/.gradle
|
|
||||||
key: gradle-cache
|
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<classpath>
|
||||||
|
<classpathentry kind="src" path="src"/>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
|
||||||
|
<classpathentry kind="output" path="bin"/>
|
||||||
|
</classpath>
|
||||||
-15
@@ -4,23 +4,8 @@
|
|||||||
.mtj.tmp/
|
.mtj.tmp/
|
||||||
|
|
||||||
# Package Files #
|
# Package Files #
|
||||||
*.jar
|
|
||||||
*.war
|
*.war
|
||||||
*.ear
|
*.ear
|
||||||
|
|
||||||
# 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/
|
|
||||||
|
|
||||||
#eclipse
|
|
||||||
*/.classpath
|
|
||||||
.classpath
|
|
||||||
*/.project
|
|
||||||
.project
|
|
||||||
.settings/
|
|
||||||
|
|
||||||
#gradle
|
|
||||||
.gradle/
|
|
||||||
build/
|
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>CustomSkinLoaderGUI</name>
|
||||||
|
<comment></comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
|
</natures>
|
||||||
|
</projectDescription>
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
eclipse.preferences.version=1
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||||
|
org.eclipse.jdt.core.compiler.compliance=1.7
|
||||||
|
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||||
|
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||||
|
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||||
|
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||||
|
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||||
|
org.eclipse.jdt.core.compiler.source=1.7
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
/build/
|
|
||||||
/src/main/
|
|
||||||
|
|
||||||
@@ -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_20180203
|
|
||||||
@@ -1,402 +0,0 @@
|
|||||||
package net.minecraft.client.gui;
|
|
||||||
|
|
||||||
import com.google.common.collect.ComparisonChain;
|
|
||||||
import com.google.common.collect.Ordering;
|
|
||||||
import com.mojang.authlib.GameProfile;
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.List;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.network.NetHandlerPlayClient;
|
|
||||||
import net.minecraft.client.network.NetworkPlayerInfo;
|
|
||||||
import net.minecraft.client.renderer.GlStateManager;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.entity.player.EnumPlayerModelParts;
|
|
||||||
import net.minecraft.scoreboard.IScoreCriteria;
|
|
||||||
import net.minecraft.scoreboard.ScoreObjective;
|
|
||||||
import net.minecraft.scoreboard.ScorePlayerTeam;
|
|
||||||
import net.minecraft.scoreboard.Scoreboard;
|
|
||||||
import net.minecraft.util.math.MathHelper;
|
|
||||||
import net.minecraft.util.text.ITextComponent;
|
|
||||||
import net.minecraft.util.text.TextFormatting;
|
|
||||||
import net.minecraft.world.GameType;
|
|
||||||
import net.minecraftforge.fml.relauncher.Side;
|
|
||||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public class GuiPlayerTabOverlay extends Gui
|
|
||||||
{
|
|
||||||
private static final Ordering<NetworkPlayerInfo> ENTRY_ORDERING = Ordering.from(new GuiPlayerTabOverlay.PlayerComparator());
|
|
||||||
private final Minecraft mc;
|
|
||||||
private final GuiIngame guiIngame;
|
|
||||||
private ITextComponent footer;
|
|
||||||
private ITextComponent header;
|
|
||||||
/** The last time the playerlist was opened (went from not being renderd, to being rendered) */
|
|
||||||
private long lastTimeOpened;
|
|
||||||
/** Weither or not the playerlist is currently being rendered */
|
|
||||||
private boolean isBeingRendered;
|
|
||||||
|
|
||||||
public GuiPlayerTabOverlay(Minecraft mcIn, GuiIngame guiIngameIn)
|
|
||||||
{
|
|
||||||
this.mc = mcIn;
|
|
||||||
this.guiIngame = guiIngameIn;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the name that should be renderd for the player supplied
|
|
||||||
*/
|
|
||||||
public String getPlayerName(NetworkPlayerInfo networkPlayerInfoIn)
|
|
||||||
{
|
|
||||||
return networkPlayerInfoIn.getDisplayName() != null ? networkPlayerInfoIn.getDisplayName().getFormattedText() : ScorePlayerTeam.formatPlayerName(networkPlayerInfoIn.getPlayerTeam(), networkPlayerInfoIn.getGameProfile().getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called by GuiIngame to update the information stored in the playerlist, does not actually render the list,
|
|
||||||
* however.
|
|
||||||
*/
|
|
||||||
public void updatePlayerList(boolean willBeRendered)
|
|
||||||
{
|
|
||||||
if (willBeRendered && !this.isBeingRendered)
|
|
||||||
{
|
|
||||||
this.lastTimeOpened = Minecraft.getSystemTime();
|
|
||||||
}
|
|
||||||
|
|
||||||
this.isBeingRendered = willBeRendered;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Renders the playerlist, its background, headers and footers.
|
|
||||||
*/
|
|
||||||
public void renderPlayerlist(int width, Scoreboard scoreboardIn, @Nullable ScoreObjective scoreObjectiveIn)
|
|
||||||
{
|
|
||||||
NetHandlerPlayClient nethandlerplayclient = this.mc.player.connection;
|
|
||||||
List<NetworkPlayerInfo> list = ENTRY_ORDERING.<NetworkPlayerInfo>sortedCopy(nethandlerplayclient.getPlayerInfoMap());
|
|
||||||
int i = 0;
|
|
||||||
int j = 0;
|
|
||||||
|
|
||||||
for (NetworkPlayerInfo networkplayerinfo : list)
|
|
||||||
{
|
|
||||||
int k = this.mc.fontRenderer.getStringWidth(this.getPlayerName(networkplayerinfo));
|
|
||||||
i = Math.max(i, k);
|
|
||||||
|
|
||||||
if (scoreObjectiveIn != null && scoreObjectiveIn.getRenderType() != IScoreCriteria.EnumRenderType.HEARTS)
|
|
||||||
{
|
|
||||||
k = this.mc.fontRenderer.getStringWidth(" " + scoreboardIn.getOrCreateScore(networkplayerinfo.getGameProfile().getName(), scoreObjectiveIn).getScorePoints());
|
|
||||||
j = Math.max(j, k);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
list = list.subList(0, Math.min(list.size(), 80));
|
|
||||||
int l3 = list.size();
|
|
||||||
int i4 = l3;
|
|
||||||
int j4;
|
|
||||||
|
|
||||||
for (j4 = 1; i4 > 20; i4 = (l3 + j4 - 1) / j4)
|
|
||||||
{
|
|
||||||
++j4;
|
|
||||||
}
|
|
||||||
|
|
||||||
//boolean flag = this.mc.isIntegratedServerRunning() || this.mc.getConnection().getNetworkManager().isEncrypted();
|
|
||||||
boolean flag = true;//Modified
|
|
||||||
int l;
|
|
||||||
|
|
||||||
if (scoreObjectiveIn != null)
|
|
||||||
{
|
|
||||||
if (scoreObjectiveIn.getRenderType() == IScoreCriteria.EnumRenderType.HEARTS)
|
|
||||||
{
|
|
||||||
l = 90;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
l = j;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
l = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int i1 = Math.min(j4 * ((flag ? 9 : 0) + i + l + 13), width - 50) / j4;
|
|
||||||
int j1 = width / 2 - (i1 * j4 + (j4 - 1) * 5) / 2;
|
|
||||||
int k1 = 10;
|
|
||||||
int l1 = i1 * j4 + (j4 - 1) * 5;
|
|
||||||
List<String> list1 = null;
|
|
||||||
|
|
||||||
if (this.header != null)
|
|
||||||
{
|
|
||||||
list1 = this.mc.fontRenderer.listFormattedStringToWidth(this.header.getFormattedText(), width - 50);
|
|
||||||
|
|
||||||
for (String s : list1)
|
|
||||||
{
|
|
||||||
l1 = Math.max(l1, this.mc.fontRenderer.getStringWidth(s));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
List<String> list2 = null;
|
|
||||||
|
|
||||||
if (this.footer != null)
|
|
||||||
{
|
|
||||||
list2 = this.mc.fontRenderer.listFormattedStringToWidth(this.footer.getFormattedText(), width - 50);
|
|
||||||
|
|
||||||
for (String s1 : list2)
|
|
||||||
{
|
|
||||||
l1 = Math.max(l1, this.mc.fontRenderer.getStringWidth(s1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (list1 != null)
|
|
||||||
{
|
|
||||||
drawRect(width / 2 - l1 / 2 - 1, k1 - 1, width / 2 + l1 / 2 + 1, k1 + list1.size() * this.mc.fontRenderer.FONT_HEIGHT, Integer.MIN_VALUE);
|
|
||||||
|
|
||||||
for (String s2 : list1)
|
|
||||||
{
|
|
||||||
int i2 = this.mc.fontRenderer.getStringWidth(s2);
|
|
||||||
this.mc.fontRenderer.drawStringWithShadow(s2, (float)(width / 2 - i2 / 2), (float)k1, -1);
|
|
||||||
k1 += this.mc.fontRenderer.FONT_HEIGHT;
|
|
||||||
}
|
|
||||||
|
|
||||||
++k1;
|
|
||||||
}
|
|
||||||
|
|
||||||
drawRect(width / 2 - l1 / 2 - 1, k1 - 1, width / 2 + l1 / 2 + 1, k1 + i4 * 9, Integer.MIN_VALUE);
|
|
||||||
|
|
||||||
for (int k4 = 0; k4 < l3; ++k4)
|
|
||||||
{
|
|
||||||
int l4 = k4 / i4;
|
|
||||||
int i5 = k4 % i4;
|
|
||||||
int j2 = j1 + l4 * i1 + l4 * 5;
|
|
||||||
int k2 = k1 + i5 * 9;
|
|
||||||
drawRect(j2, k2, j2 + i1, k2 + 8, 553648127);
|
|
||||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
|
||||||
GlStateManager.enableAlpha();
|
|
||||||
GlStateManager.enableBlend();
|
|
||||||
GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
|
|
||||||
|
|
||||||
if (k4 < list.size())
|
|
||||||
{
|
|
||||||
NetworkPlayerInfo networkplayerinfo1 = list.get(k4);
|
|
||||||
GameProfile gameprofile = networkplayerinfo1.getGameProfile();
|
|
||||||
|
|
||||||
if (flag)
|
|
||||||
{
|
|
||||||
EntityPlayer entityplayer = ((net.minecraft.world.World)this.mc.world).getPlayerEntityByUUID(gameprofile.getId());//Modified
|
|
||||||
boolean flag1 = entityplayer != null && entityplayer.isWearing(EnumPlayerModelParts.CAPE) && ("Dinnerbone".equals(gameprofile.getName()) || "Grumm".equals(gameprofile.getName()));
|
|
||||||
this.mc.getTextureManager().bindTexture(networkplayerinfo1.getLocationSkin());
|
|
||||||
int l2 = 8 + (flag1 ? 8 : 0);
|
|
||||||
int i3 = 8 * (flag1 ? -1 : 1);
|
|
||||||
Gui.drawScaledCustomSizeModalRect(j2, k2, 8.0F, (float)l2, 8, i3, 8, 8, 64.0F, 64.0F);
|
|
||||||
|
|
||||||
if (entityplayer != null && entityplayer.isWearing(EnumPlayerModelParts.HAT))
|
|
||||||
{
|
|
||||||
int j3 = 8 + (flag1 ? 8 : 0);
|
|
||||||
int k3 = 8 * (flag1 ? -1 : 1);
|
|
||||||
Gui.drawScaledCustomSizeModalRect(j2, k2, 40.0F, (float)j3, 8, k3, 8, 8, 64.0F, 64.0F);
|
|
||||||
}
|
|
||||||
|
|
||||||
j2 += 9;
|
|
||||||
}
|
|
||||||
|
|
||||||
String s4 = this.getPlayerName(networkplayerinfo1);
|
|
||||||
|
|
||||||
if (networkplayerinfo1.getGameType() == GameType.SPECTATOR)
|
|
||||||
{
|
|
||||||
this.mc.fontRenderer.drawStringWithShadow(TextFormatting.ITALIC + s4, (float)j2, (float)k2, -1862270977);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.mc.fontRenderer.drawStringWithShadow(s4, (float)j2, (float)k2, -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (scoreObjectiveIn != null && networkplayerinfo1.getGameType() != GameType.SPECTATOR)
|
|
||||||
{
|
|
||||||
int k5 = j2 + i + 1;
|
|
||||||
int l5 = k5 + l;
|
|
||||||
|
|
||||||
if (l5 - k5 > 5)
|
|
||||||
{
|
|
||||||
this.drawScoreboardValues(scoreObjectiveIn, k2, gameprofile.getName(), k5, l5, networkplayerinfo1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.drawPing(i1, j2 - (flag ? 9 : 0), k2, networkplayerinfo1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (list2 != null)
|
|
||||||
{
|
|
||||||
k1 = k1 + i4 * 9 + 1;
|
|
||||||
drawRect(width / 2 - l1 / 2 - 1, k1 - 1, width / 2 + l1 / 2 + 1, k1 + list2.size() * this.mc.fontRenderer.FONT_HEIGHT, Integer.MIN_VALUE);
|
|
||||||
|
|
||||||
for (String s3 : list2)
|
|
||||||
{
|
|
||||||
int j5 = this.mc.fontRenderer.getStringWidth(s3);
|
|
||||||
this.mc.fontRenderer.drawStringWithShadow(s3, (float)(width / 2 - j5 / 2), (float)k1, -1);
|
|
||||||
k1 += this.mc.fontRenderer.FONT_HEIGHT;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void drawPing(int p_175245_1_, int p_175245_2_, int p_175245_3_, NetworkPlayerInfo networkPlayerInfoIn)
|
|
||||||
{
|
|
||||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
|
||||||
this.mc.getTextureManager().bindTexture(ICONS);
|
|
||||||
int i = 0;
|
|
||||||
int j;
|
|
||||||
|
|
||||||
if (networkPlayerInfoIn.getResponseTime() < 0)
|
|
||||||
{
|
|
||||||
j = 5;
|
|
||||||
}
|
|
||||||
else if (networkPlayerInfoIn.getResponseTime() < 150)
|
|
||||||
{
|
|
||||||
j = 0;
|
|
||||||
}
|
|
||||||
else if (networkPlayerInfoIn.getResponseTime() < 300)
|
|
||||||
{
|
|
||||||
j = 1;
|
|
||||||
}
|
|
||||||
else if (networkPlayerInfoIn.getResponseTime() < 600)
|
|
||||||
{
|
|
||||||
j = 2;
|
|
||||||
}
|
|
||||||
else if (networkPlayerInfoIn.getResponseTime() < 1000)
|
|
||||||
{
|
|
||||||
j = 3;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
j = 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.zLevel += 100.0F;
|
|
||||||
this.drawTexturedModalRect(p_175245_2_ + p_175245_1_ - 11, p_175245_3_, 0, 176 + j * 8, 10, 8);
|
|
||||||
this.zLevel -= 100.0F;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void drawScoreboardValues(ScoreObjective objective, int p_175247_2_, String name, int p_175247_4_, int p_175247_5_, NetworkPlayerInfo info)
|
|
||||||
{
|
|
||||||
int i = objective.getScoreboard().getOrCreateScore(name, objective).getScorePoints();
|
|
||||||
|
|
||||||
if (objective.getRenderType() == IScoreCriteria.EnumRenderType.HEARTS)
|
|
||||||
{
|
|
||||||
this.mc.getTextureManager().bindTexture(ICONS);
|
|
||||||
|
|
||||||
if (this.lastTimeOpened == info.getRenderVisibilityId())
|
|
||||||
{
|
|
||||||
if (i < info.getLastHealth())
|
|
||||||
{
|
|
||||||
info.setLastHealthTime(Minecraft.getSystemTime());
|
|
||||||
info.setHealthBlinkTime((long)(this.guiIngame.getUpdateCounter() + 20));
|
|
||||||
}
|
|
||||||
else if (i > info.getLastHealth())
|
|
||||||
{
|
|
||||||
info.setLastHealthTime(Minecraft.getSystemTime());
|
|
||||||
info.setHealthBlinkTime((long)(this.guiIngame.getUpdateCounter() + 10));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Minecraft.getSystemTime() - info.getLastHealthTime() > 1000L || this.lastTimeOpened != info.getRenderVisibilityId())
|
|
||||||
{
|
|
||||||
info.setLastHealth(i);
|
|
||||||
info.setDisplayHealth(i);
|
|
||||||
info.setLastHealthTime(Minecraft.getSystemTime());
|
|
||||||
}
|
|
||||||
|
|
||||||
info.setRenderVisibilityId(this.lastTimeOpened);
|
|
||||||
info.setLastHealth(i);
|
|
||||||
int j = MathHelper.ceil((float)Math.max(i, info.getDisplayHealth()) / 2.0F);
|
|
||||||
int k = Math.max(MathHelper.ceil((float)(i / 2)), Math.max(MathHelper.ceil((float)(info.getDisplayHealth() / 2)), 10));
|
|
||||||
boolean flag = info.getHealthBlinkTime() > (long)this.guiIngame.getUpdateCounter() && (info.getHealthBlinkTime() - (long)this.guiIngame.getUpdateCounter()) / 3L % 2L == 1L;
|
|
||||||
|
|
||||||
if (j > 0)
|
|
||||||
{
|
|
||||||
float f = Math.min((float)(p_175247_5_ - p_175247_4_ - 4) / (float)k, 9.0F);
|
|
||||||
|
|
||||||
if (f > 3.0F)
|
|
||||||
{
|
|
||||||
for (int l = j; l < k; ++l)
|
|
||||||
{
|
|
||||||
this.drawTexturedModalRect((float)p_175247_4_ + (float)l * f, (float)p_175247_2_, flag ? 25 : 16, 0, 9, 9);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int j1 = 0; j1 < j; ++j1)
|
|
||||||
{
|
|
||||||
this.drawTexturedModalRect((float)p_175247_4_ + (float)j1 * f, (float)p_175247_2_, flag ? 25 : 16, 0, 9, 9);
|
|
||||||
|
|
||||||
if (flag)
|
|
||||||
{
|
|
||||||
if (j1 * 2 + 1 < info.getDisplayHealth())
|
|
||||||
{
|
|
||||||
this.drawTexturedModalRect((float)p_175247_4_ + (float)j1 * f, (float)p_175247_2_, 70, 0, 9, 9);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (j1 * 2 + 1 == info.getDisplayHealth())
|
|
||||||
{
|
|
||||||
this.drawTexturedModalRect((float)p_175247_4_ + (float)j1 * f, (float)p_175247_2_, 79, 0, 9, 9);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (j1 * 2 + 1 < i)
|
|
||||||
{
|
|
||||||
this.drawTexturedModalRect((float)p_175247_4_ + (float)j1 * f, (float)p_175247_2_, j1 >= 10 ? 160 : 52, 0, 9, 9);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (j1 * 2 + 1 == i)
|
|
||||||
{
|
|
||||||
this.drawTexturedModalRect((float)p_175247_4_ + (float)j1 * f, (float)p_175247_2_, j1 >= 10 ? 169 : 61, 0, 9, 9);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
float f1 = MathHelper.clamp((float)i / 20.0F, 0.0F, 1.0F);
|
|
||||||
int i1 = (int)((1.0F - f1) * 255.0F) << 16 | (int)(f1 * 255.0F) << 8;
|
|
||||||
String s = "" + (float)i / 2.0F;
|
|
||||||
|
|
||||||
if (p_175247_5_ - this.mc.fontRenderer.getStringWidth(s + "hp") >= p_175247_4_)
|
|
||||||
{
|
|
||||||
s = s + "hp";
|
|
||||||
}
|
|
||||||
|
|
||||||
this.mc.fontRenderer.drawStringWithShadow(s, (float)((p_175247_5_ + p_175247_4_) / 2 - this.mc.fontRenderer.getStringWidth(s) / 2), (float)p_175247_2_, i1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
String s1 = TextFormatting.YELLOW + "" + i;
|
|
||||||
this.mc.fontRenderer.drawStringWithShadow(s1, (float)(p_175247_5_ - this.mc.fontRenderer.getStringWidth(s1)), (float)p_175247_2_, 16777215);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFooter(@Nullable ITextComponent footerIn)
|
|
||||||
{
|
|
||||||
this.footer = footerIn;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setHeader(@Nullable ITextComponent headerIn)
|
|
||||||
{
|
|
||||||
this.header = headerIn;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void resetFooterHeader()
|
|
||||||
{
|
|
||||||
this.header = null;
|
|
||||||
this.footer = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
static class PlayerComparator implements Comparator<NetworkPlayerInfo>
|
|
||||||
{
|
|
||||||
private PlayerComparator()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public int compare(NetworkPlayerInfo p_compare_1_, NetworkPlayerInfo p_compare_2_)
|
|
||||||
{
|
|
||||||
ScorePlayerTeam scoreplayerteam = p_compare_1_.getPlayerTeam();
|
|
||||||
ScorePlayerTeam scoreplayerteam1 = p_compare_2_.getPlayerTeam();
|
|
||||||
return ComparisonChain.start().compareTrueFirst(p_compare_1_.getGameType() != GameType.SPECTATOR, p_compare_2_.getGameType() != GameType.SPECTATOR).compare(scoreplayerteam != null ? scoreplayerteam.getName() : "", scoreplayerteam1 != null ? scoreplayerteam1.getName() : "").compare(p_compare_1_.getGameProfile().getName(), p_compare_2_.getGameProfile().getName()).result();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
package net.minecraft.client.gui.spectator;
|
|
||||||
|
|
||||||
import com.mojang.authlib.GameProfile;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.entity.AbstractClientPlayer;
|
|
||||||
import net.minecraft.client.gui.Gui;
|
|
||||||
import net.minecraft.client.renderer.GlStateManager;
|
|
||||||
import net.minecraft.network.play.client.CPacketSpectate;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
import net.minecraft.util.text.ITextComponent;
|
|
||||||
import net.minecraft.util.text.TextComponentString;
|
|
||||||
import net.minecraftforge.fml.relauncher.Side;
|
|
||||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public class PlayerMenuObject implements ISpectatorMenuObject
|
|
||||||
{
|
|
||||||
private final GameProfile profile;
|
|
||||||
private final ResourceLocation resourceLocation;
|
|
||||||
|
|
||||||
public PlayerMenuObject(GameProfile profileIn)
|
|
||||||
{
|
|
||||||
this.profile = profileIn;
|
|
||||||
/*
|
|
||||||
this.resourceLocation = AbstractClientPlayer.getLocationSkin(profileIn.getName());
|
|
||||||
AbstractClientPlayer.getDownloadImageSkin(this.resourceLocation, profileIn.getName());
|
|
||||||
*/
|
|
||||||
this.resourceLocation = customskinloader.fake.FakeClientPlayer.getLocationSkin(profileIn.getName());
|
|
||||||
customskinloader.fake.FakeClientPlayer.getDownloadImageSkin(this.resourceLocation, profileIn.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void selectItem(SpectatorMenu menu)
|
|
||||||
{
|
|
||||||
Minecraft.getMinecraft().getConnection().sendPacket(new CPacketSpectate(this.profile.getId()));
|
|
||||||
}
|
|
||||||
|
|
||||||
public ITextComponent getSpectatorName()
|
|
||||||
{
|
|
||||||
return new TextComponentString(this.profile.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void renderIcon(float brightness, int alpha)
|
|
||||||
{
|
|
||||||
Minecraft.getMinecraft().getTextureManager().bindTexture(this.resourceLocation);
|
|
||||||
GlStateManager.color(1.0F, 1.0F, 1.0F, (float)alpha / 255.0F);
|
|
||||||
Gui.drawScaledCustomSizeModalRect(2, 2, 8.0F, 8.0F, 8, 8, 12, 12, 64.0F, 64.0F);
|
|
||||||
Gui.drawScaledCustomSizeModalRect(2, 2, 40.0F, 8.0F, 8, 8, 12, 12, 64.0F, 64.0F);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isEnabled()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
/build/
|
|
||||||
/src/main/
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
minecraft_version=1.12.1
|
|
||||||
minecraft_full_versions=1.12.1,1.12.2
|
|
||||||
#forge gradle needs forge version
|
|
||||||
forge_mc_version=1.12.2
|
|
||||||
forge_version=14.23.2.2611
|
|
||||||
mappings_version=snapshot_20180210
|
|
||||||
@@ -1,402 +0,0 @@
|
|||||||
package net.minecraft.client.gui;
|
|
||||||
|
|
||||||
import com.google.common.collect.ComparisonChain;
|
|
||||||
import com.google.common.collect.Ordering;
|
|
||||||
import com.mojang.authlib.GameProfile;
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.List;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.network.NetHandlerPlayClient;
|
|
||||||
import net.minecraft.client.network.NetworkPlayerInfo;
|
|
||||||
import net.minecraft.client.renderer.GlStateManager;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.entity.player.EnumPlayerModelParts;
|
|
||||||
import net.minecraft.scoreboard.IScoreCriteria;
|
|
||||||
import net.minecraft.scoreboard.ScoreObjective;
|
|
||||||
import net.minecraft.scoreboard.ScorePlayerTeam;
|
|
||||||
import net.minecraft.scoreboard.Scoreboard;
|
|
||||||
import net.minecraft.util.math.MathHelper;
|
|
||||||
import net.minecraft.util.text.ITextComponent;
|
|
||||||
import net.minecraft.util.text.TextFormatting;
|
|
||||||
import net.minecraft.world.GameType;
|
|
||||||
import net.minecraftforge.fml.relauncher.Side;
|
|
||||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public class GuiPlayerTabOverlay extends Gui
|
|
||||||
{
|
|
||||||
private static final Ordering<NetworkPlayerInfo> ENTRY_ORDERING = Ordering.from(new GuiPlayerTabOverlay.PlayerComparator());
|
|
||||||
private final Minecraft mc;
|
|
||||||
private final GuiIngame guiIngame;
|
|
||||||
private ITextComponent footer;
|
|
||||||
private ITextComponent header;
|
|
||||||
/** The last time the playerlist was opened (went from not being renderd, to being rendered) */
|
|
||||||
private long lastTimeOpened;
|
|
||||||
/** Weither or not the playerlist is currently being rendered */
|
|
||||||
private boolean isBeingRendered;
|
|
||||||
|
|
||||||
public GuiPlayerTabOverlay(Minecraft mcIn, GuiIngame guiIngameIn)
|
|
||||||
{
|
|
||||||
this.mc = mcIn;
|
|
||||||
this.guiIngame = guiIngameIn;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the name that should be renderd for the player supplied
|
|
||||||
*/
|
|
||||||
public String getPlayerName(NetworkPlayerInfo networkPlayerInfoIn)
|
|
||||||
{
|
|
||||||
return networkPlayerInfoIn.getDisplayName() != null ? networkPlayerInfoIn.getDisplayName().getFormattedText() : ScorePlayerTeam.formatPlayerName(networkPlayerInfoIn.getPlayerTeam(), networkPlayerInfoIn.getGameProfile().getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called by GuiIngame to update the information stored in the playerlist, does not actually render the list,
|
|
||||||
* however.
|
|
||||||
*/
|
|
||||||
public void updatePlayerList(boolean willBeRendered)
|
|
||||||
{
|
|
||||||
if (willBeRendered && !this.isBeingRendered)
|
|
||||||
{
|
|
||||||
this.lastTimeOpened = Minecraft.getSystemTime();
|
|
||||||
}
|
|
||||||
|
|
||||||
this.isBeingRendered = willBeRendered;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Renders the playerlist, its background, headers and footers.
|
|
||||||
*/
|
|
||||||
public void renderPlayerlist(int width, Scoreboard scoreboardIn, @Nullable ScoreObjective scoreObjectiveIn)
|
|
||||||
{
|
|
||||||
NetHandlerPlayClient nethandlerplayclient = this.mc.player.connection;
|
|
||||||
List<NetworkPlayerInfo> list = ENTRY_ORDERING.<NetworkPlayerInfo>sortedCopy(nethandlerplayclient.getPlayerInfoMap());
|
|
||||||
int i = 0;
|
|
||||||
int j = 0;
|
|
||||||
|
|
||||||
for (NetworkPlayerInfo networkplayerinfo : list)
|
|
||||||
{
|
|
||||||
int k = this.mc.fontRenderer.getStringWidth(this.getPlayerName(networkplayerinfo));
|
|
||||||
i = Math.max(i, k);
|
|
||||||
|
|
||||||
if (scoreObjectiveIn != null && scoreObjectiveIn.getRenderType() != IScoreCriteria.EnumRenderType.HEARTS)
|
|
||||||
{
|
|
||||||
k = this.mc.fontRenderer.getStringWidth(" " + scoreboardIn.getOrCreateScore(networkplayerinfo.getGameProfile().getName(), scoreObjectiveIn).getScorePoints());
|
|
||||||
j = Math.max(j, k);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
list = list.subList(0, Math.min(list.size(), 80));
|
|
||||||
int l3 = list.size();
|
|
||||||
int i4 = l3;
|
|
||||||
int j4;
|
|
||||||
|
|
||||||
for (j4 = 1; i4 > 20; i4 = (l3 + j4 - 1) / j4)
|
|
||||||
{
|
|
||||||
++j4;
|
|
||||||
}
|
|
||||||
|
|
||||||
//boolean flag = this.mc.isIntegratedServerRunning() || this.mc.getConnection().getNetworkManager().isEncrypted();
|
|
||||||
boolean flag = true;//Modified
|
|
||||||
int l;
|
|
||||||
|
|
||||||
if (scoreObjectiveIn != null)
|
|
||||||
{
|
|
||||||
if (scoreObjectiveIn.getRenderType() == IScoreCriteria.EnumRenderType.HEARTS)
|
|
||||||
{
|
|
||||||
l = 90;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
l = j;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
l = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int i1 = Math.min(j4 * ((flag ? 9 : 0) + i + l + 13), width - 50) / j4;
|
|
||||||
int j1 = width / 2 - (i1 * j4 + (j4 - 1) * 5) / 2;
|
|
||||||
int k1 = 10;
|
|
||||||
int l1 = i1 * j4 + (j4 - 1) * 5;
|
|
||||||
List<String> list1 = null;
|
|
||||||
|
|
||||||
if (this.header != null)
|
|
||||||
{
|
|
||||||
list1 = this.mc.fontRenderer.listFormattedStringToWidth(this.header.getFormattedText(), width - 50);
|
|
||||||
|
|
||||||
for (String s : list1)
|
|
||||||
{
|
|
||||||
l1 = Math.max(l1, this.mc.fontRenderer.getStringWidth(s));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
List<String> list2 = null;
|
|
||||||
|
|
||||||
if (this.footer != null)
|
|
||||||
{
|
|
||||||
list2 = this.mc.fontRenderer.listFormattedStringToWidth(this.footer.getFormattedText(), width - 50);
|
|
||||||
|
|
||||||
for (String s1 : list2)
|
|
||||||
{
|
|
||||||
l1 = Math.max(l1, this.mc.fontRenderer.getStringWidth(s1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (list1 != null)
|
|
||||||
{
|
|
||||||
drawRect(width / 2 - l1 / 2 - 1, k1 - 1, width / 2 + l1 / 2 + 1, k1 + list1.size() * this.mc.fontRenderer.FONT_HEIGHT, Integer.MIN_VALUE);
|
|
||||||
|
|
||||||
for (String s2 : list1)
|
|
||||||
{
|
|
||||||
int i2 = this.mc.fontRenderer.getStringWidth(s2);
|
|
||||||
this.mc.fontRenderer.drawStringWithShadow(s2, (float)(width / 2 - i2 / 2), (float)k1, -1);
|
|
||||||
k1 += this.mc.fontRenderer.FONT_HEIGHT;
|
|
||||||
}
|
|
||||||
|
|
||||||
++k1;
|
|
||||||
}
|
|
||||||
|
|
||||||
drawRect(width / 2 - l1 / 2 - 1, k1 - 1, width / 2 + l1 / 2 + 1, k1 + i4 * 9, Integer.MIN_VALUE);
|
|
||||||
|
|
||||||
for (int k4 = 0; k4 < l3; ++k4)
|
|
||||||
{
|
|
||||||
int l4 = k4 / i4;
|
|
||||||
int i5 = k4 % i4;
|
|
||||||
int j2 = j1 + l4 * i1 + l4 * 5;
|
|
||||||
int k2 = k1 + i5 * 9;
|
|
||||||
drawRect(j2, k2, j2 + i1, k2 + 8, 553648127);
|
|
||||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
|
||||||
GlStateManager.enableAlpha();
|
|
||||||
GlStateManager.enableBlend();
|
|
||||||
GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
|
|
||||||
|
|
||||||
if (k4 < list.size())
|
|
||||||
{
|
|
||||||
NetworkPlayerInfo networkplayerinfo1 = list.get(k4);
|
|
||||||
GameProfile gameprofile = networkplayerinfo1.getGameProfile();
|
|
||||||
|
|
||||||
if (flag)
|
|
||||||
{
|
|
||||||
EntityPlayer entityplayer = ((net.minecraft.world.World)this.mc.world).getPlayerEntityByUUID(gameprofile.getId());//Modified
|
|
||||||
boolean flag1 = entityplayer != null && entityplayer.isWearing(EnumPlayerModelParts.CAPE) && ("Dinnerbone".equals(gameprofile.getName()) || "Grumm".equals(gameprofile.getName()));
|
|
||||||
this.mc.getTextureManager().bindTexture(networkplayerinfo1.getLocationSkin());
|
|
||||||
int l2 = 8 + (flag1 ? 8 : 0);
|
|
||||||
int i3 = 8 * (flag1 ? -1 : 1);
|
|
||||||
Gui.drawScaledCustomSizeModalRect(j2, k2, 8.0F, (float)l2, 8, i3, 8, 8, 64.0F, 64.0F);
|
|
||||||
|
|
||||||
if (entityplayer != null && entityplayer.isWearing(EnumPlayerModelParts.HAT))
|
|
||||||
{
|
|
||||||
int j3 = 8 + (flag1 ? 8 : 0);
|
|
||||||
int k3 = 8 * (flag1 ? -1 : 1);
|
|
||||||
Gui.drawScaledCustomSizeModalRect(j2, k2, 40.0F, (float)j3, 8, k3, 8, 8, 64.0F, 64.0F);
|
|
||||||
}
|
|
||||||
|
|
||||||
j2 += 9;
|
|
||||||
}
|
|
||||||
|
|
||||||
String s4 = this.getPlayerName(networkplayerinfo1);
|
|
||||||
|
|
||||||
if (networkplayerinfo1.getGameType() == GameType.SPECTATOR)
|
|
||||||
{
|
|
||||||
this.mc.fontRenderer.drawStringWithShadow(TextFormatting.ITALIC + s4, (float)j2, (float)k2, -1862270977);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.mc.fontRenderer.drawStringWithShadow(s4, (float)j2, (float)k2, -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (scoreObjectiveIn != null && networkplayerinfo1.getGameType() != GameType.SPECTATOR)
|
|
||||||
{
|
|
||||||
int k5 = j2 + i + 1;
|
|
||||||
int l5 = k5 + l;
|
|
||||||
|
|
||||||
if (l5 - k5 > 5)
|
|
||||||
{
|
|
||||||
this.drawScoreboardValues(scoreObjectiveIn, k2, gameprofile.getName(), k5, l5, networkplayerinfo1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.drawPing(i1, j2 - (flag ? 9 : 0), k2, networkplayerinfo1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (list2 != null)
|
|
||||||
{
|
|
||||||
k1 = k1 + i4 * 9 + 1;
|
|
||||||
drawRect(width / 2 - l1 / 2 - 1, k1 - 1, width / 2 + l1 / 2 + 1, k1 + list2.size() * this.mc.fontRenderer.FONT_HEIGHT, Integer.MIN_VALUE);
|
|
||||||
|
|
||||||
for (String s3 : list2)
|
|
||||||
{
|
|
||||||
int j5 = this.mc.fontRenderer.getStringWidth(s3);
|
|
||||||
this.mc.fontRenderer.drawStringWithShadow(s3, (float)(width / 2 - j5 / 2), (float)k1, -1);
|
|
||||||
k1 += this.mc.fontRenderer.FONT_HEIGHT;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void drawPing(int p_175245_1_, int p_175245_2_, int p_175245_3_, NetworkPlayerInfo networkPlayerInfoIn)
|
|
||||||
{
|
|
||||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
|
||||||
this.mc.getTextureManager().bindTexture(ICONS);
|
|
||||||
int i = 0;
|
|
||||||
int j;
|
|
||||||
|
|
||||||
if (networkPlayerInfoIn.getResponseTime() < 0)
|
|
||||||
{
|
|
||||||
j = 5;
|
|
||||||
}
|
|
||||||
else if (networkPlayerInfoIn.getResponseTime() < 150)
|
|
||||||
{
|
|
||||||
j = 0;
|
|
||||||
}
|
|
||||||
else if (networkPlayerInfoIn.getResponseTime() < 300)
|
|
||||||
{
|
|
||||||
j = 1;
|
|
||||||
}
|
|
||||||
else if (networkPlayerInfoIn.getResponseTime() < 600)
|
|
||||||
{
|
|
||||||
j = 2;
|
|
||||||
}
|
|
||||||
else if (networkPlayerInfoIn.getResponseTime() < 1000)
|
|
||||||
{
|
|
||||||
j = 3;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
j = 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.zLevel += 100.0F;
|
|
||||||
this.drawTexturedModalRect(p_175245_2_ + p_175245_1_ - 11, p_175245_3_, 0, 176 + j * 8, 10, 8);
|
|
||||||
this.zLevel -= 100.0F;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void drawScoreboardValues(ScoreObjective objective, int p_175247_2_, String name, int p_175247_4_, int p_175247_5_, NetworkPlayerInfo info)
|
|
||||||
{
|
|
||||||
int i = objective.getScoreboard().getOrCreateScore(name, objective).getScorePoints();
|
|
||||||
|
|
||||||
if (objective.getRenderType() == IScoreCriteria.EnumRenderType.HEARTS)
|
|
||||||
{
|
|
||||||
this.mc.getTextureManager().bindTexture(ICONS);
|
|
||||||
|
|
||||||
if (this.lastTimeOpened == info.getRenderVisibilityId())
|
|
||||||
{
|
|
||||||
if (i < info.getLastHealth())
|
|
||||||
{
|
|
||||||
info.setLastHealthTime(Minecraft.getSystemTime());
|
|
||||||
info.setHealthBlinkTime((long)(this.guiIngame.getUpdateCounter() + 20));
|
|
||||||
}
|
|
||||||
else if (i > info.getLastHealth())
|
|
||||||
{
|
|
||||||
info.setLastHealthTime(Minecraft.getSystemTime());
|
|
||||||
info.setHealthBlinkTime((long)(this.guiIngame.getUpdateCounter() + 10));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Minecraft.getSystemTime() - info.getLastHealthTime() > 1000L || this.lastTimeOpened != info.getRenderVisibilityId())
|
|
||||||
{
|
|
||||||
info.setLastHealth(i);
|
|
||||||
info.setDisplayHealth(i);
|
|
||||||
info.setLastHealthTime(Minecraft.getSystemTime());
|
|
||||||
}
|
|
||||||
|
|
||||||
info.setRenderVisibilityId(this.lastTimeOpened);
|
|
||||||
info.setLastHealth(i);
|
|
||||||
int j = MathHelper.ceil((float)Math.max(i, info.getDisplayHealth()) / 2.0F);
|
|
||||||
int k = Math.max(MathHelper.ceil((float)(i / 2)), Math.max(MathHelper.ceil((float)(info.getDisplayHealth() / 2)), 10));
|
|
||||||
boolean flag = info.getHealthBlinkTime() > (long)this.guiIngame.getUpdateCounter() && (info.getHealthBlinkTime() - (long)this.guiIngame.getUpdateCounter()) / 3L % 2L == 1L;
|
|
||||||
|
|
||||||
if (j > 0)
|
|
||||||
{
|
|
||||||
float f = Math.min((float)(p_175247_5_ - p_175247_4_ - 4) / (float)k, 9.0F);
|
|
||||||
|
|
||||||
if (f > 3.0F)
|
|
||||||
{
|
|
||||||
for (int l = j; l < k; ++l)
|
|
||||||
{
|
|
||||||
this.drawTexturedModalRect((float)p_175247_4_ + (float)l * f, (float)p_175247_2_, flag ? 25 : 16, 0, 9, 9);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int j1 = 0; j1 < j; ++j1)
|
|
||||||
{
|
|
||||||
this.drawTexturedModalRect((float)p_175247_4_ + (float)j1 * f, (float)p_175247_2_, flag ? 25 : 16, 0, 9, 9);
|
|
||||||
|
|
||||||
if (flag)
|
|
||||||
{
|
|
||||||
if (j1 * 2 + 1 < info.getDisplayHealth())
|
|
||||||
{
|
|
||||||
this.drawTexturedModalRect((float)p_175247_4_ + (float)j1 * f, (float)p_175247_2_, 70, 0, 9, 9);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (j1 * 2 + 1 == info.getDisplayHealth())
|
|
||||||
{
|
|
||||||
this.drawTexturedModalRect((float)p_175247_4_ + (float)j1 * f, (float)p_175247_2_, 79, 0, 9, 9);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (j1 * 2 + 1 < i)
|
|
||||||
{
|
|
||||||
this.drawTexturedModalRect((float)p_175247_4_ + (float)j1 * f, (float)p_175247_2_, j1 >= 10 ? 160 : 52, 0, 9, 9);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (j1 * 2 + 1 == i)
|
|
||||||
{
|
|
||||||
this.drawTexturedModalRect((float)p_175247_4_ + (float)j1 * f, (float)p_175247_2_, j1 >= 10 ? 169 : 61, 0, 9, 9);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
float f1 = MathHelper.clamp((float)i / 20.0F, 0.0F, 1.0F);
|
|
||||||
int i1 = (int)((1.0F - f1) * 255.0F) << 16 | (int)(f1 * 255.0F) << 8;
|
|
||||||
String s = "" + (float)i / 2.0F;
|
|
||||||
|
|
||||||
if (p_175247_5_ - this.mc.fontRenderer.getStringWidth(s + "hp") >= p_175247_4_)
|
|
||||||
{
|
|
||||||
s = s + "hp";
|
|
||||||
}
|
|
||||||
|
|
||||||
this.mc.fontRenderer.drawStringWithShadow(s, (float)((p_175247_5_ + p_175247_4_) / 2 - this.mc.fontRenderer.getStringWidth(s) / 2), (float)p_175247_2_, i1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
String s1 = TextFormatting.YELLOW + "" + i;
|
|
||||||
this.mc.fontRenderer.drawStringWithShadow(s1, (float)(p_175247_5_ - this.mc.fontRenderer.getStringWidth(s1)), (float)p_175247_2_, 16777215);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFooter(@Nullable ITextComponent footerIn)
|
|
||||||
{
|
|
||||||
this.footer = footerIn;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setHeader(@Nullable ITextComponent headerIn)
|
|
||||||
{
|
|
||||||
this.header = headerIn;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void resetFooterHeader()
|
|
||||||
{
|
|
||||||
this.header = null;
|
|
||||||
this.footer = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
static class PlayerComparator implements Comparator<NetworkPlayerInfo>
|
|
||||||
{
|
|
||||||
private PlayerComparator()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public int compare(NetworkPlayerInfo p_compare_1_, NetworkPlayerInfo p_compare_2_)
|
|
||||||
{
|
|
||||||
ScorePlayerTeam scoreplayerteam = p_compare_1_.getPlayerTeam();
|
|
||||||
ScorePlayerTeam scoreplayerteam1 = p_compare_2_.getPlayerTeam();
|
|
||||||
return ComparisonChain.start().compareTrueFirst(p_compare_1_.getGameType() != GameType.SPECTATOR, p_compare_2_.getGameType() != GameType.SPECTATOR).compare(scoreplayerteam != null ? scoreplayerteam.getName() : "", scoreplayerteam1 != null ? scoreplayerteam1.getName() : "").compare(p_compare_1_.getGameProfile().getName(), p_compare_2_.getGameProfile().getName()).result();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
package net.minecraft.client.gui.spectator;
|
|
||||||
|
|
||||||
import com.mojang.authlib.GameProfile;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.entity.AbstractClientPlayer;
|
|
||||||
import net.minecraft.client.gui.Gui;
|
|
||||||
import net.minecraft.client.renderer.GlStateManager;
|
|
||||||
import net.minecraft.network.play.client.CPacketSpectate;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
import net.minecraft.util.text.ITextComponent;
|
|
||||||
import net.minecraft.util.text.TextComponentString;
|
|
||||||
import net.minecraftforge.fml.relauncher.Side;
|
|
||||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public class PlayerMenuObject implements ISpectatorMenuObject
|
|
||||||
{
|
|
||||||
private final GameProfile profile;
|
|
||||||
private final ResourceLocation resourceLocation;
|
|
||||||
|
|
||||||
public PlayerMenuObject(GameProfile profileIn)
|
|
||||||
{
|
|
||||||
this.profile = profileIn;
|
|
||||||
/*
|
|
||||||
this.resourceLocation = AbstractClientPlayer.getLocationSkin(profileIn.getName());
|
|
||||||
AbstractClientPlayer.getDownloadImageSkin(this.resourceLocation, profileIn.getName());
|
|
||||||
*/
|
|
||||||
this.resourceLocation = customskinloader.fake.FakeClientPlayer.getLocationSkin(profileIn.getName());
|
|
||||||
customskinloader.fake.FakeClientPlayer.getDownloadImageSkin(this.resourceLocation, profileIn.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void selectItem(SpectatorMenu menu)
|
|
||||||
{
|
|
||||||
Minecraft.getMinecraft().getConnection().sendPacket(new CPacketSpectate(this.profile.getId()));
|
|
||||||
}
|
|
||||||
|
|
||||||
public ITextComponent getSpectatorName()
|
|
||||||
{
|
|
||||||
return new TextComponentString(this.profile.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void renderIcon(float brightness, int alpha)
|
|
||||||
{
|
|
||||||
Minecraft.getMinecraft().getTextureManager().bindTexture(this.resourceLocation);
|
|
||||||
GlStateManager.color(1.0F, 1.0F, 1.0F, (float)alpha / 255.0F);
|
|
||||||
Gui.drawScaledCustomSizeModalRect(2, 2, 8.0F, 8.0F, 8, 8, 12, 12, 64.0F, 64.0F);
|
|
||||||
Gui.drawScaledCustomSizeModalRect(2, 2, 40.0F, 8.0F, 8, 8, 12, 12, 64.0F, 64.0F);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isEnabled()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,91 +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;
|
|
||||||
|
|
||||||
//From 1.12-mcp940
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "CustomSkinLoader",
|
|
||||||
"version": "${modVersion}",
|
|
||||||
"fullVersion": "${modFullVersion}",
|
|
||||||
"mcVersion": "${mcVersion}",
|
|
||||||
"mcFullVersions": "${mcFullVersions}",
|
|
||||||
"forgeVersion": "${forgeVersion}",
|
|
||||||
"gitVersion": "${gitVersion}",
|
|
||||||
"buildUrl": "${buildUrl}"
|
|
||||||
}
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
English(en)
|
|
||||||
|
|
||||||
LICENSE - Binary File
|
|
||||||
You could not modify binary file.
|
|
||||||
Feel free to use and share this mod and unmodified file in anyway like modpack.
|
|
||||||
When using in modpack, you must put 'CustomSkinLoader' in mod list.
|
|
||||||
You could not repost this mod to any website without permission.
|
|
||||||
You could not earn money with this mod excluding modpack.
|
|
||||||
|
|
||||||
LICENSE - Source Code
|
|
||||||
GPLv3: http://www.gnu.org/licenses/gpl.html
|
|
||||||
When using the code, you should change the name of package to avoid others' misunderstanding.
|
|
||||||
|
|
||||||
OTHER - Useful Link
|
|
||||||
Source Code: https://github.com/xfl03/MCCustomSkinLoader
|
|
||||||
Release Page: http://www.mcbbs.net/thread-269807-1-1.html
|
|
||||||
Build Server: https://ci.infstudio.net/job/CustomSkinLoader/
|
|
||||||
|
|
||||||
|
|
||||||
中文简体(zh_cn)
|
|
||||||
|
|
||||||
许可 - 编译产物
|
|
||||||
您不得对CustomSkinLoader的成品jar内部内容进行任何修改
|
|
||||||
您可以在不经我许可的情况下,以任意方式传播这一mod以及jar文件(例如加入整合包)。
|
|
||||||
在加入整合包时,请必须在帖子内mod列表中明确写上"万用皮肤补丁"或者"CustomSkinLoader"或者附上发布页面地址。
|
|
||||||
您不得在未经许可的情况下,在国内外任何网站进行二次发布(包括皮肤站)。
|
|
||||||
您不得以任何形式出售CustomSkinLoader或任何使用或参考CustomSkinLoader源代码的作品。
|
|
||||||
|
|
||||||
许可 - 源代码
|
|
||||||
GPLv3: http://www.gnu.org/licenses/gpl.html
|
|
||||||
为避免他人误解,您在使用代码时必须修改包名。
|
|
||||||
|
|
||||||
其他 - 有用的链接
|
|
||||||
源代码: https://github.com/xfl03/MCCustomSkinLoader
|
|
||||||
发布页面: http://www.mcbbs.net/thread-269807-1-1.html
|
|
||||||
构建服务器: https://ci.infstudio.net/job/CustomSkinLoader/
|
|
||||||
@@ -1,177 +0,0 @@
|
|||||||
package customskinloader;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import com.google.common.collect.Maps;
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.google.gson.GsonBuilder;
|
|
||||||
import com.mojang.authlib.GameProfile;
|
|
||||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
|
||||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
|
|
||||||
|
|
||||||
import customskinloader.config.Config;
|
|
||||||
import customskinloader.config.SkinSiteProfile;
|
|
||||||
import customskinloader.loader.*;
|
|
||||||
import customskinloader.profile.DynamicSkullManager;
|
|
||||||
import customskinloader.profile.ModelManager0;
|
|
||||||
import customskinloader.profile.ProfileCache;
|
|
||||||
import customskinloader.profile.UserProfile;
|
|
||||||
import customskinloader.utils.MinecraftUtil;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Custom skin loader mod for Minecraft.
|
|
||||||
* @author (C) Jeremy Lam [JLChnToZ] 2013 & Alexander Xia [xfl03] 2014-2018
|
|
||||||
* @version @MOD_FULL_VERSION@
|
|
||||||
*/
|
|
||||||
public class CustomSkinLoader {
|
|
||||||
public static final String CustomSkinLoader_VERSION="@MOD_VERSION@";
|
|
||||||
public static final String CustomSkinLoader_FULL_VERSION="@MOD_FULL_VERSION@";
|
|
||||||
|
|
||||||
public static final File DATA_DIR=new File(MinecraftUtil.getMinecraftDataDir(),"CustomSkinLoader"),
|
|
||||||
LOG_FILE=new File(DATA_DIR,"CustomSkinLoader.log"),
|
|
||||||
CONFIG_FILE=new File(DATA_DIR,"CustomSkinLoader.json");
|
|
||||||
public static final SkinSiteProfile[] DEFAULT_LOAD_LIST={
|
|
||||||
SkinSiteProfile.createMojangAPI("Mojang"),
|
|
||||||
SkinSiteProfile.createCustomSkinAPI("LittleSkin","https://mcskin.littleservice.cn/"),
|
|
||||||
SkinSiteProfile.createCustomSkinAPI("BlessingSkin","http://skin.prinzeugen.net/"),
|
|
||||||
//OneSkin has been removed temporarily
|
|
||||||
//SkinSiteProfile.createCustomSkinAPI("OneSkin","http://fleey.cn/skin/skin_user/skin_json.php/"),
|
|
||||||
//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.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 Logger logger=initLogger();
|
|
||||||
public static final Config config=Config.loadConfig0();
|
|
||||||
|
|
||||||
private static final ProfileCache profileCache=new ProfileCache();
|
|
||||||
private static final DynamicSkullManager dynamicSkullManager=new DynamicSkullManager();
|
|
||||||
|
|
||||||
//For User Skin
|
|
||||||
public static Map loadProfile(GameProfile gameProfile){
|
|
||||||
String username=gameProfile.getName();
|
|
||||||
String credential=MinecraftUtil.getCredential(gameProfile);
|
|
||||||
//Fix: http://hopper.minecraft.net/crashes/minecraft/MCX-2773713
|
|
||||||
if(username==null){
|
|
||||||
logger.warning("Could not load profile: username is null.");
|
|
||||||
return Maps.newHashMap();
|
|
||||||
}
|
|
||||||
String tempName=Thread.currentThread().getName();
|
|
||||||
Thread.currentThread().setName(username);//Change Thread Name
|
|
||||||
UserProfile profile=null;
|
|
||||||
if(profileCache.isReady(credential)){
|
|
||||||
logger.info("Cached profile will be used.");
|
|
||||||
profile=profileCache.getProfile(credential);
|
|
||||||
if(profile==null){
|
|
||||||
logger.warning("(!Cached Profile is empty!) Expiry:"+profileCache.getExpiry(credential));
|
|
||||||
if(profileCache.isExpired(credential))//force load
|
|
||||||
profile=loadProfile0(gameProfile);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
logger.info(profile.toString(profileCache.getExpiry(credential)));
|
|
||||||
}else{
|
|
||||||
profileCache.setLoading(credential, true);
|
|
||||||
profile=loadProfile0(gameProfile);
|
|
||||||
}
|
|
||||||
Thread.currentThread().setName(tempName);
|
|
||||||
return ModelManager0.fromUserProfile(profile);
|
|
||||||
}
|
|
||||||
//Core
|
|
||||||
public static UserProfile loadProfile0(GameProfile gameProfile){
|
|
||||||
String username=gameProfile.getName();
|
|
||||||
String credential=MinecraftUtil.getCredential(gameProfile);
|
|
||||||
|
|
||||||
profileCache.setLoading(credential, true);
|
|
||||||
logger.info("Loading "+username+"'s profile.");
|
|
||||||
if(config.loadlist==null||config.loadlist.isEmpty()){
|
|
||||||
logger.info("LoadList is Empty.");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
UserProfile profile0=new UserProfile();
|
|
||||||
for(int i=0;i<config.loadlist.size();i++){
|
|
||||||
SkinSiteProfile ssp=config.loadlist.get(i);
|
|
||||||
logger.info((i+1)+"/"+config.loadlist.size()+" Try to load profile from '"+ssp.name+"'.");
|
|
||||||
ProfileLoader.IProfileLoader loader=ProfileLoader.LOADERS.get(ssp.type.toLowerCase());
|
|
||||||
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(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.");
|
|
||||||
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.");
|
|
||||||
|
|
||||||
if(config.enableLocalProfileCache){
|
|
||||||
UserProfile profile=profileCache.getLocalProfile(credential);
|
|
||||||
if(profile==null)
|
|
||||||
logger.info(username+"'s LocalProfile not found.");
|
|
||||||
else{
|
|
||||||
profileCache.updateCache(credential, profile, false);
|
|
||||||
profileCache.setLoading(credential, false);
|
|
||||||
logger.info(username+"'s LocalProfile will be used.");
|
|
||||||
logger.info(profile.toString(profileCache.getExpiry(credential)));
|
|
||||||
return profile;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
profileCache.setLoading(credential, false);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
//For Skull
|
|
||||||
public static Map<Type, MinecraftProfileTexture> loadProfileFromCache(final GameProfile gameProfile) {
|
|
||||||
String username=gameProfile.getName();
|
|
||||||
String credential=MinecraftUtil.getCredential(gameProfile);
|
|
||||||
|
|
||||||
if(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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,95 +0,0 @@
|
|||||||
package customskinloader;
|
|
||||||
|
|
||||||
import java.io.BufferedWriter;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.OutputStreamWriter;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
public class Logger {
|
|
||||||
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
||||||
public enum Level{
|
|
||||||
DEBUG("DEBUG",false),
|
|
||||||
INFO("INFO",true),
|
|
||||||
WARNING("WARNING",true);
|
|
||||||
|
|
||||||
|
|
||||||
String name;
|
|
||||||
boolean display;
|
|
||||||
Level(String name,boolean display){
|
|
||||||
this.name=name;
|
|
||||||
this.display=display;
|
|
||||||
}
|
|
||||||
public String getName(){
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
public boolean display(){
|
|
||||||
return display;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private BufferedWriter writer=null;
|
|
||||||
public Logger(){
|
|
||||||
//Logger isn't created.
|
|
||||||
}
|
|
||||||
public Logger(File logFile){
|
|
||||||
try {
|
|
||||||
if(!logFile.getParentFile().exists()){
|
|
||||||
logFile.getParentFile().mkdirs();
|
|
||||||
}
|
|
||||||
if(!logFile.exists())
|
|
||||||
logFile.createNewFile();
|
|
||||||
|
|
||||||
writer = new BufferedWriter(new OutputStreamWriter(
|
|
||||||
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){
|
|
||||||
if(!level.display()&&writer==null)
|
|
||||||
return;
|
|
||||||
StringBuilder sb=new StringBuilder();
|
|
||||||
sb.append("[").append(Thread.currentThread().getName()).append(" ").append(level.getName()).append("] ");
|
|
||||||
sb.append(msg);
|
|
||||||
if(level.display())
|
|
||||||
System.out.println(sb.toString());
|
|
||||||
if(writer==null)
|
|
||||||
return;
|
|
||||||
try {
|
|
||||||
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();
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public void debug(String msg){
|
|
||||||
log(Level.DEBUG,msg);
|
|
||||||
}
|
|
||||||
public void info(String msg){
|
|
||||||
log(Level.INFO,msg);
|
|
||||||
}
|
|
||||||
public void warning(String msg){
|
|
||||||
log(Level.WARNING,msg);
|
|
||||||
}
|
|
||||||
public void warning(Throwable e){
|
|
||||||
log(Level.WARNING,"Exception: "+e.toString());
|
|
||||||
StackTraceElement[] stes=e.getStackTrace();
|
|
||||||
for(StackTraceElement ste : stes){
|
|
||||||
log(Level.WARNING,ste.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,195 +0,0 @@
|
|||||||
package customskinloader.config;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.apache.commons.io.Charsets;
|
|
||||||
import org.apache.commons.io.FileUtils;
|
|
||||||
|
|
||||||
import customskinloader.CustomSkinLoader;
|
|
||||||
import customskinloader.loader.ProfileLoader;
|
|
||||||
import customskinloader.utils.HttpRequestUtil;
|
|
||||||
import customskinloader.utils.HttpTextureUtil;
|
|
||||||
import customskinloader.utils.HttpUtil0;
|
|
||||||
|
|
||||||
public class Config {
|
|
||||||
//Program
|
|
||||||
public String version;
|
|
||||||
public List<SkinSiteProfile> loadlist;
|
|
||||||
|
|
||||||
//Function
|
|
||||||
public boolean enableDynamicSkull=true;
|
|
||||||
public boolean enableTransparentSkin=true;
|
|
||||||
public boolean ignoreHttpsCertificate=false;
|
|
||||||
public boolean forceLoadAllTextures=false;
|
|
||||||
|
|
||||||
//Cache
|
|
||||||
public int cacheExpiry=20;
|
|
||||||
public boolean enableUpdateSkull=false;
|
|
||||||
public boolean enableLocalProfileCache=false;
|
|
||||||
public boolean enableCacheAutoClean=false;
|
|
||||||
|
|
||||||
|
|
||||||
//Init config
|
|
||||||
public Config(SkinSiteProfile[] loadlist){
|
|
||||||
this.version=CustomSkinLoader.CustomSkinLoader_VERSION;
|
|
||||||
this.loadlist=Arrays.asList(loadlist);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Config loadConfig0() {
|
|
||||||
Config config=loadConfig();
|
|
||||||
|
|
||||||
//LoadList null checker
|
|
||||||
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--);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Init program
|
|
||||||
config.loadExtraList();
|
|
||||||
config.initLocalFolder();
|
|
||||||
if(config.ignoreHttpsCertificate)
|
|
||||||
HttpUtil0.ignoreHttpsCertificate();
|
|
||||||
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
|
|
||||||
CustomSkinLoader.logger.info("EnableDynamicSkull:"+config.enableDynamicSkull+
|
|
||||||
", EnableTranSkin:"+config.enableTransparentSkin+
|
|
||||||
", IgnoreHttpsCertificate:"+config.ignoreHttpsCertificate+
|
|
||||||
", CacheExpiry:"+config.cacheExpiry+
|
|
||||||
", EnableUpdateSkull:"+config.enableUpdateSkull+
|
|
||||||
", EnableLocalProfileCache:"+config.enableLocalProfileCache+
|
|
||||||
", EnableCacheAutoClean:"+config.enableCacheAutoClean+
|
|
||||||
", LoadList:"+(config.loadlist==null?0:config.loadlist.size()));
|
|
||||||
|
|
||||||
//Check config version
|
|
||||||
float floatVersion=0f;
|
|
||||||
float configVersion=0f;
|
|
||||||
try{
|
|
||||||
floatVersion=Float.parseFloat(CustomSkinLoader.CustomSkinLoader_VERSION);
|
|
||||||
configVersion=Float.parseFloat(config.version);
|
|
||||||
if(configVersion==15.1f)//To avoid some bug
|
|
||||||
configVersion=14.6f;
|
|
||||||
}catch (Exception e){
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Config loadConfig() {
|
|
||||||
CustomSkinLoader.logger.info("Config File: "+CustomSkinLoader.CONFIG_FILE.getAbsolutePath());
|
|
||||||
if(!CustomSkinLoader.CONFIG_FILE.exists()){
|
|
||||||
CustomSkinLoader.logger.info("Config file not found, use default instead.");
|
|
||||||
return initConfig();
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
CustomSkinLoader.logger.info("Try to load config.");
|
|
||||||
String json=FileUtils.readFileToString(CustomSkinLoader.CONFIG_FILE,Charsets.UTF_8);
|
|
||||||
Config config=CustomSkinLoader.GSON.fromJson(json, Config.class);
|
|
||||||
CustomSkinLoader.logger.info("Successfully load config.");
|
|
||||||
return config;
|
|
||||||
}catch (Exception e) {
|
|
||||||
CustomSkinLoader.logger.info("Failed to load config, use default instead.("+e.toString()+")");
|
|
||||||
File brokenFile=new File(CustomSkinLoader.DATA_DIR,"BROKEN-CustomSkinLoader.json");
|
|
||||||
if(brokenFile.exists())
|
|
||||||
brokenFile.delete();
|
|
||||||
CustomSkinLoader.CONFIG_FILE.renameTo(brokenFile);
|
|
||||||
return initConfig();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void loadExtraList(){
|
|
||||||
File listAddition=new File(CustomSkinLoader.DATA_DIR,"ExtraList");
|
|
||||||
if(!listAddition.isDirectory()){
|
|
||||||
listAddition.mkdirs();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
List<SkinSiteProfile> adds=new ArrayList<SkinSiteProfile>();
|
|
||||||
File[] files=listAddition.listFiles();
|
|
||||||
for(File file:files){
|
|
||||||
if(!file.getName().toLowerCase().endsWith(".json")&&!file.getName().toLowerCase().endsWith(".txt"))
|
|
||||||
continue;
|
|
||||||
try {
|
|
||||||
CustomSkinLoader.logger.info("Try to load Extra List.("+file.getName()+")");
|
|
||||||
String json=FileUtils.readFileToString(file,Charsets.UTF_8);
|
|
||||||
SkinSiteProfile ssp=CustomSkinLoader.GSON.fromJson(json, SkinSiteProfile.class);
|
|
||||||
CustomSkinLoader.logger.info("Successfully load Extra List.");
|
|
||||||
file.delete();
|
|
||||||
ProfileLoader.IProfileLoader loader=ProfileLoader.LOADERS.get(ssp.type.toLowerCase());
|
|
||||||
if(loader==null){
|
|
||||||
CustomSkinLoader.logger.info("Extra List will be ignore: Type '"+ssp.type+"' is not defined.");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
boolean duplicate=false;
|
|
||||||
for(SkinSiteProfile ssp0:this.loadlist){
|
|
||||||
if(!ssp0.type.equalsIgnoreCase(ssp.type))
|
|
||||||
continue;
|
|
||||||
if(loader.compare(ssp0, ssp)){
|
|
||||||
duplicate=true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(!duplicate){
|
|
||||||
adds.add(ssp);
|
|
||||||
CustomSkinLoader.logger.info("Successfully apply Extra List.("+ssp.name+")");
|
|
||||||
}else{
|
|
||||||
CustomSkinLoader.logger.info("Extra List will be ignore: Duplicate.("+ssp.name+")");
|
|
||||||
}
|
|
||||||
}catch (Exception e) {
|
|
||||||
CustomSkinLoader.logger.info("Failed to load Extra List.("+e.toString()+")");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(adds.size()!=0){
|
|
||||||
adds.addAll(this.loadlist);
|
|
||||||
this.loadlist=adds;
|
|
||||||
writeConfig(this,true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initLocalFolder(){
|
|
||||||
for(SkinSiteProfile ssp:this.loadlist){
|
|
||||||
ProfileLoader.IProfileLoader loader=ProfileLoader.LOADERS.get(ssp.type.toLowerCase());
|
|
||||||
if(loader==null)
|
|
||||||
continue;
|
|
||||||
loader.initLocalFolder(ssp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Config initConfig() {
|
|
||||||
Config config=new Config(CustomSkinLoader.DEFAULT_LOAD_LIST);
|
|
||||||
writeConfig(config,false);
|
|
||||||
return config;
|
|
||||||
}
|
|
||||||
private static void writeConfig(Config config,boolean update){
|
|
||||||
String json=CustomSkinLoader.GSON.toJson(config);
|
|
||||||
if(CustomSkinLoader.CONFIG_FILE.exists())
|
|
||||||
CustomSkinLoader.CONFIG_FILE.delete();
|
|
||||||
try {
|
|
||||||
CustomSkinLoader.CONFIG_FILE.createNewFile();
|
|
||||||
FileUtils.write(CustomSkinLoader.CONFIG_FILE, json, Charsets.UTF_8);
|
|
||||||
CustomSkinLoader.logger.info("Successfully "+(update?"update":"create")+" config.");
|
|
||||||
} catch (Exception e) {
|
|
||||||
CustomSkinLoader.logger.info("Failed to "+(update?"update":"create")+" config.("+e.toString()+")");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,64 +0,0 @@
|
|||||||
package customskinloader.config;
|
|
||||||
|
|
||||||
import customskinloader.loader.jsonapi.CustomSkinAPIPlus.CustomSkinAPIPlusPrivacy;
|
|
||||||
|
|
||||||
public class SkinSiteProfile {
|
|
||||||
public String name;
|
|
||||||
public String type;
|
|
||||||
public String userAgent;
|
|
||||||
|
|
||||||
public String root;
|
|
||||||
public CustomSkinAPIPlusPrivacy privacy;
|
|
||||||
|
|
||||||
public Boolean checkPNG;//Not suitable for local skin
|
|
||||||
public String skin;
|
|
||||||
public String model;
|
|
||||||
public String cape;
|
|
||||||
public String elytra;
|
|
||||||
|
|
||||||
public static SkinSiteProfile createMojangAPI(String name){
|
|
||||||
SkinSiteProfile ssp=new SkinSiteProfile();
|
|
||||||
ssp.name=name;
|
|
||||||
ssp.type="MojangAPI";
|
|
||||||
return ssp;
|
|
||||||
}
|
|
||||||
public static SkinSiteProfile createCustomSkinAPI(String name,String root){
|
|
||||||
SkinSiteProfile ssp=new SkinSiteProfile();
|
|
||||||
ssp.name=name;
|
|
||||||
ssp.type="CustomSkinAPI";
|
|
||||||
ssp.root=root;
|
|
||||||
return ssp;
|
|
||||||
}
|
|
||||||
public static SkinSiteProfile creatCustomSkinAPIPlus(String name,String root){
|
|
||||||
SkinSiteProfile ssp=new SkinSiteProfile();
|
|
||||||
ssp.name=name;
|
|
||||||
ssp.type="CustomSkinAPIPlus";
|
|
||||||
ssp.root=root;
|
|
||||||
ssp.privacy=new CustomSkinAPIPlusPrivacy();
|
|
||||||
return ssp;
|
|
||||||
}
|
|
||||||
public static SkinSiteProfile createUniSkinAPI(String name,String root){
|
|
||||||
SkinSiteProfile ssp=new SkinSiteProfile();
|
|
||||||
ssp.name=name;
|
|
||||||
ssp.type="UniSkinAPI";
|
|
||||||
ssp.root=root;
|
|
||||||
return ssp;
|
|
||||||
}
|
|
||||||
public static SkinSiteProfile createLegacy(String name,String skin,String cape,String elytra){
|
|
||||||
SkinSiteProfile ssp=new SkinSiteProfile();
|
|
||||||
ssp.name=name;
|
|
||||||
ssp.type="Legacy";
|
|
||||||
ssp.checkPNG=false;
|
|
||||||
ssp.skin=skin;
|
|
||||||
ssp.model="default";
|
|
||||||
ssp.cape=cape;
|
|
||||||
ssp.elytra=elytra;
|
|
||||||
return ssp;
|
|
||||||
}
|
|
||||||
public static SkinSiteProfile createElfSkin(String name){
|
|
||||||
SkinSiteProfile ssp=new SkinSiteProfile();
|
|
||||||
ssp.name=name;
|
|
||||||
ssp.type="ElfSkin";
|
|
||||||
return ssp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,86 +0,0 @@
|
|||||||
package customskinloader.fake;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
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.entity.player.EntityPlayer;
|
|
||||||
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=EntityPlayer.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));
|
|
||||||
}
|
|
||||||
|
|
||||||
private 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;
|
|
||||||
|
|
||||||
loaded=true;
|
|
||||||
|
|
||||||
|
|
||||||
TextureManager textman = Minecraft.getMinecraft().getTextureManager();
|
|
||||||
ITextureObject ito = textman.getTexture(location);
|
|
||||||
|
|
||||||
if(ito!=null)
|
|
||||||
textman.loadTexture(resourceLocationIn, ito);
|
|
||||||
CustomSkinLoader.logger.debug("Legacy Texture ("+resourceLocationIn+") Loaded as "+
|
|
||||||
ito==null?null:ito.toString()+" ("+location+")");
|
|
||||||
//textman.bindTexture(resourceLocationIn);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,117 +0,0 @@
|
|||||||
package customskinloader.fake;
|
|
||||||
|
|
||||||
import java.awt.Color;
|
|
||||||
import java.awt.Graphics;
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
import java.awt.image.DataBufferInt;
|
|
||||||
import java.awt.image.ImageObserver;
|
|
||||||
|
|
||||||
public class FakeSkinBuffer implements net.minecraft.client.renderer.IImageBuffer {
|
|
||||||
|
|
||||||
private int[] imageData;
|
|
||||||
private int ratio=1;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BufferedImage parseUserSkin(BufferedImage image) {
|
|
||||||
if(image==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
|
|
||||||
setAreaTransparent(32 * ratio, 0 * ratio,64 * ratio,16 * ratio);//Head - 2
|
|
||||||
|
|
||||||
setAreaDueToConfig( 0 * ratio,16 * ratio,16 * ratio,32 * ratio);//Right Leg - 1
|
|
||||||
setAreaDueToConfig(16 * ratio,16 * ratio,40 * ratio,32 * ratio);//Body - 1
|
|
||||||
setAreaDueToConfig(40 * ratio,16 * ratio,56 * ratio,32 * ratio);//Right Arm - 1
|
|
||||||
|
|
||||||
setAreaTransparent( 0 * ratio,32 * ratio,16 * ratio,48 * ratio);//Right Leg - 2
|
|
||||||
setAreaTransparent(16 * ratio,32 * ratio,40 * ratio,48 * ratio);//Body - 2
|
|
||||||
setAreaTransparent(40 * ratio,32 * ratio,56 * ratio,48 * ratio);//Right Arm - 2
|
|
||||||
|
|
||||||
setAreaTransparent( 0 * ratio,48 * ratio,16 * ratio,64 * ratio);//Left Leg - 2
|
|
||||||
setAreaDueToConfig(16 * ratio,48 * ratio,32 * ratio,64 * ratio);//Left Leg - 1
|
|
||||||
setAreaDueToConfig(32 * ratio,48 * ratio,48 * ratio,64 * ratio);//Left Arm - 1
|
|
||||||
setAreaTransparent(48 * ratio,48 * ratio,64 * ratio,64 * ratio);//Left Arm - 2
|
|
||||||
|
|
||||||
return bufferedimage;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 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=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
|
|
||||||
* 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)
|
|
||||||
this.imageData[getPosition(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);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void skinAvailable(){
|
|
||||||
//A callback when skin loaded
|
|
||||||
}
|
|
||||||
|
|
||||||
private static int getARGB(int a,int r,int g,int b){
|
|
||||||
return (a << 24) | (r << 16) | (g << 8) | b;
|
|
||||||
}
|
|
||||||
|
|
||||||
private int getPosition(int x,int y){
|
|
||||||
return x+y*64*ratio;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,107 +0,0 @@
|
|||||||
package customskinloader.fake;
|
|
||||||
|
|
||||||
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 com.google.common.collect.Maps;
|
|
||||||
import com.mojang.authlib.GameProfile;
|
|
||||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
|
||||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
|
|
||||||
import com.mojang.authlib.minecraft.MinecraftSessionService;
|
|
||||||
|
|
||||||
import customskinloader.CustomSkinLoader;
|
|
||||||
import customskinloader.utils.HttpTextureUtil;
|
|
||||||
import customskinloader.utils.HttpTextureUtil.HttpTextureInfo;
|
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.renderer.IImageBuffer;
|
|
||||||
import net.minecraft.client.renderer.ThreadDownloadImageData;
|
|
||||||
import net.minecraft.client.renderer.texture.ITextureObject;
|
|
||||||
import net.minecraft.client.renderer.texture.TextureManager;
|
|
||||||
import net.minecraft.client.resources.DefaultPlayerSkin;
|
|
||||||
import net.minecraft.client.resources.SkinManager.SkinAvailableCallback;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
|
|
||||||
public class FakeSkinManager{
|
|
||||||
private static final ExecutorService THREAD_POOL = new ThreadPoolExecutor(0, 2, 1L, TimeUnit.MINUTES, new LinkedBlockingQueue());
|
|
||||||
private final TextureManager textureManager;
|
|
||||||
|
|
||||||
public FakeSkinManager(TextureManager textureManagerInstance, File skinCacheDirectory, MinecraftSessionService sessionService) {
|
|
||||||
this.textureManager=textureManagerInstance;
|
|
||||||
HttpTextureUtil.defaultCacheDir=skinCacheDirectory;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ResourceLocation loadSkin(MinecraftProfileTexture profileTexture, Type textureType){
|
|
||||||
return this.loadSkin(profileTexture, textureType, null);
|
|
||||||
}
|
|
||||||
public ResourceLocation loadSkin(final MinecraftProfileTexture profileTexture, final Type textureType, final SkinAvailableCallback skinAvailableCallback){
|
|
||||||
HttpTextureInfo info=HttpTextureUtil.toHttpTextureInfo(profileTexture.getUrl());
|
|
||||||
|
|
||||||
final ResourceLocation resourcelocation = new ResourceLocation("skins/" + info.hash);
|
|
||||||
ITextureObject itextureobject = this.textureManager.getTexture(resourcelocation);
|
|
||||||
|
|
||||||
if (itextureobject != null)//Have already loaded
|
|
||||||
makeCallback(skinAvailableCallback,textureType, resourcelocation, profileTexture);
|
|
||||||
else{
|
|
||||||
ThreadDownloadImageData threaddownloadimagedata = new ThreadDownloadImageData(info.cacheFile, info.url, DefaultPlayerSkin.getDefaultSkinLegacy(),
|
|
||||||
new BaseBuffer(skinAvailableCallback, textureType, resourcelocation, profileTexture));
|
|
||||||
this.textureManager.loadTexture(resourcelocation, threaddownloadimagedata);
|
|
||||||
}
|
|
||||||
return resourcelocation;
|
|
||||||
}
|
|
||||||
public void loadProfileTextures(final GameProfile profile, final SkinAvailableCallback skinAvailableCallback, final boolean requireSecure){
|
|
||||||
THREAD_POOL.submit(new Runnable(){
|
|
||||||
public void run(){
|
|
||||||
final Map<Type, MinecraftProfileTexture> map = Maps.<Type, MinecraftProfileTexture>newHashMap();
|
|
||||||
map.putAll(customskinloader.CustomSkinLoader.loadProfile(profile));
|
|
||||||
|
|
||||||
Minecraft.getMinecraft().addScheduledTask(new Runnable(){
|
|
||||||
public void run(){
|
|
||||||
for(Type type:Type.values())
|
|
||||||
if(map.containsKey(type))
|
|
||||||
FakeSkinManager.this.loadSkin((MinecraftProfileTexture)map.get(type), type, skinAvailableCallback);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
public Map<Type, MinecraftProfileTexture> loadSkinFromCache(GameProfile profile){
|
|
||||||
return CustomSkinLoader.loadProfileFromCache(profile);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void makeCallback(SkinAvailableCallback callback,Type type, ResourceLocation location, MinecraftProfileTexture texture){
|
|
||||||
if(callback!=null)
|
|
||||||
callback.skinAvailable(type, location, texture);
|
|
||||||
}
|
|
||||||
private class BaseBuffer implements IImageBuffer{
|
|
||||||
private IImageBuffer buffer;
|
|
||||||
|
|
||||||
private SkinAvailableCallback callback;
|
|
||||||
private Type type;
|
|
||||||
private ResourceLocation location;
|
|
||||||
private MinecraftProfileTexture texture;
|
|
||||||
public BaseBuffer(SkinAvailableCallback callback,Type type,ResourceLocation location,MinecraftProfileTexture texture){
|
|
||||||
this.buffer=(type==Type.SKIN?new FakeSkinBuffer():null);
|
|
||||||
|
|
||||||
this.callback=callback;
|
|
||||||
this.type=type;
|
|
||||||
this.location=location;
|
|
||||||
this.texture=texture;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BufferedImage parseUserSkin(BufferedImage image){
|
|
||||||
return buffer==null?image:buffer.parseUserSkin(image);
|
|
||||||
}
|
|
||||||
public void skinAvailable(){
|
|
||||||
if (buffer != null)
|
|
||||||
buffer.skinAvailable();
|
|
||||||
|
|
||||||
FakeSkinManager.makeCallback(callback,type, location, texture);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,101 +0,0 @@
|
|||||||
package customskinloader.loader;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
|
|
||||||
import org.apache.commons.io.IOUtils;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
|
|
||||||
import com.mojang.authlib.GameProfile;
|
|
||||||
|
|
||||||
import customskinloader.CustomSkinLoader;
|
|
||||||
import customskinloader.config.SkinSiteProfile;
|
|
||||||
import customskinloader.loader.jsonapi.*;
|
|
||||||
import customskinloader.profile.UserProfile;
|
|
||||||
import customskinloader.utils.HttpRequestUtil;
|
|
||||||
import customskinloader.utils.HttpUtil0;
|
|
||||||
import customskinloader.utils.HttpRequestUtil.HttpRequest;
|
|
||||||
import customskinloader.utils.HttpRequestUtil.HttpResponce;
|
|
||||||
|
|
||||||
public class JsonAPILoader implements ProfileLoader.IProfileLoader {
|
|
||||||
|
|
||||||
public interface IJsonAPI {
|
|
||||||
public String toJsonUrl(String root,String username);
|
|
||||||
public String getPayload(SkinSiteProfile ssp);
|
|
||||||
public UserProfile toUserProfile(String root,String json,boolean local);
|
|
||||||
public String getName();
|
|
||||||
}
|
|
||||||
public static class ErrorProfile{
|
|
||||||
public int errno;
|
|
||||||
public String msg;
|
|
||||||
}
|
|
||||||
public static enum Type{
|
|
||||||
CustomSkinAPI(new CustomSkinAPI()),CustomSkinAPIPlus(new CustomSkinAPIPlus()),UniSkinAPI(new UniSkinAPI());
|
|
||||||
public IJsonAPI jsonAPI;
|
|
||||||
private Type(IJsonAPI jsonAPI){
|
|
||||||
this.jsonAPI=jsonAPI;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private Type type;
|
|
||||||
public JsonAPILoader(Type type){
|
|
||||||
this.type=type;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UserProfile loadProfile(SkinSiteProfile ssp, GameProfile gameProfile) throws Exception {
|
|
||||||
String username=gameProfile.getName();
|
|
||||||
boolean local=HttpUtil0.isLocal(ssp.root);
|
|
||||||
if(ssp.root==null||ssp.root.equals("")){
|
|
||||||
CustomSkinLoader.logger.info("Root not defined.");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
String jsonUrl=type.jsonAPI.toJsonUrl(ssp.root, username);
|
|
||||||
String json;
|
|
||||||
if(local){
|
|
||||||
File jsonFile=new File(jsonUrl);
|
|
||||||
if(!jsonFile.exists()){
|
|
||||||
CustomSkinLoader.logger.info("Profile File not found.");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
json=IOUtils.toString(new FileInputStream(jsonFile));
|
|
||||||
}else{
|
|
||||||
HttpResponce responce=HttpRequestUtil.makeHttpRequest(new HttpRequest(jsonUrl).setCacheTime(90).setUserAgent(ssp.userAgent).setPayload(type.jsonAPI.getPayload(ssp)));
|
|
||||||
json=responce.content;
|
|
||||||
}
|
|
||||||
if(json==null||json.equals("")){
|
|
||||||
CustomSkinLoader.logger.info("Profile not found.");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
ErrorProfile profile=CustomSkinLoader.GSON.fromJson(json, ErrorProfile.class);
|
|
||||||
if(profile.errno!=0){
|
|
||||||
CustomSkinLoader.logger.info("Error "+profile.errno+": "+profile.msg);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
UserProfile p=type.jsonAPI.toUserProfile(ssp.root, json, local);
|
|
||||||
if(p==null||p.isEmpty()){
|
|
||||||
CustomSkinLoader.logger.info("Both skin and cape not found.");
|
|
||||||
return null;
|
|
||||||
}else{
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public boolean compare(SkinSiteProfile ssp0, SkinSiteProfile ssp1) {
|
|
||||||
return StringUtils.isNoneEmpty(ssp0.root)?ssp0.root.equalsIgnoreCase(ssp1.root):true;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return type.jsonAPI.getName();
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void initLocalFolder(SkinSiteProfile ssp) {
|
|
||||||
if(HttpUtil0.isLocal(ssp.root)){
|
|
||||||
File f=new File(ssp.root);
|
|
||||||
if(!f.exists())
|
|
||||||
f.mkdirs();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,94 +0,0 @@
|
|||||||
package customskinloader.loader;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
|
|
||||||
import com.mojang.authlib.GameProfile;
|
|
||||||
|
|
||||||
import customskinloader.CustomSkinLoader;
|
|
||||||
import customskinloader.config.SkinSiteProfile;
|
|
||||||
import customskinloader.profile.ModelManager0;
|
|
||||||
import customskinloader.profile.UserProfile;
|
|
||||||
import customskinloader.utils.HttpRequestUtil;
|
|
||||||
import customskinloader.utils.HttpRequestUtil.HttpRequest;
|
|
||||||
import customskinloader.utils.HttpRequestUtil.HttpResponce;
|
|
||||||
import customskinloader.utils.HttpTextureUtil;
|
|
||||||
import customskinloader.utils.HttpUtil0;
|
|
||||||
|
|
||||||
public class LegacyLoader implements ProfileLoader.IProfileLoader {
|
|
||||||
public static final String USERNAME_REGEX="\\{USERNAME\\}";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UserProfile loadProfile(SkinSiteProfile ssp, GameProfile gameProfile) throws Exception {
|
|
||||||
String username=gameProfile.getName();
|
|
||||||
UserProfile profile=new UserProfile();
|
|
||||||
if(StringUtils.isNoneEmpty(ssp.skin)){
|
|
||||||
String skin=ssp.skin.replaceAll(USERNAME_REGEX, username);
|
|
||||||
if(HttpUtil0.isLocal(ssp.skin)){
|
|
||||||
File skinFile=new File(CustomSkinLoader.DATA_DIR,skin);
|
|
||||||
if(skinFile.exists()&&skinFile.isFile())
|
|
||||||
profile.skinUrl=HttpTextureUtil.getLocalLegacyFakeUrl(skin, HttpTextureUtil.getHash(skin, skinFile.length(), skinFile.lastModified()));
|
|
||||||
}else{
|
|
||||||
HttpResponce responce=HttpRequestUtil.makeHttpRequest(new HttpRequest(skin).setUserAgent(ssp.userAgent).setCheckPNG(ssp.checkPNG!=null&&ssp.checkPNG!=false).setLoadContent(false).setCacheTime(90));
|
|
||||||
if(responce.success)
|
|
||||||
profile.skinUrl=HttpTextureUtil.getLegacyFakeUrl(skin);
|
|
||||||
}
|
|
||||||
profile.model=profile.hasSkinUrl()?ssp.model:null;
|
|
||||||
}
|
|
||||||
if(StringUtils.isNoneEmpty(ssp.cape)){
|
|
||||||
String cape=ssp.cape.replaceAll(USERNAME_REGEX, username);
|
|
||||||
if(HttpUtil0.isLocal(ssp.cape)){
|
|
||||||
File capeFile=new File(CustomSkinLoader.DATA_DIR,cape);
|
|
||||||
if(capeFile.exists()&&capeFile.isFile())
|
|
||||||
profile.capeUrl=HttpTextureUtil.getLocalLegacyFakeUrl(cape, HttpTextureUtil.getHash(cape, capeFile.length(), capeFile.lastModified()));
|
|
||||||
}else{
|
|
||||||
HttpResponce responce=HttpRequestUtil.makeHttpRequest(new HttpRequest(cape).setUserAgent(ssp.userAgent).setCheckPNG(ssp.checkPNG!=null&&ssp.checkPNG!=false).setLoadContent(false).setCacheTime(90));
|
|
||||||
if(responce.success)
|
|
||||||
profile.capeUrl=HttpTextureUtil.getLegacyFakeUrl(cape);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(ModelManager0.isElytraSupported()&&StringUtils.isNoneEmpty(ssp.elytra)){
|
|
||||||
String elytra=ssp.elytra.replaceAll(USERNAME_REGEX, username);
|
|
||||||
if(HttpUtil0.isLocal(ssp.elytra)){
|
|
||||||
File elytraFile=new File(CustomSkinLoader.DATA_DIR,elytra);
|
|
||||||
if(elytraFile.exists()&&elytraFile.isFile())
|
|
||||||
profile.elytraUrl=HttpTextureUtil.getLocalLegacyFakeUrl(elytra, HttpTextureUtil.getHash(elytra, elytraFile.length(), elytraFile.lastModified()));
|
|
||||||
}else{
|
|
||||||
HttpResponce responce=HttpRequestUtil.makeHttpRequest(new HttpRequest(elytra).setUserAgent(ssp.userAgent).setCheckPNG(ssp.checkPNG!=null&&ssp.checkPNG!=false).setLoadContent(false).setCacheTime(90));
|
|
||||||
if(responce.success)
|
|
||||||
profile.elytraUrl=HttpTextureUtil.getLegacyFakeUrl(elytra);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(profile.isEmpty()){
|
|
||||||
CustomSkinLoader.logger.info("Both skin and cape not found.");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return profile;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return "Legacy";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void initLocalFolder(SkinSiteProfile ssp) {
|
|
||||||
if(HttpUtil0.isLocal(ssp.skin))
|
|
||||||
initFolder(ssp.skin);
|
|
||||||
if(HttpUtil0.isLocal(ssp.cape))
|
|
||||||
initFolder(ssp.cape);
|
|
||||||
if(HttpUtil0.isLocal(ssp.elytra))
|
|
||||||
initFolder(ssp.elytra);
|
|
||||||
}
|
|
||||||
private void initFolder(String target){
|
|
||||||
String file=target.replaceAll(USERNAME_REGEX, "init");
|
|
||||||
File folder=new File(CustomSkinLoader.DATA_DIR,file).getParentFile();
|
|
||||||
if(folder!=null&&!folder.exists())
|
|
||||||
folder.mkdirs();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,119 +0,0 @@
|
|||||||
package customskinloader.loader;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import org.apache.commons.codec.Charsets;
|
|
||||||
import org.apache.commons.codec.binary.Base64;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
|
|
||||||
import com.google.common.collect.Iterables;
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.google.gson.GsonBuilder;
|
|
||||||
import com.mojang.authlib.GameProfile;
|
|
||||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
|
||||||
import com.mojang.authlib.minecraft.MinecraftSessionService;
|
|
||||||
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.util.UUIDTypeAdapter;
|
|
||||||
|
|
||||||
import customskinloader.CustomSkinLoader;
|
|
||||||
import customskinloader.config.SkinSiteProfile;
|
|
||||||
import customskinloader.profile.ModelManager0;
|
|
||||||
import customskinloader.profile.UserProfile;
|
|
||||||
import customskinloader.utils.HttpRequestUtil;
|
|
||||||
import customskinloader.utils.HttpRequestUtil.HttpRequest;
|
|
||||||
import customskinloader.utils.HttpRequestUtil.HttpResponce;
|
|
||||||
import customskinloader.utils.MinecraftUtil;
|
|
||||||
|
|
||||||
public class MojangAPILoader implements ProfileLoader.IProfileLoader {
|
|
||||||
|
|
||||||
public static final MinecraftSessionService defaultSessionService=MinecraftUtil.getSessionService();
|
|
||||||
@Override
|
|
||||||
public UserProfile loadProfile(SkinSiteProfile ssp, GameProfile gameProfile) throws Exception {
|
|
||||||
Map<MinecraftProfileTexture.Type,MinecraftProfileTexture> map=getTextures(gameProfile);
|
|
||||||
if(!map.isEmpty()){
|
|
||||||
CustomSkinLoader.logger.info("Default profile will be used.");
|
|
||||||
return ModelManager0.toUserProfile(map);
|
|
||||||
}
|
|
||||||
String username=gameProfile.getName();
|
|
||||||
GameProfile newGameProfile=loadGameProfile(username);
|
|
||||||
if(newGameProfile==null){
|
|
||||||
CustomSkinLoader.logger.info("Profile not found.("+username+"'s profile not found.)");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
newGameProfile=fillGameProfile(newGameProfile);
|
|
||||||
map=getTextures(newGameProfile);
|
|
||||||
if(!map.isEmpty()){
|
|
||||||
gameProfile.getProperties().putAll(newGameProfile.getProperties());
|
|
||||||
return ModelManager0.toUserProfile(map);
|
|
||||||
}
|
|
||||||
CustomSkinLoader.logger.info("Profile not found.("+username+" doesn't have skin/cape.)");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Username -> UUID
|
|
||||||
public static GameProfile loadGameProfile(String username) throws Exception{
|
|
||||||
//Doc (http://wiki.vg/Mojang_API#Username_-.3E_UUID_at_time)
|
|
||||||
HttpResponce responce=HttpRequestUtil.makeHttpRequest(new HttpRequest("https://api.mojang.com/users/profiles/minecraft/"+username).setCacheTime(0));
|
|
||||||
if(StringUtils.isEmpty(responce.content))
|
|
||||||
return null;
|
|
||||||
|
|
||||||
Gson gson=new GsonBuilder().registerTypeAdapter(UUID.class, new UUIDTypeAdapter()).create();
|
|
||||||
GameProfile gameProfile=gson.fromJson(responce.content, GameProfile.class);
|
|
||||||
|
|
||||||
if(gameProfile.getId()==null)
|
|
||||||
return null;
|
|
||||||
return new GameProfile(gameProfile.getId(),gameProfile.getName());
|
|
||||||
}
|
|
||||||
//UUID -> Profile
|
|
||||||
public static GameProfile fillGameProfile(GameProfile profile) throws Exception{
|
|
||||||
//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) throws Exception{
|
|
||||||
if(gameProfile==null)
|
|
||||||
return new HashMap();
|
|
||||||
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
|
|
||||||
public boolean compare(SkinSiteProfile ssp0, SkinSiteProfile ssp1) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return "MojangAPI";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void initLocalFolder(SkinSiteProfile ssp) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
package customskinloader.loader;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
import com.mojang.authlib.GameProfile;
|
|
||||||
|
|
||||||
import customskinloader.config.SkinSiteProfile;
|
|
||||||
import customskinloader.profile.UserProfile;
|
|
||||||
|
|
||||||
public class ProfileLoader {
|
|
||||||
private static final IProfileLoader[] DEFAULT_LOADERS={
|
|
||||||
new MojangAPILoader(),
|
|
||||||
new JsonAPILoader(JsonAPILoader.Type.CustomSkinAPI),
|
|
||||||
new JsonAPILoader(JsonAPILoader.Type.CustomSkinAPIPlus),
|
|
||||||
new LegacyLoader(),
|
|
||||||
new JsonAPILoader(JsonAPILoader.Type.UniSkinAPI)};
|
|
||||||
|
|
||||||
public static final HashMap<String,IProfileLoader> LOADERS=initLoaders();
|
|
||||||
|
|
||||||
private static HashMap<String, IProfileLoader> initLoaders() {
|
|
||||||
HashMap<String, IProfileLoader> loaders=new HashMap<String, IProfileLoader>();
|
|
||||||
for(IProfileLoader loader:DEFAULT_LOADERS){
|
|
||||||
loaders.put(loader.getName().toLowerCase(), loader);
|
|
||||||
}
|
|
||||||
return loaders;
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface IProfileLoader {
|
|
||||||
public UserProfile loadProfile(SkinSiteProfile ssp,GameProfile gameProfile) throws Exception;
|
|
||||||
public boolean compare(SkinSiteProfile ssp0,SkinSiteProfile ssp1);
|
|
||||||
public String getName();
|
|
||||||
public void initLocalFolder(SkinSiteProfile ssp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,90 +0,0 @@
|
|||||||
package customskinloader.loader.jsonapi;
|
|
||||||
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
|
|
||||||
import customskinloader.CustomSkinLoader;
|
|
||||||
import customskinloader.config.SkinSiteProfile;
|
|
||||||
import customskinloader.loader.JsonAPILoader.IJsonAPI;
|
|
||||||
import customskinloader.profile.ModelManager0;
|
|
||||||
import customskinloader.profile.ModelManager0.Model;
|
|
||||||
import customskinloader.profile.UserProfile;
|
|
||||||
import customskinloader.utils.HttpTextureUtil;
|
|
||||||
|
|
||||||
public class CustomSkinAPI implements IJsonAPI {
|
|
||||||
private static final String TEXTURES="textures/";
|
|
||||||
private static final String SUFFIX=".json";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toJsonUrl(String root, String username) {
|
|
||||||
return new StringBuilder().append(root).append(username).append(SUFFIX).toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UserProfile toUserProfile(String root, String json, boolean local) {
|
|
||||||
CustomSkinAPIProfile profile=CustomSkinLoader.GSON.fromJson(json, CustomSkinAPIProfile.class);
|
|
||||||
UserProfile p=new UserProfile();
|
|
||||||
|
|
||||||
if(StringUtils.isNotBlank(profile.skin)){
|
|
||||||
p.skinUrl=root+TEXTURES+profile.skin;
|
|
||||||
if(local)
|
|
||||||
p.skinUrl=HttpTextureUtil.getLocalFakeUrl(p.skinUrl);
|
|
||||||
}
|
|
||||||
if(StringUtils.isNotBlank(profile.cape)){
|
|
||||||
p.capeUrl=root+TEXTURES+profile.cape;
|
|
||||||
if(local)
|
|
||||||
p.capeUrl=HttpTextureUtil.getLocalFakeUrl(p.capeUrl);
|
|
||||||
}
|
|
||||||
if(StringUtils.isNotBlank(profile.elytra)){
|
|
||||||
p.elytraUrl=root+TEXTURES+profile.elytra;
|
|
||||||
if(local)
|
|
||||||
p.elytraUrl=HttpTextureUtil.getLocalFakeUrl(p.elytraUrl);
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String,String> textures=new LinkedHashMap<String,String>();
|
|
||||||
if(profile.skins!=null)
|
|
||||||
textures.putAll(profile.skins);
|
|
||||||
if(profile.textures!=null)
|
|
||||||
textures.putAll(profile.textures);
|
|
||||||
if(textures.isEmpty())
|
|
||||||
return p;
|
|
||||||
|
|
||||||
boolean hasSkin=false;
|
|
||||||
for(String model:textures.keySet()){
|
|
||||||
Model enumModel=ModelManager0.getEnumModel(model);
|
|
||||||
if(enumModel==null||StringUtils.isEmpty(textures.get(model)))
|
|
||||||
continue;
|
|
||||||
if(ModelManager0.isSkin(enumModel))
|
|
||||||
if(hasSkin)
|
|
||||||
continue;
|
|
||||||
else
|
|
||||||
hasSkin=true;
|
|
||||||
String url=root+TEXTURES+textures.get(model);
|
|
||||||
if(local)
|
|
||||||
url=HttpTextureUtil.getLocalFakeUrl(url);
|
|
||||||
p.put(enumModel, url);
|
|
||||||
}
|
|
||||||
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
private class CustomSkinAPIProfile{
|
|
||||||
public String username;
|
|
||||||
public LinkedHashMap<String,String> textures;
|
|
||||||
|
|
||||||
public LinkedHashMap<String,String> skins;
|
|
||||||
|
|
||||||
public String skin;
|
|
||||||
public String cape;
|
|
||||||
public String elytra;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public String getPayload(SkinSiteProfile ssp) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return "CustomSkinAPI";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,82 +0,0 @@
|
|||||||
package customskinloader.loader.jsonapi;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import org.apache.commons.io.FileUtils;
|
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
|
|
||||||
import customskinloader.CustomSkinLoader;
|
|
||||||
import customskinloader.config.SkinSiteProfile;
|
|
||||||
import customskinloader.loader.JsonAPILoader;
|
|
||||||
import customskinloader.loader.JsonAPILoader.IJsonAPI;
|
|
||||||
import customskinloader.profile.UserProfile;
|
|
||||||
import customskinloader.utils.MinecraftUtil;
|
|
||||||
|
|
||||||
public class CustomSkinAPIPlus implements IJsonAPI {
|
|
||||||
|
|
||||||
private static String clientID=null;
|
|
||||||
public CustomSkinAPIPlus(){
|
|
||||||
File clientIDFile=new File(CustomSkinLoader.DATA_DIR,"CustomSkinAPIPlus-ClientID");
|
|
||||||
|
|
||||||
if(clientIDFile.isFile())
|
|
||||||
try{
|
|
||||||
clientID=FileUtils.readFileToString(clientIDFile);
|
|
||||||
}catch(Exception e){
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
if(clientID==null){
|
|
||||||
clientID=UUID.randomUUID().toString();
|
|
||||||
try {
|
|
||||||
FileUtils.write(clientIDFile, clientID);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public String toJsonUrl(String root, String username) {
|
|
||||||
return JsonAPILoader.Type.CustomSkinAPI.jsonAPI.toJsonUrl(root, username);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getPayload(SkinSiteProfile ssp) {
|
|
||||||
if(ssp.privacy==null)
|
|
||||||
ssp.privacy=new CustomSkinAPIPlusPrivacy();
|
|
||||||
return new Gson().toJson(new CustomSkinAPIPlusPayload(ssp.privacy));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UserProfile toUserProfile(String root, String json, boolean local) {
|
|
||||||
return JsonAPILoader.Type.CustomSkinAPI.jsonAPI.toUserProfile(root, json, local);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return "CustomSKinAPIPlus";
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class CustomSkinAPIPlusPayload{
|
|
||||||
public String gameVersion;//minecraft version
|
|
||||||
public String modVersion;//mod version
|
|
||||||
public String serverAddress;//ip:port
|
|
||||||
public String clientID;//Minecraft Client ID
|
|
||||||
public CustomSkinAPIPlusPayload(CustomSkinAPIPlusPrivacy privacy){
|
|
||||||
if(privacy.gameVersion)
|
|
||||||
gameVersion=MinecraftUtil.getMinecraftMainVersion();
|
|
||||||
if(privacy.modVersion)
|
|
||||||
modVersion=CustomSkinLoader.CustomSkinLoader_VERSION;
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,80 +0,0 @@
|
|||||||
package customskinloader.loader.jsonapi;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
|
|
||||||
import customskinloader.CustomSkinLoader;
|
|
||||||
import customskinloader.config.SkinSiteProfile;
|
|
||||||
import customskinloader.loader.JsonAPILoader.IJsonAPI;
|
|
||||||
import customskinloader.profile.ModelManager0;
|
|
||||||
import customskinloader.profile.UserProfile;
|
|
||||||
import customskinloader.profile.ModelManager0.Model;
|
|
||||||
import customskinloader.utils.HttpTextureUtil;
|
|
||||||
|
|
||||||
public class UniSkinAPI implements IJsonAPI {
|
|
||||||
private static final String TEXTURES="textures/";
|
|
||||||
private static final String SUFFIX=".json";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toJsonUrl(String root, String username) {
|
|
||||||
return new StringBuilder().append(root).append(username).append(SUFFIX).toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UserProfile toUserProfile(String root, String json, boolean local) {
|
|
||||||
UniSkinAPIProfile profile=CustomSkinLoader.GSON.fromJson(json, UniSkinAPIProfile.class);
|
|
||||||
UserProfile p=new UserProfile();
|
|
||||||
|
|
||||||
if(StringUtils.isNotBlank(profile.cape)){
|
|
||||||
p.capeUrl=root+TEXTURES+profile.cape;
|
|
||||||
if(local)
|
|
||||||
p.capeUrl=HttpTextureUtil.getLocalFakeUrl(p.capeUrl);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(profile.skins==null||profile.skins.isEmpty())
|
|
||||||
return p;
|
|
||||||
if(profile.model_preference==null||profile.model_preference.isEmpty())
|
|
||||||
return p;
|
|
||||||
|
|
||||||
boolean hasSkin=false;
|
|
||||||
for(String model:profile.model_preference){
|
|
||||||
Model enumModel=ModelManager0.getEnumModel(model);
|
|
||||||
if(enumModel==null||StringUtils.isEmpty(profile.skins.get(model)))
|
|
||||||
continue;
|
|
||||||
if(ModelManager0.isSkin(enumModel))
|
|
||||||
if(hasSkin)
|
|
||||||
continue;
|
|
||||||
else
|
|
||||||
hasSkin=true;
|
|
||||||
String url=root+TEXTURES+profile.skins.get(model);
|
|
||||||
if(local)
|
|
||||||
url=HttpTextureUtil.getLocalFakeUrl(url);
|
|
||||||
p.put(enumModel, url);
|
|
||||||
}
|
|
||||||
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Json profile for UniSkinAPI
|
|
||||||
* Source Code: https://github.com/RecursiveG/UniSkinMod/blob/master/src/main/java/org/devinprogress/uniskinmod/UniSkinApiProfile.java#L18-L22
|
|
||||||
* @author RecursiveG
|
|
||||||
*/
|
|
||||||
private class UniSkinAPIProfile{
|
|
||||||
public String player_name;
|
|
||||||
public long last_update;
|
|
||||||
public List<String> model_preference;
|
|
||||||
public Map<String,String> skins;
|
|
||||||
|
|
||||||
public String cape;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public String getPayload(SkinSiteProfile ssp) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return "UniSkinAPI";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,163 +0,0 @@
|
|||||||
package customskinloader.profile;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import org.apache.commons.codec.Charsets;
|
|
||||||
import org.apache.commons.codec.binary.Base64;
|
|
||||||
import org.apache.commons.io.FileUtils;
|
|
||||||
import org.apache.commons.io.FilenameUtils;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
|
|
||||||
import com.google.common.collect.Iterables;
|
|
||||||
import com.google.common.collect.Maps;
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.google.gson.GsonBuilder;
|
|
||||||
import com.mojang.authlib.GameProfile;
|
|
||||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
|
||||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
|
|
||||||
import com.mojang.authlib.properties.Property;
|
|
||||||
import com.mojang.util.UUIDTypeAdapter;
|
|
||||||
|
|
||||||
import customskinloader.CustomSkinLoader;
|
|
||||||
import customskinloader.utils.HttpRequestUtil;
|
|
||||||
import customskinloader.utils.HttpRequestUtil.HttpRequest;
|
|
||||||
import customskinloader.utils.HttpRequestUtil.HttpResponce;
|
|
||||||
import customskinloader.utils.HttpTextureUtil;
|
|
||||||
import customskinloader.utils.HttpUtil0;
|
|
||||||
|
|
||||||
public class DynamicSkullManager {
|
|
||||||
public static class SkullTexture{
|
|
||||||
public Map<Type,MinecraftProfileTexture> textures;
|
|
||||||
public String index;//Index File
|
|
||||||
public ArrayList<String> skins;
|
|
||||||
public int interval;
|
|
||||||
public boolean fromZero;
|
|
||||||
//For program
|
|
||||||
public long startTime;
|
|
||||||
public int period;
|
|
||||||
}
|
|
||||||
private Map<GameProfile,SkullTexture> dynamicTextures=new HashMap<GameProfile,SkullTexture>();
|
|
||||||
private Map<GameProfile,Map<Type,MinecraftProfileTexture>> staticTextures=new HashMap<GameProfile,Map<Type,MinecraftProfileTexture>>();
|
|
||||||
private List<GameProfile> loadingList=new ArrayList<GameProfile>();
|
|
||||||
|
|
||||||
private void parseGameProfile(GameProfile profile){
|
|
||||||
Property textureProperty=(Property)Iterables.getFirst(profile.getProperties().get("textures"), null);
|
|
||||||
if (textureProperty==null){
|
|
||||||
staticTextures.put(profile, new HashMap());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
String value=textureProperty.getValue();
|
|
||||||
if(StringUtils.isBlank(value)){
|
|
||||||
staticTextures.put(profile, new HashMap());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
String json=new String(Base64.decodeBase64(value),Charsets.UTF_8);
|
|
||||||
Gson gson=new GsonBuilder().registerTypeAdapter(UUID.class,new UUIDTypeAdapter()).create();
|
|
||||||
SkullTexture result=gson.fromJson(json,SkullTexture.class);
|
|
||||||
if(result==null){
|
|
||||||
staticTextures.put(profile, new HashMap());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
staticTextures.put(profile, (result.textures==null||!result.textures.containsKey(Type.SKIN))?new HashMap():parseTextures(result.textures));
|
|
||||||
|
|
||||||
if(StringUtils.isNotEmpty(result.index)){
|
|
||||||
File indexFile=new File(CustomSkinLoader.DATA_DIR,result.index);
|
|
||||||
try{
|
|
||||||
String index=FileUtils.readFileToString(indexFile, Charsets.UTF_8);
|
|
||||||
if(StringUtils.isNotEmpty(index)){
|
|
||||||
ArrayList<String> skins=CustomSkinLoader.GSON.fromJson(index, ArrayList.class);
|
|
||||||
if(skins!=null&&!skins.isEmpty())
|
|
||||||
result.skins=skins;
|
|
||||||
}
|
|
||||||
}catch(Exception e){
|
|
||||||
CustomSkinLoader.logger.warning("Exception occurs while parsing index file: "+e.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!CustomSkinLoader.config.enableDynamicSkull||result.skins==null||result.skins.isEmpty())
|
|
||||||
return;
|
|
||||||
|
|
||||||
CustomSkinLoader.logger.info("Try to load Dynamic Skull: "+json);
|
|
||||||
|
|
||||||
for(int i=0;i<result.skins.size();i++){//check and cache skins
|
|
||||||
String skin=result.skins.get(i);
|
|
||||||
if(HttpUtil0.isLocal(skin)){
|
|
||||||
//Local Skin
|
|
||||||
File skinFile=new File(CustomSkinLoader.DATA_DIR,skin);
|
|
||||||
if(skinFile.isFile()&&skinFile.length()>0){
|
|
||||||
//Skin found
|
|
||||||
String fakeUrl=HttpTextureUtil.getLocalFakeUrl(skin);
|
|
||||||
result.skins.set(i, fakeUrl);
|
|
||||||
}else{
|
|
||||||
//Could not find skin
|
|
||||||
result.skins.remove(i--);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
//Online Skin
|
|
||||||
HttpResponce responce=HttpRequestUtil.makeHttpRequest(new HttpRequest(skin).setCacheFile(HttpTextureUtil.getCacheFile(FilenameUtils.getBaseName(skin))).setCacheTime(0).setLoadContent(false));
|
|
||||||
if(!responce.success){
|
|
||||||
//Could not load skin
|
|
||||||
result.skins.remove(i--);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(result.skins.isEmpty()){//Nothing loaded
|
|
||||||
CustomSkinLoader.logger.info("Failed: Nothing loaded.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
result.interval=Math.max(result.interval, 50);
|
|
||||||
if(result.fromZero)
|
|
||||||
result.startTime=System.currentTimeMillis();
|
|
||||||
result.period=result.interval*result.skins.size();
|
|
||||||
CustomSkinLoader.logger.info("Successfully loaded Dynamic Skull: "+new Gson().toJson(result));
|
|
||||||
dynamicTextures.put(profile, result);
|
|
||||||
staticTextures.remove(profile);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Support local skin for skull
|
|
||||||
public Map<Type, MinecraftProfileTexture> parseTextures(Map<Type, MinecraftProfileTexture> textures) {
|
|
||||||
MinecraftProfileTexture skin=textures.get(Type.SKIN);
|
|
||||||
String skinUrl=skin.getUrl();
|
|
||||||
if(!HttpUtil0.isLocal(skinUrl))
|
|
||||||
return textures;
|
|
||||||
File skinFile=new File(CustomSkinLoader.DATA_DIR,skinUrl);
|
|
||||||
if(!skinFile.isFile())
|
|
||||||
return new HashMap();
|
|
||||||
textures.put(Type.SKIN, ModelManager0.getProfileTexture(HttpTextureUtil.getLocalFakeUrl(skinUrl), null));
|
|
||||||
return textures;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map<Type,MinecraftProfileTexture> getTexture(final GameProfile profile){
|
|
||||||
if(staticTextures.get(profile)!=null)
|
|
||||||
return staticTextures.get(profile);
|
|
||||||
if(loadingList.contains(profile))
|
|
||||||
return new HashMap();
|
|
||||||
if(dynamicTextures.containsKey(profile)){
|
|
||||||
SkullTexture texture=dynamicTextures.get(profile);
|
|
||||||
long time=System.currentTimeMillis()-texture.startTime;
|
|
||||||
int index=(int)Math.floor((time%texture.period)/texture.interval);
|
|
||||||
Map<Type,MinecraftProfileTexture> map=Maps.newHashMap();
|
|
||||||
map.put(Type.SKIN, ModelManager0.getProfileTexture(texture.skins.get(index), null));
|
|
||||||
return map;
|
|
||||||
}
|
|
||||||
|
|
||||||
loadingList.add(profile);
|
|
||||||
Thread loadThread=new Thread(){
|
|
||||||
public void run(){
|
|
||||||
parseGameProfile(profile);//Load in thread
|
|
||||||
loadingList.remove(profile);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
loadThread.setName("Skull "+profile.hashCode());
|
|
||||||
loadThread.start();
|
|
||||||
return new HashMap();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,121 +0,0 @@
|
|||||||
package customskinloader.profile;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
|
|
||||||
import com.google.common.collect.Maps;
|
|
||||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
|
||||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Model Manager for 1.8 and higher.
|
|
||||||
* A manager to check if model is available.
|
|
||||||
* It is the only class in package 'customskinloader' which has differences in different Minecraft version.
|
|
||||||
* @since 13.1
|
|
||||||
*/
|
|
||||||
public class ModelManager0 {
|
|
||||||
public static enum Model{
|
|
||||||
SKIN_DEFAULT,
|
|
||||||
SKIN_SLIM,
|
|
||||||
CAPE,
|
|
||||||
ELYTRA
|
|
||||||
}
|
|
||||||
private static HashMap<String,Model> models=new HashMap<String,Model>();
|
|
||||||
private static Type typeElytra=null;
|
|
||||||
static{
|
|
||||||
for(Type type:Type.values()){
|
|
||||||
if(type.ordinal()==2)//ELYTRA
|
|
||||||
typeElytra=type;
|
|
||||||
}
|
|
||||||
models.put("default", Model.SKIN_DEFAULT);
|
|
||||||
models.put("slim", Model.SKIN_SLIM);
|
|
||||||
models.put("cape", Model.CAPE);
|
|
||||||
if(typeElytra!=null)
|
|
||||||
models.put("elytra", Model.ELYTRA);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get enum for the model.
|
|
||||||
* @param model - string model
|
|
||||||
* @since 14.5
|
|
||||||
*/
|
|
||||||
public static Model getEnumModel(String model){
|
|
||||||
return models.get(model);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if model is skin.
|
|
||||||
* @since 14.5
|
|
||||||
* */
|
|
||||||
public static boolean isSkin(Model model){
|
|
||||||
return model==Model.SKIN_DEFAULT||model==Model.SKIN_SLIM;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if elytra is supported.
|
|
||||||
* @since 14.5
|
|
||||||
*/
|
|
||||||
public static boolean isElytraSupported(){
|
|
||||||
return typeElytra!=null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Parse hashMapProfile to UserProfile
|
|
||||||
* @param profile - hashMapProfile (HashMap<String,MinecraftProfileTexture>)
|
|
||||||
* @return profile - UserProfile instance
|
|
||||||
* @since 13.1
|
|
||||||
*/
|
|
||||||
public static UserProfile toUserProfile(Map profile){
|
|
||||||
UserProfile userProfile=new UserProfile();
|
|
||||||
if(profile==null)
|
|
||||||
return userProfile;
|
|
||||||
MinecraftProfileTexture skin=(MinecraftProfileTexture)profile.get(Type.SKIN);
|
|
||||||
userProfile.skinUrl= skin==null?null:skin.getUrl();//Avoid NullPointerException
|
|
||||||
userProfile.model= skin==null?null:skin.getMetadata("model");
|
|
||||||
if(StringUtils.isEmpty(userProfile.model))
|
|
||||||
userProfile.model="default";
|
|
||||||
|
|
||||||
MinecraftProfileTexture cape=(MinecraftProfileTexture)profile.get(Type.CAPE);
|
|
||||||
userProfile.capeUrl= cape==null?null:cape.getUrl();
|
|
||||||
return userProfile;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Parse UserProfile to hashMapProfile
|
|
||||||
* @param profile - UserProfile instance
|
|
||||||
* @return profile - hashMapProfile (HashMap<String,MinecraftProfileTexture>)
|
|
||||||
* @since 13.1
|
|
||||||
*/
|
|
||||||
public static Map fromUserProfile(UserProfile profile){
|
|
||||||
Map map=Maps.newHashMap();
|
|
||||||
if(profile==null)
|
|
||||||
return map;
|
|
||||||
if(profile.skinUrl!=null){
|
|
||||||
Map metadata=null;
|
|
||||||
if(profile.model!=null&&profile.model.equals("slim")){
|
|
||||||
metadata = Maps.newHashMap();
|
|
||||||
metadata.put("model", "slim");
|
|
||||||
}
|
|
||||||
map.put(Type.SKIN, getProfileTexture(profile.skinUrl,metadata));
|
|
||||||
}
|
|
||||||
if(profile.capeUrl!=null)
|
|
||||||
map.put(Type.CAPE, getProfileTexture(profile.capeUrl,null));
|
|
||||||
if(typeElytra!=null && profile.elytraUrl!=null)
|
|
||||||
map.put(typeElytra, getProfileTexture(profile.elytraUrl,null));
|
|
||||||
return map;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Parse url to MinecraftProfileTexture
|
|
||||||
*
|
|
||||||
* @param url - textureUrl
|
|
||||||
* metadata - metadata
|
|
||||||
* @return MinecraftProfileTexture
|
|
||||||
* @since 14.5
|
|
||||||
*/
|
|
||||||
public static MinecraftProfileTexture getProfileTexture(String url,Map metadata){
|
|
||||||
return new MinecraftProfileTexture(url,metadata);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,106 +0,0 @@
|
|||||||
package customskinloader.profile;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
import org.apache.commons.io.IOUtils;
|
|
||||||
|
|
||||||
import customskinloader.CustomSkinLoader;
|
|
||||||
import customskinloader.utils.TimeUtil;
|
|
||||||
|
|
||||||
public class 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,UserProfile> localProfiles=new HashMap<String,UserProfile>();
|
|
||||||
|
|
||||||
public ProfileCache(){
|
|
||||||
if(!PROFILE_CACHE_DIR.exists())
|
|
||||||
PROFILE_CACHE_DIR.mkdir();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isExist(String username){
|
|
||||||
return cachedProfiles.containsKey(username.toLowerCase());
|
|
||||||
}
|
|
||||||
public boolean isReady(String username){
|
|
||||||
CachedProfile cp=cachedProfiles.get(username.toLowerCase());
|
|
||||||
return cp==null?false:(cp.loading||cp.expiryTime>TimeUtil.getCurrentUnixTimestamp());
|
|
||||||
}
|
|
||||||
public boolean isExpired(String username){
|
|
||||||
CachedProfile cp=cachedProfiles.get(username.toLowerCase());
|
|
||||||
return cp==null?true:(cp.expiryTime<=TimeUtil.getCurrentUnixTimestamp());
|
|
||||||
}
|
|
||||||
|
|
||||||
public UserProfile getProfile(String username){
|
|
||||||
return getCachedProfile(username).profile;
|
|
||||||
}
|
|
||||||
public long getExpiry(String username){
|
|
||||||
return getCachedProfile(username).expiryTime;
|
|
||||||
}
|
|
||||||
public UserProfile getLocalProfile(String username){
|
|
||||||
if(localProfiles.containsKey(username.toLowerCase()))
|
|
||||||
return localProfiles.get(username.toLowerCase());
|
|
||||||
return loadLocalProfile(username);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLoading(String username,boolean loading){
|
|
||||||
getCachedProfile(username).loading=loading;
|
|
||||||
}
|
|
||||||
public void updateCache(String username,UserProfile profile){
|
|
||||||
updateCache(username,profile,CustomSkinLoader.config.enableLocalProfileCache);
|
|
||||||
}
|
|
||||||
public void updateCache(String username,UserProfile profile,boolean saveLocalProfile){
|
|
||||||
CachedProfile cp=getCachedProfile(username);
|
|
||||||
cp.profile=profile;
|
|
||||||
cp.expiryTime=TimeUtil.getUnixTimestampRandomDelay(CustomSkinLoader.config.cacheExpiry);
|
|
||||||
if(!saveLocalProfile)
|
|
||||||
return;
|
|
||||||
saveLocalProfile(username,profile);
|
|
||||||
}
|
|
||||||
|
|
||||||
private CachedProfile getCachedProfile(String username){
|
|
||||||
CachedProfile cp=cachedProfiles.get(username.toLowerCase());
|
|
||||||
if(cp!=null)
|
|
||||||
return cp;
|
|
||||||
cp=new CachedProfile();
|
|
||||||
cachedProfiles.put(username.toLowerCase(), cp);
|
|
||||||
return cp;
|
|
||||||
}
|
|
||||||
private UserProfile loadLocalProfile(String username){
|
|
||||||
File localProfile=new File(PROFILE_CACHE_DIR,username.toLowerCase()+".json");
|
|
||||||
if(!localProfile.exists()){
|
|
||||||
localProfiles.put(username.toLowerCase(), null);
|
|
||||||
}
|
|
||||||
try{
|
|
||||||
String json=IOUtils.toString(new FileInputStream(localProfile));
|
|
||||||
UserProfile profile=CustomSkinLoader.GSON.fromJson(json, UserProfile.class);
|
|
||||||
localProfiles.put(username.toLowerCase(), profile);
|
|
||||||
CustomSkinLoader.logger.info("Successfully load LocalProfile.");
|
|
||||||
return profile;
|
|
||||||
}catch(Exception e){
|
|
||||||
CustomSkinLoader.logger.info("Failed to load LocalProfile.("+e.toString()+")");
|
|
||||||
localProfiles.put(username.toLowerCase(), null);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
private void saveLocalProfile(String username,UserProfile profile){
|
|
||||||
String json=CustomSkinLoader.GSON.toJson(profile);
|
|
||||||
File localProfile=new File(PROFILE_CACHE_DIR,username+".json");
|
|
||||||
if(localProfile.exists())
|
|
||||||
localProfile.delete();
|
|
||||||
try {
|
|
||||||
localProfile.createNewFile();
|
|
||||||
IOUtils.write(json, new FileOutputStream(localProfile));
|
|
||||||
CustomSkinLoader.logger.info("Successfully save LocalProfile.");
|
|
||||||
} catch (Exception e) {
|
|
||||||
CustomSkinLoader.logger.info("Failed to save LocalProfile.("+e.toString()+")");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
class CachedProfile{
|
|
||||||
public UserProfile profile;
|
|
||||||
public long expiryTime=0;
|
|
||||||
public boolean loading=false;
|
|
||||||
}
|
|
||||||
@@ -1,102 +0,0 @@
|
|||||||
package customskinloader.profile;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
|
|
||||||
import customskinloader.profile.ModelManager0.Model;
|
|
||||||
|
|
||||||
/**The instance to storage user's profile in memory temporarily.
|
|
||||||
* In this manner, it could be easier to pass profile in program.
|
|
||||||
* @since 13.1
|
|
||||||
*/
|
|
||||||
public class UserProfile {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Direct url for skin.
|
|
||||||
* @since 13.1
|
|
||||||
*/
|
|
||||||
public String skinUrl=null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Model for skin.
|
|
||||||
* default/slim
|
|
||||||
* @since 13.1
|
|
||||||
*/
|
|
||||||
public String model=null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Direct url for cape.
|
|
||||||
* @since 13.1
|
|
||||||
*/
|
|
||||||
public String capeUrl=null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Direct url for elytra.
|
|
||||||
* @since 14.5
|
|
||||||
*/
|
|
||||||
public String elytraUrl=null;
|
|
||||||
|
|
||||||
public void put(Model model,String url){
|
|
||||||
if(model==null||StringUtils.isEmpty(url))
|
|
||||||
return;
|
|
||||||
switch(model){
|
|
||||||
case SKIN_DEFAULT:
|
|
||||||
this.skinUrl=url;
|
|
||||||
this.model="default";
|
|
||||||
return;
|
|
||||||
case SKIN_SLIM:
|
|
||||||
this.skinUrl=url;
|
|
||||||
this.model="slim";
|
|
||||||
return;
|
|
||||||
case CAPE:
|
|
||||||
this.capeUrl=url;
|
|
||||||
return;
|
|
||||||
case ELYTRA:
|
|
||||||
this.capeUrl=url;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get parsed String to output the instance.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public String toString(){
|
|
||||||
return toString(0);
|
|
||||||
}
|
|
||||||
public String toString(long expiry){
|
|
||||||
return "(SkinUrl: "+skinUrl+
|
|
||||||
" , Model: "+model+
|
|
||||||
" , CapeUrl: "+capeUrl+
|
|
||||||
(StringUtils.isBlank(elytraUrl)?" ":" , ElytraUrl: "+elytraUrl)+
|
|
||||||
(expiry==0?"":(" , Expiry: "+expiry))+")";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if the instance is empty.
|
|
||||||
* @return status (true - empty)
|
|
||||||
*/
|
|
||||||
public boolean isEmpty(){
|
|
||||||
return StringUtils.isEmpty(skinUrl) && StringUtils.isEmpty(capeUrl) && StringUtils.isEmpty(elytraUrl);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Check if the instance is full(Both skin and cape).
|
|
||||||
* @return status (true - full)
|
|
||||||
* @since 14.7
|
|
||||||
*/
|
|
||||||
public boolean isFull(){
|
|
||||||
return StringUtils.isNoneBlank(skinUrl,capeUrl);
|
|
||||||
}
|
|
||||||
public boolean hasSkinUrl(){
|
|
||||||
return StringUtils.isNotEmpty(skinUrl);
|
|
||||||
}
|
|
||||||
public void mix(UserProfile profile){
|
|
||||||
if(profile==null)
|
|
||||||
return;
|
|
||||||
if(StringUtils.isEmpty(this.skinUrl))
|
|
||||||
this.skinUrl=profile.skinUrl;
|
|
||||||
if(StringUtils.isEmpty(this.capeUrl))
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,213 +0,0 @@
|
|||||||
package customskinloader.utils;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.OutputStream;
|
|
||||||
import java.net.HttpURLConnection;
|
|
||||||
import java.net.URI;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
import java.util.zip.GZIPInputStream;
|
|
||||||
|
|
||||||
import org.apache.commons.codec.digest.DigestUtils;
|
|
||||||
import org.apache.commons.io.Charsets;
|
|
||||||
import org.apache.commons.io.FileUtils;
|
|
||||||
import org.apache.commons.io.IOUtils;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
|
|
||||||
import customskinloader.CustomSkinLoader;
|
|
||||||
|
|
||||||
public class HttpRequestUtil {
|
|
||||||
public static class HttpRequest{
|
|
||||||
public String url;
|
|
||||||
public String userAgent=null;
|
|
||||||
public String payload=null;
|
|
||||||
public boolean loadContent=true;
|
|
||||||
public boolean checkPNG=false;
|
|
||||||
|
|
||||||
public int cacheTime=600;//-1=No Cache 0=Always Cache t=Default Cache Time(second)
|
|
||||||
public File cacheFile=null;//Default Cache File
|
|
||||||
|
|
||||||
public HttpRequest(String url){
|
|
||||||
this.url=url;
|
|
||||||
}
|
|
||||||
public HttpRequest setUserAgent(String userAgent){
|
|
||||||
this.userAgent=userAgent;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
public HttpRequest setPayload(String payload){
|
|
||||||
this.payload=payload;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
public HttpRequest setLoadContent(boolean loadContent){
|
|
||||||
this.loadContent=loadContent;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
public HttpRequest setCheckPNG(boolean checkPNG){
|
|
||||||
this.checkPNG=checkPNG;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
public HttpRequest setCacheTime(int cacheTime){
|
|
||||||
this.cacheTime=cacheTime;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
public HttpRequest setCacheFile(File cacheFile){
|
|
||||||
this.cacheFile=cacheFile;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public static class HttpResponce{
|
|
||||||
public String content=null;
|
|
||||||
public int responceCode=-1;
|
|
||||||
public boolean success=false;
|
|
||||||
public boolean fromCache=false;
|
|
||||||
}
|
|
||||||
public static class CacheInfo{
|
|
||||||
public String url;
|
|
||||||
public String etag=null;
|
|
||||||
|
|
||||||
public long lastModified=-1;//ms
|
|
||||||
public long expire=-1;//UNIX timestamp
|
|
||||||
}
|
|
||||||
public static final File CACHE_DIR=new File(CustomSkinLoader.DATA_DIR,"caches");
|
|
||||||
|
|
||||||
public static HttpResponce makeHttpRequest(HttpRequest request){
|
|
||||||
try{
|
|
||||||
CustomSkinLoader.logger.debug("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
|
|
||||||
String url=new URI(request.url).toASCIIString();
|
|
||||||
if(!url.equalsIgnoreCase(request.url))
|
|
||||||
CustomSkinLoader.logger.debug("Encoded URL: "+url);
|
|
||||||
HttpURLConnection c = (HttpURLConnection) (new URL(url)).openConnection();
|
|
||||||
c.setReadTimeout(1000 * 10);
|
|
||||||
c.setConnectTimeout(1000 * 10);
|
|
||||||
c.setDoInput(true);
|
|
||||||
c.setUseCaches(false);
|
|
||||||
c.setInstanceFollowRedirects(true);
|
|
||||||
|
|
||||||
//Make Connection
|
|
||||||
if(cacheInfo.lastModified>=0)
|
|
||||||
c.setIfModifiedSince(cacheInfo.lastModified);
|
|
||||||
if(cacheInfo.etag!=null)
|
|
||||||
c.setRequestProperty("If-None-Match",cacheInfo.etag);
|
|
||||||
c.setRequestProperty("Accept-Encoding","gzip");
|
|
||||||
if(request.userAgent!=null)
|
|
||||||
c.setRequestProperty("User-Agent",request.userAgent);
|
|
||||||
if(StringUtils.isNotEmpty(request.payload)){
|
|
||||||
CustomSkinLoader.logger.info("Payload: "+request.payload);
|
|
||||||
c.setDoOutput(true);
|
|
||||||
OutputStream os=c.getOutputStream();
|
|
||||||
IOUtils.write(request.payload, os);
|
|
||||||
IOUtils.closeQuietly(os);
|
|
||||||
}
|
|
||||||
c.connect();
|
|
||||||
|
|
||||||
//Check Connection
|
|
||||||
HttpResponce responce=new HttpResponce();
|
|
||||||
responce.responceCode=c.getResponseCode();
|
|
||||||
int res=c.getResponseCode()/100;
|
|
||||||
if(res==4||res==5){//Failed
|
|
||||||
CustomSkinLoader.logger.debug("Failed to request (Response Code: "+c.getResponseCode()+")");
|
|
||||||
return responce;
|
|
||||||
}
|
|
||||||
responce.success=true;
|
|
||||||
CustomSkinLoader.logger.debug("Successfully request (Response Code: "+c.getResponseCode()+" , Content Length: "+c.getContentLength()+")");
|
|
||||||
if(responce.responceCode==HttpURLConnection.HTTP_NOT_MODIFIED)
|
|
||||||
return loadFromCache(request,responce);
|
|
||||||
|
|
||||||
//Load Content
|
|
||||||
InputStream is="gzip".equals(c.getContentEncoding())?new GZIPInputStream(c.getInputStream()):c.getInputStream();
|
|
||||||
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));
|
|
||||||
}
|
|
||||||
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,Charsets.UTF_8);
|
|
||||||
CustomSkinLoader.logger.debug("Content: "+responce.content);
|
|
||||||
return responce;
|
|
||||||
|
|
||||||
}catch(Exception e){
|
|
||||||
CustomSkinLoader.logger.debug("Failed to request (Exception: "+e.toString()+")");
|
|
||||||
return loadFromCache(request,new HttpResponce());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static File getCacheFile(String hash){
|
|
||||||
return new File(CACHE_DIR,hash);
|
|
||||||
}
|
|
||||||
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.debug("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()+"'.");
|
|
||||||
try {
|
|
||||||
responce.content=FileUtils.readFileToString(request.cacheFile);
|
|
||||||
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!=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);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,82 +0,0 @@
|
|||||||
package customskinloader.utils;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
import org.apache.commons.codec.digest.DigestUtils;
|
|
||||||
import org.apache.commons.io.FilenameUtils;
|
|
||||||
|
|
||||||
import customskinloader.CustomSkinLoader;
|
|
||||||
|
|
||||||
public class HttpTextureUtil {
|
|
||||||
public static class HttpTextureInfo{
|
|
||||||
public String url="";
|
|
||||||
public File cacheFile;
|
|
||||||
public String hash;
|
|
||||||
}
|
|
||||||
private static final String
|
|
||||||
LEGACY_MARK="(LEGACY)",
|
|
||||||
LOCAL_MARK="(LOCAL)",
|
|
||||||
LOCAL_LEGACY_MARK="(LOCAL_LEGACY)";
|
|
||||||
public static File defaultCacheDir;
|
|
||||||
public static void cleanCacheDir(){
|
|
||||||
if(defaultCacheDir!=null){
|
|
||||||
defaultCacheDir.delete();
|
|
||||||
defaultCacheDir.mkdirs();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public static File getCacheDir(){
|
|
||||||
return defaultCacheDir==null?new File(MinecraftUtil.getMinecraftDataDir(),"assets/skins"):defaultCacheDir;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static HttpTextureInfo toHttpTextureInfo(String fakeUrl){
|
|
||||||
HttpTextureInfo info=new HttpTextureInfo();
|
|
||||||
if(fakeUrl.startsWith("http")){
|
|
||||||
info.url=fakeUrl;
|
|
||||||
info.hash=FilenameUtils.getBaseName(fakeUrl);
|
|
||||||
info.cacheFile=getCacheFile(info.hash);
|
|
||||||
return info;
|
|
||||||
}
|
|
||||||
if(fakeUrl.startsWith(LOCAL_LEGACY_MARK)){
|
|
||||||
fakeUrl=fakeUrl.replace(LOCAL_LEGACY_MARK, "");
|
|
||||||
String[] t=fakeUrl.split(",",2);
|
|
||||||
if(t.length!=2)
|
|
||||||
return info;
|
|
||||||
info.cacheFile=new File(CustomSkinLoader.DATA_DIR,t[1]);
|
|
||||||
info.hash=t[0];
|
|
||||||
return info;
|
|
||||||
}
|
|
||||||
if(fakeUrl.startsWith(LOCAL_MARK)){
|
|
||||||
fakeUrl=fakeUrl.replace(LOCAL_MARK, "");
|
|
||||||
info.cacheFile=new File(CustomSkinLoader.DATA_DIR,fakeUrl);
|
|
||||||
info.hash=FilenameUtils.getBaseName(fakeUrl);
|
|
||||||
return info;
|
|
||||||
}
|
|
||||||
if(fakeUrl.startsWith(LEGACY_MARK)){
|
|
||||||
fakeUrl=fakeUrl.replace(LEGACY_MARK, "");
|
|
||||||
info.url=fakeUrl;
|
|
||||||
info.hash=DigestUtils.sha1Hex(info.url);;
|
|
||||||
info.cacheFile=HttpTextureUtil.getCacheFile(info.hash);
|
|
||||||
return info;
|
|
||||||
}
|
|
||||||
return info;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getLegacyFakeUrl(String url){
|
|
||||||
return LEGACY_MARK+url;
|
|
||||||
}
|
|
||||||
public static String getLocalFakeUrl(String path){
|
|
||||||
return LOCAL_MARK+path;
|
|
||||||
}
|
|
||||||
public static String getLocalLegacyFakeUrl(String path,String hash){
|
|
||||||
return LOCAL_LEGACY_MARK+hash+","+path;
|
|
||||||
}
|
|
||||||
public static String getHash(String url,long size,long lastModified){
|
|
||||||
return DigestUtils.sha1Hex(size+url+lastModified);
|
|
||||||
}
|
|
||||||
public static File getCacheFile(String hash){
|
|
||||||
return getCacheFile(defaultCacheDir,hash);
|
|
||||||
}
|
|
||||||
public static File getCacheFile(File cacheDir,String hash){
|
|
||||||
return new File(new File(cacheDir,hash.length()>2?hash.substring(0,2):"xx"), hash);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,79 +0,0 @@
|
|||||||
package customskinloader.utils;
|
|
||||||
|
|
||||||
import java.net.InetAddress;
|
|
||||||
import java.net.UnknownHostException;
|
|
||||||
import java.security.cert.X509Certificate;
|
|
||||||
|
|
||||||
import javax.net.ssl.HostnameVerifier;
|
|
||||||
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;
|
|
||||||
|
|
||||||
public class HttpUtil0 {
|
|
||||||
public static boolean isLocal(String url){
|
|
||||||
return url==null? false : !url.startsWith("http");
|
|
||||||
}
|
|
||||||
|
|
||||||
//From: http://blog.csdn.net/xiyushiyi/article/details/46685387
|
|
||||||
public static void ignoreHttpsCertificate(){
|
|
||||||
HostnameVerifier doNotVerify = new HostnameVerifier() {
|
|
||||||
|
|
||||||
public boolean verify(String hostname, SSLSession session) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
TrustManager[] trustAllCerts = new TrustManager[] {new X509TrustManager() {
|
|
||||||
public X509Certificate[] getAcceptedIssuers() {
|
|
||||||
return new X509Certificate[] {};
|
|
||||||
}
|
|
||||||
public void checkClientTrusted(X509Certificate[] chain, String authType){}
|
|
||||||
public void checkServerTrusted(X509Certificate[] chain, String authType){}
|
|
||||||
}};
|
|
||||||
|
|
||||||
try {
|
|
||||||
SSLContext sc = SSLContext.getInstance("TLS");
|
|
||||||
sc.init(null, trustAllCerts, new java.security.SecureRandom());
|
|
||||||
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
|
|
||||||
HttpsURLConnection.setDefaultHostnameVerifier(doNotVerify);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String parseAddress(String address) {
|
|
||||||
if(StringUtils.isEmpty(address))
|
|
||||||
return null;
|
|
||||||
String[] addresses=address.split(":");
|
|
||||||
InetAddress add;
|
|
||||||
try {
|
|
||||||
add = InetAddress.getByName(addresses[0]);
|
|
||||||
} catch (UnknownHostException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return add.getHostAddress()+(addresses.length==2 ? addresses[1] : "25565");
|
|
||||||
}
|
|
||||||
public static boolean isLanServer(String standardAddress){
|
|
||||||
if(StringUtils.isEmpty(standardAddress))
|
|
||||||
return true;
|
|
||||||
String[] addresses=standardAddress.split(":");
|
|
||||||
int numIp=getNumIp(addresses[0]);
|
|
||||||
return numIp==0||numIp==getNumIp("127.0.0.1")||
|
|
||||||
(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("172.16.0.0")&&numIp<=getNumIp("172.31.255.255"));
|
|
||||||
}
|
|
||||||
public static int getNumIp(String ip){
|
|
||||||
int num=0;
|
|
||||||
String[] ips=ip.split("\\.");
|
|
||||||
if(ips.length!=4)
|
|
||||||
return 0;
|
|
||||||
for(int i=0;i<4;i++)
|
|
||||||
num+=Integer.parseInt(ips[i])*(256^(3-i));
|
|
||||||
return num;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,130 +0,0 @@
|
|||||||
package customskinloader.utils;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.net.URLClassLoader;
|
|
||||||
import java.net.URLDecoder;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
|
|
||||||
import com.mojang.authlib.GameProfile;
|
|
||||||
import com.mojang.authlib.minecraft.MinecraftSessionService;
|
|
||||||
|
|
||||||
import net.minecraft.client.renderer.texture.TextureManager;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Alexander Xia
|
|
||||||
* @since 13.6
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class MinecraftUtil {
|
|
||||||
public static File getMinecraftDataDir(){
|
|
||||||
return net.minecraft.client.Minecraft.getMinecraft().mcDataDir;
|
|
||||||
}
|
|
||||||
public static MinecraftSessionService getSessionService(){
|
|
||||||
return net.minecraft.client.Minecraft.getMinecraft().getSessionService();
|
|
||||||
}
|
|
||||||
public static TextureManager getTextureManager(){
|
|
||||||
return net.minecraft.client.Minecraft.getMinecraft().getTextureManager();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static ArrayList<String> minecraftVersion=new ArrayList<String>();
|
|
||||||
private static String minecraftMainVersion=null;
|
|
||||||
private final static Pattern MINECRAFT_VERSION_PATTERN = Pattern.compile(".*?(\\d+\\.\\d+[\\.]?\\d*).*?");
|
|
||||||
public static ArrayList<String> getMinecraftVersions(){
|
|
||||||
if(minecraftVersion!=null&&!minecraftVersion.isEmpty())
|
|
||||||
return minecraftVersion;
|
|
||||||
testProbe();
|
|
||||||
return minecraftVersion;
|
|
||||||
}
|
|
||||||
public static String getMinecraftVersionText(){
|
|
||||||
StringBuilder sb=new StringBuilder();
|
|
||||||
for(String version:getMinecraftVersions())
|
|
||||||
sb.append(version).append(" ");
|
|
||||||
return StringUtils.trim(sb.toString());
|
|
||||||
}
|
|
||||||
public static String getMinecraftMainVersion(){
|
|
||||||
if(minecraftMainVersion!=null)
|
|
||||||
return minecraftMainVersion;
|
|
||||||
for(String version:getMinecraftVersions()){
|
|
||||||
Matcher m = null;
|
|
||||||
try{
|
|
||||||
m=MINECRAFT_VERSION_PATTERN.matcher(version);
|
|
||||||
}catch(Exception e){
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
if(m==null || !m.matches())
|
|
||||||
continue;
|
|
||||||
minecraftMainVersion=m.group(m.groupCount());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return minecraftMainVersion;
|
|
||||||
}
|
|
||||||
|
|
||||||
// (domain|ip)(:port)
|
|
||||||
public static String getServerAddress(){
|
|
||||||
net.minecraft.client.multiplayer.ServerData data=net.minecraft.client.Minecraft.getMinecraft().getCurrentServerData();
|
|
||||||
if(data==null)//Single Player
|
|
||||||
return null;
|
|
||||||
return data.serverIP;
|
|
||||||
}
|
|
||||||
// ip:port
|
|
||||||
public static String getStandardServerAddress(){
|
|
||||||
return HttpUtil0.parseAddress(getServerAddress());
|
|
||||||
}
|
|
||||||
public static boolean isLanServer(){
|
|
||||||
return HttpUtil0.isLanServer(getStandardServerAddress());
|
|
||||||
}
|
|
||||||
public static String getCurrentUsername(){
|
|
||||||
return net.minecraft.client.Minecraft.getMinecraft().getSession().getProfile().getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
private final static Pattern MINECRAFT_CORE_FILE_PATTERN = Pattern.compile("^(.*?)/versions/([^\\/\\\\]*?)/([^\\/\\\\]*?).jar$");
|
|
||||||
private static void testProbe(){
|
|
||||||
minecraftVersion.clear();
|
|
||||||
URLClassLoader ucl = (URLClassLoader)new MinecraftUtil().getClass().getClassLoader();
|
|
||||||
URL urls[] = ucl.getURLs();
|
|
||||||
for(URL url:urls){
|
|
||||||
Matcher m = null;
|
|
||||||
try{
|
|
||||||
m=MINECRAFT_CORE_FILE_PATTERN.matcher(URLDecoder.decode(url.getPath(),"UTF-8"));
|
|
||||||
}catch(Exception e){
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
if(m==null || !m.matches())
|
|
||||||
continue;
|
|
||||||
minecraftVersion.add(m.group(2));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isCoreFile(URL url){
|
|
||||||
Matcher m = null;
|
|
||||||
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$");
|
|
||||||
public static boolean isLibraryFile(URL url){
|
|
||||||
Matcher m = null;
|
|
||||||
try{
|
|
||||||
m=LIBRARY_FILE_PATTERN.matcher(URLDecoder.decode(url.getPath(),"UTF-8"));
|
|
||||||
}catch(Exception e){
|
|
||||||
e.printStackTrace();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return m!=null && 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 +0,0 @@
|
|||||||
package customskinloader.utils;
|
|
||||||
|
|
||||||
public class TimeUtil {
|
|
||||||
public static long getCurrentUnixTimestamp(){
|
|
||||||
return System.currentTimeMillis()/1000l;
|
|
||||||
}
|
|
||||||
public static long getUnixTimestamp(long offset){
|
|
||||||
return getCurrentUnixTimestamp()+offset;
|
|
||||||
}
|
|
||||||
public static long getUnixTimestampRandomDelay(long offset){
|
|
||||||
return getCurrentUnixTimestamp()+offset+random(0,5);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static int random(int min,int max){
|
|
||||||
return (int)(Math.random()*(max-min+1))+min;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Binary file not shown.
@@ -1,2 +0,0 @@
|
|||||||
/bin/
|
|
||||||
/build/
|
|
||||||
@@ -1,108 +0,0 @@
|
|||||||
buildscript {
|
|
||||||
repositories {
|
|
||||||
/*maven {
|
|
||||||
name = "fmm"
|
|
||||||
url = "http://forgemavenmirror.sinaapp.com/maven"
|
|
||||||
}*/
|
|
||||||
jcenter()
|
|
||||||
maven { url = "http://files.minecraftforge.net/maven" }
|
|
||||||
}
|
|
||||||
dependencies {
|
|
||||||
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
apply plugin: 'net.minecraftforge.gradle.forge'
|
|
||||||
|
|
||||||
ext.MINECRAFT_VERSION="1.12.2"
|
|
||||||
ext.FORGE_VERSION="14.23.2.2611"
|
|
||||||
ext.MAPPING_VERSION="snapshot_20180210"
|
|
||||||
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)
|
|
||||||
|
|
||||||
archivesBaseName = "CustomSkinLoader_Forge"
|
|
||||||
version = rootProject.ext.config.version + rootProject.ext.config.dev_version + (snapshot?"-SNAPSHOT-"+System.getenv("CIRCLE_BUILD_NUM"):"")
|
|
||||||
group = "customskinloader"
|
|
||||||
|
|
||||||
sourceCompatibility = targetCompatibility = "1.6"
|
|
||||||
compileJava {
|
|
||||||
sourceCompatibility = targetCompatibility = "1.6"
|
|
||||||
}
|
|
||||||
jar {
|
|
||||||
manifest {
|
|
||||||
attributes 'FMLCorePlugin': 'customskinloader.forge.ForgePlugin'
|
|
||||||
attributes 'FMLCorePluginContainsFMLMod': true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sourceSets {
|
|
||||||
main {
|
|
||||||
java {
|
|
||||||
srcDir 'MergedSource'//Merge source
|
|
||||||
}
|
|
||||||
resources {
|
|
||||||
srcDir 'MergedResource'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
minecraft {
|
|
||||||
version = MINECRAFT_VERSION+"-"+FORGE_VERSION
|
|
||||||
runDir = "run"
|
|
||||||
|
|
||||||
mappings = MAPPING_VERSION
|
|
||||||
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
|
|
||||||
|
|
||||||
replace '@MOD_VERSION@', rootProject.ext.config.version
|
|
||||||
replace '@MOD_FULL_VERSION@', project.version
|
|
||||||
replaceIn 'CustomSkinLoader.java'
|
|
||||||
replaceIn 'ForgeMod.java'
|
|
||||||
}
|
|
||||||
|
|
||||||
task mergeSource { doLast {
|
|
||||||
copy {
|
|
||||||
from '../Common/source'
|
|
||||||
exclude '**/tweaker/**'
|
|
||||||
from 'source'
|
|
||||||
into 'MergedSource'
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
sourceMainJava.dependsOn mergeSource
|
|
||||||
|
|
||||||
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("CIRCLE_SHA1"),
|
|
||||||
buildUrl :System.getenv("CIRCLE_BUILD_URL")
|
|
||||||
])
|
|
||||||
}
|
|
||||||
|
|
||||||
task afterBuild { doLast {
|
|
||||||
//Clean Up
|
|
||||||
def sourceDir = file("MergedSource")
|
|
||||||
sourceDir.deleteDir()
|
|
||||||
def resourceDir = file("MergedResource")
|
|
||||||
resourceDir.deleteDir()
|
|
||||||
|
|
||||||
//copyBuildFile
|
|
||||||
copy {
|
|
||||||
from 'build/libs'
|
|
||||||
into '../build/libs'
|
|
||||||
include '**/*.jar'
|
|
||||||
exclude '**/*-sources.jar'
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
build.finalizedBy afterBuild
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"modid": "customskinloader",
|
|
||||||
"name": "CustomSkinLoader",
|
|
||||||
"description": "Custom Skin Loader for Minecraft",
|
|
||||||
"version": "${modFullVersion}",
|
|
||||||
"url": "https://github.com/xfl03/MCCustomSkinLoader",
|
|
||||||
"authorList": ["xfl03"],
|
|
||||||
"credits": "GPLv3"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
package customskinloader.forge;
|
|
||||||
|
|
||||||
import net.minecraftforge.fml.common.Mod;
|
|
||||||
|
|
||||||
@Mod(modid = "customskinloader",
|
|
||||||
name = "CustomSkinLoader",
|
|
||||||
version = "@MOD_FULL_VERSION@",
|
|
||||||
clientSideOnly=true,
|
|
||||||
acceptedMinecraftVersions="[1.8,)")
|
|
||||||
public class ForgeMod{
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
package customskinloader.forge;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin;
|
|
||||||
|
|
||||||
public class ForgePlugin implements IFMLLoadingPlugin {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String[] getASMTransformerClass() {
|
|
||||||
return new String[] {TransformerManager.class.getName()};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getModContainerClass() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getSetupClass() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void injectData(Map<String, Object> data) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getAccessTransformerClass() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -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,48 +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.InsnList;
|
|
||||||
import org.objectweb.asm.tree.MethodInsnNode;
|
|
||||||
import org.objectweb.asm.tree.MethodNode;
|
|
||||||
|
|
||||||
import customskinloader.forge.TransformerManager.IMethodTransformer;
|
|
||||||
import customskinloader.forge.TransformerManager.TransformTarget;
|
|
||||||
|
|
||||||
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;
|
|
||||||
//MethodInsnNode min=(MethodInsnNode)nn;
|
|
||||||
//min.owner="customskinloader/fake/FakeClientPlayer";
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,97 +0,0 @@
|
|||||||
package customskinloader.forge;
|
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
|
||||||
import java.lang.annotation.Retention;
|
|
||||||
import java.lang.annotation.RetentionPolicy;
|
|
||||||
import java.lang.annotation.Target;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
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.MethodNode;
|
|
||||||
|
|
||||||
import net.minecraft.launchwrapper.IClassTransformer;
|
|
||||||
import net.minecraftforge.fml.common.asm.transformers.deobf.FMLDeobfuscatingRemapper;
|
|
||||||
import net.minecraftforge.fml.relauncher.FMLRelaunchLog;
|
|
||||||
import customskinloader.forge.PlayerTabTransformer.ScoreObjectiveTransformer;
|
|
||||||
import customskinloader.forge.SkinManagerTransformer.*;
|
|
||||||
import customskinloader.forge.SpectatorMenuTransformer.PlayerMenuObjectTransformer;
|
|
||||||
|
|
||||||
public class TransformerManager implements IClassTransformer {
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
@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(),
|
|
||||||
new PlayerMenuObjectTransformer()};
|
|
||||||
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
|
|
||||||
@Override
|
|
||||||
public byte[] transform(String obfClassName, String className, byte[] bytes) {
|
|
||||||
if (!map.containsKey(className)) return bytes;
|
|
||||||
FMLRelaunchLog.info("[CSL DEBUG] CLASS %s will be transformed", className);
|
|
||||||
Map<String, IMethodTransformer> transMap = map.get(className);
|
|
||||||
|
|
||||||
ClassReader cr = new ClassReader(bytes);
|
|
||||||
ClassNode cn = new ClassNode();
|
|
||||||
cr.accept(cn, 0);
|
|
||||||
|
|
||||||
// NOTE: `map` = convert obfuscated name to srgName;
|
|
||||||
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);
|
|
||||||
cn.accept(cw);
|
|
||||||
return cw.toByteArray();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,84 +1,23 @@
|
|||||||
# CustomSkinLoader
|
MCCustomSkinLoaderGUI
|
||||||
## What's this?
|
=====================
|
||||||
Custom Skin Loader mod for Minecraft.
|
/*
|
||||||
You can use it to load any skin from any website.
|
|
||||||
|
|
||||||
## Download
|
|
||||||
Build Server : [CircleCI](https://circleci.com/gh/xfl03/MCCustomSkinLoader) & [~~Infinity Studio CI~~](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)
|
|
||||||
|
|
||||||
## Feature
|
|
||||||
### Plenty of Skin Load API Support and Customizable Skin Load List
|
|
||||||
Skin Load API Supported:
|
|
||||||
- [Mojang API](http://wiki.vg/Mojang_API)
|
|
||||||
- [CustomSkinAPI](https://github.com/xfl03/CustomSkinLoaderAPI/tree/master/CustomSkinAPI)
|
|
||||||
- CustomSkinAPIPlus (Test Only)
|
|
||||||
- [UniSkinAPI](https://github.com/RecursiveG/UniSkinServer/tree/master/doc)
|
|
||||||
- Legacy
|
|
||||||
|
|
||||||
You can use this feature to customize your skin load list so as to load 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.
|
|
||||||
|
|
||||||
### HD Skins Support
|
|
||||||
Even though there is no Optifine or MCPatcher, CustomSkinLoader has fix this problem.
|
|
||||||
You can easily to get a better view in skin.
|
|
||||||
|
|
||||||
### Skull Support
|
|
||||||
Fixed skull load bug.
|
|
||||||
Dynamic skull supported.
|
|
||||||
|
|
||||||
### Profile Cache
|
|
||||||
- Decrease frenquency of using network.
|
|
||||||
- Meanwhile,you can still load profile without network.
|
|
||||||
|
|
||||||
*Should be open in configratulation file.
|
版权所有(C) 2013-2014 JLChnToZ xfl03
|
||||||
|
|
||||||
### Local Skin
|
这一程序是自由软件,你可以遵照自由软件基金会出版的GNU通用公共许可证条款来修改和重新发布这一程序。或者用许可证的第三版,或者(根据你的选择)用任何更新的版本。
|
||||||
Load skin without skin server.
|
|
||||||
Furthermore, by using this function you can preview your skin in game and even change default skin and model.
|
发布这一程序的目的是希望它有用,但没有任何担保。甚至没有适合特定目的的隐含的担保。更详细的情况请参阅GNU通用公共许可证。
|
||||||
You can load local skin by using any API(excluding MojangAPI).
|
|
||||||
*While using default configratulation, just put skin into `.minecraft/CustomSkinLoader/LocalSkin/(skin|cape)s/{USERNAME}.png`.
|
|
||||||
|
Copyright(C) 2013-2014 JLChnToZ xfl03
|
||||||
### Extra List
|
|
||||||
A json file generated by supported skin server.
|
|
||||||
To add server to load list, users just need to put file into `.minecraft/CustomSkinLoader/ExtraList` .
|
|
||||||
|
|
||||||
### Transparent Skin Support
|
|
||||||
The problem of rendering incorrect texture has been fixed.
|
|
||||||
|
|
||||||
## Default Load List
|
|
||||||
- [Mojang](http://www.minecraft.net/) (Mojang API)
|
|
||||||
- [Little Skin](https://mcskin.littleservice.cn/) (CustomSkinAPI)
|
|
||||||
- [Blessing Skin](http://skin.prinzeugen.net/) (CustomSkinAPI)
|
|
||||||
- SkinMe (UniSkinAPI)
|
|
||||||
- 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).
|
|
||||||
|
|
||||||
## To Skin Server Owner
|
|
||||||
CustomSkinLoader is designed for loading from any server, which makes it complex.
|
|
||||||
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.
|
|
||||||
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.
|
|
||||||
|
|
||||||
## Copyright & LICENSE
|
|
||||||
### Binary File
|
|
||||||
You could not modify binary file.
|
|
||||||
Feel free to use and share this mod and unmodified file in anyway like modpack.
|
|
||||||
When using in modpack, you must put 'CustomSkinLoader' in mod list.
|
|
||||||
You could not repost this mod to any website without permission.
|
|
||||||
You could not earn money with this mod excluding modpack.
|
|
||||||
### Source Code
|
|
||||||
#### Package 'customskinloader'
|
|
||||||
Including some code from
|
|
||||||
- [AsteriskTeam/TabIconHackForge](http://git.oschina.net/AsteriskTeam/TabIconHackForge) (GPLv3)
|
|
||||||
- [RecursiveG/UniSkinMod](https://github.com/RecursiveG/UniSkinMod) (GPLv3)
|
|
||||||
|
|
||||||
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
|
|
||||||
You should change the name of package to avoid others' misunderstanding.
|
http://www.gnu.org/licenses/gpl.html
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
apply plugin: 'base'
|
|
||||||
|
|
||||||
ext.configFile = file "build.properties"
|
|
||||||
configFile.withReader {
|
|
||||||
// read config. it shall from now on be referenced as simply config or as project.config
|
|
||||||
def prop = new Properties()
|
|
||||||
prop.load(it)
|
|
||||||
project.ext.config = new ConfigSlurper().parse prop
|
|
||||||
}
|
|
||||||
buildscript {
|
|
||||||
repositories {
|
|
||||||
/*
|
|
||||||
maven {
|
|
||||||
name = "fmm"
|
|
||||||
url = "http://forgemavenmirror.sinaapp.com/maven"
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
jcenter()
|
|
||||||
maven {
|
|
||||||
name = "forge"
|
|
||||||
url = "http://files.minecraftforge.net/maven"
|
|
||||||
}
|
|
||||||
maven {
|
|
||||||
name = "sonatype"
|
|
||||||
url = "https://oss.sonatype.org/content/repositories/snapshots/"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
dependencies {
|
|
||||||
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
subprojects {
|
|
||||||
if(!project.name.toLowerCase().contains("forge"))
|
|
||||||
apply from: rootProject.file('common.gradle')
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
name=CustomSkinLoader
|
|
||||||
group=customskinloader
|
|
||||||
version=14.8
|
|
||||||
dev_version=
|
|
||||||
#RELEASE: snapshot=0
|
|
||||||
snapshot=0
|
|
||||||
-144
@@ -1,144 +0,0 @@
|
|||||||
buildscript {
|
|
||||||
repositories {
|
|
||||||
/*
|
|
||||||
maven {
|
|
||||||
name = "fmm"
|
|
||||||
url = "http://forgemavenmirror.sinaapp.com/maven"
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
jcenter()
|
|
||||||
maven {
|
|
||||||
name = "forge"
|
|
||||||
url = "http://files.minecraftforge.net/maven"
|
|
||||||
}
|
|
||||||
maven {
|
|
||||||
name = "sonatype"
|
|
||||||
url = "https://oss.sonatype.org/content/repositories/snapshots/"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
dependencies {
|
|
||||||
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
apply plugin: 'net.minecraftforge.gradle.forge'
|
|
||||||
|
|
||||||
ext.configFile = file "build.properties"
|
|
||||||
configFile.withReader {
|
|
||||||
// read config. it shall from now on be referenced as simply config or as project.config
|
|
||||||
def prop = new Properties()
|
|
||||||
prop.load(it)
|
|
||||||
project.ext.config = new ConfigSlurper().parse prop
|
|
||||||
}
|
|
||||||
//Example: 14.4a-SNAPSHOT-20160820
|
|
||||||
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("CIRCLE_BUILD_NUM")))
|
|
||||||
group = config.group
|
|
||||||
archivesBaseName = rootProject.ext.config.name+"_"+config.minecraft_version
|
|
||||||
|
|
||||||
minecraft {
|
|
||||||
version = config.forge_mc_version+"-"+config.forge_version
|
|
||||||
runDir = "run"
|
|
||||||
mappings = config.mappings_version
|
|
||||||
|
|
||||||
replace '@MOD_VERSION@', rootProject.ext.config.version
|
|
||||||
replace '@MOD_FULL_VERSION@', project.version
|
|
||||||
replaceIn 'CustomSkinLoader.java'
|
|
||||||
}
|
|
||||||
|
|
||||||
jar {
|
|
||||||
manifest {
|
|
||||||
attributes 'TweakClass' : 'customskinloader.tweaker.ModSystemTweaker'
|
|
||||||
attributes 'TweakName' : rootProject.ext.config.name
|
|
||||||
attributes 'TweakAuthor' : 'xfl03,JLChnToZ'
|
|
||||||
attributes 'TweakVersion' : version
|
|
||||||
attributes 'TweakOrder' : '-10'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
task copySource << {
|
|
||||||
def outputFile = file("src/main/java")
|
|
||||||
outputFile.deleteDir()
|
|
||||||
copy {
|
|
||||||
from '../Common/source'
|
|
||||||
from 'src/minecraft/'
|
|
||||||
into 'src/main/java'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sourceMainJava.dependsOn copySource
|
|
||||||
|
|
||||||
processResources {
|
|
||||||
expand ([
|
|
||||||
modVersion:rootProject.ext.config.version,
|
|
||||||
modFullVersion:project.version,
|
|
||||||
mcVersion:config.minecraft_version,
|
|
||||||
mcFullVersions:config.minecraft_full_versions,
|
|
||||||
forgeVersion:config.forge_version,
|
|
||||||
//gitVersion:System.getenv("GIT_COMMIT"),
|
|
||||||
//buildUrl:System.getenv("BUILD_URL")
|
|
||||||
gitVersion:System.getenv("CIRCLE_SHA1"),
|
|
||||||
buildUrl:System.getenv("CIRCLE_BUILD_URL")
|
|
||||||
])
|
|
||||||
}
|
|
||||||
task copyResources << {
|
|
||||||
def outputFile = file("src/main/resources")
|
|
||||||
outputFile.deleteDir()
|
|
||||||
copy {
|
|
||||||
from '../Common/resource'
|
|
||||||
into 'src/main/resources'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
processResources.dependsOn copyResources
|
|
||||||
|
|
||||||
task afterBuild << {
|
|
||||||
//renameSrgJar
|
|
||||||
def file0 = file("build/libs/${archivesBaseName}-${version}.jar")
|
|
||||||
def file1 = file("build/libs/${archivesBaseName}-${version}-srg.jar")
|
|
||||||
file0.renameTo(file1)
|
|
||||||
|
|
||||||
//reobfSrgToNotch
|
|
||||||
reobfSrgToNotch()
|
|
||||||
|
|
||||||
//copyBuildFile
|
|
||||||
copy {
|
|
||||||
from 'build/libs'
|
|
||||||
into '../build/libs'
|
|
||||||
include '**/*.jar'
|
|
||||||
exclude '**/*-srg.jar'
|
|
||||||
exclude '**/*-dev.jar'
|
|
||||||
exclude '**/*-sources.jar'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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"
|
|
||||||
}
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
include "1.12-mcp940"
|
|
||||||
include "1.12.1-test"
|
|
||||||
|
|
||||||
//Universial Forge Version for [1.8,)
|
|
||||||
include "Forge"
|
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
package idv.jlchntoz;
|
||||||
|
|
||||||
|
import idv.jlchntoz.gui.MainFrame;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
public class CustomSkinLoaderGUI {
|
||||||
|
|
||||||
|
public static final String VERSION ="1.1.1";
|
||||||
|
|
||||||
|
public static final Logger log=Logger.getLogger("CustomSkinLoader-GUI");
|
||||||
|
public static final File LCK=new File("GUI.lck");
|
||||||
|
private static final long SECONDS=30;
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
log.info("Thanks for using CustomSkinLoader!");
|
||||||
|
log.info("Version "+VERSION+" !");
|
||||||
|
long dt=System.currentTimeMillis()-SECONDS*1000;
|
||||||
|
if(LCK.exists()&&LCK.lastModified()>=dt){
|
||||||
|
log.info("Sorry! GUI has already been running!");
|
||||||
|
log.info("If you believe it is a mistake, please delete 'GUI.lck'.");
|
||||||
|
}else{
|
||||||
|
LCK.delete();
|
||||||
|
try {
|
||||||
|
LCK.createNewFile();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
LCK.deleteOnExit();
|
||||||
|
MainFrame mf=new MainFrame();
|
||||||
|
mf.init(args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
package idv.jlchntoz;
|
||||||
|
|
||||||
|
public class Version {
|
||||||
|
private String version;
|
||||||
|
private long longVersion;
|
||||||
|
|
||||||
|
public Version(String version){
|
||||||
|
this.version=version;
|
||||||
|
longVersion=getLongVersion(version);
|
||||||
|
}
|
||||||
|
private long getLongVersion(String version){
|
||||||
|
String[] temp=version.split("\\.");
|
||||||
|
//System.out.println(version);
|
||||||
|
long multi=1;
|
||||||
|
long temp1=0;
|
||||||
|
for(int i=temp.length-1;i>=0;i--){
|
||||||
|
//System.out.println(temp[i]);
|
||||||
|
temp1+=Integer.parseInt(temp[i])*multi;
|
||||||
|
multi*=100;
|
||||||
|
}
|
||||||
|
//System.out.println(temp1);
|
||||||
|
return temp1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getVersion(){
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
public long getLongVersion(){
|
||||||
|
return longVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isNewerThan(Version compareVersion){
|
||||||
|
return longVersion>compareVersion.getLongVersion();
|
||||||
|
}
|
||||||
|
public boolean isNewerThan(String compareVersion){
|
||||||
|
return longVersion>getLongVersion(compareVersion);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isNewerThanOrEquals(Version compareVersion){
|
||||||
|
return longVersion>=compareVersion.getLongVersion();
|
||||||
|
}
|
||||||
|
public boolean isNewerThanOrEquals(String compareVersion){
|
||||||
|
return longVersion>=getLongVersion(compareVersion);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,148 @@
|
|||||||
|
package idv.jlchntoz.gui;
|
||||||
|
|
||||||
|
import idv.jlchntoz.Version;
|
||||||
|
import idv.jlchntoz.lang.ILanguage;
|
||||||
|
import idv.jlchntoz.lang.LangManager;
|
||||||
|
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Container;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.awt.Font;
|
||||||
|
import java.awt.Toolkit;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.WindowConstants;
|
||||||
|
|
||||||
|
public class MainFrame {
|
||||||
|
private static final ILanguage lang=LangManager.getLanguage();
|
||||||
|
public Version patchVersion=new Version("1.0");
|
||||||
|
public static boolean useDataFolder=false;
|
||||||
|
|
||||||
|
public static final Color bg2=new Color(244, 243, 222, 255);
|
||||||
|
public static final Color bg3=new Color(190, 173, 146, 150);
|
||||||
|
public static final Color bg5=new Color(91, 73, 70, 255);
|
||||||
|
|
||||||
|
public static final Font defaultBigFont=new Font("΢ÈíÑźÚ", Font.BOLD, 30);
|
||||||
|
public static final Font defaultSmallFont=new Font("΢ÈíÑźÚ", Font.PLAIN, 15);
|
||||||
|
public static final Font defaultSmallerFont=new Font("΢ÈíÑźÚ", Font.PLAIN, 13);
|
||||||
|
public static final Font englishBigFont=new Font("Comic Sans MS", Font.BOLD, 30);
|
||||||
|
public static final Font englishSmallFont=new Font("Comic Sans MS", Font.PLAIN, 15);
|
||||||
|
|
||||||
|
public void init(String[] args) {
|
||||||
|
|
||||||
|
JFrame jf = new JFrame (lang.title()+lang.gui());
|
||||||
|
Container con = jf.getContentPane();
|
||||||
|
con.setLayout(null);
|
||||||
|
//setBounds(x,y,width,height)
|
||||||
|
int windowWidth = 400;
|
||||||
|
int windowHeight = 300;
|
||||||
|
Toolkit kit = Toolkit.getDefaultToolkit();
|
||||||
|
Dimension screenSize = kit.getScreenSize();
|
||||||
|
int screenWidth = screenSize.width;
|
||||||
|
int screenHeight = screenSize.height;
|
||||||
|
jf.setBounds(screenWidth / 2 - windowWidth / 2, screenHeight / 2 - windowHeight / 2,
|
||||||
|
windowWidth , windowHeight);
|
||||||
|
|
||||||
|
con.setBackground(bg2);
|
||||||
|
|
||||||
|
JLabel title=new JLabel();
|
||||||
|
title.setForeground(bg5);
|
||||||
|
title.setHorizontalAlignment(JLabel.CENTER);
|
||||||
|
title.setText(lang.title()+lang.index());
|
||||||
|
if(LangManager.langCode.equalsIgnoreCase("en"))
|
||||||
|
title.setFont(englishBigFont);
|
||||||
|
else
|
||||||
|
title.setFont(defaultBigFont);
|
||||||
|
title.setBounds(15, 5, 370, 40);
|
||||||
|
con.add(title);
|
||||||
|
|
||||||
|
if(args.length>0 && args[0].equalsIgnoreCase("f")){
|
||||||
|
JLabel tip1=new JLabel();
|
||||||
|
tip1.setForeground(bg5);
|
||||||
|
tip1.setHorizontalAlignment(JLabel.CENTER);
|
||||||
|
tip1.setText(lang.first1());
|
||||||
|
tip1.setBounds(10, 50, 370, 20);
|
||||||
|
if(LangManager.langCode.equalsIgnoreCase("en"))
|
||||||
|
tip1.setFont(englishSmallFont);
|
||||||
|
else
|
||||||
|
tip1.setFont(defaultSmallFont);
|
||||||
|
con.add(tip1);
|
||||||
|
|
||||||
|
JLabel tip2=new JLabel();
|
||||||
|
tip2.setForeground(bg5);
|
||||||
|
tip2.setHorizontalAlignment(JLabel.CENTER);
|
||||||
|
tip2.setText(lang.first2());
|
||||||
|
tip2.setBounds(10, 70, 370, 20);
|
||||||
|
if(LangManager.langCode.equalsIgnoreCase("en"))
|
||||||
|
tip2.setFont(englishSmallFont);
|
||||||
|
else
|
||||||
|
tip2.setFont(defaultSmallFont);
|
||||||
|
con.add(tip2);
|
||||||
|
}
|
||||||
|
if(args.length>1){
|
||||||
|
patchVersion=new Version(args[1]);
|
||||||
|
if(patchVersion.isNewerThanOrEquals("12.1"))
|
||||||
|
useDataFolder=true;
|
||||||
|
JLabel tip3=new JLabel();
|
||||||
|
tip3.setForeground(bg5);
|
||||||
|
tip3.setHorizontalAlignment(JLabel.CENTER);
|
||||||
|
tip3.setText(lang.yourVersion()+" "+args[1]);
|
||||||
|
tip3.setBounds(10, 100, 370, 20);
|
||||||
|
if(LangManager.langCode.equalsIgnoreCase("en"))
|
||||||
|
tip3.setFont(englishSmallFont);
|
||||||
|
else
|
||||||
|
tip3.setFont(defaultSmallFont);
|
||||||
|
con.add(tip3);
|
||||||
|
}
|
||||||
|
|
||||||
|
JButton skinBtn=new JButton();
|
||||||
|
skinBtn.setForeground(bg5);
|
||||||
|
skinBtn.setBackground(bg3);
|
||||||
|
skinBtn.setText(lang.skin()+lang.loadList());
|
||||||
|
skinBtn.setBounds(15, 180, 370, 30);
|
||||||
|
if(LangManager.langCode.equalsIgnoreCase("en"))
|
||||||
|
skinBtn.setFont(englishSmallFont);
|
||||||
|
else
|
||||||
|
skinBtn.setFont(defaultSmallFont);
|
||||||
|
con.add(skinBtn);
|
||||||
|
skinBtn.addActionListener(new ActionListener(){
|
||||||
|
@Override
|
||||||
|
public void actionPerformed (ActionEvent e){
|
||||||
|
String[] aa={"skin"};
|
||||||
|
SkinFrame.main(aa);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
JButton cloakBtn=new JButton();
|
||||||
|
cloakBtn.setForeground(bg5);
|
||||||
|
cloakBtn.setBackground(bg3);
|
||||||
|
cloakBtn.setText(lang.cloak()+lang.loadList());
|
||||||
|
cloakBtn.setBounds(15, 215, 370, 30);
|
||||||
|
if(LangManager.langCode.equalsIgnoreCase("en"))
|
||||||
|
cloakBtn.setFont(englishSmallFont);
|
||||||
|
else
|
||||||
|
cloakBtn.setFont(defaultSmallFont);
|
||||||
|
con.add(cloakBtn);
|
||||||
|
cloakBtn.addActionListener(new ActionListener(){
|
||||||
|
@Override
|
||||||
|
public void actionPerformed (ActionEvent e){
|
||||||
|
String[] aa={"cape"};
|
||||||
|
SkinFrame.main(aa);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
jf.setVisible(true);
|
||||||
|
if(args.length>=3&&args[2].equalsIgnoreCase("in")){
|
||||||
|
jf.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
|
||||||
|
}else{
|
||||||
|
jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
|
||||||
|
}
|
||||||
|
jf.setResizable(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,244 @@
|
|||||||
|
package idv.jlchntoz.gui;
|
||||||
|
|
||||||
|
import idv.jlchntoz.lang.ILanguage;
|
||||||
|
import idv.jlchntoz.lang.LangManager;
|
||||||
|
|
||||||
|
import java.awt.Container;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.awt.Toolkit;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileReader;
|
||||||
|
import java.io.FileWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
import javax.swing.JTextArea;
|
||||||
|
import javax.swing.WindowConstants;
|
||||||
|
|
||||||
|
public class SkinFrame {
|
||||||
|
private static ILanguage lang=LangManager.getLanguage();
|
||||||
|
public static boolean mod=false;
|
||||||
|
private static String to="skin";
|
||||||
|
|
||||||
|
public static final String[] urls0={
|
||||||
|
"#"+lang.minecraftOffical(),
|
||||||
|
"http://skins.minecraft.net/MinecraftSkins/*.png",
|
||||||
|
"http://s3.amazonaws.com/MinecraftSkins/*.png",
|
||||||
|
"#MineCrack",
|
||||||
|
"http://minecrack.fr.nf/mc/skinsminecrackd/*.png",
|
||||||
|
/*
|
||||||
|
* XFL03's Skin Website Closed
|
||||||
|
"#OpenSkin",
|
||||||
|
"http://skin.axdt.net/MinecraftSkins/*.png",
|
||||||
|
*/
|
||||||
|
"#SkinMe",
|
||||||
|
"http://www.skinme.cc:88/MinecraftSkins/*.png"
|
||||||
|
|
||||||
|
};
|
||||||
|
public static final String[] urls1={
|
||||||
|
"#"+lang.minecraftOffical(),
|
||||||
|
"http://skins.minecraft.net/MinecraftCloaks/*.png",
|
||||||
|
"http://s3.amazonaws.com/MinecraftCloaks/*.png",
|
||||||
|
"#Optifine",
|
||||||
|
"http://s.optifine.net/capes/*.png",
|
||||||
|
"#MineCrack",
|
||||||
|
"http://minecrack.fr.nf/mc/cloaksminecrackd/*.png",
|
||||||
|
/*
|
||||||
|
* XFL03's Skin Website Closed
|
||||||
|
"#OpenSkin",
|
||||||
|
"http://skin.axdt.net/MinecraftCloaks/*.png",
|
||||||
|
*/
|
||||||
|
"#SkinMe",
|
||||||
|
"http://www.skinme.cc:88/MinecraftCloaks/*.png"
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
if(args.length>0)
|
||||||
|
to=args[0];
|
||||||
|
final String[] urls;
|
||||||
|
String ti="";
|
||||||
|
if(to.equalsIgnoreCase("cape")){
|
||||||
|
urls=urls1;
|
||||||
|
ti=lang.cloak();
|
||||||
|
}else{
|
||||||
|
urls=urls0;
|
||||||
|
ti=lang.skin();
|
||||||
|
}
|
||||||
|
final JFrame jf = new JFrame (lang.title()+" - "+ti+lang.loadList());
|
||||||
|
Container con = jf.getContentPane();
|
||||||
|
con.setLayout(null);
|
||||||
|
con.setBackground(MainFrame.bg2);
|
||||||
|
int windowWidth = 507;
|
||||||
|
int windowHeight = 420;
|
||||||
|
Toolkit kit = Toolkit.getDefaultToolkit();
|
||||||
|
Dimension screenSize = kit.getScreenSize();
|
||||||
|
int screenWidth = screenSize.width;
|
||||||
|
int screenHeight = screenSize.height;
|
||||||
|
jf.setBounds(screenWidth / 2 - windowWidth / 2, screenHeight / 2 - windowHeight / 2, windowWidth , windowHeight);
|
||||||
|
|
||||||
|
JLabel title=new JLabel();
|
||||||
|
title.setForeground(MainFrame.bg5);
|
||||||
|
title.setHorizontalAlignment(JLabel.CENTER);
|
||||||
|
title.setText(ti+lang.loadList());
|
||||||
|
if(LangManager.langCode.equalsIgnoreCase("en"))
|
||||||
|
title.setFont(MainFrame.englishBigFont);
|
||||||
|
else
|
||||||
|
title.setFont(MainFrame.defaultBigFont);
|
||||||
|
title.setBounds(10, 5, 480, 30);
|
||||||
|
con.add(title);
|
||||||
|
|
||||||
|
final JTextArea skinList=new JTextArea();
|
||||||
|
skinList.setBounds(15, 45, 470, 260);
|
||||||
|
skinList.setFont(MainFrame.defaultSmallerFont);
|
||||||
|
skinList.setForeground(MainFrame.bg5);
|
||||||
|
con.add(skinList);
|
||||||
|
File temp0=new File("CustomSkinLoader/"+to+"urls.txt");
|
||||||
|
if(temp0.exists())
|
||||||
|
skinList.setText(read(temp0));
|
||||||
|
else{
|
||||||
|
|
||||||
|
skinList.setText(read(new File(""+to+"urls.txt")));
|
||||||
|
}
|
||||||
|
|
||||||
|
JButton defaultBtn=new JButton();
|
||||||
|
defaultBtn.setText(lang.useDefault());
|
||||||
|
defaultBtn.setBounds(15, 310, 233, 30);
|
||||||
|
defaultBtn.setForeground(MainFrame.bg5);
|
||||||
|
defaultBtn.setBackground(MainFrame.bg3);
|
||||||
|
if(LangManager.langCode.equalsIgnoreCase("en"))
|
||||||
|
defaultBtn.setFont(MainFrame.englishSmallFont);
|
||||||
|
else
|
||||||
|
defaultBtn.setFont(MainFrame.defaultSmallFont);
|
||||||
|
con.add(defaultBtn);
|
||||||
|
defaultBtn.addActionListener(new ActionListener(){
|
||||||
|
@Override
|
||||||
|
public void actionPerformed (ActionEvent e){
|
||||||
|
String temp="";
|
||||||
|
for(int i=0;i<=2;i++)
|
||||||
|
temp+=urls[i]+"\r\n";
|
||||||
|
skinList.setText(temp);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
JButton urlBtn=new JButton();
|
||||||
|
urlBtn.setText(lang.useRecommended());
|
||||||
|
urlBtn.setBounds(252, 310, 235, 30);
|
||||||
|
urlBtn.setForeground(MainFrame.bg5);
|
||||||
|
urlBtn.setBackground(MainFrame.bg3);
|
||||||
|
if(LangManager.langCode.equalsIgnoreCase("en"))
|
||||||
|
urlBtn.setFont(MainFrame.englishSmallFont);
|
||||||
|
else
|
||||||
|
urlBtn.setFont(MainFrame.defaultSmallFont);
|
||||||
|
con.add(urlBtn);
|
||||||
|
urlBtn.addActionListener(new ActionListener(){
|
||||||
|
@Override
|
||||||
|
public void actionPerformed (ActionEvent e){
|
||||||
|
String temp=skinList.getText()+"\r\n";
|
||||||
|
if(temp.equalsIgnoreCase("\r\n")){
|
||||||
|
temp="";
|
||||||
|
}
|
||||||
|
for(int i=0;i<urls.length;i++)
|
||||||
|
temp+=urls[i]+"\r\n";
|
||||||
|
skinList.setText(temp);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
JButton saveBtn=new JButton();
|
||||||
|
saveBtn.setText(lang.save());
|
||||||
|
saveBtn.setBounds(15, 350, 233, 30);
|
||||||
|
saveBtn.setForeground(MainFrame.bg5);
|
||||||
|
saveBtn.setBackground(MainFrame.bg3);
|
||||||
|
if(LangManager.langCode.equalsIgnoreCase("en"))
|
||||||
|
saveBtn.setFont(MainFrame.englishSmallFont);
|
||||||
|
else
|
||||||
|
saveBtn.setFont(MainFrame.defaultSmallFont);
|
||||||
|
con.add(saveBtn);
|
||||||
|
saveBtn.addActionListener(new ActionListener(){
|
||||||
|
@Override
|
||||||
|
public void actionPerformed (ActionEvent e){
|
||||||
|
save(skinList.getText());
|
||||||
|
JOptionPane.showMessageDialog(null,lang.saved());
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
JButton closeBtn=new JButton();
|
||||||
|
closeBtn.setText(lang.close());
|
||||||
|
closeBtn.setBounds(252, 350, 235, 30);
|
||||||
|
closeBtn.setForeground(MainFrame.bg5);
|
||||||
|
closeBtn.setBackground(MainFrame.bg3);
|
||||||
|
if(LangManager.langCode.equalsIgnoreCase("en"))
|
||||||
|
closeBtn.setFont(MainFrame.englishSmallFont);
|
||||||
|
else
|
||||||
|
closeBtn.setFont(MainFrame.defaultSmallFont);
|
||||||
|
con.add(closeBtn);
|
||||||
|
closeBtn.addActionListener(new ActionListener(){
|
||||||
|
@Override
|
||||||
|
public void actionPerformed (ActionEvent e){
|
||||||
|
jf.setVisible(false);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
jf.setVisible(true);
|
||||||
|
jf.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
|
||||||
|
jf.setResizable(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void save(String data){
|
||||||
|
File a=new File(to+"urls.txt");
|
||||||
|
File b=new File("CustomSkinLoader/"+to+"urls.txt");
|
||||||
|
//System.out.println(b.getAbsolutePath());
|
||||||
|
try {
|
||||||
|
if(!MainFrame.useDataFolder)
|
||||||
|
a.createNewFile();
|
||||||
|
b.createNewFile();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
if(!MainFrame.useDataFolder)
|
||||||
|
write(a,data);
|
||||||
|
if(b.exists())
|
||||||
|
write(b,data);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean write(File file,String Data){
|
||||||
|
System.out.println("Write to "+file.getAbsolutePath());
|
||||||
|
FileWriter fw=null;
|
||||||
|
try{
|
||||||
|
fw = new FileWriter(file);
|
||||||
|
fw.write(Data,0,Data.length());
|
||||||
|
fw.flush();
|
||||||
|
fw.close();
|
||||||
|
}catch(Exception ex){
|
||||||
|
ex.printStackTrace();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
private static String read(File file){
|
||||||
|
System.out.println("Read from "+file.getAbsolutePath());
|
||||||
|
BufferedReader br = null;
|
||||||
|
String data="";
|
||||||
|
try {
|
||||||
|
br = new BufferedReader(new FileReader(file));
|
||||||
|
data = br.readLine();
|
||||||
|
while( br.ready()){
|
||||||
|
data += "\r\n"+br.readLine();
|
||||||
|
}
|
||||||
|
br.close();
|
||||||
|
return data;
|
||||||
|
} catch (Exception ex) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
package idv.jlchntoz.lang;
|
||||||
|
|
||||||
|
|
||||||
|
public class ChineseSimpLang implements ILanguage {
|
||||||
|
public String title(){
|
||||||
|
return "自定义皮肤加载器";
|
||||||
|
}
|
||||||
|
public String gui(){
|
||||||
|
return " 图形化界面";
|
||||||
|
}
|
||||||
|
public String index(){
|
||||||
|
return " 索引";
|
||||||
|
}
|
||||||
|
public String first1(){
|
||||||
|
return "这是您第一次使用自定义皮肤加载器!";
|
||||||
|
}
|
||||||
|
public String first2(){
|
||||||
|
return "请点击下列按钮以修改设置!";
|
||||||
|
}
|
||||||
|
public String skin(){
|
||||||
|
return "皮肤";
|
||||||
|
}
|
||||||
|
public String cloak(){
|
||||||
|
return "披风";
|
||||||
|
}
|
||||||
|
public String loadList(){
|
||||||
|
return "加载列表";
|
||||||
|
}
|
||||||
|
public String minecraftOffical(){
|
||||||
|
return "Minecraft 官方[正版]";
|
||||||
|
}
|
||||||
|
public String useDefault(){
|
||||||
|
return "使用默认(官方)";
|
||||||
|
}
|
||||||
|
public String useRecommended(){
|
||||||
|
return "使用推荐";
|
||||||
|
}
|
||||||
|
public String save(){
|
||||||
|
return "保存";
|
||||||
|
}
|
||||||
|
public String saved(){
|
||||||
|
return "已保存,请重新启动游戏!";
|
||||||
|
}
|
||||||
|
public String close(){
|
||||||
|
return "关闭";
|
||||||
|
}
|
||||||
|
public String yourVersion(){
|
||||||
|
return "您的皮肤模组版本:";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
package idv.jlchntoz.lang;
|
||||||
|
|
||||||
|
|
||||||
|
public class ChineseTranLang implements ILanguage {
|
||||||
|
public String title(){
|
||||||
|
return "萬用皮膚模組";
|
||||||
|
}
|
||||||
|
public String gui(){
|
||||||
|
return " 用戶界面";
|
||||||
|
}
|
||||||
|
public String index(){
|
||||||
|
return " 目錄";
|
||||||
|
}
|
||||||
|
public String first1(){
|
||||||
|
return "這是您第一次使用本模組!";
|
||||||
|
}
|
||||||
|
public String first2(){
|
||||||
|
return "請單擊下列按鈕進行配置修改!";
|
||||||
|
}
|
||||||
|
public String skin(){
|
||||||
|
return "皮膚";
|
||||||
|
}
|
||||||
|
public String cloak(){
|
||||||
|
return "披風";
|
||||||
|
}
|
||||||
|
public String loadList(){
|
||||||
|
return "加載列表";
|
||||||
|
}
|
||||||
|
public String minecraftOffical(){
|
||||||
|
return "Minecraft 官方[正版]";
|
||||||
|
}
|
||||||
|
public String useDefault(){
|
||||||
|
return "使用默認(官方)";
|
||||||
|
}
|
||||||
|
public String useRecommended(){
|
||||||
|
return "使用推薦";
|
||||||
|
}
|
||||||
|
public String save(){
|
||||||
|
return "保存";
|
||||||
|
}
|
||||||
|
public String saved(){
|
||||||
|
return "已保存,請重新開啟遊戲!";
|
||||||
|
}
|
||||||
|
public String close(){
|
||||||
|
return "關閉";
|
||||||
|
}
|
||||||
|
public String yourVersion(){
|
||||||
|
return "您的皮膚模組版本:";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
package idv.jlchntoz.lang;
|
||||||
|
|
||||||
|
public class EnglishLang implements ILanguage{
|
||||||
|
public String title(){
|
||||||
|
return "CustomSkinLoader";
|
||||||
|
}
|
||||||
|
public String gui(){
|
||||||
|
return " GUI";
|
||||||
|
}
|
||||||
|
public String index(){
|
||||||
|
return " Index";
|
||||||
|
}
|
||||||
|
public String first1(){
|
||||||
|
return "It's your first time use CustomSkinLoader!";
|
||||||
|
}
|
||||||
|
public String first2(){
|
||||||
|
return "Please click buttons below to modify config!";
|
||||||
|
}
|
||||||
|
public String skin(){
|
||||||
|
return "Skin";
|
||||||
|
}
|
||||||
|
public String cloak(){
|
||||||
|
return "Cloak";
|
||||||
|
}
|
||||||
|
public String loadList(){
|
||||||
|
return " Load List";
|
||||||
|
}
|
||||||
|
public String minecraftOffical(){
|
||||||
|
return "Minecraft Offical";
|
||||||
|
}
|
||||||
|
public String useDefault(){
|
||||||
|
return "Use Default(Offical)";
|
||||||
|
}
|
||||||
|
public String useRecommended(){
|
||||||
|
return "Use Recommended";
|
||||||
|
}
|
||||||
|
public String save(){
|
||||||
|
return "Save";
|
||||||
|
}
|
||||||
|
public String saved(){
|
||||||
|
return "Saved!Restart the game, please!";
|
||||||
|
}
|
||||||
|
public String close(){
|
||||||
|
return "Close";
|
||||||
|
}
|
||||||
|
public String yourVersion(){
|
||||||
|
return "Your CustomSkinLoader Version:";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package idv.jlchntoz.lang;
|
||||||
|
|
||||||
|
public interface ILanguage {
|
||||||
|
public String title();
|
||||||
|
public String gui();
|
||||||
|
public String index();
|
||||||
|
public String first1();
|
||||||
|
public String first2();
|
||||||
|
public String skin();
|
||||||
|
public String cloak();
|
||||||
|
public String loadList();
|
||||||
|
public String minecraftOffical();
|
||||||
|
public String useDefault();
|
||||||
|
public String useRecommended();
|
||||||
|
public String save();
|
||||||
|
public String saved();
|
||||||
|
public String close();
|
||||||
|
public String yourVersion();
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package idv.jlchntoz.lang;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
public class LangManager {
|
||||||
|
public static String langCode="en";
|
||||||
|
public static ILanguage getLanguage(){
|
||||||
|
Locale locale = Locale.getDefault();
|
||||||
|
String l=locale.getLanguage().toLowerCase();
|
||||||
|
String c=locale.getCountry().toLowerCase();
|
||||||
|
if(l.equalsIgnoreCase("zh")){
|
||||||
|
if(c.equalsIgnoreCase("cn")){
|
||||||
|
//zh_cn
|
||||||
|
langCode="zh_cn";
|
||||||
|
return new ChineseSimpLang();
|
||||||
|
}
|
||||||
|
//zh
|
||||||
|
langCode="zh";
|
||||||
|
return new ChineseTranLang();
|
||||||
|
}
|
||||||
|
//en
|
||||||
|
langCode="en";
|
||||||
|
return new EnglishLang();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
Reference in new issue
Block a user