explicit presence declaration

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

View File

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