Skip to content

Commit

Permalink
slightly different javadoc
Browse files Browse the repository at this point in the history
  • Loading branch information
powercasgamer committed May 31, 2024
1 parent 45146b9 commit 0328028
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -40,9 +40,9 @@ private JarManifests() {
private static final Map<ClassLoader, Manifest> 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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 0328028

Please sign in to comment.