From 351b8aaf84258760a568552add7c88ba244e0173 Mon Sep 17 00:00:00 2001
From: Quentin Legot
Date: Fri, 24 Mar 2023 19:56:10 +0100
Subject: [PATCH] Add a new api method (not developed yet)
Signed-off-by: Quentin Legot
---
.../toolbox/pagination/api/PaginationApi.java | 29 ++++++++++++++++++-
.../pagination/api/PaginationApiImpl.java | 6 ++++
2 files changed, 34 insertions(+), 1 deletion(-)
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 88f345e..c7bea9a 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
@@ -1,12 +1,15 @@
package fr.altarik.toolbox.pagination.api;
import net.minecraft.server.network.ServerPlayerEntity;
+import net.minecraft.text.Text;
+
+import java.util.List;
public interface PaginationApi {
/**
* Create a pagination table for player, content is separated into multiple pages.
- * You can separate yourself content by adding *\n\n* between two pages.
+ * You can separate yourself content between two pages by adding *\n\n*.
* Content have a time-to-live of 15 minutes (18,000 ticks)
* @param playerEntity The player who will be able to interact and see the paginated message
* @param content Content you want to paginate
@@ -24,6 +27,30 @@ public interface PaginationApi {
*/
void createTable(ServerPlayerEntity playerEntity, String content, String header, boolean display);
+ /**
+ * Create a pagination table for player the same way than
+ * {@link PaginationApi#createTable(ServerPlayerEntity, String, String, boolean)},
+ * content is separated into multiple pages.
+ * You can separate yourself content between 2 pages by adding a null instance of Text in content list.
+ * Content have a time-to-live of 15 minutes (18,000 ticks)
+ * @param playerEntity The player who will be able to interact and see the paginated message
+ * @param content Content you want to paginate
+ * @param header header/title you want to add to every page, empty space is filled with "=".
+ * Special values are:
+ * - null if you doesn't want to add a header
+ * - Empty textif you want just the header to be filled only with "="
+ * @param display true if you want the message to be displayed now, false otherwise if you want to display the
+ * message yourself
+ * @throws IllegalArgumentException if one of its conditions is met:
+ * - header length is more than 50 characters
+ * - content is empty/blank
+ * - playerEntity or content are null
+ *
+ * @see Text#empty()
+ */
+ void createTable(ServerPlayerEntity playerEntity, List content, Text header, boolean display);
+
+
/**
* Display the given page for the given player
* @param player display the content of this player
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 43c858f..a95946c 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
@@ -7,6 +7,7 @@ import fr.altarik.toolbox.pagination.precondition.NullPlayerCondition;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.network.ServerPlayerEntity;
+import net.minecraft.text.Text;
import net.minecraft.util.Pair;
import java.util.ArrayList;
@@ -44,6 +45,11 @@ public class PaginationApiImpl implements PaginationApi {
}
}
+ @Override
+ public void createTable(ServerPlayerEntity playerEntity, List content, Text header, boolean display) {
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+
@Override
public void display(ServerPlayerEntity player, int page) throws PageIndexOutOfBoundException {
if(player == null)