Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-26 00:00:28 +01:00
Fix InformativeException value shuffling
Dieser Commit ist enthalten in:
Ursprung
009b6c810c
Commit
df69f1f344
@ -22,11 +22,12 @@
|
|||||||
*/
|
*/
|
||||||
package com.viaversion.viaversion.exception;
|
package com.viaversion.viaversion.exception;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.ArrayList;
|
||||||
import java.util.Map;
|
import java.util.List;
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
public class InformativeException extends RuntimeException {
|
public class InformativeException extends RuntimeException {
|
||||||
private final Map<String, Object> info = new HashMap<>();
|
private final List<DataEntry> dataEntries = new ArrayList<>();
|
||||||
private boolean shouldBePrinted = true;
|
private boolean shouldBePrinted = true;
|
||||||
private int sources;
|
private int sources;
|
||||||
|
|
||||||
@ -34,8 +35,8 @@ public class InformativeException extends RuntimeException {
|
|||||||
super(cause);
|
super(cause);
|
||||||
}
|
}
|
||||||
|
|
||||||
public InformativeException set(String key, Object value) {
|
public InformativeException set(String key, @Nullable Object value) {
|
||||||
info.put(key, value);
|
dataEntries.add(new DataEntry(key, value));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,11 +60,11 @@ public class InformativeException extends RuntimeException {
|
|||||||
public String getMessage() {
|
public String getMessage() {
|
||||||
StringBuilder builder = new StringBuilder("Please report this on the Via support Discord or open an issue on the relevant GitHub repository\n");
|
StringBuilder builder = new StringBuilder("Please report this on the Via support Discord or open an issue on the relevant GitHub repository\n");
|
||||||
boolean first = true;
|
boolean first = true;
|
||||||
for (Map.Entry<String, Object> entry : info.entrySet()) {
|
for (DataEntry entry : dataEntries) {
|
||||||
if (!first) {
|
if (!first) {
|
||||||
builder.append(", ");
|
builder.append(", ");
|
||||||
}
|
}
|
||||||
builder.append(entry.getKey()).append(": ").append(entry.getValue());
|
builder.append(entry.name()).append(": ").append(entry.value());
|
||||||
first = false;
|
first = false;
|
||||||
}
|
}
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
@ -74,4 +75,7 @@ public class InformativeException extends RuntimeException {
|
|||||||
// Don't record this stack
|
// Don't record this stack
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private record DataEntry(String name, @Nullable Object value) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -243,11 +243,11 @@ public class PacketWrapperImpl implements PacketWrapper {
|
|||||||
|
|
||||||
private InformativeException createInformativeException(final Exception cause, final Type<?> type, final int index) {
|
private InformativeException createInformativeException(final Exception cause, final Type<?> type, final int index) {
|
||||||
return new InformativeException(cause)
|
return new InformativeException(cause)
|
||||||
|
.set("Packet Type", this.packetType)
|
||||||
.set("Index", index)
|
.set("Index", index)
|
||||||
.set("Type", type.getTypeName())
|
.set("Type", type.getTypeName())
|
||||||
.set("Packet ID", this.id)
|
.set("Data", this.packetValues)
|
||||||
.set("Packet Type", this.packetType)
|
.set("Packet ID", this.id);
|
||||||
.set("Data", this.packetValues);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren