diff --git a/build.gradle b/build.gradle index 0157bae..980e5b1 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ plugins { } -group 'net.william278' +group 'org.inksnow.husk' version "1.1.2${versionMetadata()}" defaultTasks 'licenseFormat', 'build' @@ -32,7 +32,7 @@ archivesBaseName = "${rootProject.name}" tasks { compileJava { options.encoding = 'UTF-8' - options.release.set(11) + options.release.set(8) } jar { manifest { @@ -67,42 +67,24 @@ test { publishing { repositories { - if (System.getenv("RELEASES_MAVEN_USERNAME") != null) { - maven { - name = "william278-releases" - url = "https://repo.william278.net/releases" - credentials { - username = System.getenv("RELEASES_MAVEN_USERNAME") - password = System.getenv("RELEASES_MAVEN_PASSWORD") - } - authentication { - basic(BasicAuthentication) - } - } - } - if (System.getenv("SNAPSHOTS_MAVEN_USERNAME") != null) { - maven { - name = "william278-snapshots" - url = "https://repo.william278.net/snapshots" - credentials { - username = System.getenv("SNAPSHOTS_MAVEN_USERNAME") - password = System.getenv("SNAPSHOTS_MAVEN_PASSWORD") - } - authentication { - basic(BasicAuthentication) - } + maven { + name = 'husk-release' + url = findProperty("repository.huskrelease.url") + credentials { + username = findProperty("repository.huskrelease.username") + password = findProperty("repository.huskrelease.password") } } + } - publications { - mavenJava(MavenPublication) { - groupId = 'net.william278' - artifactId = 'paginedown' - version = "$rootProject.version" - artifact jar - artifact javadocJar - artifact sourcesJar - } + publications { + mavenJava(MavenPublication) { + groupId = 'org.inksnow.husk' + artifactId = 'paginedown' + version = "$rootProject.version" + artifact jar + artifact javadocJar + artifact sourcesJar } } } diff --git a/src/main/java/net/william278/paginedown/PaginatedList.java b/src/main/java/net/william278/paginedown/PaginatedList.java index ff9398c..1d1d37f 100644 --- a/src/main/java/net/william278/paginedown/PaginatedList.java +++ b/src/main/java/net/william278/paginedown/PaginatedList.java @@ -21,6 +21,7 @@ package net.william278.paginedown; import de.themoep.minedown.adventure.MineDown; +import net.william278.paginedown.util.StringUtil; import org.jetbrains.annotations.NotNull; import java.util.List; @@ -136,7 +137,7 @@ public class PaginatedList { } final StringJoiner menuJoiner = new StringJoiner("\n"); - if (!options.headerFormat.isBlank()) { + if (!StringUtil.isBlank(options.headerFormat)) { menuJoiner.add(formatPageString(options.headerFormat, page)); if (options.spaceAfterHeader) { menuJoiner.add(""); @@ -150,7 +151,7 @@ public class PaginatedList { menuJoiner.add(String.join(options.itemSeparator, getItemsForPage(page))); } - if (!options.footerFormat.isBlank()) { + if (!StringUtil.isBlank(options.footerFormat)) { if (options.spaceBeforeFooter) { menuJoiner.add(""); } @@ -291,7 +292,7 @@ public class PaginatedList { lastPage = i; } } - if (!pages.toString().isBlank()) { + if (!StringUtil.isBlank(pages.toString())) { pageGroups.add(pages.toString()); } return pageGroups.toString(); diff --git a/src/main/java/net/william278/paginedown/util/StringUtil.java b/src/main/java/net/william278/paginedown/util/StringUtil.java new file mode 100644 index 0000000..0f09eb1 --- /dev/null +++ b/src/main/java/net/william278/paginedown/util/StringUtil.java @@ -0,0 +1,40 @@ +/* + * This file is part of PagineDown, licensed under the Apache License 2.0. + * + * Copyright (c) William278 + * Copyright (c) contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.william278.paginedown.util; + +public final class StringUtil { + + private StringUtil() { + throw new UnsupportedOperationException("This is a utility class and cannot be instantiated"); + } + + public static boolean isBlank(String $this) { + final int strLen = $this.length(); + if (strLen == 0) { + return true; + } + for (int i = 0; i < strLen; i++) { + if (!Character.isWhitespace($this.charAt(i))) { + return false; + } + } + return true; + } +}