Remove a few deprecated methods

This commit is contained in:
Nassim Jahnke 2024-01-09 20:51:32 +01:00
parent 5991ac5633
commit aecef3c3f8
No known key found for this signature in database
GPG Key ID: EF6771C01F6EF02F
15 changed files with 2 additions and 245 deletions

View File

@ -63,7 +63,7 @@ public interface ViaAPI<T> {
* @return API version incremented with meaningful API changes
*/
default int apiVersion() {
return 22;
return 23;
}
/**

View File

@ -29,11 +29,6 @@ import org.checkerframework.checker.nullness.qual.Nullable;
*/
public interface FullMappings extends Mappings {
@Deprecated
default Mappings mappings() {
return this;
}
/**
* Returns the unmapped integer id for the given identifier, or -1 if not found.
*

View File

@ -52,11 +52,6 @@ public class FullMappingsBase implements FullMappings {
this.mappings = mappings;
}
@Override
public Mappings mappings() {
return mappings;
}
@Override
public int id(final String identifier) {
return stringToId.getInt(Key.stripMinecraftNamespace(identifier));

View File

@ -37,11 +37,6 @@ public class IntArrayMappings implements Mappings {
return new IntArrayMappings(mappings, mappedIds);
}
@Deprecated
public static Builder<IntArrayMappings> builder() {
return Mappings.builder(IntArrayMappings::new);
}
@Override
public int getNewId(int id) {
return id >= 0 && id < mappings.length ? mappings[id] : -1;

View File

@ -60,11 +60,6 @@ public final class MappingDataLoader {
private static final byte IDENTITY_ID = 3;
private static boolean cacheValid = true;
@Deprecated/*(forRemoval = true)*/
public static void enableMappingsCache() {
// Always enabled
}
public static void clearCache() {
MAPPINGS_CACHE.clear();
cacheValid = false;
@ -250,56 +245,6 @@ public final class MappingDataLoader {
);
}
@Deprecated
public static void mapIdentifiers(final int[] output, final JsonObject unmappedIdentifiers, final JsonObject mappedIdentifiers, @Nullable final JsonObject diffIdentifiers, final boolean warnOnMissing) {
final Object2IntMap<String> newIdentifierMap = MappingDataLoader.indexedObjectToMap(mappedIdentifiers);
for (final Map.Entry<String, JsonElement> entry : unmappedIdentifiers.entrySet()) {
final int id = Integer.parseInt(entry.getKey());
final int mappedId = mapIdentifierEntry(id, entry.getValue().getAsString(), newIdentifierMap, diffIdentifiers, warnOnMissing);
if (mappedId != -1) {
output[id] = mappedId;
}
}
}
private static int mapIdentifierEntry(final int id, final String val, final Object2IntMap<String> mappedIdentifiers, @Nullable final JsonObject diffIdentifiers, final boolean warnOnMissing) {
int mappedId = mappedIdentifiers.getInt(val);
if (mappedId == -1) {
// Search in diff mappings
if (diffIdentifiers != null) {
JsonElement diffElement = diffIdentifiers.get(val);
if (diffElement != null || (diffElement = diffIdentifiers.get(Integer.toString(id))) != null) {
final String mappedName = diffElement.getAsString();
if (mappedName.isEmpty()) {
return -1; // "empty" remaps without warnings
}
mappedId = mappedIdentifiers.getInt(mappedName);
}
}
if (mappedId == -1) {
if (warnOnMissing && !Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
Via.getPlatform().getLogger().warning("No key for " + val + " :( ");
}
return -1;
}
}
return mappedId;
}
@Deprecated
public static void mapIdentifiers(final int[] output, final JsonArray unmappedIdentifiers, final JsonArray mappedIdentifiers, @Nullable final JsonObject diffIdentifiers, final boolean warnOnMissing) {
final Object2IntMap<String> newIdentifierMap = MappingDataLoader.arrayToMap(mappedIdentifiers);
for (int id = 0; id < unmappedIdentifiers.size(); id++) {
final JsonElement unmappedIdentifier = unmappedIdentifiers.get(id);
final int mappedId = mapIdentifierEntry(id, unmappedIdentifier.getAsString(), newIdentifierMap, diffIdentifiers, warnOnMissing);
if (mappedId != -1) {
output[id] = mappedId;
}
}
}
/**
* Returns a map of the object entries hashed by their id value.
*

View File

@ -22,11 +22,6 @@
*/
package com.viaversion.viaversion.api.data;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import java.util.Arrays;
public interface Mappings {
/**
@ -90,122 +85,9 @@ public interface Mappings {
*/
Mappings inverse();
static <T extends Mappings> Builder<T> builder(final MappingsSupplier<T> supplier) {
return new Builder<>(supplier);
}
@FunctionalInterface
interface MappingsSupplier<T extends Mappings> {
T supply(int[] mappings, int mappedIds);
}
@Deprecated
class Builder<T extends Mappings> {
protected final MappingsSupplier<T> supplier;
protected JsonElement unmapped;
protected JsonElement mapped;
protected JsonObject diffMappings;
protected int mappedSize = -1;
protected int size = -1;
protected boolean warnOnMissing = true;
protected Builder(final MappingsSupplier<T> supplier) {
this.supplier = supplier;
}
/**
* Sets a custom entry size different to the size of the unmapped collection.
*
* @param size custom entry size
* @return self
*/
public Builder<T> customEntrySize(final int size) {
this.size = size;
return this;
}
/**
* Sets a custom entry mapped ids count different to the size of the mapped collection.
*
* @param size custom mapped id count
* @return self
*/
public Builder<T> customMappedSize(final int size) {
this.mappedSize = size;
return this;
}
/**
* Sets whether warnings should be logged for missing mapped ids.
*
* @param warnOnMissing whether warnings should be logged for missing mapped ids
* @return self
*/
public Builder<T> warnOnMissing(final boolean warnOnMissing) {
this.warnOnMissing = warnOnMissing;
return this;
}
public Builder<T> unmapped(final JsonArray unmappedArray) {
this.unmapped = unmappedArray;
return this;
}
public Builder<T> unmapped(final JsonObject unmappedObject) {
this.unmapped = unmappedObject;
return this;
}
public Builder<T> mapped(final JsonArray mappedArray) {
this.mapped = mappedArray;
return this;
}
public Builder<T> mapped(final JsonObject mappedObject) {
this.mapped = mappedObject;
return this;
}
public Builder<T> diffMappings(final JsonObject diffMappings) {
this.diffMappings = diffMappings;
return this;
}
public T build() {
final int size = this.size != -1 ? this.size : size(unmapped);
final int mappedSize = this.mappedSize != -1 ? this.mappedSize : size(mapped);
final int[] mappings = new int[size];
Arrays.fill(mappings, -1);
// Do conversion if one is an array and the other an object, otherwise directly map
if (unmapped.isJsonArray()) {
if (mapped.isJsonObject()) {
MappingDataLoader.mapIdentifiers(mappings, toJsonObject(unmapped.getAsJsonArray()), mapped.getAsJsonObject(), diffMappings, warnOnMissing);
} else {
MappingDataLoader.mapIdentifiers(mappings, unmapped.getAsJsonArray(), mapped.getAsJsonArray(), diffMappings, warnOnMissing);
}
} else if (mapped.isJsonArray()) {
MappingDataLoader.mapIdentifiers(mappings, unmapped.getAsJsonObject(), toJsonObject(mapped.getAsJsonArray()), diffMappings, warnOnMissing);
} else {
MappingDataLoader.mapIdentifiers(mappings, unmapped.getAsJsonObject(), mapped.getAsJsonObject(), diffMappings, warnOnMissing);
}
return supplier.supply(mappings, mappedSize);
}
protected int size(final JsonElement element) {
return element.isJsonObject() ? element.getAsJsonObject().size() : element.getAsJsonArray().size();
}
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);
object.add(Integer.toString(i), element);
}
return object;
}
}
}

View File

@ -55,19 +55,4 @@ public class ParticleMappings extends FullMappingsBase {
public boolean isItemParticle(final int id) {
return itemParticleIds.contains(id);
}
@Deprecated/*(forRemoval = true)*/
public int getBlockId() {
return id("block");
}
@Deprecated/*(forRemoval = true)*/
public int getFallingDustId() {
return id("falling_dust");
}
@Deprecated/*(forRemoval = true)*/
public int getItemId() {
return id("item");
}
}

View File

@ -23,7 +23,6 @@
package com.viaversion.viaversion.api.minecraft;
import com.viaversion.viaversion.api.connection.StorableObject;
import com.viaversion.viaversion.api.connection.UserConnection;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@ -32,10 +31,6 @@ import org.checkerframework.checker.nullness.qual.Nullable;
public class ClientWorld implements StorableObject {
private Environment environment;
@Deprecated/*(forRemoval = true)*/
public ClientWorld(final UserConnection connection) {
}
public ClientWorld() {
}

View File

@ -57,11 +57,6 @@ public enum RegistryType {
this.resourceLocation = resourceLocation;
}
@Deprecated/*(forRemoval = true)*/
public String getResourceLocation() {
return resourceLocation;
}
public String resourceLocation() {
return resourceLocation;
}

View File

@ -63,16 +63,6 @@ public interface EntityType {
*/
boolean isAbstractType();
@Deprecated/*(forRemoval = true)*/
default boolean is(EntityType... types) {
for (EntityType type : types) {
if (this == type) {
return true;
}
}
return false;
}
default boolean is(EntityType type) {
return this == type;
}

View File

@ -63,11 +63,6 @@ public final class BukkitChannelInitializer extends ChannelInitializer<Channel>
this.original = oldInit;
}
@Deprecated/*(forRemoval = true)*/
public ChannelInitializer<Channel> getOriginal() {
return original;
}
@Override
protected void initChannel(Channel channel) throws Exception {
// Add originals

View File

@ -70,11 +70,6 @@ public class BukkitViaLoader implements ViaPlatformLoader {
plugin.getServer().getPluginManager().registerEvents(listener, plugin);
}
@Deprecated/*(forRemoval = true)*/
public <T extends Listener> T storeListener(T listener) {
return listener;
}
@Override
public void load() {
registerListener(new UpdateListener());

View File

@ -155,7 +155,7 @@ public class Protocol1_9_3To1_9_1_2 extends AbstractProtocol<ClientboundPackets1
@Override
public void init(UserConnection user) {
if (!user.has(ClientWorld.class)) {
user.put(new ClientWorld(user));
user.put(new ClientWorld());
}
}
}

View File

@ -45,11 +45,6 @@ public class ComponentRewriter<C extends ClientboundPacketType> {
protected final Protocol<C, ?, ?, ?> protocol;
protected final ReadType type;
@Deprecated/*(forRemoval = true)*/
public ComponentRewriter(final Protocol<C, ?, ?, ?> protocol) {
this(protocol, ReadType.JSON);
}
public ComponentRewriter(final Protocol<C, ?, ?, ?> protocol, final ReadType type) {
this.protocol = protocol;
this.type = type;

View File

@ -68,11 +68,6 @@ public class SpongeChannelInitializer extends ChannelInitializer<Channel> implem
}
}
/*@Deprecated(forRemoval = true)*/
public ChannelInitializer<Channel> getOriginal() {
return original;
}
@Override
public ChannelInitializer<Channel> original() {
return original;