diff --git a/api/src/main/java/com/velocitypowered/api/util/buildinfo/ServerBuildInfo.java b/api/src/main/java/com/velocitypowered/api/util/buildinfo/ServerBuildInfo.java index 4e485a168c..da708ac0e6 100644 --- a/api/src/main/java/com/velocitypowered/api/util/buildinfo/ServerBuildInfo.java +++ b/api/src/main/java/com/velocitypowered/api/util/buildinfo/ServerBuildInfo.java @@ -12,6 +12,7 @@ import java.util.OptionalInt; import net.kyori.adventure.key.Key; import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer; import net.kyori.adventure.util.Services; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; @@ -102,10 +103,12 @@ final class Holder { * @return a string */ // This *could* be a PlainTextSerializer string of asComponent()? - @NotNull String asString(final @NotNull StringRepresentation representation); + @NotNull default String asString(final @NotNull StringRepresentation representation) { + return PlainTextComponentSerializer.plainText().serialize(asComponent(representation)); + } @NotNull - default Component asComponent(final @NotNull StringRepresentation representation) { return Component.empty(); } + Component asComponent(final @NotNull StringRepresentation representation); /** * String representation types. diff --git a/proxy/src/main/java/com/velocitypowered/proxy/util/JarManifests.java b/proxy/src/main/java/com/velocitypowered/proxy/util/JarManifests.java index b9e3dccdf1..b13ca9499e 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/util/JarManifests.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/util/JarManifests.java @@ -24,13 +24,13 @@ import java.util.Map; import java.util.WeakHashMap; import java.util.jar.Manifest; + import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** - * This is the jar manifest class. - * It does manifest stuff. + * Internal class that is able to do {@link Manifest} stuff. */ @ApiStatus.Internal public final class JarManifests { @@ -40,9 +40,9 @@ private JarManifests() { private static final Map MANIFESTS = Collections.synchronizedMap(new WeakHashMap<>()); /** - * Manifest. It gets a manifest from a jar. + * Gets the {@link Manifest} from a class. * - * @param clazz the CLASS. + * @param clazz the class to get the {@link Manifest} from. * @return the manifest or null. */ public static @Nullable Manifest manifest(final @NotNull Class clazz) { diff --git a/proxy/src/main/java/com/velocitypowered/proxy/util/buildinfo/ServerBuildInfoImpl.java b/proxy/src/main/java/com/velocitypowered/proxy/util/buildinfo/ServerBuildInfoImpl.java index b99493738d..d81314450f 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/util/buildinfo/ServerBuildInfoImpl.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/util/buildinfo/ServerBuildInfoImpl.java @@ -37,7 +37,7 @@ import org.jetbrains.annotations.NotNull; /** - * This is internal it does not need a javadoc CHECKSTYLE. + * Information about the current proxy build. */ @AutoService(ServerBuildInfo.class) public record ServerBuildInfoImpl( @@ -94,40 +94,6 @@ public boolean isBrandCompatible(final @NotNull Key brandId) { return brandId.equals(this.brandId); } - @Override - public @NotNull String asString(final @NotNull StringRepresentation representation) { - final StringBuilder sb = new StringBuilder(); - sb.append(this.velocityVersionName); - sb.append('-'); - final OptionalInt buildNumber = this.buildNumber; - if (buildNumber.isPresent()) { - sb.append(buildNumber.getAsInt()); - } else { - sb.append(BUILD_DEV); - } - final boolean hasGitBranch = this.gitBranch.isPresent(); - final boolean hasGitCommit = this.gitCommit.isPresent(); - if (hasGitBranch || hasGitCommit) { - sb.append('-'); - } - if (hasGitBranch && representation == StringRepresentation.VERSION_FULL) { - sb.append(this.gitBranch.get()); - if (hasGitCommit) { - sb.append('@'); - } - } - if (hasGitCommit) { - sb.append(this.gitCommit.get()); - } - if (representation == StringRepresentation.VERSION_FULL) { - sb.append(' '); - sb.append('('); - sb.append(this.buildTime.truncatedTo(ChronoUnit.SECONDS)); - sb.append(')'); - } - return sb.toString(); - } - @Override public @NotNull Component asComponent(final @NotNull StringRepresentation representation) { final TextComponent.Builder sb = text();