Skip to content

Commit

Permalink
fix a mistake i made
Browse files Browse the repository at this point in the history
which will cause a local skin file rendered as a cape
  • Loading branch information
zlainsama committed Feb 26, 2016
1 parent adf57d0 commit b84bd90
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 35 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ buildscript {

apply plugin: 'forge'

version = "1.7.10-v8b"
version = "1.7.10-v8c"
group= "lain.mods.skinport"
archivesBaseName = "SkinPort"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
import java.net.Proxy;
import java.net.URL;
import java.util.UUID;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import javax.imageio.ImageIO;
import lain.mods.skinport.PlayerUtils;
import lain.mods.skinport.SkinData;
Expand All @@ -24,9 +22,6 @@
public class CrafatarCachedCapeProvider implements ISkinProvider
{

private static final ExecutorService pool = Executors.newCachedThreadPool();
private static final BufferedImage dummy = new BufferedImage(1, 1, 2);

private File _workDir;

public CrafatarCachedCapeProvider()
Expand All @@ -47,7 +42,7 @@ public ISkin getSkin(AbstractClientPlayer player)
data.profile = player.getGameProfile();
final boolean skipUUID = PlayerUtils.isOfflinePlayer(player);
final UUID fbID = player.getUniqueID();
pool.execute(new Runnable()
Shared.pool.execute(new Runnable()
{

@Override
Expand Down Expand Up @@ -82,7 +77,7 @@ public void run()
}
}

if (image != null && image != dummy)
if (image != null && image != Shared.dummy)
{
data.put(image, "cape");
}
Expand Down Expand Up @@ -222,7 +217,7 @@ private BufferedImage readImageCached(File workDir, String local, URL remote, Pr
}
else if (code == 404)
{
return dummy;
return Shared.dummy;
}

if (!file1.exists())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
import java.net.Proxy;
import java.net.URL;
import java.util.UUID;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import javax.imageio.ImageIO;
import lain.mods.skinport.LegacyConversion;
import lain.mods.skinport.PlayerUtils;
Expand All @@ -25,9 +23,6 @@
public class CrafatarCachedSkinProvider implements ISkinProvider
{

private static final ExecutorService pool = Executors.newCachedThreadPool();
private static final BufferedImage dummy = new BufferedImage(1, 1, 2);

private File _workDir;

public CrafatarCachedSkinProvider()
Expand All @@ -48,7 +43,7 @@ public ISkin getSkin(AbstractClientPlayer player)
data.profile = player.getGameProfile();
final boolean skipUUID = PlayerUtils.isOfflinePlayer(player);
final UUID fbID = player.getUniqueID();
pool.execute(new Runnable()
Shared.pool.execute(new Runnable()
{

@Override
Expand Down Expand Up @@ -83,7 +78,7 @@ public void run()
}
}

if (image != null && image != dummy)
if (image != null && image != Shared.dummy)
{
String type = SkinData.judgeSkinType(image);
if ("legacy".equals(type))
Expand Down Expand Up @@ -227,7 +222,7 @@ private BufferedImage readImageCached(File workDir, String local, URL remote, Pr
}
else if (code == 404)
{
return dummy;
return Shared.dummy;
}

if (!file1.exists())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
import java.net.URL;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import javax.imageio.ImageIO;
import lain.mods.skinport.PlayerUtils;
import lain.mods.skinport.SkinData;
Expand All @@ -26,9 +24,6 @@
public class MojangCachedCapeProvider implements ISkinProvider
{

private static final ExecutorService pool = Executors.newCachedThreadPool();
private static final BufferedImage dummy = new BufferedImage(1, 1, 2);

private File _workDir;

public MojangCachedCapeProvider()
Expand All @@ -49,7 +44,7 @@ public ISkin getSkin(AbstractClientPlayer player)
data.profile = player.getGameProfile();
final boolean flag = PlayerUtils.isOfflinePlayer(player);
final UUID fbID = player.getUniqueID();
pool.execute(new Runnable()
Shared.pool.execute(new Runnable()
{

@Override
Expand Down Expand Up @@ -77,7 +72,7 @@ public void run()
}
}

if (image != null && image != dummy)
if (image != null && image != Shared.dummy)
{
data.put(image, "cape");
}
Expand Down Expand Up @@ -217,7 +212,7 @@ private BufferedImage readImageCached(File workDir, String local, URL remote, Pr
}
else if (code == 404)
{
return dummy;
return Shared.dummy;
}

if (!file1.exists())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
import java.net.URL;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import javax.imageio.ImageIO;
import lain.mods.skinport.LegacyConversion;
import lain.mods.skinport.PlayerUtils;
Expand All @@ -27,9 +25,6 @@
public class MojangCachedSkinProvider implements ISkinProvider
{

private static final ExecutorService pool = Executors.newCachedThreadPool();
private static final BufferedImage dummy = new BufferedImage(1, 1, 2);

private File _workDir;

public MojangCachedSkinProvider()
Expand All @@ -50,7 +45,7 @@ public ISkin getSkin(AbstractClientPlayer player)
data.profile = player.getGameProfile();
final boolean flag = PlayerUtils.isOfflinePlayer(player);
final UUID fbID = player.getUniqueID();
pool.execute(new Runnable()
Shared.pool.execute(new Runnable()
{

@Override
Expand Down Expand Up @@ -78,7 +73,7 @@ public void run()
}
}

if (image != null && image != dummy)
if (image != null && image != Shared.dummy)
{
String type = SkinData.judgeSkinType(image);
if ("legacy".equals(type))
Expand Down Expand Up @@ -222,7 +217,7 @@ private BufferedImage readImageCached(File workDir, String local, URL remote, Pr
}
else if (code == 404)
{
return dummy;
return Shared.dummy;
}

if (!file1.exists())
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/lain/mods/skinport/providers/Shared.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package lain.mods.skinport.providers;

import java.awt.image.BufferedImage;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class Shared
{

protected static final ExecutorService pool = Executors.newCachedThreadPool();
protected static final BufferedImage dummy = new BufferedImage(1, 1, 2);

}
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ public UserManagedCapeProvider()
@Override
public ISkin getSkin(AbstractClientPlayer player)
{
BufferedImage image = readImage(String.format("skins/uuid/%s.png", ObjectUtils.defaultIfNull(player.getGameProfile().getId(), player.getUniqueID()).toString().replaceAll("-", "")));
BufferedImage image = readImage(String.format("capes/uuid/%s.png", ObjectUtils.defaultIfNull(player.getGameProfile().getId(), player.getUniqueID()).toString().replaceAll("-", "")));
if (image == null)
image = readImage(String.format("skins/%s.png", ObjectUtils.defaultIfNull(player.getGameProfile().getName(), "")));
image = readImage(String.format("capes/%s.png", ObjectUtils.defaultIfNull(player.getGameProfile().getName(), "")));
if (image == null)
return null;
SkinData data = new SkinData();
Expand Down

0 comments on commit b84bd90

Please sign in to comment.