Skip to content

Commit ea39b7b

Browse files
committed
Localization and provider registering fixed.
Signed-off-by: Pavel Erokhin (MairwunNx) <MairwunNx@gmail.com>
1 parent 4493386 commit ea39b7b

File tree

1 file changed

+27
-40
lines changed

1 file changed

+27
-40
lines changed

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

Lines changed: 27 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@
22

33
package com.mairwunnx.projectessentials.spawn
44

5-
import com.mairwunnx.projectessentials.core.api.v1.IMCLocalizationMessage
6-
import com.mairwunnx.projectessentials.core.api.v1.IMCProvidersMessage
75
import com.mairwunnx.projectessentials.core.api.v1.configuration.ConfigurationAPI.getConfigurationByName
8-
import com.mairwunnx.projectessentials.core.api.v1.events.ModuleEventAPI.subscribeOn
9-
import com.mairwunnx.projectessentials.core.api.v1.events.forge.ForgeEventType
10-
import com.mairwunnx.projectessentials.core.api.v1.events.forge.InterModEnqueueEventData
6+
import com.mairwunnx.projectessentials.core.api.v1.localization.Localization
7+
import com.mairwunnx.projectessentials.core.api.v1.localization.LocalizationAPI
118
import com.mairwunnx.projectessentials.core.api.v1.module.IModule
9+
import com.mairwunnx.projectessentials.core.api.v1.providers.ProviderAPI
1210
import com.mairwunnx.projectessentials.spawn.commands.SetSpawnCommand
1311
import com.mairwunnx.projectessentials.spawn.commands.SpawnCommand
1412
import com.mairwunnx.projectessentials.spawn.configurations.SpawnConfiguration
@@ -18,7 +16,6 @@ import net.minecraftforge.common.MinecraftForge.EVENT_BUS
1816
import net.minecraftforge.event.entity.player.PlayerEvent
1917
import net.minecraftforge.eventbus.api.EventPriority
2018
import net.minecraftforge.eventbus.api.SubscribeEvent
21-
import net.minecraftforge.fml.InterModComms
2219
import net.minecraftforge.fml.common.Mod
2320
import net.minecraftforge.fml.event.server.FMLServerStartingEvent
2421

@@ -45,12 +42,30 @@ class ModuleObject : IModule {
4542

4643
init {
4744
EVENT_BUS.register(this)
48-
subscribeOn<InterModEnqueueEventData>(
49-
ForgeEventType.EnqueueIMCEvent
50-
) {
51-
sendLocalizationRequest()
52-
sendProvidersRequest()
53-
}
45+
initProviders()
46+
initLocalization()
47+
}
48+
49+
private fun initProviders() {
50+
listOf(
51+
SpawnConfiguration::class.java,
52+
ModuleObject::class.java,
53+
SetSpawnCommand::class.java,
54+
SpawnCommand::class.java
55+
).forEach(ProviderAPI::addProvider)
56+
}
57+
58+
private fun initLocalization() {
59+
LocalizationAPI.apply(
60+
Localization(
61+
mutableListOf(
62+
"/assets/projectessentialsspawn/lang/en_us.json",
63+
"/assets/projectessentialsspawn/lang/ru_ru.json",
64+
"/assets/projectessentialsspawn/lang/zh_cn.json",
65+
"/assets/projectessentialsspawn/lang/de_de.json"
66+
), "core", this.javaClass
67+
)
68+
)
5469
}
5570

5671
@SubscribeEvent
@@ -81,32 +96,4 @@ class ModuleObject : IModule {
8196
forceTeleportToSpawn(player)
8297
}
8398
}
84-
85-
private fun sendLocalizationRequest() {
86-
InterModComms.sendTo(
87-
"project_essentials_core",
88-
IMCLocalizationMessage
89-
) {
90-
fun() = mutableListOf(
91-
"/assets/projectessentialsspawn/lang/en_us.json",
92-
"/assets/projectessentialsspawn/lang/ru_ru.json",
93-
"/assets/projectessentialsspawn/lang/zh_cn.json",
94-
"/assets/projectessentialsspawn/lang/de_de.json"
95-
)
96-
}
97-
}
98-
99-
private fun sendProvidersRequest() {
100-
InterModComms.sendTo(
101-
"project_essentials_core",
102-
IMCProvidersMessage
103-
) {
104-
fun() = listOf(
105-
SpawnConfiguration::class.java,
106-
ModuleObject::class.java,
107-
SetSpawnCommand::class.java,
108-
SpawnCommand::class.java
109-
)
110-
}
111-
}
11299
}

0 commit comments

Comments
 (0)