3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-11-03 14:50:30 +01:00

Make Mappings extendable

Dieser Commit ist enthalten in:
Nassim Jahnke 2021-11-16 13:15:27 +01:00
Ursprung 3051ddb6c0
Commit 390155e03b
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 6BE3B555EBC5982B
2 geänderte Dateien mit 9 neuen und 5 gelöschten Zeilen

Datei anzeigen

@ -32,11 +32,15 @@ public class IntArrayMappings implements Mappings {
private final int[] oldToNew;
private final int mappedIds;
private IntArrayMappings(int[] oldToNew, int mappedIds) {
protected IntArrayMappings(final int[] oldToNew, final int mappedIds) {
this.oldToNew = oldToNew;
this.mappedIds = mappedIds;
}
public static IntArrayMappings of(final int[] oldToNew, final int mappedIds) {
return new IntArrayMappings(oldToNew, mappedIds);
}
public static Builder<IntArrayMappings> builder() {
return Mappings.builder(IntArrayMappings::new);
}

Datei anzeigen

@ -70,7 +70,7 @@ public interface Mappings {
T supply(int[] mappings, int mappedIds);
}
final class Builder<T extends Mappings> {
class Builder<T extends Mappings> {
private final MappingsSupplier<T> supplier;
private JsonElement unmapped;
@ -80,7 +80,7 @@ public interface Mappings {
private int size = -1;
private boolean warnOnMissing = true;
private Builder(final MappingsSupplier<T> supplier) {
protected Builder(final MappingsSupplier<T> supplier) {
this.supplier = supplier;
}
@ -163,11 +163,11 @@ public interface Mappings {
return supplier.supply(mappings, mappedSize);
}
private int size(final JsonElement element) {
protected int size(final JsonElement element) {
return element.isJsonObject() ? element.getAsJsonObject().size() : element.getAsJsonArray().size();
}
private JsonObject toJsonObject(final JsonArray array) {
protected JsonObject toJsonObject(final JsonArray array) {
final JsonObject object = new JsonObject();
for (int i = 0; i < array.size(); i++) {
final JsonElement element = array.get(i);