explicit presence declaration

This commit is contained in:
Szum123321 2022-08-31 22:50:48 +02:00
parent 91447b7b3c
commit 6707e813b2
2 changed files with 6 additions and 8 deletions

View File

@ -34,9 +34,7 @@ import java.util.concurrent.CompletableFuture;
public final class FileSuggestionProvider implements SuggestionProvider<ServerCommandSource> {
private static final FileSuggestionProvider INSTANCE = new FileSuggestionProvider();
public static FileSuggestionProvider Instance() {
return INSTANCE;
}
public static FileSuggestionProvider Instance() { return INSTANCE; }
@Override
public CompletableFuture<Suggestions> getSuggestions(CommandContext<ServerCommandSource> ctx, SuggestionsBuilder builder) {
@ -47,14 +45,14 @@ public final class FileSuggestionProvider implements SuggestionProvider<ServerCo
if (formattedCreationTime.startsWith(remaining)) {
if (Utilities.wasSentByPlayer(ctx.getSource())) { //was typed by player
if (file.getComment() != null) {
builder.suggest(formattedCreationTime, new LiteralMessage("Comment: " + file.getComment()));
if (file.getComment().isPresent()) {
builder.suggest(formattedCreationTime, new LiteralMessage("Comment: " + file.getComment().get()));
} else {
builder.suggest(formattedCreationTime);
}
} else { //was typed from server console
if (file.getComment() != null) {
builder.suggest(file.getCreationTime() + "#" + file.getComment());
if (file.getComment().isPresent()) {
builder.suggest(file.getCreationTime() + "#" + file.getComment().get());
} else {
builder.suggest(formattedCreationTime);
}

View File

@ -107,7 +107,7 @@ public class RestoreableFile implements Comparable<RestoreableFile> {
public LocalDateTime getCreationTime() { return creationTime; }
public String getComment() { return comment; }
public Optional<String> getComment() { return Optional.ofNullable(comment); }
@Override
public int compareTo(@NotNull RestoreableFile o) { return creationTime.compareTo(o.creationTime); }