Added builder, DataTracker and KeyValue #16

Manually merged
quentinlegot merged 40 commits from dev into master 2023-06-13 22:15:40 +02:00
4 changed files with 12 additions and 5 deletions
Showing only changes of commit be9c4de097 - Show all commits

View File

@ -1,4 +1,9 @@
package fr.altarik.toolbox.pagination; package fr.altarik.toolbox.pagination;
public class PaginatedContent { public class PaginatedContent {
public PaginatedContent(String header, String content) {
// TODO: 19/03/2023
}
} }

View File

@ -2,6 +2,7 @@ package fr.altarik.toolbox.pagination.api;
import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.network.ServerPlayerEntity;
@SuppressWarnings("unused") // Api usage
public interface PaginationApi { public interface PaginationApi {
/** /**

View File

@ -12,6 +12,9 @@ import java.util.Map;
import java.util.function.Predicate; import java.util.function.Predicate;
public class PaginationApiImpl implements PaginationApi { 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 Map<ServerPlayerEntity, Pair<Integer, PaginatedContent>> paginatedContent = new HashMap<>();
private final Predicate<ServerPlayerEntity> playerCondition = new NullPlayerCondition().negate(); private final Predicate<ServerPlayerEntity> playerCondition = new NullPlayerCondition().negate();
private final Predicate<String> headerCondition = new HeaderCondition().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)) { if(playerCondition.test(playerEntity) || headerCondition.test(header) || contentCondition.test(content)) {
throw new IllegalArgumentException("Preconditions aren't satisfied"); throw new IllegalArgumentException("Preconditions aren't satisfied");
} }
paginatedContent.put(playerEntity, new Pair<>(900, new PaginatedContent(header, content)));
// TODO: 01/03/2023
} }
} }

View File

@ -3,12 +3,11 @@ package fr.altarik.toolbox.pagination.precondition;
import java.util.function.Predicate; import java.util.function.Predicate;
/** /**
* This predicate returns true if header is not null, not blank (not empty excluding whitespaces) * This predicate returns true if its length doesn't exceed 50 characters.
* and if its length doesn't exceed 50 characters.
*/ */
public class HeaderCondition implements Predicate<String> { public class HeaderCondition implements Predicate<String> {
@Override @Override
public boolean test(String header) { public boolean test(String header) {
return header != null && !header.isBlank() && header.length() <= 50; return header.length() <= 50;
} }
} }