Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-27 08:30:09 +01:00
Make Mappings extendable
Dieser Commit ist enthalten in:
Ursprung
3051ddb6c0
Commit
390155e03b
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren