Skip to content

Commit b97b461

Browse files
committed
Providers and localizations resolution strategy changed.
Signed-off-by: Pavel Erokhin (MairwunNx) <MairwunNx@gmail.com>
1 parent d0d74c0 commit b97b461

File tree

1 file changed

+55
-43
lines changed

1 file changed

+55
-43
lines changed

src/main/kotlin/com/mairwunnx/projectessentials/home/ModuleObject.kt

Lines changed: 55 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,83 @@
22

33
package com.mairwunnx.projectessentials.home
44

5-
import com.mairwunnx.projectessentials.core.api.v1.IMCLocalizationMessage
6-
import com.mairwunnx.projectessentials.core.api.v1.IMCProvidersMessage
7-
import com.mairwunnx.projectessentials.core.api.v1.events.ModuleEventAPI.subscribeOn
8-
import com.mairwunnx.projectessentials.core.api.v1.events.forge.ForgeEventType
9-
import com.mairwunnx.projectessentials.core.api.v1.events.forge.InterModEnqueueEventData
5+
import com.mairwunnx.projectessentials.core.api.v1.localization.Localization
6+
import com.mairwunnx.projectessentials.core.api.v1.localization.LocalizationAPI
107
import com.mairwunnx.projectessentials.core.api.v1.module.IModule
8+
import com.mairwunnx.projectessentials.core.api.v1.providers.ProviderAPI
119
import com.mairwunnx.projectessentials.home.commands.DelHomeCommand
1210
import com.mairwunnx.projectessentials.home.commands.HomeCommand
1311
import com.mairwunnx.projectessentials.home.commands.SetHomeCommand
1412
import com.mairwunnx.projectessentials.home.configurations.HomeConfiguration
13+
import com.mairwunnx.projectessentials.home.configurations.HomeConfigurationModel
1514
import com.mairwunnx.projectessentials.home.configurations.HomeSettingsConfiguration
1615
import com.mairwunnx.projectessentials.home.enums.HomeSelectStrategy.First
1716
import com.mairwunnx.projectessentials.home.enums.HomeSelectStrategy.Last
1817
import net.minecraft.entity.player.ServerPlayerEntity
1918
import net.minecraftforge.common.MinecraftForge.EVENT_BUS
2019
import net.minecraftforge.event.entity.player.PlayerEvent
2120
import net.minecraftforge.eventbus.api.SubscribeEvent
22-
import net.minecraftforge.fml.InterModComms
2321
import net.minecraftforge.fml.common.Mod
22+
import net.minecraftforge.fml.event.server.FMLServerStartingEvent
23+
import org.apache.logging.log4j.LogManager
2424

2525
@Mod("project_essentials_home")
2626
class ModuleObject : IModule {
2727
override val name = this::class.java.`package`.implementationTitle.split(" ").last()
2828
override val version = this::class.java.`package`.implementationVersion!!
29-
override val loadIndex = 4
29+
override val loadIndex = 20
3030
override fun init() = Unit
3131

3232
init {
3333
EVENT_BUS.register(this)
34-
subscribeOn<InterModEnqueueEventData>(
35-
ForgeEventType.EnqueueIMCEvent
36-
) {
37-
sendLocalizationRequest()
38-
sendProvidersRequest()
39-
}
34+
initProviders()
35+
initLocalization()
36+
}
37+
38+
private fun initProviders() {
39+
listOf(
40+
SetHomeCommand::class.java,
41+
HomeCommand::class.java,
42+
DelHomeCommand::class.java,
43+
HomeConfiguration::class.java,
44+
HomeSettingsConfiguration::class.java,
45+
ModuleObject::class.java
46+
).forEach(ProviderAPI::addProvider)
47+
}
48+
49+
private fun initLocalization() {
50+
LocalizationAPI.apply(
51+
Localization(
52+
mutableListOf(
53+
"/assets/projectessentialshome/lang/en_us.json",
54+
"/assets/projectessentialshome/lang/ru_ru.json",
55+
"/assets/projectessentialshome/lang/de_de.json",
56+
"/assets/projectessentialshome/lang/zh_cn.json"
57+
), "core", this.javaClass
58+
)
59+
)
60+
// LocalizationAPI.apply(this.javaClass) {
61+
// mutableListOf(
62+
// "/assets/projectessentialshome/lang/en_us.json",
63+
// "/assets/projectessentialshome/lang/ru_ru.json",
64+
// "/assets/projectessentialshome/lang/de_de.json",
65+
// "/assets/projectessentialshome/lang/zh_cn.json"
66+
// )
67+
// }
68+
}
69+
70+
@SubscribeEvent
71+
fun onServerStart(event: FMLServerStartingEvent) {
72+
LogManager.getLogger().info(homeConfiguration.users.count())
73+
LogManager.getLogger().info("test")
74+
LogManager.getLogger().info(
75+
homeConfiguration.users.add(
76+
HomeConfigurationModel.User(
77+
"test", "testuuid", mutableListOf()
78+
)
79+
)
80+
)
81+
LogManager.getLogger().info(homeConfiguration.users.count())
4082
}
4183

4284
@SubscribeEvent
@@ -52,34 +94,4 @@ class ModuleObject : IModule {
5294
}
5395
}
5496
}
55-
56-
private fun sendLocalizationRequest() {
57-
InterModComms.sendTo(
58-
"project_essentials_core",
59-
IMCLocalizationMessage
60-
) {
61-
fun() = mutableListOf(
62-
"/assets/projectessentialshome/lang/en_us.json",
63-
"/assets/projectessentialshome/lang/ru_ru.json",
64-
"/assets/projectessentialshome/lang/de_de.json",
65-
"/assets/projectessentialshome/lang/zh_cn.json"
66-
)
67-
}
68-
}
69-
70-
private fun sendProvidersRequest() {
71-
InterModComms.sendTo(
72-
"project_essentials_core",
73-
IMCProvidersMessage
74-
) {
75-
fun() = listOf(
76-
SetHomeCommand::class.java,
77-
HomeCommand::class.java,
78-
DelHomeCommand::class.java,
79-
HomeConfiguration::class.java,
80-
HomeSettingsConfiguration::class.java,
81-
ModuleObject::class.java
82-
)
83-
}
84-
}
8597
}

0 commit comments

Comments
 (0)