From be9c4de0978a21ad83d1b0922868f064eec3b6e4 Mon Sep 17 00:00:00 2001 From: Quentin Legot Date: Sun, 19 Mar 2023 19:53:54 +0100 Subject: [PATCH] Fix HeaderCondition Signed-off-by: Quentin Legot --- .../fr/altarik/toolbox/pagination/PaginatedContent.java | 5 +++++ .../fr/altarik/toolbox/pagination/api/PaginationApi.java | 1 + .../altarik/toolbox/pagination/api/PaginationApiImpl.java | 6 ++++-- .../toolbox/pagination/precondition/HeaderCondition.java | 5 ++--- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Pagination/src/main/java/fr/altarik/toolbox/pagination/PaginatedContent.java b/Pagination/src/main/java/fr/altarik/toolbox/pagination/PaginatedContent.java index ca07c3a..50eb02c 100644 --- a/Pagination/src/main/java/fr/altarik/toolbox/pagination/PaginatedContent.java +++ b/Pagination/src/main/java/fr/altarik/toolbox/pagination/PaginatedContent.java @@ -1,4 +1,9 @@ package fr.altarik.toolbox.pagination; public class PaginatedContent { + + public PaginatedContent(String header, String content) { + // TODO: 19/03/2023 + } + } diff --git a/Pagination/src/main/java/fr/altarik/toolbox/pagination/api/PaginationApi.java b/Pagination/src/main/java/fr/altarik/toolbox/pagination/api/PaginationApi.java index 3b23724..36f4f07 100644 --- a/Pagination/src/main/java/fr/altarik/toolbox/pagination/api/PaginationApi.java +++ b/Pagination/src/main/java/fr/altarik/toolbox/pagination/api/PaginationApi.java @@ -2,6 +2,7 @@ package fr.altarik.toolbox.pagination.api; import net.minecraft.server.network.ServerPlayerEntity; +@SuppressWarnings("unused") // Api usage public interface PaginationApi { /** diff --git a/Pagination/src/main/java/fr/altarik/toolbox/pagination/api/PaginationApiImpl.java b/Pagination/src/main/java/fr/altarik/toolbox/pagination/api/PaginationApiImpl.java index 2e27090..93e7972 100644 --- a/Pagination/src/main/java/fr/altarik/toolbox/pagination/api/PaginationApiImpl.java +++ b/Pagination/src/main/java/fr/altarik/toolbox/pagination/api/PaginationApiImpl.java @@ -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> paginatedContent = new HashMap<>(); private final Predicate playerCondition = new NullPlayerCondition().negate(); private final Predicate 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))); } } diff --git a/Pagination/src/main/java/fr/altarik/toolbox/pagination/precondition/HeaderCondition.java b/Pagination/src/main/java/fr/altarik/toolbox/pagination/precondition/HeaderCondition.java index d39cde5..9b9ee5e 100644 --- a/Pagination/src/main/java/fr/altarik/toolbox/pagination/precondition/HeaderCondition.java +++ b/Pagination/src/main/java/fr/altarik/toolbox/pagination/precondition/HeaderCondition.java @@ -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 { @Override public boolean test(String header) { - return header != null && !header.isBlank() && header.length() <= 50; + return header.length() <= 50; } }