Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,36 +37,45 @@ public float getWidth() {
}

public NativeImage getImage() {
if (this.textures.isEmpty() && !this.loading && !this.failed) {
new Thread(() -> {
List<EmoteBackedTexture> textures;
URL url;
try {
url = new URL(this.emote.url.replace("http:", "https:"));
} catch (MalformedURLException ignored) {
TwitchEmotes.LOGGER.error("Invalid URL for emote '" + this.emote.name + "'.");
TwitchEmotes.invalidateEmote(this.emote);
return;
}
try {
TextureReader textureReader = new TextureReader(url, this.emote.imageType);
textures = new ArrayList<>(textureReader.read());
} catch (IOException e) {
TwitchEmotes.LOGGER.error("Error while reading image for '" + this.emote.name + "'", e);
TwitchEmotes.invalidateEmote(this.emote);
this.failed = true;
try {
if (this.textures.isEmpty() && !this.loading && !this.failed) {
new Thread(() -> {
List<EmoteBackedTexture> textures;
URL url;
try {
url = new URL(this.emote.url.replace("http:", "https:"));
} catch (MalformedURLException ignored) {
TwitchEmotes.LOGGER.error("Invalid URL for emote '" + this.emote.name + "'.");
TwitchEmotes.invalidateEmote(this.emote);
return;
}
try {
TextureReader textureReader = new TextureReader(url, this.emote.imageType);
textures = new ArrayList<>(textureReader.read());
} catch (IOException e) {
TwitchEmotes.LOGGER.error("Error while reading image for '" + this.emote.name + "'", e);
TwitchEmotes.invalidateEmote(this.emote);
this.failed = true;
this.loading = false;
return null;
}
this.textures.addAll(textures);
this.loading = false;
return;
}
this.textures.addAll(textures);
this.loading = false;
}).start();
this.loading = true;
return null;
} else if (this.loading) {
}).start();
this.loading = true;
return null;
} else if (this.loading) {
return null;
}
return this.textures.get(this.currentFrame).getImage();
} catch (Exception e) {
TwitchEmotes.LOGGER.error("Error while reading image for '" + this.emote.name + "'", e);
TwitchEmotes.invalidateEmote(this.emote);
this.failed = true;
this.loading = false;
return null;
}
return this.textures.get(this.currentFrame).getImage();
return null;
}

public void postRender() {
Expand Down