Skip to content

Commit

Permalink
Fix wrong detection of relocation
Browse files Browse the repository at this point in the history
  • Loading branch information
rainbowdashlabs committed Jan 8, 2025
1 parent f169d90 commit 03499f7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ plugins {
publishData {
addRepo(Repo.main("", "", false))
addRepo(Repo.snapshot("SNAPSHOT", "", false))
publishingVersion = "2.1.8"
publishingVersion = "2.1.9"
}
version = publishData.getVersion()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class MessageSenderBuilder {
private final TagResolver.Builder errorTagResolver = TagResolver.builder()
.tag("default", Tag.styling(NamedTextColor.RED));
private final TagResolver.Builder defaultTagResolver = TagResolver.builder();
private static final String ADVENTURE_PATH = String.join(".","net", "kyori", "adventure", "text");

@NotNull
private final Plugin plugin;
Expand Down Expand Up @@ -117,8 +118,13 @@ public MessageSender register() {
.resolver(StandardTags.defaults())
.build();
MessageSender messageSender;
if (!isPaper() || hasRelocatedAdventure()) {
plugin.getLogger().info("Using Spigot Message Sender");
plugin.getLogger().info("Determining message sender type");
boolean paper = isPaper();
if (!paper) {
plugin.getLogger().info("Detected non paper based server");
}
if (!paper || hasRelocatedAdventure()) {
plugin.getLogger().info("Using legacy message sender");
messageSender = new SpigotMessageSender(plugin,
miniMessage.tags(defaultResolver)
.preProcessor(in -> preProcessor.apply(localizer.localize(in)))
Expand All @@ -140,7 +146,11 @@ public MessageSender register() {
return messageSender;
}

public static boolean hasRelocatedAdventure() {
return !Component.class.getPackageName().startsWith(String.join("net", "kyori", "adventure", "text"));
boolean hasRelocatedAdventure() {
boolean relocated = !Component.class.getPackageName().startsWith(ADVENTURE_PATH);
if (relocated) {
plugin.getLogger().info("Found relocated adventure at %s instead of net.kyori.adventure.text.".formatted(Component.class.getPackageName()));
}
return relocated;
}
}

0 comments on commit 03499f7

Please sign in to comment.