Skip to content

Commit

Permalink
Refactor import statements and optimize MiniMessage builder in NameMC…
Browse files Browse the repository at this point in the history
….java
  • Loading branch information
NonSwag committed Jul 19, 2024
1 parent 93301a2 commit dccda0e
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/main/java/net/thenextlvl/namemc/NameMC.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
import com.velocitypowered.api.plugin.annotation.DataDirectory;
import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.ProxyServer;
import core.api.file.format.GsonFile;
import core.file.format.GsonFile;
import core.i18n.file.ComponentBundle;
import core.io.IO;
import lombok.Getter;
import lombok.experimental.Accessors;
import net.kyori.adventure.text.minimessage.MiniMessage;
Expand Down Expand Up @@ -48,7 +49,7 @@ public NameMC(ProxyServer server, Logger logger, @DataDirectory Path dataDirecto
this.logger = logger;
this.dataDirectory = dataDirectory.toFile();
this.config = new GsonFile<>(
new File(dataDirectory(), "config.json"),
IO.of(dataDirectory(), "config.json"),
new Config("example.com", "https://example.com/namemc", 60000)
).saveIfAbsent().getRoot();
this.bundle = new ComponentBundle(
Expand All @@ -58,12 +59,11 @@ public NameMC(ProxyServer server, Logger logger, @DataDirectory Path dataDirecto
: Locale.US)
.register("namemc", Locale.US)
.register("namemc_german", Locale.GERMANY)
.fallback(Locale.US);
bundle().miniMessage(MiniMessage.builder().tags(TagResolver.resolver(
TagResolver.standard(),
Placeholder.component("prefix", bundle().component(Locale.US, "prefix")),
Placeholder.parsed("url", config().url())
)).build());
.miniMessage(bundle -> MiniMessage.builder().tags(TagResolver.resolver(
TagResolver.standard(),
Placeholder.parsed("url", config().url()),
Placeholder.component("prefix", bundle.component(Locale.US, "prefix"))
)).build());
this.cache = new Likes(this);
}

Expand Down

0 comments on commit dccda0e

Please sign in to comment.