Added builder, DataTracker and KeyValue #16
@ -1,4 +1,9 @@
|
||||
package fr.altarik.toolbox.pagination;
|
||||
|
||||
public class PaginatedContent {
|
||||
|
||||
public PaginatedContent(String header, String content) {
|
||||
// TODO: 19/03/2023
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package fr.altarik.toolbox.pagination.api;
|
||||
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
|
||||
@SuppressWarnings("unused") // Api usage
|
||||
public interface PaginationApi {
|
||||
|
||||
/**
|
||||
|
@ -12,6 +12,9 @@ import java.util.Map;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class PaginationApiImpl implements PaginationApi {
|
||||
/**
|
||||
* Integer represent relative tts of the paginated content, decreased by 1 every seconds
|
||||
*/
|
||||
private final Map<ServerPlayerEntity, Pair<Integer, PaginatedContent>> paginatedContent = new HashMap<>();
|
||||
private final Predicate<ServerPlayerEntity> playerCondition = new NullPlayerCondition().negate();
|
||||
private final Predicate<String> headerCondition = new HeaderCondition().negate();
|
||||
@ -21,7 +24,6 @@ public class PaginationApiImpl implements PaginationApi {
|
||||
if(playerCondition.test(playerEntity) || headerCondition.test(header) || contentCondition.test(content)) {
|
||||
throw new IllegalArgumentException("Preconditions aren't satisfied");
|
||||
}
|
||||
|
||||
// TODO: 01/03/2023
|
||||
paginatedContent.put(playerEntity, new Pair<>(900, new PaginatedContent(header, content)));
|
||||
}
|
||||
}
|
||||
|
@ -3,12 +3,11 @@ package fr.altarik.toolbox.pagination.precondition;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
/**
|
||||
* This predicate returns true if header is not null, not blank (not empty excluding whitespaces)
|
||||
* and if its length doesn't exceed 50 characters.
|
||||
* This predicate returns true if its length doesn't exceed 50 characters.
|
||||
*/
|
||||
public class HeaderCondition implements Predicate<String> {
|
||||
@Override
|
||||
public boolean test(String header) {
|
||||
return header != null && !header.isBlank() && header.length() <= 50;
|
||||
return header.length() <= 50;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user