diff --git a/README.md b/README.md index 222f879b..11241295 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,20 @@ # FDUtilities -基于Taboolib开发的一个动态类、模组加载插件。 +~~基于Taboolib开发的一个动态类、模组加载插件。~~ + +基于Taboolib开发的一个插件。 *** ## 计划 -- [ ] 写FClassLoader -- [ ] 抄Artifex代码 -- [ ] 重写Taboolib的Config代码 -- [x] 不知道 +- [ ] 基础功能实现 +- [ ] 工作空间 +- [ ] 多线程加载配置 +- [ ] 动态更新配置 +- [ ] FItem实现 +- [ ] FItem的其他插件支持 +- [ ] ~~完成脚本动态加载、卸载功能~~ *八千年后再实现 *** diff --git a/build.gradle.kts b/build.gradle.kts index 0cf34b7b..f3ec297b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -34,7 +34,8 @@ subprojects { group = rootGroup version = rootVersion - if (parent?.name != "plugin" && parent?.name != "module") { + //TODO ǧٸ + if (parent?.name != "plugin" /*&& parent?.name != "module"*/) { buildDirClean() } @@ -47,9 +48,9 @@ gradle.buildFinished { .childProjects["plugin"]!!.childProjects.values .forEach { copyByProject(it, "${rootName}-${it.version}") } - rootProject - .childProjects["module"]!!.childProjects.values - .forEach { copyByProject(it) } +// rootProject TODO do after 8000 years +// .childProjects["module"]!!.childProjects.values +// .forEach { copyByProject(it) } } fun copyByProject(p: Project, caught: String = "${p.name}-${p.version}") { diff --git a/module/TestModule/build.gradle.kts b/module/TestModule/build.gradle.kts deleted file mode 100644 index e2e760e1..00000000 --- a/module/TestModule/build.gradle.kts +++ /dev/null @@ -1,5 +0,0 @@ -version = "0.0.1" - -dependencies { - api(project(":project:core")) -} \ No newline at end of file diff --git a/module/TestModule/src/main/kotlin/Test2.kt b/module/TestModule/src/main/kotlin/Test2.kt deleted file mode 100644 index bc5adcbe..00000000 --- a/module/TestModule/src/main/kotlin/Test2.kt +++ /dev/null @@ -1,5 +0,0 @@ -object Test2 { - - val abc = "66666666sadasaaaaaaadsada666" - -} diff --git a/module/TestModule/src/main/kotlin/TestModule.kt b/module/TestModule/src/main/kotlin/TestModule.kt deleted file mode 100644 index 1cb5223a..00000000 --- a/module/TestModule/src/main/kotlin/TestModule.kt +++ /dev/null @@ -1,20 +0,0 @@ -import cn.fd.utilities.core.module.ModuleExpansion - -class TestModule : ModuleExpansion() { - - override val name: String = "Test" - override val author: String = "MC~蛟龙 (qq1610105206)" - override val version: String = "0.0.1" - - override fun printMyself() { - super.printMyself() - println("测试awa2") - println(Test2.abc) - } - - override fun load() { - //TestConfig.reload() - printMyself() - } - -} \ No newline at end of file diff --git a/module/TestModule/src/main/resources/ServerTeleport.yml b/module/TestModule/src/main/resources/ServerTeleport.yml deleted file mode 100644 index b89ed3d3..00000000 --- a/module/TestModule/src/main/resources/ServerTeleport.yml +++ /dev/null @@ -1,2 +0,0 @@ -#跨服传送 -#测试 diff --git a/plugin/platform-bukkit/src/main/kotlin/cn/fd/utilities/bukkit/FDUtilities.kt b/plugin/platform-bukkit/src/main/kotlin/cn/fd/utilities/bukkit/FDUtilities.kt index 21d422ff..cfa96c3e 100644 --- a/plugin/platform-bukkit/src/main/kotlin/cn/fd/utilities/bukkit/FDUtilities.kt +++ b/plugin/platform-bukkit/src/main/kotlin/cn/fd/utilities/bukkit/FDUtilities.kt @@ -1,20 +1,8 @@ package cn.fd.utilities.bukkit -import cn.fd.utilities.bukkit.config.ConfigYaml -import cn.fd.utilities.bukkit.util.FileListener -import cn.fd.utilities.bukkit.util.Loader -import cn.fd.utilities.env.BukkitEnv -import cn.fd.utilities.env.CommonEnv -import org.bukkit.Bukkit -import taboolib.common.env.RuntimeEnv -import taboolib.common.platform.Awake import taboolib.common.platform.Platform import taboolib.common.platform.PlatformSide import taboolib.common.platform.Plugin -import taboolib.common.platform.function.console -import taboolib.common.platform.function.pluginVersion -import taboolib.module.lang.Language -import taboolib.module.lang.sendLang import taboolib.platform.BukkitPlugin @PlatformSide([Platform.BUKKIT]) @@ -22,35 +10,8 @@ object FDUtilities : Plugin() { val plugin by lazy { BukkitPlugin.getInstance() } - /** - * 加载依赖项 - */ - @Awake - fun loadDependency() { - RuntimeEnv.ENV.loadDependency(CommonEnv::class.java, true) - RuntimeEnv.ENV.loadDependency(BukkitEnv::class.java, true) - } - override fun onLoad() { - //BungeeChannel.init() - //插件语言设置 - Language.default = ConfigYaml.LANGUAGE - //加载模块配置文件 - Loader.reloadAll() - console().sendLang("Plugin-Loading", Bukkit.getBukkitVersion()) - } - - override fun onEnable() { -// //开启并创建 BukkitAudiences -// Adventure.enable() - - //Extension.printInfo() - console().sendLang("Plugin-Enabled", pluginVersion) - } - - override fun onDisable() { - //关闭配置文件监听器 - FileListener.uninstall() + println("Hello World!") } } \ No newline at end of file diff --git a/plugin/platform-bukkit/src/main/kotlin/cn/fd/utilities/bukkit/channel/BungeeChannel.kt b/plugin/platform-bukkit/src/main/kotlin/cn/fd/utilities/bukkit/channel/BungeeChannel.kt deleted file mode 100644 index f1bd2623..00000000 --- a/plugin/platform-bukkit/src/main/kotlin/cn/fd/utilities/bukkit/channel/BungeeChannel.kt +++ /dev/null @@ -1,61 +0,0 @@ -package cn.fd.utilities.bukkit.channel - -import com.google.common.io.ByteStreams -import org.bukkit.Bukkit -import org.bukkit.entity.Player -import org.bukkit.plugin.messaging.PluginMessageListener -import taboolib.common.platform.function.submit -import java.io.IOException - -@Deprecated("未完成") -object BungeeChannel : ChannelManager(), PluginMessageListener { - - var Servers: ArrayList = ArrayList() - - fun init() { - - if (!Bukkit.getMessenger().isOutgoingChannelRegistered(plugin, BUNGEE_CHANNEL)) { - Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, BUNGEE_CHANNEL) - } - if (!Bukkit.getMessenger().isIncomingChannelRegistered(plugin, BUNGEE_CHANNEL)) { - Bukkit.getMessenger().registerIncomingPluginChannel(plugin, BUNGEE_CHANNEL, this) - } - submit(period = 60, async = true) { - sendCommonMessage(plugin.server, "GetServers") - } - } - - fun printServers() { - if (Servers.isEmpty()) - sendCommonMessage(plugin.server, "GetServers") - println(Servers) - } - - override fun onPluginMessageReceived(channel: String, player: Player, message: ByteArray) { - println("频道: $channel \n玩家: $player \n信息: $message") - //如果为Bungee频道 - if (channel == BUNGEE_CHANNEL) { - try { - val data = ByteStreams.newDataInput(message) - val subChannel = data.readUTF() - - println(subChannel) - if (subChannel == "GetServers") { - val list: List = data.readUTF().split(", ") - //Servers.clear() - for (server in list) { - println(server) - Servers.add(server) - } - - } - } catch (_: IOException) { - } - } - if (channel == FDUTILITIES_CHANNEL) { - error("我就过来皮一下~") - } - - } - -} \ No newline at end of file diff --git a/plugin/platform-bukkit/src/main/kotlin/cn/fd/utilities/bukkit/channel/ChannelManager.kt b/plugin/platform-bukkit/src/main/kotlin/cn/fd/utilities/bukkit/channel/ChannelManager.kt deleted file mode 100644 index d31919a4..00000000 --- a/plugin/platform-bukkit/src/main/kotlin/cn/fd/utilities/bukkit/channel/ChannelManager.kt +++ /dev/null @@ -1,43 +0,0 @@ -package cn.fd.utilities.bukkit.channel - -import cn.fd.utilities.bukkit.FDUtilities -import com.google.common.io.ByteStreams -import org.bukkit.plugin.messaging.PluginMessageRecipient -import taboolib.common.platform.function.submit -import java.io.IOException - -@Deprecated("未完成") -open class ChannelManager { - - //不可修改! - val BUNGEE_CHANNEL = "BungeeCord" - - val FDUTILITIES_CHANNEL = "FDUtilities:Channel" - - val plugin by lazy { FDUtilities.plugin } - - fun sendCommonMessage(recipient: PluginMessageRecipient, vararg args: String, async: Boolean = false): Boolean { - var success = true - submit(async = async) { - val out = ByteStreams.newDataOutput() - - try { - for (arg in args) { - out.writeUTF(arg) - } - } catch (e: IOException) { - e.printStackTrace() - //e.print("Failed to send proxy common message!") - success = false - } - - recipient.sendPluginMessage(plugin, BUNGEE_CHANNEL, out.toByteArray()) - } - return success - } - - @Deprecated("未完成") - fun sendFDUtilitiesMessage() { - } - -} \ No newline at end of file diff --git a/plugin/platform-bukkit/src/main/kotlin/cn/fd/utilities/bukkit/command/MainCommand.kt b/plugin/platform-bukkit/src/main/kotlin/cn/fd/utilities/bukkit/command/MainCommand.kt deleted file mode 100644 index cdbb620b..00000000 --- a/plugin/platform-bukkit/src/main/kotlin/cn/fd/utilities/bukkit/command/MainCommand.kt +++ /dev/null @@ -1,91 +0,0 @@ -package cn.fd.utilities.bukkit.command - -import cn.fd.utilities.bukkit.util.Loader -import taboolib.common.platform.Platform -import taboolib.common.platform.PlatformSide -import taboolib.common.platform.command.CommandBody -import taboolib.common.platform.command.CommandHeader -import taboolib.common.platform.command.subCommand -import taboolib.common.platform.function.console -import taboolib.module.lang.sendLang - -@Deprecated("测试用") -@PlatformSide([Platform.BUKKIT]) -@CommandHeader(name = "fdutilities") -object MainCommand { - - /** - * 重载插件的命令 - */ - @CommandBody - val main = subCommand { - //时间计算 - val before = System.currentTimeMillis() - //重载部分 - Loader.reloadAll() - //发送重载消息 - console().sendLang("Plugin-Reload", System.currentTimeMillis() - before) - } -// -// //测试命令 -// @CommandBody(permission = "fdutilities.command.test", permissionDefault = PermissionDefault.TRUE, optional = true) -// val test = subCommand { -// execute { sender, _, argument -> -// val arg = argument.split("test")[1] -// if (sender is Player) { -// val player: Player = sender -// val msg = player.eval(arg).thenApply { Coerce.toString(it) }.get() -// player.sendMessage(msg) -// -// runKether { -// arg.parseKetherScript().broadcast() -// player.sendMessage(arg.parseKetherScript().toString()) -// } -// -// } -// -// //val mapList = PlaceholderAPIExtension.conf.getMapList("TestMap") -// //info(mapList) -//// for (map in mapList) { -//// val c = map["condition"] -//// info(map) -//// info(c) -//// if (sender is Player) { -//// val player: Player = sender -//// val msg = player.eval(c.toString()).thenApply { Coerce.toString(it) }.get() -//// player.sendMessage(msg) -//// -//// } -//// } -// -// -// } -// } -// -// /** -// * 帮助命令 -// */ -// @CommandBody(permission = "fdutilities.command.help", permissionDefault = PermissionDefault.TRUE, optional = true) -// val help = subCommand { -// execute { sender, _, _ -> -// //显示帮助消息 -// adaptCommandSender(sender).sendLang("Command-Help", pluginVersion) -// } -// } -// -// /** -// * 主命令 -// */ -// @CommandBody -// val main = mainCommand { -// execute { sender, _, argument -> -// if (argument.isEmpty()) { -// //显示帮助消息 -// adaptCommandSender(sender).sendLang("Command-Help", pluginVersion) -// return@execute -// } -// } -// } - - -} \ No newline at end of file diff --git a/plugin/platform-bukkit/src/main/kotlin/cn/fd/utilities/bukkit/config/ConfigYaml.kt b/plugin/platform-bukkit/src/main/kotlin/cn/fd/utilities/bukkit/config/ConfigYaml.kt deleted file mode 100644 index 0cd1bb21..00000000 --- a/plugin/platform-bukkit/src/main/kotlin/cn/fd/utilities/bukkit/config/ConfigYaml.kt +++ /dev/null @@ -1,28 +0,0 @@ -package cn.fd.utilities.bukkit.config - -import taboolib.module.configuration.Config -import taboolib.module.configuration.ConfigNode -import taboolib.module.configuration.Configuration - -/** - * 配置文件: config.yml - * @author MC~蛟龙 - * @since 2023/5/13 15:28 - */ -object ConfigYaml { - - @Config(autoReload = true) - lateinit var conf: Configuration - private set - - - @ConfigNode(value = "Settings.language") - var LANGUAGE = "zh_CN" - - @ConfigNode(value = "Settings.Multi-Thread") - var MULTI_THREAD = true - - @ConfigNode(value = "Workspaces.paths") - var WORKSPACES_PATHS = listOf("plugins/FDUtilities/workspace") - -} \ No newline at end of file diff --git a/plugin/platform-bukkit/src/main/kotlin/cn/fd/utilities/bukkit/loader/DependenciesLoader.kt b/plugin/platform-bukkit/src/main/kotlin/cn/fd/utilities/bukkit/loader/DependenciesLoader.kt new file mode 100644 index 00000000..52c1d810 --- /dev/null +++ b/plugin/platform-bukkit/src/main/kotlin/cn/fd/utilities/bukkit/loader/DependenciesLoader.kt @@ -0,0 +1,20 @@ +package cn.fd.utilities.bukkit.loader + +import cn.fd.utilities.env.BukkitEnv +import cn.fd.utilities.env.CommonEnv +import taboolib.common.env.RuntimeEnv +import taboolib.common.platform.Awake + +//оеС +object DependenciesLoader { + + /** + * + */ + @Awake + fun loadDependency() { + RuntimeEnv.ENV.loadDependency(CommonEnv::class.java, true) + RuntimeEnv.ENV.loadDependency(BukkitEnv::class.java, true) + } + +} \ No newline at end of file diff --git a/plugin/platform-bukkit/src/main/kotlin/cn/fd/utilities/bukkit/util/FileListener.kt b/plugin/platform-bukkit/src/main/kotlin/cn/fd/utilities/bukkit/util/FileListener.kt deleted file mode 100644 index 32bf38cb..00000000 --- a/plugin/platform-bukkit/src/main/kotlin/cn/fd/utilities/bukkit/util/FileListener.kt +++ /dev/null @@ -1,51 +0,0 @@ -package cn.fd.utilities.bukkit.util - -import taboolib.common5.FileWatcher -import java.io.File - - -/** - * @author MC~蛟龙 - * qq: 1610105206 - * @date 2022/6/15 - */ -object FileListener { - - private val listening = mutableSetOf() - - fun isListening(file: File): Boolean { - return watcher.hasListener(file) - } - - fun listener(file: File, runFirst: Boolean = true, runnable: () -> Unit) { - watcher.addSimpleListener(file, runnable, runFirst) - listening.add(file) - } - - fun unlisten(file: File) { - watcher.removeListener(file) - listening.remove(file) - } - - fun clear() { - var count = 0 - listening.removeIf { - val remove = !it.exists() - if (remove) { - watcher.removeListener(it) - count++ - } - remove - } - if (count > 0) { - println("DEBUG: CLEARED $count unused listeners") - } - } - - fun uninstall() { - watcher.unregisterAll() - } - - val watcher = FileWatcher() - -} \ No newline at end of file diff --git a/plugin/platform-bukkit/src/main/kotlin/cn/fd/utilities/bukkit/util/KetherParser.kt b/plugin/platform-bukkit/src/main/kotlin/cn/fd/utilities/bukkit/util/KetherParser.kt deleted file mode 100644 index 07f8839f..00000000 --- a/plugin/platform-bukkit/src/main/kotlin/cn/fd/utilities/bukkit/util/KetherParser.kt +++ /dev/null @@ -1,30 +0,0 @@ -package cn.fd.utilities.bukkit.util - -import org.bukkit.entity.Player -import taboolib.common.platform.function.adaptPlayer -import taboolib.common.platform.function.console -import taboolib.common5.mirrorNow -import taboolib.library.kether.LocalizedException -import taboolib.module.kether.KetherShell -import taboolib.module.lang.sendLang -import java.util.concurrent.CompletableFuture - -object KetherParser { - - @JvmStatic - fun Player.eval(script: String): CompletableFuture { - return mirrorNow("Handler:Script:Evaluation") { - return@mirrorNow try { - KetherShell.eval(script, namespace = listOf("fdutilities")) { - sender = adaptPlayer(this@eval) - } - } catch (e: LocalizedException) { - e.localizedMessage.split("\n").forEach { - console().sendLang("Kether-Shell-Exception", it) - } - CompletableFuture.completedFuture(false) - } - } - } - -} \ No newline at end of file diff --git a/plugin/platform-bukkit/src/main/kotlin/cn/fd/utilities/bukkit/util/Loader.kt b/plugin/platform-bukkit/src/main/kotlin/cn/fd/utilities/bukkit/util/Loader.kt deleted file mode 100644 index 013b866a..00000000 --- a/plugin/platform-bukkit/src/main/kotlin/cn/fd/utilities/bukkit/util/Loader.kt +++ /dev/null @@ -1,102 +0,0 @@ -package cn.fd.utilities.bukkit.util - -import cn.fd.utilities.bukkit.config.ConfigYaml -import cn.fd.utilities.bukkit.util.FileListener.unlisten -import cn.fd.utilities.core.module.ModuleLoader -import cn.fd.utilities.core.module.ModuleLoader.getModuleManager -import cn.fd.utilities.core.module.ModuleManager -import cn.fd.utilities.core.module.outdated.Module -import taboolib.common.platform.function.console -import taboolib.common.reflect.Reflex.Companion.invokeMethod -import taboolib.module.lang.Language -import taboolib.module.lang.sendLang -import java.io.File -import java.util.function.Consumer - -object Loader { - - fun reloadConfigs() { - ConfigYaml.conf.reload() - } - - fun reloadAll() { - - ModuleLoader.setModuleManager( - ModuleManager( - arrayListOf().apply { - ConfigYaml.WORKSPACES_PATHS.forEach { - add(File(it)) - } - } - ) - ) - - //重载语言 - Language.reload() - //重载所有配置文件 - reloadConfigs() - //重载所有模块 - //reloadModules() - //测试 - //BungeeChannel.printServers() - //TODO 多线程 -// val lock = ReentrantLock() -// Thread { -// lock.lock() - getModuleManager().registerAll() -// lock.unlock() -// }.apply { name = "Module-Loader" }.start() - - println(getModuleManager().modules) - getModuleManager().modules.keys.forEach { - println(it) - getModuleManager().getModuleById(it.identifier).printMyself() - } - } - - - /** - * 监听文件 - * @param file 要监听的文件 - */ - @Deprecated("后面会改") - fun listen(file: File, function: Consumer /*() -> Unit*/) { - //如果未开启多线程,就不监听文件了 - if (!ConfigYaml.MULTI_THREAD) return - println("测试1") - //如果未开启多线程,就不监听文件了 - if (!ConfigYaml.MULTI_THREAD) return - - /** - * 当文件变化时,重新加载模块 - */ - if (!FileListener.isListening(file)) { - //监听文件变化 - FileListener.listener(file) { - val start = System.currentTimeMillis() - try { - //执行方法 - //run(function) - function.invokeMethod(String(), null) - } catch (t: Throwable) { - //报告错误日志 - console().sendLang("Module-Config-Failed", file.name, t.stackTraceToString()) - return@listener - } - - //输出日志 - console().sendLang("Module-Config-Reloaded", file.name, System.currentTimeMillis() - start) - } - } - } - - /** - * 取消监听模块 - */ - @Deprecated("后面会改") - fun unlisten(module: Module) { - if (FileListener.isListening(module.file)) unlisten(module.file) - } - - -} \ No newline at end of file diff --git a/plugin/platform-bukkit/src/main/resources/config.yml b/plugin/platform-bukkit/src/main/resources/config.yml deleted file mode 100644 index dfd1c3ba..00000000 --- a/plugin/platform-bukkit/src/main/resources/config.yml +++ /dev/null @@ -1,12 +0,0 @@ -#欢迎使用FDUtilities插件 -#作者: MC~蛟龙 -#QQ: 1610105206 -#邮箱: 1610105206@qq.com - -Settings: - language: zh_CN - Multi-Thread: true - -Workspaces: - paths: - - 'plugins/FDUtilities/workspace' \ No newline at end of file diff --git a/plugin/platform-bukkit/src/main/resources/lang/en_US.yml b/plugin/platform-bukkit/src/main/resources/lang/en_US.yml deleted file mode 100644 index a5dbfa29..00000000 --- a/plugin/platform-bukkit/src/main/resources/lang/en_US.yml +++ /dev/null @@ -1,57 +0,0 @@ -#Language File -Plugin-Loading: - - '&r' - - '&7Loading &3FD&bUtilities&7... &8{0}' - - '&r' -Plugin-Enabled: '&8[&6FD&bUtilities] &bINFO &8| &3Loaded. FDUtilities &av{0} &3has been enabled.' -Plugin-Reload: '&8[&6FD&eUtilities&r&8] &aINFO &8| &3Successfully reloaded all configuration files &8({0}ms)' -Plugin-Dependency-Hooked: '&8[&6FD&eUtilities&r&8] &6HOOK &8| &7Soft-Dependency &f{0} &7is hooked.' - -Module-Config-Failed: - - '&8[&6FD&eUtilities&r&8] &cERROR &8| &4Unexpected error while loading module configuration file &c{0} &4:' - - ' &8{1}' -Module-Config-Reloaded: '&8[&6FD&eUtilities&r&8] &aMODULE &8| &7Settings &f{0} changed, reloaded... &8({1}ms)' -Module-Loader-Loading: '&8[&6FD&eUtilities&r&8] &6MODULE &8| &7Initializing modules...' -Module-Loader-Success: '&8[&6FD&eUtilities&r&8] &6MODULE &8| &aSuccessfully loaded module &6{0} &a!' -Module-Loader-Finished: '&8[&6FD&eUtilities&r&8] &6MODULE &8| &aSuccessfully registered and loaded &6{0} &a modules!' -Module-Loader-UnknownError: '&8[&6FD&eUtilities&r&8] &cERROR &8| &4An unknown problem occurred while creating an instance of the extension module.' -Module-Loader-NotClassError: '&8[&6FD&eUtilities&r&8] &cERROR &8| &4Could not load extension module &c{0} &4, Failed to find inheritance of related class.' -Module-Loader-NotRequiredMethodError: '&8[&6FD&eUtilities&r&8] &cERROR &8| &4Unable to load extension module &c{0} &4, Failed to find required method declaration.' -Module-Loader-NotDependencyError: '&8[&6FD&eUtilities&r&8] &cERROR &8| &4Failed to load extension module class &c{0} &4 &7 (Missing dependencies?)' -Module-Loader-NullIdentifierError: '&8[&6FD&eUtilities&r&8] &cERROR &8| &4Failed to load extension module class &c{0} &4, extension module identifier is empty!' -Module-Loader-VerifyError: - - '&8[&6FD&eUtilities&r&8] &cERROR &8| &4Unable to load extension module: &c{0} &7(Are there missing dependencies?)' - - ' &8{1} {2}' - -#Command Side -Command-Help: - - '&r' - - type: JSON - text: ' [&6FDUtilities] [&f{0}]' - args: - - hover: '&7FDUtilities is a fantaskic plugin' - - hover: '&7Plugin Version: &a{0}' - - '&r' - - type: JSON - text: ' &7Command: [&f/fdutilities]' - args: - - hover: '&f/fdutilities &8[...]' - suggest: '/fdutilities ' - - ' &7Parameter:' - - type: JSON - text: ' &8- [&fhelp]' - args: - - hover: '&f/fdutilities help &8- &7Show help' - suggest: '/fdutilities help ' - - ' &7Show help' - - type: JSON - text: ' &8- [&freload]' - args: - - hover: '&f/fdutilities reload &8- &7Reload plugin configs' - suggest: '/fdutilities reload ' - - ' &7Reload plugin configs' - - '&r' - -Kether-Shell-Exception: - - '&8[&6FD&eUtilities&r&8] &cERROR &8| §7Unexpected exception while parsing kether shell:' - - ' &8{0}' diff --git a/plugin/platform-bukkit/src/main/resources/lang/zh_CN.yml b/plugin/platform-bukkit/src/main/resources/lang/zh_CN.yml index 55fd62c8..09959ab9 100644 --- a/plugin/platform-bukkit/src/main/resources/lang/zh_CN.yml +++ b/plugin/platform-bukkit/src/main/resources/lang/zh_CN.yml @@ -1,59 +1,59 @@ -#语言文件 -Plugin-Loading: - - '&r' - - '&7正在加载 &6FD&eUtilities&7... &8{0}' - - '&r' -Plugin-Enabled: '&8[&6FD&eUtilities&r&8] &b信息 &8| &3加载完毕. FDUtilities &av{0} &3现已启用, 敬请使用.' -Plugin-Reload: '&8[&6FD&eUtilities&r&8] &a良好 &8| &3成功重载所有配置文件 &8({0}ms)' -Plugin-Dependency-Hooked: '&8[&6FD&eUtilities&r&8] &6挂钩 &8| &7软依赖 &f{0} &7已兼容.' - -Module-Config-Failed: - - '&8[&6FD&eUtilities&r&8] &c错误 &8| &4载入模块配置文件 &c{0} &4过程中出现意外错误:' - - ' &8{1}' -Module-Config-Reloaded: '&8[&6FD&eUtilities&r&8] &6模块 &8| &7监听到模块配置文件 &f{0} 改动, 已自动载入相关配置等... &8({1}ms)' -Module-Loader-Loading: '&8[&6FD&eUtilities&r&8] &6模块 &8| &7正在加载模块...' -Module-Loader-Success: '&8[&6FD&eUtilities&r&8] &6模块 &8| &a成功加载模块 &6{0} &a!' -Module-Loader-Unregistered: '&8[&6FD&eUtilities&r&8] &6模块 &8| &a已卸载模块 &6{0} &a!' -Module-Loader-Finished: '&8[&6FD&eUtilities&r&8] &6模块 &8| &a成功注册并加载了 &6{0} &a个模块!' -Module-Loader-UnknownError: '&8[&6FD&eUtilities&r&8] &c错误 &8| &4创建扩展模块实例时出现未知的问题.' -Module-Loader-NotClassError: '&8[&6FD&eUtilities&r&8] &c错误 &8| &4无法加载扩展模块 &c{0} &4, 未能找到相关类的继承.' -Module-Loader-NotRequiredMethodError: '&8[&6FD&eUtilities&r&8] &c错误 &8| &4无法加载扩展模块 &c{0} &4, 未能找到必要方法的声明.' -Module-Loader-NotDependencyError: '&8[&6FD&eUtilities&r&8] &c错误 &8| &4加载扩展模块类 &c{0} &4时失败 &7(是否缺少依赖项?)' -Module-Loader-NullIdentifierError: '&8[&6FD&eUtilities&r&8] &c错误 &8| &4加载扩展模块类 &c{0} &4时失败, 扩展模块的标识符(名称)为空!' -Module-Loader-VerifyError: - - '&8[&6FD&eUtilities&r&8] &c错误 &8| &4无法加载扩展模块: &c{0} &7(是否缺少依赖项?)' - - ' &8{1} {2}' - - -#命令方面 -Command-Help: - - '&r' - - type: JSON - text: ' [&6FDUtilities] [&f{0}]' - args: - - hover: '&7FDUtilities 是一个多功能插件' - - hover: '&7插件版本: &a{0}' - - '&r' - - type: JSON - text: ' &7命令: [&f/fdutilities]' - args: - - hover: '&f/fdutilities &8[...]' - suggest: '/fdutilities ' - - ' &7参数:' - - type: JSON - text: ' &8- [&fhelp]' - args: - - hover: '&f/fdutilities help &8- &7显示帮助信息' - suggest: '/fdutilities help ' - - ' &7显示帮助信息' - - type: JSON - text: ' &8- [&freload]' - args: - - hover: '&f/fdutilities reload &8- &7重载配置文件' - suggest: '/fdutilities reload ' - - ' &7重载配置文件' - - '&r' - -Kether-Shell-Exception: - - '&8[&6FD&eUtilities&r&8] &c错误 &8| &7解析 Kether Shell 时出现意外异常:' - - ' &8{0}' +##语言文件 +#Plugin-Loading: +# - '&r' +# - '&7正在加载 &6FD&eUtilities&7... &8{0}' +# - '&r' +#Plugin-Enabled: '&8[&6FD&eUtilities&r&8] &b信息 &8| &3加载完毕. FDUtilities &av{0} &3现已启用, 敬请使用.' +#Plugin-Reload: '&8[&6FD&eUtilities&r&8] &a良好 &8| &3成功重载所有配置文件 &8({0}ms)' +#Plugin-Dependency-Hooked: '&8[&6FD&eUtilities&r&8] &6挂钩 &8| &7软依赖 &f{0} &7已兼容.' +# +#Module-Config-Failed: +# - '&8[&6FD&eUtilities&r&8] &c错误 &8| &4载入模块配置文件 &c{0} &4过程中出现意外错误:' +# - ' &8{1}' +#Module-Config-Reloaded: '&8[&6FD&eUtilities&r&8] &6模块 &8| &7监听到模块配置文件 &f{0} 改动, 已自动载入相关配置等... &8({1}ms)' +#Module-Loader-Loading: '&8[&6FD&eUtilities&r&8] &6模块 &8| &7正在加载模块...' +#Module-Loader-Success: '&8[&6FD&eUtilities&r&8] &6模块 &8| &a成功加载模块 &6{0} &a!' +#Module-Loader-Unregistered: '&8[&6FD&eUtilities&r&8] &6模块 &8| &a已卸载模块 &6{0} &a!' +#Module-Loader-Finished: '&8[&6FD&eUtilities&r&8] &6模块 &8| &a成功注册并加载了 &6{0} &a个模块!' +#Module-Loader-UnknownError: '&8[&6FD&eUtilities&r&8] &c错误 &8| &4创建扩展模块实例时出现未知的问题.' +#Module-Loader-NotClassError: '&8[&6FD&eUtilities&r&8] &c错误 &8| &4无法加载扩展模块 &c{0} &4, 未能找到相关类的继承.' +#Module-Loader-NotRequiredMethodError: '&8[&6FD&eUtilities&r&8] &c错误 &8| &4无法加载扩展模块 &c{0} &4, 未能找到必要方法的声明.' +#Module-Loader-NotDependencyError: '&8[&6FD&eUtilities&r&8] &c错误 &8| &4加载扩展模块类 &c{0} &4时失败 &7(是否缺少依赖项?)' +#Module-Loader-NullIdentifierError: '&8[&6FD&eUtilities&r&8] &c错误 &8| &4加载扩展模块类 &c{0} &4时失败, 扩展模块的标识符(名称)为空!' +#Module-Loader-VerifyError: +# - '&8[&6FD&eUtilities&r&8] &c错误 &8| &4无法加载扩展模块: &c{0} &7(是否缺少依赖项?)' +# - ' &8{1} {2}' +# +# +##命令方面 +#Command-Help: +# - '&r' +# - type: JSON +# text: ' [&6FDUtilities] [&f{0}]' +# args: +# - hover: '&7FDUtilities 是一个多功能插件' +# - hover: '&7插件版本: &a{0}' +# - '&r' +# - type: JSON +# text: ' &7命令: [&f/fdutilities]' +# args: +# - hover: '&f/fdutilities &8[...]' +# suggest: '/fdutilities ' +# - ' &7参数:' +# - type: JSON +# text: ' &8- [&fhelp]' +# args: +# - hover: '&f/fdutilities help &8- &7显示帮助信息' +# suggest: '/fdutilities help ' +# - ' &7显示帮助信息' +# - type: JSON +# text: ' &8- [&freload]' +# args: +# - hover: '&f/fdutilities reload &8- &7重载配置文件' +# suggest: '/fdutilities reload ' +# - ' &7重载配置文件' +# - '&r' +# +#Kether-Shell-Exception: +# - '&8[&6FD&eUtilities&r&8] &c错误 &8| &7解析 Kether Shell 时出现意外异常:' +# - ' &8{0}' diff --git a/plugin/platform-bukkit/src/main/resources/module_outdated/Extensions/PlaceholderAPI.yml b/plugin/platform-bukkit/src/main/resources/module_outdated/Extensions/PlaceholderAPI.yml deleted file mode 100644 index 41cf0ece..00000000 --- a/plugin/platform-bukkit/src/main/resources/module_outdated/Extensions/PlaceholderAPI.yml +++ /dev/null @@ -1,9 +0,0 @@ -#请必须安装PlaceholderAPI使用!!! - -TestMap: - - condition: 'ke: print "hello world"' - print: - - condition: 'awa' - text: 'a1' - - condition: 'qwq' - text: 'q1' diff --git a/plugin/platform-bukkit/src/main/resources/module_outdated/ServerTeleport.yml b/plugin/platform-bukkit/src/main/resources/module_outdated/ServerTeleport.yml deleted file mode 100644 index ded2cb5a..00000000 --- a/plugin/platform-bukkit/src/main/resources/module_outdated/ServerTeleport.yml +++ /dev/null @@ -1 +0,0 @@ -#跨服传送 \ No newline at end of file diff --git a/project/common/src/main/kotlin/cn/fd/utilities/common/util/Utils.kt b/project/common/src/main/kotlin/cn/fd/utilities/common/util/Utils.kt deleted file mode 100644 index 96fa216c..00000000 --- a/project/common/src/main/kotlin/cn/fd/utilities/common/util/Utils.kt +++ /dev/null @@ -1,10 +0,0 @@ -package cn.fd.utilities.common.util - -fun List>.toSimple(): List { - val list: MutableList = mutableListOf() - //Ƕѭ - this.forEach { f -> - f.forEach { s -> list.add(s) } - } - return list -} \ No newline at end of file diff --git a/project/core/build.gradle.kts b/project/core/build.gradle.kts deleted file mode 100644 index 2d720d95..00000000 --- a/project/core/build.gradle.kts +++ /dev/null @@ -1,3 +0,0 @@ -dependencies { - compileModule("common") -} \ No newline at end of file diff --git a/project/core/src/main/kotlin/cn/fd/utilities/core/clsload/ClassUtil.kt b/project/core/src/main/kotlin/cn/fd/utilities/core/clsload/ClassUtil.kt deleted file mode 100644 index bcb523df..00000000 --- a/project/core/src/main/kotlin/cn/fd/utilities/core/clsload/ClassUtil.kt +++ /dev/null @@ -1,86 +0,0 @@ -package cn.fd.utilities.core.clsload - -import taboolib.common5.util.getStackTraceString -import java.io.File -import java.net.URLClassLoader -import java.util.jar.JarEntry -import java.util.jar.JarFile - -object ClassUtil { - - fun loadClasses( - file: File, /*获取所有包名*/ - classLoader: ClassLoader - ): List> { - //如果文件不存在 - if (!file.exists()) return listOf() - - val classes: MutableList> = mutableListOf() - //如果是jar文件 - if (file.extension == "jar") { - getClassesName(file).forEach { - //加载类(不初始化) - try { - val loader = URLClassLoader(arrayOf(file.toURI().toURL()), classLoader) - //classes.add(loadClass(it, initialize)) - classes.add(loader.loadClass(it)) - } catch (ex: Exception) { - //TODO - println("发现错误: ${ex.getStackTraceString()}") - } - } - } - //如果是class文件 - else if (file.extension == "class") { - }//TODO - - return classes - } - - fun List>.findSubClasses(file: File, clazz: Class): List> { - //检查文件是否存在 - if (!file.exists()) return listOf() - - val classes: MutableList> = mutableListOf() - - //加载所有类(不初始化) - this.forEach { - if (clazz.isAssignableFrom(it)) { - classes.add(it.asSubclass(clazz)) - } - } - - return classes - } - - fun getSubClasses(file: File, clazz: Class): List> { - return loadClasses(file, clazz.classLoader).findSubClasses(file, clazz) - } - - fun getClassesName(file: File): List { - val cns: MutableList = mutableListOf() - - val entries: MutableList = mutableListOf() - - JarFile(file).entries().let { e -> - while (e.hasMoreElements()) { - e.nextElement().let { - if (it.name.endsWith(".class")) entries.add(it) - } - } - } - - entries.forEach { - //采用一般文件名替换的方式获取class包名 - cns.add(it.name.toPackageName()) - } - - return cns - } - - private fun String.toPackageName(): String { - return this.replace('/', '.').substring(0, this.length - 6) - } - - -} diff --git a/project/core/src/main/kotlin/cn/fd/utilities/core/clsload/FClassLoader.kt b/project/core/src/main/kotlin/cn/fd/utilities/core/clsload/FClassLoader.kt deleted file mode 100644 index 95bec905..00000000 --- a/project/core/src/main/kotlin/cn/fd/utilities/core/clsload/FClassLoader.kt +++ /dev/null @@ -1,18 +0,0 @@ -package cn.fd.utilities.core.clsload - -object FClassLoader : ClassLoader() { - - /** - * - */ -// public override fun loadClass(className: String, isInitialized: Boolean): Class<*> { -// return Class.forName(className, isInitialized, Thread.currentThread().contextClassLoader) -// //return super.loadClass(className, isInitialized) -// } - - override fun loadClass(className: String): Class<*> { - return loadClass(className, false) - } - - -} \ No newline at end of file diff --git a/project/core/src/main/kotlin/cn/fd/utilities/core/module/MethodSignature.kt b/project/core/src/main/kotlin/cn/fd/utilities/core/module/MethodSignature.kt deleted file mode 100644 index 12d18d4a..00000000 --- a/project/core/src/main/kotlin/cn/fd/utilities/core/module/MethodSignature.kt +++ /dev/null @@ -1,21 +0,0 @@ -package cn.fd.utilities.core.module - -import java.util.* - -class MethodSignature constructor(private val name: String, private val params: Array>) { - - override fun equals(other: Any?): Boolean { - if (this === other) return true - if (other == null || javaClass != other.javaClass) { - return false - } - val that = other as MethodSignature - return name == that.name && params.contentEquals(that.params) - } - - override fun hashCode(): Int { - var result = Objects.hash(name) - result = 31 * result + params.contentHashCode() - return result - } -} \ No newline at end of file diff --git a/project/core/src/main/kotlin/cn/fd/utilities/core/module/ModuleExpansion.kt b/project/core/src/main/kotlin/cn/fd/utilities/core/module/ModuleExpansion.kt deleted file mode 100644 index 229a12ff..00000000 --- a/project/core/src/main/kotlin/cn/fd/utilities/core/module/ModuleExpansion.kt +++ /dev/null @@ -1,62 +0,0 @@ -package cn.fd.utilities.core.module - -import cn.fd.utilities.core.module.ModuleLoader.register -import cn.fd.utilities.core.module.ModuleLoader.unregister - -abstract class ModuleExpansion { - - //模块名称,也就是模块标识符 - abstract val name: String - - //模块作者 - open val author: String = "UNKNOWN" - - //模块版本 - open val version: String = "UNKNOWN" - - /* - 模块初始化方法,在模块启用前调用 - 可用于更新模块启用状态 - */ - open fun init() {} - - - /* - 模块重载方法,在模块启用后调用 - 可用于加载模块配置文件 - */ - open fun load() {} - - //测试方法 - open fun printMyself() { - println("Hello World") - println("作者: $author \n名称: $name \n版本: $version") - println("Test successful") - } - - /** - * 重载模块 - */ - fun reload() { - //卸载模块 - this.unregister() - //初始化方法 - init() - this.register() - //加载方法 - load() - - } - -// //注册此模块 -// fun register(): Boolean { -// return ModuleManager.register(this) -// } -// -// //取消注册此模块 -// fun unregister(): Boolean { -// return ModuleManager.unregister(this) -// } - - -} \ No newline at end of file diff --git a/project/core/src/main/kotlin/cn/fd/utilities/core/module/ModuleInfo.kt b/project/core/src/main/kotlin/cn/fd/utilities/core/module/ModuleInfo.kt deleted file mode 100644 index f75d5f53..00000000 --- a/project/core/src/main/kotlin/cn/fd/utilities/core/module/ModuleInfo.kt +++ /dev/null @@ -1,12 +0,0 @@ -package cn.fd.utilities.core.module - -import java.io.File - -class ModuleInfo( - //ģʶ - val identifier: String, - //Ƿ - val isEnabled: Boolean = true, - //ģڵļ(.jar.class) - val filePath: File? = null -) \ No newline at end of file diff --git a/project/core/src/main/kotlin/cn/fd/utilities/core/module/ModuleLoader.kt b/project/core/src/main/kotlin/cn/fd/utilities/core/module/ModuleLoader.kt deleted file mode 100644 index 4a03f0a9..00000000 --- a/project/core/src/main/kotlin/cn/fd/utilities/core/module/ModuleLoader.kt +++ /dev/null @@ -1,113 +0,0 @@ -package cn.fd.utilities.core.module - -import cn.fd.utilities.common.util.toSimple -import cn.fd.utilities.core.clsload.ClassUtil.getSubClasses -import taboolib.common.platform.function.console -import taboolib.common.platform.function.getDataFolder -import taboolib.module.lang.sendLang -import java.io.File - -object ModuleLoader { - - - private var moduleManager = ModuleManager(listOf(File(getDataFolder().path, "workspace"))) - - /** - * ļѰļ - */ - fun findModulesInDirs(dirs: List): List> {/* - ȡģļJAR׺ļ - һļûУͷһյб - */ - val files: List = arrayListOf().also { list -> - dirs.forEach { ws -> - ws.listFiles { _, name: String -> - name.endsWith(".jar") || name.endsWith(".class") - }?.forEach { list.add(it) } - } - } - - return if (files.isEmpty()) emptyList() - else { - //ļģչļ - files.map { file: File? -> - findModuleClass(file!!) - }.toSimple() - } - } - - - //עģ - fun ModuleExpansion.register(): Boolean { - //ȡģʶ - val identifier = this.name - -// val removed: ModuleExpansion? = ModuleManager.getModule(identifier) -// if (removed != null && !removed.unregister()) { -// return false -// } - - moduleManager.modules[ModuleInfo(identifier)] = this - - console().sendLang("Module-Loader-Success", identifier, this.version) - return true - } - - //жģ - fun ModuleExpansion.unregister() { - moduleManager.modules.remove(ModuleInfo(this.name)) - console().sendLang("Module-Loader-Unregistered", this.name, this.version) - } - - /** - * ӵļѰģչ - * @param file ҪѰҵĵļ - */ - fun findModuleClass(file: File): List> { - try { - //ȡ̳е (ȼ,ȡ) - val subClasses = getSubClasses(file, ModuleExpansion::class.java) - //JARļҲģչ - if (file.endsWith(".jar") && subClasses.isEmpty()) { - console().sendLang("Module-Loader-NotClassError", file.name) - return listOf() - } - //::Begin ƺûʲô - //ȡģչķ -// val moduleMethods = Arrays.stream(mClass!!.declaredMethods).map { method: Method -> -// MethodSignature(method.name, method.parameterTypes) -// }.collect(Collectors.toSet()) -// //ûбķ -// if (!moduleMethods.containsAll( -// Arrays.stream(ModuleExpansion::class.java.declaredMethods).filter { method: Method -> -// Modifier.isAbstract(method.modifiers) -// }.map { method: Method -> -// MethodSignature(method.name, method.parameterTypes) -// }.collect(Collectors.toSet()) -// ) -// ) { -// console().sendLang("Module-Loader-NotRequiredMethodError", file.name) -// return null -// } - //::END - - return subClasses - - } catch (ex: VerifyError) { - console().sendLang("Module-Loader-VerifyError", file.name, ex.javaClass.simpleName, ex.message ?: "UNKNOWN") - return listOf() - } catch (ex: Exception) { - ex.printStackTrace() - } - return listOf() - } - - fun setModuleManager(mm: ModuleManager) { - moduleManager = mm - } - - fun getModuleManager(): ModuleManager { - return moduleManager - } - -} \ No newline at end of file diff --git a/project/core/src/main/kotlin/cn/fd/utilities/core/module/ModuleManager.kt b/project/core/src/main/kotlin/cn/fd/utilities/core/module/ModuleManager.kt deleted file mode 100644 index 8dec0f5e..00000000 --- a/project/core/src/main/kotlin/cn/fd/utilities/core/module/ModuleManager.kt +++ /dev/null @@ -1,76 +0,0 @@ -package cn.fd.utilities.core.module - -import cn.fd.utilities.core.module.ModuleLoader.findModulesInDirs -import cn.fd.utilities.core.module.ModuleLoader.register -import cn.fd.utilities.core.module.ModuleLoader.unregister -import taboolib.common.io.getInstance -import taboolib.common.platform.function.console -import taboolib.module.lang.sendLang -import java.io.File -import java.nio.file.Path -import java.util.* -import java.util.concurrent.locks.ReentrantLock - -class ModuleManager( - private val workspacePaths: List, -) { - - /** - * 储存着加载的所有模块 - * String 模块名称 - * ModuleExpansion 模块对象 - */ - val modules: MutableMap = mutableMapOf() - - fun getWorkspaces(): List { - return workspacePaths - } - - //获取所有模块 -// fun getModules(): MutableMap { -// return this.modules -// } - - //获取启用的所有模块 - fun getEnabledModules(): Map { - return this.modules.filter { it.key.isEnabled } - } - - //通过标识符找到模块 - fun getModuleById(identifier: String): ModuleExpansion { - return modules.filter { it.key.identifier == identifier }.values.first().javaClass.getInstance(true)!!.get() - } - - //通过路径找到模块 - fun getModuleByPath(path: Path): ModuleExpansion { - return modules.filter { it.key.filePath == path }.values.first().javaClass.getInstance(true)!!.get() - } - - //模块锁 - private val modulesLock = ReentrantLock() - - /** - * 注册所有模块 - * @param sender 发送消息的命令发送者(就是注册模块的消息提示发给谁) - */ - fun registerAll() { - console().sendLang("Module-Loader-Loading") - - val registered = findModulesInDirs(getWorkspaces()).map { - it.getInstance(true)?.get()?.register() - }.filter { it == true } - - console().sendLang("Module-Loader-Finished", registered.size) - } - - /** - * 卸载所有模块 - */ - fun unregisterAll() { - for (module in modules.values) { - module.unregister() - } - modules.clear() - } - -} diff --git a/project/core/src/main/kotlin/cn/fd/utilities/core/module/outdated/Extension.kt b/project/core/src/main/kotlin/cn/fd/utilities/core/module/outdated/Extension.kt deleted file mode 100644 index d66fcfb5..00000000 --- a/project/core/src/main/kotlin/cn/fd/utilities/core/module/outdated/Extension.kt +++ /dev/null @@ -1,33 +0,0 @@ -package cn.fd.utilities.core.module.outdated - -import org.bukkit.Bukkit -import taboolib.common.platform.function.console -import taboolib.module.lang.sendLang - -@Deprecated("过时") -abstract class Extension(private val pluginName: String) : Module() { - - val pluginEnabled by lazy { Bukkit.getPluginManager().getPlugin(pluginName) != null } - - override fun reload() { - registry.takeUnless { it.contains(this) }?.add(this) - super.reload() - } - - companion object { - - //注册库: 保存着所有扩展模块 - private var registry: ArrayList = ArrayList() - - /** - * 输出挂钩信息 - */ - fun printInfo() { - registry.filter { it.isEnabled }.forEach { - console().sendLang("Plugin-Dependency-Hooked", it.pluginName) - } - } - - } - -} \ No newline at end of file diff --git a/project/core/src/main/kotlin/cn/fd/utilities/core/module/outdated/Module.kt b/project/core/src/main/kotlin/cn/fd/utilities/core/module/outdated/Module.kt deleted file mode 100644 index 70c41779..00000000 --- a/project/core/src/main/kotlin/cn/fd/utilities/core/module/outdated/Module.kt +++ /dev/null @@ -1,55 +0,0 @@ -package cn.fd.utilities.core.module.outdated - -import taboolib.common.platform.function.getDataFolder -import taboolib.common.platform.function.releaseResourceFile -import taboolib.module.configuration.Configuration -import java.io.File - -@Deprecated("过时") -abstract class Module { - - abstract val resourcePath: String - - abstract var path: String - - var isEnabled: Boolean = true - - abstract var conf: Configuration - - //初始化方法 - abstract fun init() - - //重载方法 - abstract fun onReload() - - lateinit var file: File - - open fun reload() { - file = File(getDataFolder(), "module\\$path") - - //调用模块的初始化的方法(模块不启用也会执行) - init() - - if (isEnabled) { - //初始化配置文件 - reloadConfig() - //调用模块的重载时的方法(要模块启用才能重载) - onReload() - } - } - - /** - * 重新读取配置文件 - */ - fun reloadConfig() { - //创建配置文件 - if (!file.exists()) { - releaseResourceFile(resourcePath, replace = true) - } - //从路径获取配置文件 - val config = Configuration.loadFromFile(file) - //设置模块配置文件 - this.conf = config - } - -} \ No newline at end of file diff --git a/project/core/src/main/kotlin/cn/fd/utilities/core/module/outdated/ModuleConfig.kt b/project/core/src/main/kotlin/cn/fd/utilities/core/module/outdated/ModuleConfig.kt deleted file mode 100644 index 9008762e..00000000 --- a/project/core/src/main/kotlin/cn/fd/utilities/core/module/outdated/ModuleConfig.kt +++ /dev/null @@ -1,92 +0,0 @@ -package cn.fd.utilities.core.module.outdated - -import taboolib.common.io.newFile -import taboolib.common.platform.function.getDataFolder -import taboolib.module.configuration.Configuration -import java.io.File -import java.util.* - -@Deprecated("烂的一批没有用") -abstract class ModuleConfig(val resourcePath: String /*文件资源位置,就是jar包内的文件的路径*/) { - - //根据这个路径初始化文件的储存位置 - open val path: String = File(resourcePath).name - - //配置文件 - lateinit var conf: Configuration - - //文件储存位置 - open lateinit var file: File - - //是否启用此配置文件 - open val enable: Boolean = true - - init { - init() - } - - /** - * 初始化模块配置文件 - * 主要有两个步骤: - * 1.设置文件路径 - * 2.创建配置文件 - */ - fun init() { - //初始化文件 - File(getDataFolder(), "module\\$path").also { - file = it - it.releaseFile(resourcePath) - } - } - - /** - * 重载方法 - */ - open fun reload() { - if (enable) { - init() - reloadConfig() - } - } - - /** - * 从文件路径重载配置文件 - */ - fun reloadConfig() { - //从路径获取配置文件 - val config = Configuration.loadFromFile(file) - //设置模块配置文件 - this.conf = config - } - - /** - * 创建配置文件 - * (复制JAR文件中资源路径内的文件到配置文件路径) - */ - open fun File.releaseFile(resourcePath: String) { - if (!this.exists()) { - releaseResourceFile( - resourcePath, - this.javaClass.classLoader, - File("${getDataFolder().path}\\module", resourcePath) - ) - } - } - - fun releaseResourceFile( - path: String, - classloader: ClassLoader = this.javaClass.classLoader, - file: File = File(getDataFolder(), path), - replace: Boolean = true - ): File { - if (file.exists() && !replace) { - return file - } - newFile(file).writeBytes( - classloader.getResourceAsStream(path)?.readBytes() - ?: error("${if (Locale.getDefault().language == "zh_CN") "找不到资源" else "resource not found"}: $path") - ) - return file - } - -} \ No newline at end of file diff --git a/project/common/build.gradle.kts b/project/module-common/build.gradle.kts similarity index 100% rename from project/common/build.gradle.kts rename to project/module-common/build.gradle.kts diff --git a/project/common/src/main/java/cn/fd/utilities/env/CommonEnv.java b/project/module-common/src/main/java/cn/fd/utilities/env/CommonEnv.java similarity index 100% rename from project/common/src/main/java/cn/fd/utilities/env/CommonEnv.java rename to project/module-common/src/main/java/cn/fd/utilities/env/CommonEnv.java diff --git a/project/common/src/main/kotlin/cn/fd/utilities/adventure/AdventureCommon.kt b/project/module-common/src/main/kotlin/cn/fd/utilities/adventure/AdventureCommon.kt similarity index 100% rename from project/common/src/main/kotlin/cn/fd/utilities/adventure/AdventureCommon.kt rename to project/module-common/src/main/kotlin/cn/fd/utilities/adventure/AdventureCommon.kt diff --git a/project/module-common/src/main/kotlin/cn/fd/utilities/common/util/Utils.kt b/project/module-common/src/main/kotlin/cn/fd/utilities/common/util/Utils.kt new file mode 100644 index 00000000..9de14a72 --- /dev/null +++ b/project/module-common/src/main/kotlin/cn/fd/utilities/common/util/Utils.kt @@ -0,0 +1,13 @@ +package cn.fd.utilities.common.util + +/** + * һб(Ԫ)бкϲб(Ԫ) + * Ч: + * listA[ listB[ 1, 2, 3], listB[ 4, 5, 6] ] + * To: ListB[ 1, 2, 3, 4, 5, 6] + */ +fun List>.mergeAll(): List { + return mutableListOf().also { out -> + this.forEach { out.addAll(it) } + } +} \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index b78c23f9..edf8057a 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,12 +1,15 @@ rootProject.name = "FDUtilities" +//Bukkitʵ include("plugin:platform-bukkit") -include("project:common") -include("project:core") -include("project:taboolib-generate-bukkit") +//Ŀļ(Լһһ) +File("${rootDir}\\project").listFiles()?.filter { it.isDirectory }?.forEach { + include("project:${it.name}") +} -//ģ -File("${rootDir}\\module").listFiles()?.filter { it.isDirectory }?.forEach { - include("module:${it.name}") -} \ No newline at end of file + +//ģ TODO ӦΪűϵͳ(FScript-) +//File("${rootDir}\\module").listFiles()?.filter { it.isDirectory }?.forEach { +// include("module:${it.name}") +//} \ No newline at end of file