Mirror von
https://github.com/ViaVersion/ViaBackwards.git
synchronisiert 2024-11-20 06:50:10 +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;
|
package com.viaversion.viabackwards.api.entities.storage;
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.connection.StoredObject;
|
import com.viaversion.viaversion.api.connection.StorableObject;
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
|
||||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
|
|
||||||
public abstract class PlayerPositionStorage extends StoredObject {
|
public abstract class PlayerPositionStorage implements StorableObject {
|
||||||
private double x;
|
private double x;
|
||||||
private double y;
|
private double y;
|
||||||
private double z;
|
private double z;
|
||||||
|
|
||||||
protected PlayerPositionStorage(UserConnection user) {
|
protected PlayerPositionStorage() {
|
||||||
super(user);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getX() {
|
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));
|
user.addEntityTracker(this.getClass(), new EntityTrackerBase(user, Entity1_11Types.EntityType.PLAYER, true));
|
||||||
|
|
||||||
if (!user.has(WindowTracker.class)) {
|
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;
|
package com.viaversion.viabackwards.protocol.protocol1_10to1_11.storage;
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.connection.StoredObject;
|
import com.viaversion.viaversion.api.connection.StorableObject;
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
|
||||||
|
|
||||||
public class WindowTracker extends StoredObject {
|
public class WindowTracker implements StorableObject {
|
||||||
private String inventory;
|
private String inventory;
|
||||||
private int entityId = -1;
|
private int entityId = -1;
|
||||||
|
|
||||||
public WindowTracker(UserConnection user) {
|
|
||||||
super(user);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getInventory() {
|
public String getInventory() {
|
||||||
return inventory;
|
return inventory;
|
||||||
}
|
}
|
||||||
|
@ -18,16 +18,11 @@
|
|||||||
|
|
||||||
package com.viaversion.viabackwards.protocol.protocol1_12_1to1_12_2;
|
package com.viaversion.viabackwards.protocol.protocol1_12_1to1_12_2;
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.connection.StoredObject;
|
import com.viaversion.viaversion.api.connection.StorableObject;
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
|
||||||
|
|
||||||
public class KeepAliveTracker extends StoredObject {
|
public class KeepAliveTracker implements StorableObject {
|
||||||
private long keepAlive = Integer.MAX_VALUE;
|
private long keepAlive = Integer.MAX_VALUE;
|
||||||
|
|
||||||
public KeepAliveTracker(UserConnection user) {
|
|
||||||
super(user);
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getKeepAlive() {
|
public long getKeepAlive() {
|
||||||
return keepAlive;
|
return keepAlive;
|
||||||
}
|
}
|
||||||
|
@ -72,6 +72,6 @@ public class Protocol1_12_1To1_12_2 extends BackwardsProtocol<ClientboundPackets
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(UserConnection userConnection) {
|
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));
|
user.addEntityTracker(this.getClass(), new EntityTrackerBase(user, Entity1_13Types.EntityType.PLAYER));
|
||||||
|
|
||||||
// Register Block Storage
|
user.put(new BackwardsBlockStorage());
|
||||||
if (!user.has(BackwardsBlockStorage.class)) {
|
user.put(new TabCompleteStorage());
|
||||||
user.put(new BackwardsBlockStorage(user));
|
|
||||||
}
|
|
||||||
// Register Block Storage
|
|
||||||
if (!user.has(TabCompleteStorage.class)) {
|
|
||||||
user.put(new TabCompleteStorage(user));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ViaBackwards.getConfig().isFix1_13FacePlayer() && !user.has(PlayerPositionStorage1_13.class)) {
|
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;
|
package com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.storage;
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.connection.StoredObject;
|
import com.viaversion.viaversion.api.connection.StorableObject;
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
|
||||||
import com.viaversion.viaversion.api.minecraft.Position;
|
import com.viaversion.viaversion.api.minecraft.Position;
|
||||||
import com.viaversion.viaversion.libs.fastutil.ints.IntOpenHashSet;
|
import com.viaversion.viaversion.libs.fastutil.ints.IntOpenHashSet;
|
||||||
import com.viaversion.viaversion.libs.fastutil.ints.IntSet;
|
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.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
public class BackwardsBlockStorage extends StoredObject {
|
public class BackwardsBlockStorage implements StorableObject {
|
||||||
// This BlockStorage is very exclusive (;
|
// This BlockStorage is very exclusive (;
|
||||||
private static final IntSet WHITELIST = new IntOpenHashSet(779);
|
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<>();
|
private final Map<Position, Integer> blocks = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
public BackwardsBlockStorage(UserConnection user) {
|
|
||||||
super(user);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void checkAndStore(Position position, int block) {
|
public void checkAndStore(Position position, int block) {
|
||||||
if (!WHITELIST.contains(block)) {
|
if (!WHITELIST.contains(block)) {
|
||||||
// Remove if not whitelisted
|
// Remove if not whitelisted
|
||||||
|
@ -18,11 +18,9 @@
|
|||||||
package com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.storage;
|
package com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.storage;
|
||||||
|
|
||||||
import com.viaversion.viabackwards.api.entities.storage.PlayerPositionStorage;
|
import com.viaversion.viabackwards.api.entities.storage.PlayerPositionStorage;
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
|
||||||
|
|
||||||
public class PlayerPositionStorage1_13 extends PlayerPositionStorage {
|
public class PlayerPositionStorage1_13 extends PlayerPositionStorage {
|
||||||
|
|
||||||
public PlayerPositionStorage1_13(UserConnection user) {
|
public PlayerPositionStorage1_13() {
|
||||||
super(user);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,8 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.storage;
|
package com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.storage;
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.connection.StoredObject;
|
import com.viaversion.viaversion.api.connection.StorableObject;
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@ -26,14 +25,10 @@ import java.util.Map;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class TabCompleteStorage extends StoredObject {
|
public class TabCompleteStorage implements StorableObject {
|
||||||
public int lastId;
|
public int lastId;
|
||||||
public String lastRequest;
|
public String lastRequest;
|
||||||
public boolean lastAssumeCommand;
|
public boolean lastAssumeCommand;
|
||||||
public Map<UUID, String> usernames = new HashMap<>();
|
public Map<UUID, String> usernames = new HashMap<>();
|
||||||
public Set<String> commands = new HashSet<>();
|
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
|
@Override
|
||||||
public void init(UserConnection user) {
|
public void init(UserConnection user) {
|
||||||
if (!user.has(ImmediateRespawn.class)) {
|
user.put(new ImmediateRespawn());
|
||||||
user.put(new ImmediateRespawn(user));
|
|
||||||
}
|
|
||||||
user.addEntityTracker(getClass(), new EntityTrackerBase(user, Entity1_15Types.PLAYER));
|
user.addEntityTracker(getClass(), new EntityTrackerBase(user, Entity1_15Types.PLAYER));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,16 +17,11 @@
|
|||||||
*/
|
*/
|
||||||
package com.viaversion.viabackwards.protocol.protocol1_14_4to1_15.data;
|
package com.viaversion.viabackwards.protocol.protocol1_14_4to1_15.data;
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.connection.StoredObject;
|
import com.viaversion.viaversion.api.connection.StorableObject;
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
|
||||||
|
|
||||||
public class ImmediateRespawn extends StoredObject {
|
public class ImmediateRespawn implements StorableObject {
|
||||||
private boolean immediateRespawn;
|
private boolean immediateRespawn;
|
||||||
|
|
||||||
public ImmediateRespawn(UserConnection user) {
|
|
||||||
super(user);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isImmediateRespawn() {
|
public boolean isImmediateRespawn() {
|
||||||
return immediateRespawn;
|
return immediateRespawn;
|
||||||
}
|
}
|
||||||
|
@ -200,8 +200,8 @@ public class Protocol1_15_2To1_16 extends BackwardsProtocol<ClientboundPackets1_
|
|||||||
user.put(new ClientWorld(user));
|
user.put(new ClientWorld(user));
|
||||||
}
|
}
|
||||||
|
|
||||||
user.put(new PlayerSneakStorage(user));
|
user.put(new PlayerSneakStorage());
|
||||||
user.put(new WorldNameTracker(user));
|
user.put(new WorldNameTracker());
|
||||||
user.addEntityTracker(this.getClass(), new EntityTrackerBase(user, Entity1_16Types.PLAYER));
|
user.addEntityTracker(this.getClass(), new EntityTrackerBase(user, Entity1_16Types.PLAYER));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,16 +17,11 @@
|
|||||||
*/
|
*/
|
||||||
package com.viaversion.viabackwards.protocol.protocol1_15_2to1_16.data;
|
package com.viaversion.viabackwards.protocol.protocol1_15_2to1_16.data;
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.connection.StoredObject;
|
import com.viaversion.viaversion.api.connection.StorableObject;
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
|
||||||
|
|
||||||
public class WorldNameTracker extends StoredObject {
|
public class WorldNameTracker implements StorableObject {
|
||||||
private String worldName;
|
private String worldName;
|
||||||
|
|
||||||
public WorldNameTracker(UserConnection user) {
|
|
||||||
super(user);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getWorldName() {
|
public String getWorldName() {
|
||||||
return worldName;
|
return worldName;
|
||||||
}
|
}
|
||||||
|
@ -17,16 +17,11 @@
|
|||||||
*/
|
*/
|
||||||
package com.viaversion.viabackwards.protocol.protocol1_15_2to1_16.storage;
|
package com.viaversion.viabackwards.protocol.protocol1_15_2to1_16.storage;
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.connection.StoredObject;
|
import com.viaversion.viaversion.api.connection.StorableObject;
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
|
||||||
|
|
||||||
public class PlayerSneakStorage extends StoredObject {
|
public class PlayerSneakStorage implements StorableObject {
|
||||||
private boolean sneaking;
|
private boolean sneaking;
|
||||||
|
|
||||||
public PlayerSneakStorage(UserConnection user) {
|
|
||||||
super(user);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSneaking() {
|
public boolean isSneaking() {
|
||||||
return sneaking;
|
return sneaking;
|
||||||
}
|
}
|
||||||
|
@ -62,6 +62,6 @@ public class Protocol1_16_3To1_16_4 extends BackwardsProtocol<ClientboundPackets
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(UserConnection user) {
|
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;
|
package com.viaversion.viabackwards.protocol.protocol1_16_3to1_16_4.storage;
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.connection.StoredObject;
|
import com.viaversion.viaversion.api.connection.StorableObject;
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
|
||||||
|
|
||||||
public class PlayerHandStorage extends StoredObject {
|
public class PlayerHandStorage implements StorableObject {
|
||||||
|
|
||||||
private int currentHand;
|
private int currentHand;
|
||||||
|
|
||||||
public PlayerHandStorage(UserConnection user) {
|
|
||||||
super(user);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getCurrentHand() {
|
public int getCurrentHand() {
|
||||||
return currentHand;
|
return currentHand;
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren