Skip to content

Commit

Permalink
Merge pull request #126 from cg0/issues/124
Browse files Browse the repository at this point in the history
Add plugin reload command
  • Loading branch information
cg0 authored Jun 24, 2020
2 parents fb66426 + b0a28cd commit 82cf06e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/main/kotlin/io/hirasawa/server/commands/ReloadCommand.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package io.hirasawa.server.commands

import io.hirasawa.server.Hirasawa
import io.hirasawa.server.bancho.chat.command.ChatCommand
import io.hirasawa.server.bancho.chat.command.CommandContext
import io.hirasawa.server.plugin.InternalPlugin
import io.hirasawa.server.plugin.PluginDescriptor
import java.io.File

class ReloadCommand: ChatCommand("reload", "Reloads the loaded plugins", "hirasawa.command.reload") {
override fun onCommand(context: CommandContext, command: String, args: List<String>): Boolean {
val pluginNames = Hirasawa.pluginManager.loadedPlugins.keys.toMutableList()
for (pluginName in pluginNames) {
Hirasawa.pluginManager.unloadPlugin(pluginName)
}

Hirasawa.pluginManager.loadPluginsFromDirectory(File("plugins"), true)
Hirasawa.pluginManager.loadPlugin(InternalPlugin(), PluginDescriptor("Internal Plugin", Hirasawa.version,
"Hirasawa", "")
)
return true
}

}
2 changes: 2 additions & 0 deletions src/main/kotlin/io/hirasawa/server/plugin/InternalPlugin.kt
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package io.hirasawa.server.plugin

import io.hirasawa.server.commands.HelpCommand
import io.hirasawa.server.commands.ReloadCommand
import io.hirasawa.server.commands.TestCommand

class InternalPlugin: HirasawaPlugin() {
override fun onEnable() {
registerCommand(TestCommand())
registerCommand(HelpCommand())
registerCommand(ReloadCommand())
}

override fun onDisable() {
Expand Down

0 comments on commit 82cf06e

Please sign in to comment.