|
2 | 2 |
|
3 | 3 | import com.google.gson.Gson; |
4 | 4 | import com.google.gson.GsonBuilder; |
| 5 | +import org.geysermc.mcprotocollib.auth.texture.Texture; |
| 6 | +import org.geysermc.mcprotocollib.auth.texture.TextureType; |
5 | 7 | import org.geysermc.mcprotocollib.auth.util.TextureUrlChecker; |
6 | 8 | import org.geysermc.mcprotocollib.auth.util.UndashedUUIDAdapter; |
7 | 9 |
|
@@ -192,7 +194,7 @@ public Map<TextureType, Texture> getTextures(boolean requireSecure) throws Illeg |
192 | 194 |
|
193 | 195 | if (result != null && result.textures != null) { |
194 | 196 | if (requireSecure) { |
195 | | - for (GameProfile.Texture texture : result.textures.values()) { |
| 197 | + for (Texture texture : result.textures.values()) { |
196 | 198 | if (TextureUrlChecker.isAllowedTextureDomain(texture.getURL())) { |
197 | 199 | continue; |
198 | 200 | } |
@@ -357,100 +359,11 @@ public String toString() { |
357 | 359 | } |
358 | 360 | } |
359 | 361 |
|
360 | | - /** |
361 | | - * The type of a profile texture. |
362 | | - */ |
363 | | - public enum TextureType { |
364 | | - SKIN, |
365 | | - CAPE, |
366 | | - ELYTRA; |
367 | | - } |
368 | | - |
369 | | - /** |
370 | | - * The model used for a profile texture. |
371 | | - */ |
372 | | - public enum TextureModel { |
373 | | - WIDE, |
374 | | - SLIM; |
375 | | - } |
376 | | - |
377 | | - /** |
378 | | - * A texture contained within a profile. |
379 | | - */ |
380 | | - public static class Texture { |
381 | | - private final String url; |
382 | | - private final Map<String, String> metadata; |
383 | | - |
384 | | - /** |
385 | | - * Creates a new Texture instance. |
386 | | - * |
387 | | - * @param url URL of the texture. |
388 | | - * @param metadata Metadata of the texture. |
389 | | - */ |
390 | | - public Texture(String url, Map<String, String> metadata) { |
391 | | - this.url = url; |
392 | | - this.metadata = metadata; |
393 | | - } |
394 | | - |
395 | | - /** |
396 | | - * Gets the URL of the texture. |
397 | | - * |
398 | | - * @return The texture's URL. |
399 | | - */ |
400 | | - public String getURL() { |
401 | | - return this.url; |
402 | | - } |
403 | | - |
404 | | - /** |
405 | | - * Gets a metadata string from the texture. |
406 | | - * |
407 | | - * @return The metadata value corresponding to the given key. |
408 | | - */ |
409 | | - public String getMetadata(String key) { |
410 | | - if (this.metadata == null) { |
411 | | - return null; |
412 | | - } |
413 | | - |
414 | | - return this.metadata.get(key); |
415 | | - } |
416 | | - |
417 | | - /** |
418 | | - * Gets the model of the texture. |
419 | | - * |
420 | | - * @return The texture's model. |
421 | | - */ |
422 | | - public TextureModel getModel() { |
423 | | - String model = this.getMetadata("model"); |
424 | | - return model != null && model.equals("slim") ? TextureModel.SLIM : TextureModel.WIDE; |
425 | | - } |
426 | | - |
427 | | - /** |
428 | | - * Gets the hash of the texture. |
429 | | - * |
430 | | - * @return The texture's hash. |
431 | | - */ |
432 | | - public String getHash() { |
433 | | - String url = this.url.endsWith("/") ? this.url.substring(0, this.url.length() - 1) : this.url; |
434 | | - int slash = url.lastIndexOf("/"); |
435 | | - int dot = url.lastIndexOf("."); |
436 | | - if (dot < slash) { |
437 | | - dot = url.length(); |
438 | | - } |
439 | | - |
440 | | - return url.substring(slash + 1, dot != -1 ? dot : url.length()); |
441 | | - } |
442 | | - |
443 | | - @Override |
444 | | - public String toString() { |
445 | | - return "Texture{url=" + this.url + ", model=" + this.getModel() + ", hash=" + this.getHash() + "}"; |
446 | | - } |
447 | | - } |
448 | | - |
449 | 362 | private static class MinecraftTexturesPayload { |
450 | 363 | public long timestamp; |
451 | 364 | public UUID profileId; |
452 | 365 | public String profileName; |
453 | 366 | public boolean isPublic; |
454 | | - public Map<GameProfile.TextureType, GameProfile.Texture> textures; |
| 367 | + public Map<TextureType, Texture> textures; |
455 | 368 | } |
456 | 369 | } |
0 commit comments