@@ -2,59 +2,74 @@ package app.simplecloud.plugin.proxy.bungeecord
22
33import app.simplecloud.plugin.proxy.bungeecord.event.ConfigureTagResolversEvent
44import app.simplecloud.plugin.proxy.bungeecord.handler.TabListHandler
5- import app.simplecloud.plugin.proxy.bungeecord.listener.ConfigureTagResolversListener
6- import app.simplecloud.plugin.proxy.bungeecord.listener.ProxyPingListener
7- import app.simplecloud.plugin.proxy.bungeecord.listener.TabListListener
8- import app.simplecloud.plugin.proxy.shared.config.GeneralConfig
5+ import app.simplecloud.plugin.proxy.bungeecord.listener.*
6+ import app.simplecloud.plugin.proxy.shared.ProxyPlugin
97import app.simplecloud.plugin.proxy.shared.config.YamlConfig
108import app.simplecloud.plugin.proxy.shared.config.placeholder.PlaceHolderConfiguration
119import app.simplecloud.plugin.proxy.shared.config.tablis.TabListConfiguration
1210import app.simplecloud.plugin.proxy.shared.handler.MotdLayoutHandler
11+ import app.simplecloud.plugin.proxy.shared.handler.command.CommandSender
12+ import app.simplecloud.plugin.proxy.shared.handler.command.ProxyCommandHandler
1313import net.kyori.adventure.platform.bungeecord.BungeeAudiences
1414import net.kyori.adventure.text.Component
1515import net.kyori.adventure.text.minimessage.MiniMessage
1616import net.md_5.bungee.api.connection.ProxiedPlayer
1717import net.md_5.bungee.api.plugin.Plugin
18+ import org.incendo.cloud.SenderMapper
19+ import org.incendo.cloud.bungee.BungeeCommandManager
20+ import org.incendo.cloud.execution.ExecutionCoordinator
1821
1922
2023class ProxyBungeeCordPlugin : Plugin () {
2124
22- lateinit var generalConfiguration: GeneralConfig
23- lateinit var tabListConfiguration: TabListConfiguration
24- lateinit var placeHolderConfiguration: PlaceHolderConfiguration
25+ val proxyPlugin = ProxyPlugin (this .dataFolder.path)
26+
2527
26- val config = YamlConfig (this .dataFolder.path)
2728 val tabListHandler = TabListHandler (this )
28- val motdLayoutHandler = MotdLayoutHandler (config, generalConfiguration)
29+
30+ private lateinit var commandManager: BungeeCommandManager <CommandSender >
2931
3032 private var adventure: BungeeAudiences ? = null
3133
3234 private val miniMessage = MiniMessage .miniMessage()
3335
3436 override fun onEnable () {
35- val config = YamlConfig (this .dataFolder.path)
36-
37- this .generalConfiguration = config.load<GeneralConfig >(" general" )!!
38- config.save(" general" , this .generalConfiguration)
39-
40- this .tabListConfiguration = config.load<TabListConfiguration >(" tablist" )!!
41- config.save(" tablist" , this .tabListConfiguration)
37+ this .proxyPlugin.config.save(" tablist" , this .proxyPlugin.tabListConfiguration)
38+ this .proxyPlugin.config.save(" placeholder" , this .proxyPlugin.placeHolderConfiguration)
39+ this .proxyPlugin.config.save(" messages" , this .proxyPlugin.messagesConfiguration)
4240
43- this .placeHolderConfiguration = config.load<PlaceHolderConfiguration >(" placeholder" )!!
44- config.save(" placeholder" , this .placeHolderConfiguration)
45-
46- this .motdLayoutHandler.loadMotdLayouts()
41+ this .proxyPlugin.motdLayoutHandler.loadMotdLayouts()
4742
4843 this .adventure = BungeeAudiences .create(this );
44+ this .proxy.pluginManager.registerListener(this , ProxyPingListener (this ))
45+ this .proxy.pluginManager.registerListener(this , ConfigureTagResolversListener (this ))
46+ this .proxy.pluginManager.registerListener(this , CloudListener (this ))
47+ this .proxy.pluginManager.registerListener(this , ServerPreConnectListener (this ))
4948
50- if (this .tabListConfiguration.tabListUpdateTime > 0 )
49+ if (this .proxyPlugin. tabListConfiguration.tabListUpdateTime > 0 )
5150 this .tabListHandler.startTabListTask()
5251 else
5352 this .logger.info(" Tablist update time is set to 0, tablist will not be updated automatically" )
5453
55- this .proxy.pluginManager.registerListener(this , TabListListener (this ))
56- this .proxy.pluginManager.registerListener(this , ProxyPingListener (this ))
57- this .proxy.pluginManager.registerListener(this , ConfigureTagResolversListener (this ))
54+ val executionCoordinator = ExecutionCoordinator .simpleCoordinator<CommandSender >()
55+
56+ val senderMapper = SenderMapper .create< net.md_5.bungee.api.CommandSender , CommandSender > (
57+ { commandSender -> BungeeCordCommandSender (commandSender) },
58+ { cloudSender -> (cloudSender as BungeeCordCommandSender ).getCommandSender() }
59+ )
60+
61+ commandManager = BungeeCommandManager (
62+ this ,
63+ executionCoordinator,
64+ senderMapper
65+ )
66+
67+ val proxyCommandHandler = ProxyCommandHandler (commandManager, this .proxyPlugin)
68+ proxyCommandHandler.loadCommands()
69+
70+ System .getenv(" SIMPLECLOUD_MAINTENANCE" )?.let {
71+ this .proxyPlugin.maintenance = it == " true"
72+ }
5873 }
5974
6075 override fun onDisable () {
0 commit comments