diff --git a/src/main/java/me/zeroeightsix/kami/event/ForgeEventProcessor.kt b/src/main/java/me/zeroeightsix/kami/event/ForgeEventProcessor.kt index 4754b8e42..977180f0a 100644 --- a/src/main/java/me/zeroeightsix/kami/event/ForgeEventProcessor.kt +++ b/src/main/java/me/zeroeightsix/kami/event/ForgeEventProcessor.kt @@ -41,6 +41,7 @@ object ForgeEventProcessor { } @SubscribeEvent + @Suppress("UNUSED_PARAMETER") fun onWorldRender(event: RenderWorldLastEvent) { ProjectionUtils.updateMatrix() diff --git a/src/main/java/me/zeroeightsix/kami/module/modules/misc/LogoutLogger.kt b/src/main/java/me/zeroeightsix/kami/module/modules/misc/LogoutLogger.kt index 91351adc8..b803cf8d8 100644 --- a/src/main/java/me/zeroeightsix/kami/module/modules/misc/LogoutLogger.kt +++ b/src/main/java/me/zeroeightsix/kami/module/modules/misc/LogoutLogger.kt @@ -5,11 +5,12 @@ import me.zeroeightsix.kami.event.events.ConnectionEvent import me.zeroeightsix.kami.manager.managers.WaypointManager import me.zeroeightsix.kami.module.Module import me.zeroeightsix.kami.setting.ModuleConfig.setting +import me.zeroeightsix.kami.util.EntityUtils.flooredPosition import me.zeroeightsix.kami.util.TickTimer import me.zeroeightsix.kami.util.TimeUnit import me.zeroeightsix.kami.util.math.CoordinateConverter.asString -import me.zeroeightsix.kami.util.math.VectorUtils.toBlockPos import me.zeroeightsix.kami.util.text.MessageSendHelper +import me.zeroeightsix.kami.util.threads.onMainThread import me.zeroeightsix.kami.util.threads.safeListener import net.minecraft.client.entity.EntityOtherPlayerMP import net.minecraft.util.math.BlockPos @@ -30,25 +31,28 @@ object LogoutLogger : Module() { init { listener { - loggedPlayers.clear() + onMainThread { + loggedPlayers.clear() + } } safeListener { - for (loadedPlayer in world.loadedEntityList) { + for (loadedPlayer in world.playerEntities) { if (loadedPlayer !is EntityOtherPlayerMP) continue - connection.getPlayerInfo(loadedPlayer.gameProfile.id).let { - loggedPlayers[it.gameProfile] = loadedPlayer.positionVector.toBlockPos() - } + + val info = connection.getPlayerInfo(loadedPlayer.gameProfile.id) + loggedPlayers[info.gameProfile] = loadedPlayer.flooredPosition } if (timer.tick(1L)) { val toRemove = ArrayList() + for ((profile, pos) in loggedPlayers) { - if (connection.getPlayerInfo(profile.id) != null) continue if (print.value) MessageSendHelper.sendChatMessage("${profile.name} logged out at ${pos.asString()}") if (saveToFile.value) WaypointManager.add(pos, "${profile.name} Logout Spot") toRemove.add(profile) } + loggedPlayers.keys.removeAll(toRemove) } }