Skip to content
This repository has been archived by the owner on Oct 12, 2024. It is now read-only.

Commit

Permalink
refactor: reduce I/O on Discord hook postage
Browse files Browse the repository at this point in the history
  • Loading branch information
WiIIiam278 committed Apr 5, 2024
1 parent c723437 commit a5a6f8f
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,17 @@ enum Format {
EMBEDDED,
INLINE;

private String format;

@NotNull
private String getPostMessageFormat(@NotNull HuskChat plugin) {
if (this.format != null) {
return this.format;
}
try {
return new String(plugin.getResource(
String.format("discord/%s_message.json", name().toLowerCase(Locale.ENGLISH))
).readAllBytes(), StandardCharsets.UTF_8);
return this.format = new String(plugin.getResource(String.format(
"discord/%s_message.json", name().toLowerCase(Locale.ENGLISH)
)).readAllBytes(), StandardCharsets.UTF_8);
} catch (IOException e) {
throw new IllegalStateException("Unable to load \"" + name() + "\" Discord message format", e);
}
Expand Down

0 comments on commit a5a6f8f

Please sign in to comment.