Add a new api method (not developed yet)
All checks were successful
build (17, ubuntu-latest)

Signed-off-by: Quentin Legot <legotquentin@gmail.com>
This commit is contained in:
Quentin Legot 2023-03-24 19:56:10 +01:00
parent 30853dee70
commit 351b8aaf84
2 changed files with 34 additions and 1 deletions

View File

@ -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 {
/**
* <p>Create a pagination table for player, content is separated into multiple pages.<br>
* You can separate yourself content by adding *\n\n* between two pages.</p>
* You can separate yourself content between two pages by adding *\n\n*.</p>
* <p>Content have a time-to-live of 15 minutes (18,000 ticks)</p>
* @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);
/**
* <p>Create a pagination table for player the same way than
* {@link PaginationApi#createTable(ServerPlayerEntity, String, String, boolean)},
* content is separated into multiple pages.<br />
* You can separate yourself content between 2 pages by adding a null instance of Text in content list.</p>
* <p>Content have a time-to-live of 15 minutes (18,000 ticks)</p>
* @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 "=".
* <p>Special values are:</p>
* <ul><li><b>null</b> if you doesn't want to add a header</li>
* <li><b>Empty text</b>if you want just the header to be filled only with "="</li></ul>
* @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: <ol>
* <li><b>header</b> length is more than 50 characters</li>
* <li><b>content</b> is empty/blank</li>
* <li><b>playerEntity</b> or <b>content</b> are null</li>
* </ol>
* @see Text#empty()
*/
void createTable(ServerPlayerEntity playerEntity, List<Text> content, Text header, boolean display);
/**
* Display the given page for the given player
* @param player display the content of this player

View File

@ -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<Text> content, Text header, boolean display) {
throw new UnsupportedOperationException("Not yet implemented");
}
@Override
public void display(ServerPlayerEntity player, int page) throws PageIndexOutOfBoundException {
if(player == null)