Compare commits
No commits in common. "19e1dd2937113bc3cb05b3dbd1c66914aad08f96" and "7a21af570b971f9be1e26e58d3cb27cd431c8819" have entirely different histories.
19e1dd2937
...
7a21af570b
@ -16,7 +16,7 @@ public interface PaginationApi {
|
||||
* <li><b>empty String</b> if you want just the header to be filled only with "="</li></ul>
|
||||
* @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>content</b> is empty</li>
|
||||
* <li><b>playerEntity</b> or <b>content</b> are null</li>
|
||||
* </ol>
|
||||
*/
|
||||
|
@ -1,27 +1,18 @@
|
||||
package fr.altarik.toolbox.pagination.api;
|
||||
|
||||
import fr.altarik.toolbox.pagination.PaginatedContent;
|
||||
import fr.altarik.toolbox.pagination.precondition.ContentCondition;
|
||||
import fr.altarik.toolbox.pagination.precondition.HeaderCondition;
|
||||
import fr.altarik.toolbox.pagination.precondition.NullPlayerCondition;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.util.Pair;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class PaginationApiImpl implements PaginationApi {
|
||||
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();
|
||||
private final Predicate<String> contentCondition = new ContentCondition().negate();
|
||||
|
||||
Map<ServerPlayerEntity, Pair<Integer, PaginatedContent>> paginatedContent = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void createTable(ServerPlayerEntity playerEntity, String content, String header) {
|
||||
if(playerCondition.test(playerEntity) || headerCondition.test(header) || contentCondition.test(content)) {
|
||||
throw new IllegalArgumentException("Preconditions aren't satisfied");
|
||||
}
|
||||
|
||||
// TODO: 01/03/2023
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +0,0 @@
|
||||
package fr.altarik.toolbox.pagination.precondition;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
/**
|
||||
* This predicate returns true if the String is not null or
|
||||
* if its content is not blank (empty or only contains whitespaces)
|
||||
*/
|
||||
public class ContentCondition implements Predicate<String> {
|
||||
@Override
|
||||
public boolean test(String s) {
|
||||
return s != null && !s.isBlank();
|
||||
}
|
||||
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
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.
|
||||
*/
|
||||
public class HeaderCondition implements Predicate<String> {
|
||||
@Override
|
||||
public boolean test(String header) {
|
||||
return header != null && !header.isBlank() && header.length() <= 50;
|
||||
}
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
package fr.altarik.toolbox.pagination.precondition;
|
||||
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
/**
|
||||
* This predicate returns true if the player isn't null, false otherwise
|
||||
*/
|
||||
public class NullPlayerCondition implements Predicate<ServerPlayerEntity> {
|
||||
@Override
|
||||
public boolean test(ServerPlayerEntity player) {
|
||||
return player != null;
|
||||
}
|
||||
}
|
@ -1,3 +1,24 @@
|
||||
plugins {
|
||||
id 'fabric-loom'
|
||||
|
||||
}
|
||||
|
||||
dependencies {
|
||||
minecraft "com.mojang:minecraft:${project.minecraft_version}"
|
||||
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
|
||||
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
|
||||
|
||||
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
|
||||
}
|
||||
|
||||
processResources {
|
||||
inputs.property "version", project.version
|
||||
|
||||
filesMatching("fabric.mod.json") {
|
||||
expand "version": project.version
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
// ensure that the encoding is set to UTF-8, no matter what the system default is
|
||||
// this fixes some edge cases with special characters not displaying correctly
|
||||
|
47
build.gradle
47
build.gradle
@ -1,12 +1,11 @@
|
||||
plugins {
|
||||
id 'java'
|
||||
id 'fabric-loom' version '1.1-SNAPSHOT'
|
||||
id 'fabric-loom' version '1.1-SNAPSHOT' apply false
|
||||
}
|
||||
|
||||
allprojects {
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'maven-publish'
|
||||
apply plugin: 'fabric-loom'
|
||||
|
||||
group = project.maven_group
|
||||
version = project.maven_version
|
||||
@ -47,45 +46,13 @@ allprojects {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
processResources {
|
||||
inputs.property "version", project.version
|
||||
|
||||
filesMatching("fabric.mod.json") {
|
||||
expand "version": project.version
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
// ensure that the encoding is set to UTF-8, no matter what the system default is
|
||||
// this fixes some edge cases with special characters not displaying correctly
|
||||
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
|
||||
// If Javadoc is generated, this must be specified in that task too.
|
||||
it.options.encoding = "UTF-8"
|
||||
|
||||
// The Minecraft launcher currently installs Java 8 for users, so your mod probably wants to target Java 8 too
|
||||
// JDK 9 introduced a new way of specifying this that will make sure no newer classes or methods are used.
|
||||
// We'll use that if it's available, but otherwise we'll use the older option.
|
||||
def targetVersion = 17
|
||||
if (JavaVersion.current().isJava9Compatible()) {
|
||||
it.options.release = targetVersion
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testImplementation "org.junit.jupiter:junit-jupiter-api:${project.junit_version}"
|
||||
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${project.junit_version}"
|
||||
minecraft "com.mojang:minecraft:${project.minecraft_version}"
|
||||
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
|
||||
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
subprojects {
|
||||
|
||||
dependencies {
|
||||
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
|
||||
testImplementation "org.junit.jupiter:junit-jupiter-api:${project.junit_version}"
|
||||
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${project.junit_version}"
|
||||
}
|
||||
|
||||
java {
|
||||
@ -99,15 +66,11 @@ subprojects {
|
||||
|
||||
}
|
||||
|
||||
dependencies {
|
||||
include allprojects.collect { project -> project }
|
||||
}
|
||||
|
||||
/*jar {
|
||||
jar {
|
||||
dependsOn subprojects.jar
|
||||
subprojects.each { project ->
|
||||
from(project.jar) {
|
||||
into("META-INF/jars/")
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
@ -16,6 +16,9 @@
|
||||
"license": "Altarik @ All-Rights-Reserved ",
|
||||
"icon": "assets/quests/icon.png",
|
||||
"environment": "*",
|
||||
"mixins": [
|
||||
"toolbox.mixins.json"
|
||||
],
|
||||
"depends": {
|
||||
"fabricloader": "^0.14.12",
|
||||
"fabric-api": "*",
|
||||
|
Loading…
Reference in New Issue
Block a user