diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 00000000..dcfc3147 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 00000000..bfad7a59 --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml new file mode 100644 index 00000000..ff9696e1 --- /dev/null +++ b/.idea/kotlinc.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 00000000..1abba6f0 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/build.gradle b/build.gradle index bbbe1e46..acee4570 100644 --- a/build.gradle +++ b/build.gradle @@ -2,7 +2,7 @@ plugins { id 'org.jetbrains.kotlin.jvm' version '1.7.0' id 'maven-publish' id 'com.github.johnrengelman.shadow' version '7.1.2' - id 'net.kyori.blossom' version '1.2.0' + id 'cl.franciscosolis.blossom-extended' version '1.3.1' id 'org.jetbrains.dokka' version '1.6.21' } @@ -65,8 +65,6 @@ java { } blossom { - replaceTokenIn('src/main/kotlin/xyz/theprogramsrc/simplecoreapi/velocity/VelocityLoader.kt') - replaceToken '@name@', rootProject.name replaceToken '@version@', project.version.toString() replaceToken '@description@', project.description @@ -136,4 +134,4 @@ publishing { } } -publish.dependsOn clean, test, jar, shadowJar \ No newline at end of file +publish.dependsOn clean, test, jar, shadowJar diff --git a/src/main/kotlin/xyz/theprogramsrc/simplecoreapi/global/SimpleCoreAPI.kt b/src/main/kotlin/xyz/theprogramsrc/simplecoreapi/global/SimpleCoreAPI.kt index c2b7b20c..6df49679 100644 --- a/src/main/kotlin/xyz/theprogramsrc/simplecoreapi/global/SimpleCoreAPI.kt +++ b/src/main/kotlin/xyz/theprogramsrc/simplecoreapi/global/SimpleCoreAPI.kt @@ -3,6 +3,7 @@ package xyz.theprogramsrc.simplecoreapi.global import xyz.theprogramsrc.simplecoreapi.global.module.ModuleManager import xyz.theprogramsrc.simplecoreapi.global.utils.ILogger import xyz.theprogramsrc.simplecoreapi.global.utils.SoftwareType +import xyz.theprogramsrc.simplecoreapi.global.utils.update.GitHubUpdateChecker import java.util.* /** @@ -26,12 +27,6 @@ class SimpleCoreAPI(logger: ILogger) { */ val moduleManager: ModuleManager? - /** - * SimpleCoreAPI Properties - * @return The [Properties] of SimpleCoreAPI - */ - val props: Properties = Properties() - /** * The [SoftwareType] type running on the server * @return The [SoftwareType] the server is running @@ -40,15 +35,12 @@ class SimpleCoreAPI(logger: ILogger) { init { instance = this - val resource = SimpleCoreAPI::class.java.getResource("/simplecoreapi.properties") - if (resource != null) { - props.load(resource.openStream()) - } logger.info("SimpleCoreAPI v${getVersion()} - Git Commit: ${getShortHash()}") if (getFullHash() != "unknown") { GitHubUpdateChecker(logger, "TheProgramSrc/SimpleCoreAPI", getVersion()).checkWithPrint() } + softwareType = SoftwareType.values().firstOrNull { it.check() } ?: SoftwareType.UNKNOWN if(softwareType != SoftwareType.UNKNOWN && softwareType.display != null) { logger.info("Running API with software ${softwareType.display}") @@ -60,19 +52,19 @@ class SimpleCoreAPI(logger: ILogger) { * Gets the short version of the commit hash * @return The short commit hash */ - fun getShortHash(): String = props.getProperty("git-short", "unknown") + fun getShortHash(): String = "@git_short@" /** * Gets the full version of the commit hash * @return The full commit hash */ - fun getFullHash(): String = props.getProperty("git-full", "unknown") + fun getFullHash(): String = "@git_full@" /** * Gets the version of SimpleCoreAPI * @return The version of SimpleCoreAPI */ - fun getVersion(): String = props.getProperty("version", "unknown") + fun getVersion(): String = "@version@" /** * Checks if the current [SoftwareType] is the one specified diff --git a/src/main/kotlin/xyz/theprogramsrc/simplecoreapi/global/module/ModuleManager.kt b/src/main/kotlin/xyz/theprogramsrc/simplecoreapi/global/module/ModuleManager.kt index 04123940..fd2499fa 100644 --- a/src/main/kotlin/xyz/theprogramsrc/simplecoreapi/global/module/ModuleManager.kt +++ b/src/main/kotlin/xyz/theprogramsrc/simplecoreapi/global/module/ModuleManager.kt @@ -1,9 +1,9 @@ package xyz.theprogramsrc.simplecoreapi.global.module import org.apache.commons.io.FileUtils -import xyz.theprogramsrc.simplecoreapi.global.GitHubUpdateChecker import xyz.theprogramsrc.simplecoreapi.global.exceptions.* import xyz.theprogramsrc.simplecoreapi.global.utils.ILogger +import xyz.theprogramsrc.simplecoreapi.global.utils.update.GitHubUpdateChecker import java.io.File import java.io.FileInputStream import java.io.IOException diff --git a/src/main/kotlin/xyz/theprogramsrc/simplecoreapi/global/GitHubUpdateChecker.kt b/src/main/kotlin/xyz/theprogramsrc/simplecoreapi/global/utils/update/GitHubUpdateChecker.kt similarity index 98% rename from src/main/kotlin/xyz/theprogramsrc/simplecoreapi/global/GitHubUpdateChecker.kt rename to src/main/kotlin/xyz/theprogramsrc/simplecoreapi/global/utils/update/GitHubUpdateChecker.kt index 41a334d3..f3586387 100644 --- a/src/main/kotlin/xyz/theprogramsrc/simplecoreapi/global/GitHubUpdateChecker.kt +++ b/src/main/kotlin/xyz/theprogramsrc/simplecoreapi/global/utils/update/GitHubUpdateChecker.kt @@ -1,4 +1,4 @@ -package xyz.theprogramsrc.simplecoreapi.global +package xyz.theprogramsrc.simplecoreapi.global.utils.update import com.google.gson.JsonObject import com.google.gson.JsonParser diff --git a/src/main/resources/simplecoreapi.properties b/src/main/resources/simplecoreapi.properties deleted file mode 100644 index f8288154..00000000 --- a/src/main/resources/simplecoreapi.properties +++ /dev/null @@ -1,3 +0,0 @@ -git-full=@git_full@ -git-short=@git_short@ -version=@version@ \ No newline at end of file diff --git a/src/test/kotlin/xyz/theprogramsrc/simplecoreapi/global/GitHubUpdateCheckerTest.kt b/src/test/kotlin/xyz/theprogramsrc/simplecoreapi/global/GitHubUpdateCheckerTest.kt index 20b52116..edd6c60b 100644 --- a/src/test/kotlin/xyz/theprogramsrc/simplecoreapi/global/GitHubUpdateCheckerTest.kt +++ b/src/test/kotlin/xyz/theprogramsrc/simplecoreapi/global/GitHubUpdateCheckerTest.kt @@ -2,6 +2,7 @@ package xyz.theprogramsrc.simplecoreapi.global import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Test +import xyz.theprogramsrc.simplecoreapi.global.utils.update.GitHubUpdateChecker import xyz.theprogramsrc.simplecoreapi.global.utils.logger.JavaLogger import xyz.theprogramsrc.simplecoreapi.global.utils.logger.SLF4JLogger import java.util.logging.Logger @@ -20,4 +21,4 @@ internal class GitHubUpdateCheckerTest { fun updatesAvailableTest() { assertEquals(true, check2.checkForUpdates()) } -} \ No newline at end of file +}