From 8adb80b5ebe6462f042fb7e849cbefae196dbcdd Mon Sep 17 00:00:00 2001 From: KennyTV Date: Wed, 26 May 2021 21:58:19 +0200 Subject: [PATCH] Don't store UserConnection in stored objects unless needed --- .../api/entities/storage/PlayerPositionStorage.java | 8 +++----- .../protocol1_10to1_11/Protocol1_10To1_11.java | 2 +- .../protocol1_10to1_11/storage/WindowTracker.java | 9 ++------- .../protocol1_12_1to1_12_2/KeepAliveTracker.java | 9 ++------- .../Protocol1_12_1To1_12_2.java | 2 +- .../protocol1_12_2to1_13/Protocol1_12_2To1_13.java | 12 +++--------- .../storage/BackwardsBlockStorage.java | 9 ++------- .../storage/PlayerPositionStorage1_13.java | 4 +--- .../storage/TabCompleteStorage.java | 9 ++------- .../protocol1_14_4to1_15/Protocol1_14_4To1_15.java | 4 +--- .../protocol1_14_4to1_15/data/ImmediateRespawn.java | 9 ++------- .../protocol1_15_2to1_16/Protocol1_15_2To1_16.java | 4 ++-- .../protocol1_15_2to1_16/data/WorldNameTracker.java | 9 ++------- .../storage/PlayerSneakStorage.java | 9 ++------- .../Protocol1_16_3To1_16_4.java | 2 +- .../storage/PlayerHandStorage.java | 9 ++------- 16 files changed, 29 insertions(+), 81 deletions(-) diff --git a/common/src/main/java/com/viaversion/viabackwards/api/entities/storage/PlayerPositionStorage.java b/common/src/main/java/com/viaversion/viabackwards/api/entities/storage/PlayerPositionStorage.java index 146c040e..3ae3e01d 100644 --- a/common/src/main/java/com/viaversion/viabackwards/api/entities/storage/PlayerPositionStorage.java +++ b/common/src/main/java/com/viaversion/viabackwards/api/entities/storage/PlayerPositionStorage.java @@ -17,18 +17,16 @@ */ package com.viaversion.viabackwards.api.entities.storage; -import com.viaversion.viaversion.api.connection.StoredObject; -import com.viaversion.viaversion.api.connection.UserConnection; +import com.viaversion.viaversion.api.connection.StorableObject; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.type.Type; -public abstract class PlayerPositionStorage extends StoredObject { +public abstract class PlayerPositionStorage implements StorableObject { private double x; private double y; private double z; - protected PlayerPositionStorage(UserConnection user) { - super(user); + protected PlayerPositionStorage() { } public double getX() { diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_10to1_11/Protocol1_10To1_11.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_10to1_11/Protocol1_10To1_11.java index 90612f5f..f0c9b606 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_10to1_11/Protocol1_10To1_11.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_10to1_11/Protocol1_10To1_11.java @@ -63,7 +63,7 @@ public class Protocol1_10To1_11 extends BackwardsProtocol blocks = new ConcurrentHashMap<>(); - public BackwardsBlockStorage(UserConnection user) { - super(user); - } - public void checkAndStore(Position position, int block) { if (!WHITELIST.contains(block)) { // Remove if not whitelisted diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/storage/PlayerPositionStorage1_13.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/storage/PlayerPositionStorage1_13.java index 03697d6d..f0421d1a 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/storage/PlayerPositionStorage1_13.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/storage/PlayerPositionStorage1_13.java @@ -18,11 +18,9 @@ package com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.storage; import com.viaversion.viabackwards.api.entities.storage.PlayerPositionStorage; -import com.viaversion.viaversion.api.connection.UserConnection; public class PlayerPositionStorage1_13 extends PlayerPositionStorage { - public PlayerPositionStorage1_13(UserConnection user) { - super(user); + public PlayerPositionStorage1_13() { } } diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/storage/TabCompleteStorage.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/storage/TabCompleteStorage.java index 9d5833cb..e675d07f 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/storage/TabCompleteStorage.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/storage/TabCompleteStorage.java @@ -17,8 +17,7 @@ */ package com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.storage; -import com.viaversion.viaversion.api.connection.StoredObject; -import com.viaversion.viaversion.api.connection.UserConnection; +import com.viaversion.viaversion.api.connection.StorableObject; import java.util.HashMap; import java.util.HashSet; @@ -26,14 +25,10 @@ import java.util.Map; import java.util.Set; import java.util.UUID; -public class TabCompleteStorage extends StoredObject { +public class TabCompleteStorage implements StorableObject { public int lastId; public String lastRequest; public boolean lastAssumeCommand; public Map usernames = new HashMap<>(); public Set commands = new HashSet<>(); - - public TabCompleteStorage(UserConnection user) { - super(user); - } } diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_14_4to1_15/Protocol1_14_4To1_15.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_14_4to1_15/Protocol1_14_4To1_15.java index 28ec6673..48c9301c 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_14_4to1_15/Protocol1_14_4To1_15.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_14_4to1_15/Protocol1_14_4To1_15.java @@ -103,9 +103,7 @@ public class Protocol1_14_4To1_15 extends BackwardsProtocol