2
2
3
3
package com.mairwunnx.projectessentials.spawn
4
4
5
- import com.mairwunnx.projectessentials.core.api.v1.IMCLocalizationMessage
6
- import com.mairwunnx.projectessentials.core.api.v1.IMCProvidersMessage
7
5
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
11
8
import com.mairwunnx.projectessentials.core.api.v1.module.IModule
9
+ import com.mairwunnx.projectessentials.core.api.v1.providers.ProviderAPI
12
10
import com.mairwunnx.projectessentials.spawn.commands.SetSpawnCommand
13
11
import com.mairwunnx.projectessentials.spawn.commands.SpawnCommand
14
12
import com.mairwunnx.projectessentials.spawn.configurations.SpawnConfiguration
@@ -18,7 +16,6 @@ import net.minecraftforge.common.MinecraftForge.EVENT_BUS
18
16
import net.minecraftforge.event.entity.player.PlayerEvent
19
17
import net.minecraftforge.eventbus.api.EventPriority
20
18
import net.minecraftforge.eventbus.api.SubscribeEvent
21
- import net.minecraftforge.fml.InterModComms
22
19
import net.minecraftforge.fml.common.Mod
23
20
import net.minecraftforge.fml.event.server.FMLServerStartingEvent
24
21
@@ -45,12 +42,30 @@ class ModuleObject : IModule {
45
42
46
43
init {
47
44
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
+ )
54
69
}
55
70
56
71
@SubscribeEvent
@@ -81,32 +96,4 @@ class ModuleObject : IModule {
81
96
forceTeleportToSpawn(player)
82
97
}
83
98
}
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
- }
112
99
}
0 commit comments