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