@@ -13,7 +13,12 @@ import com.mairwunnx.projectessentials.home.commands.HomeCommand
1313import com.mairwunnx.projectessentials.home.commands.SetHomeCommand
1414import com.mairwunnx.projectessentials.home.configurations.HomeConfiguration
1515import com.mairwunnx.projectessentials.home.configurations.HomeSettingsConfiguration
16+ import com.mairwunnx.projectessentials.home.enums.HomeSelectStrategy.First
17+ import com.mairwunnx.projectessentials.home.enums.HomeSelectStrategy.Last
18+ import net.minecraft.entity.player.ServerPlayerEntity
1619import net.minecraftforge.common.MinecraftForge.EVENT_BUS
20+ import net.minecraftforge.event.entity.player.PlayerEvent
21+ import net.minecraftforge.eventbus.api.SubscribeEvent
1722import net.minecraftforge.fml.InterModComms
1823import net.minecraftforge.fml.common.Mod
1924
@@ -34,6 +39,20 @@ class ModuleObject : IModule {
3439 }
3540 }
3641
42+ @SubscribeEvent
43+ fun onPlayerRespawn (event : PlayerEvent .PlayerRespawnEvent ) {
44+ val player = event.player as ServerPlayerEntity
45+ homeConfiguration.users.asSequence().find {
46+ it.name == player.name.string || it.uuid == player.uniqueID.toString()
47+ }?.let {
48+ if (it.homes.isEmpty()) return
49+ when (homeSettingsConfiguration.respawnHomeSelectStrategy) {
50+ Last -> teleportToHome(player, it.homes.last())
51+ First -> teleportToHome(player, it.homes.first())
52+ }
53+ }
54+ }
55+
3756 private fun sendLocalizationRequest () {
3857 InterModComms .sendTo(
3958 " project_essentials_core" ,
0 commit comments