Don't tick tasks when user already disconnected

This commit is contained in:
RaphiMC 2023-10-07 22:43:50 +02:00
parent f490fcc0cb
commit dd355c3c7b
No known key found for this signature in database
GPG Key ID: 0F6BB0657A03AC94
6 changed files with 11 additions and 1 deletions

View File

@ -40,6 +40,8 @@ public class TimeLockTask implements Runnable {
final PlayerInfoStorage playerInfoStorage = info.get(PlayerInfoStorage.class);
if (timeLockStorage != null && playerInfoStorage != null && playerInfoStorage.entityId != -1) {
info.getChannel().eventLoop().submit(() -> {
if (!info.getChannel().isActive()) return;
try {
if (info.getProtocolInfo().getPipeline().contains(Protocol1_6_1to1_5_2.class)) {
if (timeLockStorage.getTime() == 0) { // 0 always does the daylight cycle

View File

@ -45,6 +45,8 @@ public class AlphaInventoryUpdateTask implements Runnable {
if (inventoryStorage == null) continue;
info.getChannel().eventLoop().submit(() -> {
if (!info.getChannel().isActive()) return;
try {
final Item[] mainInventory = fixItems(Via.getManager().getProviders().get(AlphaInventoryProvider.class).getMainInventoryItems(info));
final Item[] craftingInventory = fixItems(Via.getManager().getProviders().get(AlphaInventoryProvider.class).getCraftingInventoryItems(info));

View File

@ -46,6 +46,8 @@ public class PlayerAirTimeUpdateTask implements Runnable {
final PlayerInfoStorage playerInfoStorage = info.get(PlayerInfoStorage.class);
if (playerInfoStorage == null) continue;
info.getChannel().eventLoop().submit(() -> {
if (!info.getChannel().isActive()) return;
try {
final IdAndData headBlock = info.get(ChunkTracker.class).getBlockNotNull(floor(playerInfoStorage.posX), floor(playerInfoStorage.posY + 1.62F), floor(playerInfoStorage.posZ));
if (headBlock.id == BlockList1_6.waterMoving.blockID || headBlock.id == BlockList1_6.waterStill.blockID) {

View File

@ -99,7 +99,7 @@ public class ClassicLevelStorage extends StoredObject {
public void tick() throws Exception {
final ClassicPositionTracker positionTracker = this.getUser().get(ClassicPositionTracker.class);
if (positionTracker == null || !positionTracker.spawned) return;
if (!positionTracker.spawned) return;
final long start = System.currentTimeMillis();
this.getUser().getChannel().eventLoop().submit(() -> {

View File

@ -32,6 +32,8 @@ public class ClassicLevelStorageTickTask implements Runnable {
final ClassicLevelStorage classicLevelStorage = info.get(ClassicLevelStorage.class);
if (classicLevelStorage != null) {
info.getChannel().eventLoop().submit(() -> {
if (!info.getChannel().isActive()) return;
try {
classicLevelStorage.tick();
} catch (Throwable e) {

View File

@ -39,6 +39,8 @@ public class ClassicPingTask implements Runnable {
if (protocolMetadata == null) continue;
if (!protocolMetadata.hasServerExtension(ClassicProtocolExtension.TWO_WAY_PING, 1)) continue;
info.getChannel().eventLoop().submit(() -> {
if (!info.getChannel().isActive()) return;
try {
final PacketWrapper pingRequest = PacketWrapper.create(ServerboundPacketsc0_30cpe.EXT_TWO_WAY_PING, info);
pingRequest.write(Type.BYTE, (byte) 0); // direction