Mirror von
https://github.com/ViaVersion/ViaBackwards.git
synchronisiert 2024-12-24 15:20:19 +01:00
Don't store UserConnection in stored objects unless needed
Dieser Commit ist enthalten in:
Ursprung
4a60f0f903
Commit
8adb80b5eb
@ -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() {
|
||||
|
@ -63,7 +63,7 @@ public class Protocol1_10To1_11 extends BackwardsProtocol<ClientboundPackets1_9_
|
||||
user.addEntityTracker(this.getClass(), new EntityTrackerBase(user, Entity1_11Types.EntityType.PLAYER, true));
|
||||
|
||||
if (!user.has(WindowTracker.class)) {
|
||||
user.put(new WindowTracker(user));
|
||||
user.put(new WindowTracker());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,17 +18,12 @@
|
||||
|
||||
package com.viaversion.viabackwards.protocol.protocol1_10to1_11.storage;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.StoredObject;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.connection.StorableObject;
|
||||
|
||||
public class WindowTracker extends StoredObject {
|
||||
public class WindowTracker implements StorableObject {
|
||||
private String inventory;
|
||||
private int entityId = -1;
|
||||
|
||||
public WindowTracker(UserConnection user) {
|
||||
super(user);
|
||||
}
|
||||
|
||||
public String getInventory() {
|
||||
return inventory;
|
||||
}
|
||||
|
@ -18,16 +18,11 @@
|
||||
|
||||
package com.viaversion.viabackwards.protocol.protocol1_12_1to1_12_2;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.StoredObject;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.connection.StorableObject;
|
||||
|
||||
public class KeepAliveTracker extends StoredObject {
|
||||
public class KeepAliveTracker implements StorableObject {
|
||||
private long keepAlive = Integer.MAX_VALUE;
|
||||
|
||||
public KeepAliveTracker(UserConnection user) {
|
||||
super(user);
|
||||
}
|
||||
|
||||
public long getKeepAlive() {
|
||||
return keepAlive;
|
||||
}
|
||||
|
@ -72,6 +72,6 @@ public class Protocol1_12_1To1_12_2 extends BackwardsProtocol<ClientboundPackets
|
||||
|
||||
@Override
|
||||
public void init(UserConnection userConnection) {
|
||||
userConnection.put(new KeepAliveTracker(userConnection));
|
||||
userConnection.put(new KeepAliveTracker());
|
||||
}
|
||||
}
|
||||
|
@ -103,17 +103,11 @@ public class Protocol1_12_2To1_13 extends BackwardsProtocol<ClientboundPackets1_
|
||||
|
||||
user.addEntityTracker(this.getClass(), new EntityTrackerBase(user, Entity1_13Types.EntityType.PLAYER));
|
||||
|
||||
// Register Block Storage
|
||||
if (!user.has(BackwardsBlockStorage.class)) {
|
||||
user.put(new BackwardsBlockStorage(user));
|
||||
}
|
||||
// Register Block Storage
|
||||
if (!user.has(TabCompleteStorage.class)) {
|
||||
user.put(new TabCompleteStorage(user));
|
||||
}
|
||||
user.put(new BackwardsBlockStorage());
|
||||
user.put(new TabCompleteStorage());
|
||||
|
||||
if (ViaBackwards.getConfig().isFix1_13FacePlayer() && !user.has(PlayerPositionStorage1_13.class)) {
|
||||
user.put(new PlayerPositionStorage1_13(user));
|
||||
user.put(new PlayerPositionStorage1_13());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,8 +18,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 com.viaversion.viaversion.api.minecraft.Position;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.IntOpenHashSet;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.IntSet;
|
||||
@ -27,7 +26,7 @@ import com.viaversion.viaversion.libs.fastutil.ints.IntSet;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class BackwardsBlockStorage extends StoredObject {
|
||||
public class BackwardsBlockStorage implements StorableObject {
|
||||
// This BlockStorage is very exclusive (;
|
||||
private static final IntSet WHITELIST = new IntOpenHashSet(779);
|
||||
|
||||
@ -69,10 +68,6 @@ public class BackwardsBlockStorage extends StoredObject {
|
||||
|
||||
private final Map<Position, Integer> blocks = new ConcurrentHashMap<>();
|
||||
|
||||
public BackwardsBlockStorage(UserConnection user) {
|
||||
super(user);
|
||||
}
|
||||
|
||||
public void checkAndStore(Position position, int block) {
|
||||
if (!WHITELIST.contains(block)) {
|
||||
// Remove if not whitelisted
|
||||
|
@ -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() {
|
||||
}
|
||||
}
|
||||
|
@ -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<UUID, String> usernames = new HashMap<>();
|
||||
public Set<String> commands = new HashSet<>();
|
||||
|
||||
public TabCompleteStorage(UserConnection user) {
|
||||
super(user);
|
||||
}
|
||||
}
|
||||
|
@ -103,9 +103,7 @@ public class Protocol1_14_4To1_15 extends BackwardsProtocol<ClientboundPackets1_
|
||||
|
||||
@Override
|
||||
public void init(UserConnection user) {
|
||||
if (!user.has(ImmediateRespawn.class)) {
|
||||
user.put(new ImmediateRespawn(user));
|
||||
}
|
||||
user.put(new ImmediateRespawn());
|
||||
user.addEntityTracker(getClass(), new EntityTrackerBase(user, Entity1_15Types.PLAYER));
|
||||
}
|
||||
|
||||
|
@ -17,16 +17,11 @@
|
||||
*/
|
||||
package com.viaversion.viabackwards.protocol.protocol1_14_4to1_15.data;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.StoredObject;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.connection.StorableObject;
|
||||
|
||||
public class ImmediateRespawn extends StoredObject {
|
||||
public class ImmediateRespawn implements StorableObject {
|
||||
private boolean immediateRespawn;
|
||||
|
||||
public ImmediateRespawn(UserConnection user) {
|
||||
super(user);
|
||||
}
|
||||
|
||||
public boolean isImmediateRespawn() {
|
||||
return immediateRespawn;
|
||||
}
|
||||
|
@ -200,8 +200,8 @@ public class Protocol1_15_2To1_16 extends BackwardsProtocol<ClientboundPackets1_
|
||||
user.put(new ClientWorld(user));
|
||||
}
|
||||
|
||||
user.put(new PlayerSneakStorage(user));
|
||||
user.put(new WorldNameTracker(user));
|
||||
user.put(new PlayerSneakStorage());
|
||||
user.put(new WorldNameTracker());
|
||||
user.addEntityTracker(this.getClass(), new EntityTrackerBase(user, Entity1_16Types.PLAYER));
|
||||
}
|
||||
|
||||
|
@ -17,16 +17,11 @@
|
||||
*/
|
||||
package com.viaversion.viabackwards.protocol.protocol1_15_2to1_16.data;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.StoredObject;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.connection.StorableObject;
|
||||
|
||||
public class WorldNameTracker extends StoredObject {
|
||||
public class WorldNameTracker implements StorableObject {
|
||||
private String worldName;
|
||||
|
||||
public WorldNameTracker(UserConnection user) {
|
||||
super(user);
|
||||
}
|
||||
|
||||
public String getWorldName() {
|
||||
return worldName;
|
||||
}
|
||||
|
@ -17,16 +17,11 @@
|
||||
*/
|
||||
package com.viaversion.viabackwards.protocol.protocol1_15_2to1_16.storage;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.StoredObject;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.connection.StorableObject;
|
||||
|
||||
public class PlayerSneakStorage extends StoredObject {
|
||||
public class PlayerSneakStorage implements StorableObject {
|
||||
private boolean sneaking;
|
||||
|
||||
public PlayerSneakStorage(UserConnection user) {
|
||||
super(user);
|
||||
}
|
||||
|
||||
public boolean isSneaking() {
|
||||
return sneaking;
|
||||
}
|
||||
|
@ -62,6 +62,6 @@ public class Protocol1_16_3To1_16_4 extends BackwardsProtocol<ClientboundPackets
|
||||
|
||||
@Override
|
||||
public void init(UserConnection user) {
|
||||
user.put(new PlayerHandStorage(user));
|
||||
user.put(new PlayerHandStorage());
|
||||
}
|
||||
}
|
||||
|
@ -17,17 +17,12 @@
|
||||
*/
|
||||
package com.viaversion.viabackwards.protocol.protocol1_16_3to1_16_4.storage;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.StoredObject;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.connection.StorableObject;
|
||||
|
||||
public class PlayerHandStorage extends StoredObject {
|
||||
public class PlayerHandStorage implements StorableObject {
|
||||
|
||||
private int currentHand;
|
||||
|
||||
public PlayerHandStorage(UserConnection user) {
|
||||
super(user);
|
||||
}
|
||||
|
||||
public int getCurrentHand() {
|
||||
return currentHand;
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren