This repository has been archived by the owner on Dec 3, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
63 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,68 @@ | ||
package top.wetabq.easyapi | ||
|
||
import cn.nukkit.Server | ||
import cn.nukkit.plugin.PluginBase | ||
import top.wetabq.easyapi.module.EasyAPIModuleManager | ||
import top.wetabq.easyapi.utils.MerticsLite | ||
import top.wetabq.easyapi.utils.color | ||
import java.util.* | ||
|
||
|
||
object EasyAPI : PluginBase() { | ||
class EasyAPI : PluginBase() { | ||
|
||
|
||
var TITLE = "&c[&eEasy&aAPI&c]".color() | ||
var git = getGitInfo() | ||
|
||
val VERSION: String = this.description.version | ||
var GIT_VERSION = getVersion() | ||
|
||
val moduleManager = EasyAPIModuleManager | ||
override fun onLoad() { | ||
INSTANCE = this | ||
init() | ||
} | ||
|
||
override fun onEnable() { | ||
MerticsLite(this) | ||
moduleManager.registerDefault() | ||
logger.info("EasyAPI by WetABQ Enabled...") | ||
logger.info("EasyAPI Verison:$VERSION $GIT_VERSION by WetABQ Enabled...") | ||
} | ||
|
||
override fun onDisable() { | ||
moduleManager.disableAll() | ||
} | ||
|
||
private fun getGitInfo(): Properties { | ||
val gitFileStream = EasyAPI.javaClass.classLoader.getResourceAsStream("git.properties") | ||
val properties = Properties() | ||
properties.load(gitFileStream) | ||
return properties | ||
} | ||
companion object { | ||
|
||
lateinit var git: Properties | ||
lateinit var server: Server | ||
|
||
lateinit var INSTANCE: EasyAPI | ||
lateinit var VERSION: String | ||
lateinit var GIT_VERSION: String | ||
|
||
var TITLE = "&c[&eEasy&aAPI&c]".color() | ||
|
||
val moduleManager = EasyAPIModuleManager | ||
|
||
fun init() { | ||
server = INSTANCE.server | ||
git = getGitInfo() | ||
VERSION = INSTANCE.description.version | ||
GIT_VERSION = getVersion() | ||
} | ||
|
||
private fun getGitInfo(): Properties { | ||
val gitFileStream = INSTANCE::class.java.classLoader.getResourceAsStream("git.properties") | ||
val properties = Properties() | ||
properties.load(gitFileStream) | ||
return properties | ||
} | ||
|
||
private fun getVersion(): String { | ||
val version = StringBuilder() | ||
version.append("git-") | ||
var commitId: String | ||
return if (git.getProperty("git.commit.id.abbrev").also { | ||
commitId = it | ||
} == null) { | ||
version.append("null").toString() | ||
} else version.append(commitId).toString() | ||
} | ||
|
||
private fun getVersion(): String { | ||
val version = StringBuilder() | ||
version.append("git-") | ||
var commitId: String | ||
return if (git.getProperty("git.commit.id.abbrev").also { | ||
commitId = it | ||
} == null) { | ||
version.append("null").toString() | ||
} else version.append(commitId).toString() | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters