()
| 105 | |
| 106 | EXECUTOR_SERVICE.execute(new Runnable() { |
| 107 | @Override |
| 108 | public void run() { |
| 109 | MinecraftFactory.getClassProxyCallback().getLogger().debug("Loading player resource textures from {} for player {}", minecraftProfileTexture.getUrl(), gameProfile.getName()); |
| 110 | |
| 111 | HttpURLConnection connection = null; |
| 112 | BufferedReader reader = null; |
| 113 | try { |
| 114 | connection = (HttpURLConnection) (new URL(minecraftProfileTexture.getUrl())).openConnection(MinecraftFactory.getVars().getProxy()); |
| 115 | connection.setDoInput(true); |
| 116 | connection.setDoOutput(false); |
| 117 | connection.connect(); |
| 118 | |
| 119 | if (connection.getResponseCode() != 200) { |
| 120 | return; |
| 121 | } |
| 122 | reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); |
| 123 | String line = reader.readLine(); |
| 124 | |
| 125 | TextureData data = gson.fromJson(line, TextureData.class); |
| 126 | if (data.animatedCape != null && !data.animatedCape.isEmpty()) { |
| 127 | try { |
| 128 | BufferedImage cape = ImageIO.read(new ByteArrayInputStream(Base64.decodeBase64(data.animatedCape))); |
| 129 | capeTexture.setBufferedImage(cape); |
| 130 | |
| 131 | playerResource.setCapeResource(new CapeResource(capeLocation, capeTexture)); |
| 132 | } catch (Exception e) { |
| 133 | MinecraftFactory.getClassProxyCallback().getLogger().error("Could not parse cape for " + gameProfile.getId(), e); |
| 134 | } |
| 135 | } else if (data.cape != null && !data.cape.isEmpty()) { |
| 136 | try { |
| 137 | BufferedImage cape = ImageIO.read(new ByteArrayInputStream(Base64.decodeBase64(data.cape))); |
| 138 | capeTexture.setBufferedImage(cape); |
| 139 | |
| 140 | playerResource.setCapeResource(new CapeResource(capeLocation, capeTexture)); |
| 141 | } catch (Exception e) { |
| 142 | MinecraftFactory.getClassProxyCallback().getLogger().error("Could not parse cape for " + gameProfile.getId(), e); |
| 143 | } |
| 144 | } |
| 145 | if (data.models != null) { |
| 146 | playerResource.setItemModelResources(Lists.<ItemModelResource>newArrayList()); |
| 147 | List<TextureData.Model> models = data.models; |
| 148 | for (TextureData.Model model : models) { |
| 149 | if (StringUtils.isEmpty(model.itemName) || StringUtils.isEmpty(model.texture)) { |
| 150 | continue; |
| 151 | } |
| 152 | try { |
| 153 | ail item = ail.g.c(new ResourceLocation(model.itemName)); |
| 154 | if (item != null) { |
| 155 | final ResourceLocation modelLocation = new ResourceLocation( |
| 156 | "item-models/" + gameProfile.getId() + "/" + model.itemName + (StringUtils.isNotEmpty(model.render) ? "/" + model.render.toLowerCase( |
| 157 | Locale.ROOT) : "") + ".png"); |
| 158 | final SimpleTexture modelTexture = new SimpleTexture(); |
| 159 | if (((Variables) MinecraftFactory.getVars()).getTextureManager().b(modelLocation) == null) { |
| 160 | ((Variables) MinecraftFactory.getVars()).getTextureManager().a(modelLocation, modelTexture); |
| 161 | } |
| 162 | |
| 163 | BufferedImage modelImage = ImageIO.read(new ByteArrayInputStream(Base64.decodeBase64(model.texture))); |
| 164 | modelTexture.setBufferedImage(modelImage); |
nothing calls this directly
no test coverage detected