Fix ConcurrentModificationException
This commit is contained in:
parent
583afd3dc9
commit
e0dfefb72b
|
@ -83,7 +83,7 @@ abstract class DeviceBlockEntity(type: BlockEntityType<*>): BlockEntity(type),
|
|||
arpTable[frame.query] = frame.source
|
||||
println("$this ($ipAddress) received ARP response for ${frame.query} with ${frame.source}")
|
||||
|
||||
packetQueue.removeIf { (packet, _) ->
|
||||
val toRemove = packetQueue.filter { (packet, _) ->
|
||||
if (packet.destination == frame.query) {
|
||||
send(BasePacketFrame(packet, macAddress, frame.source))
|
||||
true
|
||||
|
@ -91,6 +91,7 @@ abstract class DeviceBlockEntity(type: BlockEntityType<*>): BlockEntity(type),
|
|||
false
|
||||
}
|
||||
}
|
||||
packetQueue.removeAll(toRemove)
|
||||
}
|
||||
|
||||
override fun sendPacket(packet: Packet) {
|
||||
|
@ -118,7 +119,7 @@ abstract class DeviceBlockEntity(type: BlockEntityType<*>): BlockEntity(type),
|
|||
counter++
|
||||
|
||||
if (!world!!.isClient) {
|
||||
packetQueue.removeIf { entry ->
|
||||
val toRemove = packetQueue.filter { entry ->
|
||||
val (packet, timestamp) = entry
|
||||
if (arpTable.containsKey(packet.destination)) {
|
||||
send(BasePacketFrame(packet, macAddress, arpTable[packet.destination]!!))
|
||||
|
@ -132,6 +133,7 @@ abstract class DeviceBlockEntity(type: BlockEntityType<*>): BlockEntity(type),
|
|||
false
|
||||
}
|
||||
}
|
||||
packetQueue.removeAll(toRemove)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue