fix: make the lists actually thread-safe (maybe, but pretty likely)
https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/util/Collections.html#synchronizedList(java.util.List) > It is imperative that the user manually synchronize on the returned list when traversing it via Iterator, Spliterator or Stream > Failure to follow this advice may result in non-deterministic behavior.
This commit is contained in:
@@ -15,8 +15,8 @@ import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.entity.spaw
|
||||
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.level.ServerboundAcceptTeleportationPacket;
|
||||
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.player.ServerboundMovePlayerPosPacket;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
// some part of the code used to be in a test plugin but i thought it would be useful in the future so i moved it here
|
||||
public class PositionPlugin implements Listener {
|
||||
@@ -28,9 +28,9 @@ public class PositionPlugin implements Listener {
|
||||
|
||||
private long tpCommandCooldownTime = 0;
|
||||
|
||||
private final Map<Integer, PlayerEntry> entityIdMap = new HashMap<>();
|
||||
private final Map<Integer, Vector3d> positionMap = new HashMap<>();
|
||||
private final Map<Integer, Rotation> rotationMap = new HashMap<>();
|
||||
private final Map<Integer, PlayerEntry> entityIdMap = new ConcurrentHashMap<>();
|
||||
private final Map<Integer, Vector3d> positionMap = new ConcurrentHashMap<>();
|
||||
private final Map<Integer, Rotation> rotationMap = new ConcurrentHashMap<>();
|
||||
|
||||
public PositionPlugin (final Bot bot) {
|
||||
this.bot = bot;
|
||||
|
||||
Reference in New Issue
Block a user