Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public PacketRecorder() {
unknown.defaultReturnValue(0);
}

public void recordUnknown(ResourceLocation id) {
public synchronized void recordUnknown(ResourceLocation id) {
if (id == null) {
ArclightServer.LOGGER.debug("Received packet with null id. This should never happen.");
return;
Expand All @@ -25,16 +25,23 @@ public void recordUnknown(ResourceLocation id) {
unknown.put(id, num + 1);
}

public void update() {
public synchronized void update() {
long now = Util.getMillis();
if (Math.abs(now - lastUpdate) > ArclightConstants.PACKET_RECORDER_PERIOD_SEC *1000) {
consumeAndLog();
lastUpdate = now;
}
}

public void consumeAndLog() {
public synchronized void consumeAndLog() {
String unknowns = unknown.object2IntEntrySet().stream()
.filter(it -> {
if (it.getKey() == null) {
ArclightServer.LOGGER.warn("Packet recorder encountered a null payload id entry; skipping corrupted record.");
return false;
}
return true;
})
.map(it -> it.getKey().toString() + '(' + it.getIntValue() + ')')
.collect(Collectors.joining(", ", "unknown=[", "];"));
unknown.clear();
Expand Down