mirror of
https://github.com/ViaVersion/ViaLegacy.git
synced 2024-12-22 16:38:16 +01:00
Don't tick tasks when user already disconnected
This commit is contained in:
parent
f490fcc0cb
commit
dd355c3c7b
@ -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
|
||||
|
@ -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));
|
||||
|
@ -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) {
|
||||
|
@ -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(() -> {
|
||||
|
@ -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) {
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user