Skip to content

Commit 37ff7c8

Browse files
committed
Module logic have moved to ModuleObject.kt.
Signed-off-by: Pavel Erokhin (MairwunNx) <MairwunNx@gmail.com>
1 parent 94907cd commit 37ff7c8

File tree

2 files changed

+69
-75
lines changed

2 files changed

+69
-75
lines changed
Lines changed: 0 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,16 @@
11
package com.mairwunnx.projectessentials.core
22

3-
import com.mairwunnx.projectessentials.core.api.v1.commands.CommandAPI
43
import com.mairwunnx.projectessentials.core.api.v1.commands.CommandProcessor
5-
import com.mairwunnx.projectessentials.core.api.v1.commands.back.BackLocationAPI
64
import com.mairwunnx.projectessentials.core.api.v1.configuration.ConfigurationProcessor
75
import com.mairwunnx.projectessentials.core.api.v1.events.ModuleEventAPI.subscribeOn
86
import com.mairwunnx.projectessentials.core.api.v1.events.forge.FMLCommonSetupEventData
97
import com.mairwunnx.projectessentials.core.api.v1.events.forge.ForgeEventType
108
import com.mairwunnx.projectessentials.core.api.v1.events.forge.InterModEnqueueEventData
119
import com.mairwunnx.projectessentials.core.api.v1.events.forge.InterModProcessEventData
12-
import com.mairwunnx.projectessentials.core.api.v1.helpers.projectConfigDirectory
1310
import com.mairwunnx.projectessentials.core.api.v1.localization.Localization
1411
import com.mairwunnx.projectessentials.core.api.v1.localization.LocalizationAPI
1512
import com.mairwunnx.projectessentials.core.api.v1.localization.LocalizationProcessor
16-
import com.mairwunnx.projectessentials.core.api.v1.messaging.MessagingAPI
1713
import com.mairwunnx.projectessentials.core.api.v1.module.ModuleProcessor
18-
import com.mairwunnx.projectessentials.core.api.v1.permissions.hasPermission
1914
import com.mairwunnx.projectessentials.core.api.v1.processor.ProcessorAPI
2015
import com.mairwunnx.projectessentials.core.api.v1.providers.ProviderAPI
2116
import com.mairwunnx.projectessentials.core.impl.ModuleObject
@@ -24,22 +19,12 @@ import com.mairwunnx.projectessentials.core.impl.commands.ConfigureEssentialsCom
2419
import com.mairwunnx.projectessentials.core.impl.configurations.GeneralConfiguration
2520
import com.mairwunnx.projectessentials.core.impl.configurations.NativeAliasesConfiguration
2621
import com.mairwunnx.projectessentials.core.impl.events.EventBridge
27-
import net.minecraft.entity.player.ServerPlayerEntity
28-
import net.minecraft.util.text.event.ClickEvent
2922
import net.minecraftforge.common.MinecraftForge.EVENT_BUS
30-
import net.minecraftforge.event.entity.player.PlayerEvent
31-
import net.minecraftforge.eventbus.api.SubscribeEvent
3223
import net.minecraftforge.fml.common.Mod
33-
import net.minecraftforge.fml.event.server.FMLServerStartingEvent
34-
import org.apache.logging.log4j.LogManager
35-
import java.io.File
3624

3725
@Suppress("unused")
3826
@Mod("project_essentials_core")
3927
internal class EntryPoint {
40-
private val logger = LogManager.getLogger()
41-
private var dudeFuckedOff = true
42-
4328
/*
4429
Sorry for hardcoded classes in this list.
4530
I tried getting this classes with library https://github.com/matfax/klassindex
@@ -104,60 +89,4 @@ internal class EntryPoint {
10489
)
10590
)
10691
}
107-
108-
@SubscribeEvent
109-
fun onServerStarting(event: FMLServerStartingEvent) {
110-
dudeFuckedOff = File(
111-
projectConfigDirectory + File.separator + "fuck-off-dude.txt"
112-
).exists().also {
113-
if (!it) {
114-
logger.warn(
115-
"""
116-
117-
Notification from Project Essentials
118-
119-
Project Essentials - the project is based on the enthusiasm of the author, the project is completely free to use and distribute. However, the author needs material support, that is, a donate.
120-
Project Essentials **is not a commercial project** and all its modules distributed free and not have any restrictions.
121-
122-
I will be very happy with your support, below is a link to the donation documentation and how to disable this annoying alert.
123-
For support project you can also put an star on the Project Essentials repository.
124-
125-
[ -> Support the project https://git.io/JfZ1V ]
126-
127-
"""
128-
)
129-
}
130-
}
131-
CommandAPI.assignDispatcherRoot(event.commandDispatcher)
132-
CommandAPI.assignDispatcher(event.commandDispatcher)
133-
ProcessorAPI.getProcessorByName("command").postProcess()
134-
}
135-
136-
@SubscribeEvent
137-
fun onPlayerLeave(event: PlayerEvent.PlayerLoggedOutEvent) {
138-
BackLocationAPI.revoke(event.player as ServerPlayerEntity)
139-
}
140-
141-
@SubscribeEvent
142-
fun onPlayerJoin(event: PlayerEvent.PlayerLoggedInEvent) {
143-
if (!dudeFuckedOff) {
144-
val player = event.player as ServerPlayerEntity
145-
146-
when {
147-
hasPermission(player, "ess.notification.support", 4) -> MessagingAPI.sendMessage(
148-
player,
149-
"""
150-
§6Notification from §7Project Essentials
151-
152-
§fProject Essentials - the project is based on the enthusiasm of the author, the project is completely free to use and distribute. However, the author needs material support, that is, a donate.
153-
Project Essentials §c§ois not a commercial project §fand all its modules distributed free and not have any restrictions.
154-
155-
§7[ §c-> §7Support the project §6§nhttps://git.io/JfZ1V§7 ]
156-
""".trim(),
157-
false,
158-
clickEvent = ClickEvent(ClickEvent.Action.OPEN_URL, "https://git.io/JfZ1V")
159-
)
160-
}
161-
}
162-
}
16392
}

src/main/kotlin/com/mairwunnx/projectessentials/core/impl/ModuleObject.kt

Lines changed: 69 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,39 @@
33
package com.mairwunnx.projectessentials.core.impl
44

55
import com.mairwunnx.projectessentials.core.api.v1.*
6+
import com.mairwunnx.projectessentials.core.api.v1.commands.CommandAPI
67
import com.mairwunnx.projectessentials.core.api.v1.commands.back.BackLocationAPI
78
import com.mairwunnx.projectessentials.core.api.v1.configuration.ConfigurationAPI
89
import com.mairwunnx.projectessentials.core.api.v1.extensions.asPlayerEntity
910
import com.mairwunnx.projectessentials.core.api.v1.extensions.isPlayerEntity
11+
import com.mairwunnx.projectessentials.core.api.v1.helpers.projectConfigDirectory
12+
import com.mairwunnx.projectessentials.core.api.v1.messaging.MessagingAPI
1013
import com.mairwunnx.projectessentials.core.api.v1.module.IModule
1114
import com.mairwunnx.projectessentials.core.api.v1.module.Module
1215
import com.mairwunnx.projectessentials.core.api.v1.permissions.hasPermission
16+
import com.mairwunnx.projectessentials.core.api.v1.processor.ProcessorAPI
1317
import com.mairwunnx.projectessentials.core.impl.commands.ConfigureEssentialsCommandAPI
1418
import com.mairwunnx.projectessentials.core.impl.configurations.GeneralConfiguration
1519
import com.mairwunnx.projectessentials.core.impl.vanilla.commands.*
1620
import com.mojang.brigadier.CommandDispatcher
1721
import net.minecraft.command.CommandSource
22+
import net.minecraft.entity.player.ServerPlayerEntity
23+
import net.minecraft.util.text.event.ClickEvent
1824
import net.minecraftforge.common.MinecraftForge
1925
import net.minecraftforge.event.entity.living.LivingDeathEvent
26+
import net.minecraftforge.event.entity.player.PlayerEvent
2027
import net.minecraftforge.event.world.BlockEvent
2128
import net.minecraftforge.eventbus.api.SubscribeEvent
2229
import net.minecraftforge.fml.event.server.FMLServerStartingEvent
2330
import net.minecraftforge.fml.event.server.FMLServerStoppingEvent
31+
import org.apache.logging.log4j.LogManager
32+
import java.io.File
2433

2534
@OptIn(ExperimentalUnsignedTypes::class)
2635
@Module("core", "2.0.0-RC.1+MC-1.14.4", 0u, "1.1.0")
2736
internal class ModuleObject : IModule {
37+
private var dudeFuckedOff = true
38+
private val logger = LogManager.getLogger()
2839
private var moduleDataCached: Module? = null
2940
private val generalConfiguration by lazy {
3041
ConfigurationAPI.getConfigurationByName<GeneralConfiguration>("general")
@@ -79,6 +90,12 @@ internal class ModuleObject : IModule {
7990
}
8091
}
8192

93+
@SubscribeEvent
94+
fun onServerStopping(
95+
@Suppress("UNUSED_PARAMETER")
96+
event: FMLServerStoppingEvent
97+
) = ConfigurationAPI.saveAll()
98+
8299
@SubscribeEvent
83100
fun onServerStarting(event: FMLServerStartingEvent) {
84101
when {
@@ -89,13 +106,61 @@ internal class ModuleObject : IModule {
89106
event.server.isDedicatedServer
90107
)
91108
}
109+
110+
dudeFuckedOff = File(
111+
projectConfigDirectory + File.separator + "fuck-off-dude.txt"
112+
).exists().also {
113+
if (!it) {
114+
logger.warn(
115+
"""
116+
117+
Notification from Project Essentials
118+
119+
Project Essentials - the project is based on the enthusiasm of the author, the project is completely free to use and distribute. However, the author needs material support, that is, a donate.
120+
Project Essentials **is not a commercial project** and all its modules distributed free and not have any restrictions.
121+
122+
I will be very happy with your support, below is a link to the donation documentation and how to disable this annoying alert.
123+
For support project you can also put an star on the Project Essentials repository.
124+
125+
[ -> Github organization https://github.com/ProjectEssentials ]
126+
[ -> Support the project https://git.io/JfZ1V ]
127+
128+
"""
129+
)
130+
}
131+
}
132+
CommandAPI.assignDispatcherRoot(event.commandDispatcher)
133+
CommandAPI.assignDispatcher(event.commandDispatcher)
134+
ProcessorAPI.getProcessorByName("command").postProcess()
92135
}
93136

94137
@SubscribeEvent
95-
fun onServerStopping(
96-
@Suppress("UNUSED_PARAMETER")
97-
event: FMLServerStoppingEvent
98-
) = ConfigurationAPI.saveAll()
138+
fun onPlayerLeave(event: PlayerEvent.PlayerLoggedOutEvent) {
139+
BackLocationAPI.revoke(event.player as ServerPlayerEntity)
140+
}
141+
142+
@SubscribeEvent
143+
fun onPlayerJoin(event: PlayerEvent.PlayerLoggedInEvent) {
144+
if (!dudeFuckedOff) {
145+
val player = event.player as ServerPlayerEntity
146+
147+
when {
148+
hasPermission(player, "ess.notification.support", 4) -> MessagingAPI.sendMessage(
149+
player,
150+
"""
151+
§6Notification from §7Project Essentials
152+
153+
§fProject Essentials - the project is based on the enthusiasm of the author, the project is completely free to use and distribute. However, the author needs material support, that is, a donate.
154+
Project Essentials §c§ois not a commercial project §fand all its modules distributed free and not have any restrictions.
155+
156+
§7[ §c-> §7Support the project §6§nhttps://git.io/JfZ1V§7 ]
157+
""".trim(),
158+
false,
159+
clickEvent = ClickEvent(ClickEvent.Action.OPEN_URL, "https://git.io/JfZ1V")
160+
)
161+
}
162+
}
163+
}
99164

100165
private fun registerNativeCommands(
101166
dispatcher: CommandDispatcher<CommandSource>,

0 commit comments

Comments
 (0)