Remove a few deprecated methods
This commit is contained in:
parent
5991ac5633
commit
aecef3c3f8
|
@ -63,7 +63,7 @@ public interface ViaAPI<T> {
|
||||||
* @return API version incremented with meaningful API changes
|
* @return API version incremented with meaningful API changes
|
||||||
*/
|
*/
|
||||||
default int apiVersion() {
|
default int apiVersion() {
|
||||||
return 22;
|
return 23;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -29,11 +29,6 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
*/
|
*/
|
||||||
public interface FullMappings extends Mappings {
|
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.
|
* Returns the unmapped integer id for the given identifier, or -1 if not found.
|
||||||
*
|
*
|
||||||
|
|
|
@ -52,11 +52,6 @@ public class FullMappingsBase implements FullMappings {
|
||||||
this.mappings = mappings;
|
this.mappings = mappings;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Mappings mappings() {
|
|
||||||
return mappings;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int id(final String identifier) {
|
public int id(final String identifier) {
|
||||||
return stringToId.getInt(Key.stripMinecraftNamespace(identifier));
|
return stringToId.getInt(Key.stripMinecraftNamespace(identifier));
|
||||||
|
|
|
@ -37,11 +37,6 @@ public class IntArrayMappings implements Mappings {
|
||||||
return new IntArrayMappings(mappings, mappedIds);
|
return new IntArrayMappings(mappings, mappedIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public static Builder<IntArrayMappings> builder() {
|
|
||||||
return Mappings.builder(IntArrayMappings::new);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getNewId(int id) {
|
public int getNewId(int id) {
|
||||||
return id >= 0 && id < mappings.length ? mappings[id] : -1;
|
return id >= 0 && id < mappings.length ? mappings[id] : -1;
|
||||||
|
|
|
@ -60,11 +60,6 @@ public final class MappingDataLoader {
|
||||||
private static final byte IDENTITY_ID = 3;
|
private static final byte IDENTITY_ID = 3;
|
||||||
private static boolean cacheValid = true;
|
private static boolean cacheValid = true;
|
||||||
|
|
||||||
@Deprecated/*(forRemoval = true)*/
|
|
||||||
public static void enableMappingsCache() {
|
|
||||||
// Always enabled
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void clearCache() {
|
public static void clearCache() {
|
||||||
MAPPINGS_CACHE.clear();
|
MAPPINGS_CACHE.clear();
|
||||||
cacheValid = false;
|
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.
|
* Returns a map of the object entries hashed by their id value.
|
||||||
*
|
*
|
||||||
|
|
|
@ -22,11 +22,6 @@
|
||||||
*/
|
*/
|
||||||
package com.viaversion.viaversion.api.data;
|
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 {
|
public interface Mappings {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -90,122 +85,9 @@ public interface Mappings {
|
||||||
*/
|
*/
|
||||||
Mappings inverse();
|
Mappings inverse();
|
||||||
|
|
||||||
static <T extends Mappings> Builder<T> builder(final MappingsSupplier<T> supplier) {
|
|
||||||
return new Builder<>(supplier);
|
|
||||||
}
|
|
||||||
|
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
interface MappingsSupplier<T extends Mappings> {
|
interface MappingsSupplier<T extends Mappings> {
|
||||||
|
|
||||||
T supply(int[] mappings, int mappedIds);
|
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,19 +55,4 @@ public class ParticleMappings extends FullMappingsBase {
|
||||||
public boolean isItemParticle(final int id) {
|
public boolean isItemParticle(final int id) {
|
||||||
return itemParticleIds.contains(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");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
package com.viaversion.viaversion.api.minecraft;
|
package com.viaversion.viaversion.api.minecraft;
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.connection.StorableObject;
|
import com.viaversion.viaversion.api.connection.StorableObject;
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -32,10 +31,6 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
public class ClientWorld implements StorableObject {
|
public class ClientWorld implements StorableObject {
|
||||||
private Environment environment;
|
private Environment environment;
|
||||||
|
|
||||||
@Deprecated/*(forRemoval = true)*/
|
|
||||||
public ClientWorld(final UserConnection connection) {
|
|
||||||
}
|
|
||||||
|
|
||||||
public ClientWorld() {
|
public ClientWorld() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,11 +57,6 @@ public enum RegistryType {
|
||||||
this.resourceLocation = resourceLocation;
|
this.resourceLocation = resourceLocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated/*(forRemoval = true)*/
|
|
||||||
public String getResourceLocation() {
|
|
||||||
return resourceLocation;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String resourceLocation() {
|
public String resourceLocation() {
|
||||||
return resourceLocation;
|
return resourceLocation;
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,16 +63,6 @@ public interface EntityType {
|
||||||
*/
|
*/
|
||||||
boolean isAbstractType();
|
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) {
|
default boolean is(EntityType type) {
|
||||||
return this == type;
|
return this == type;
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,11 +63,6 @@ public final class BukkitChannelInitializer extends ChannelInitializer<Channel>
|
||||||
this.original = oldInit;
|
this.original = oldInit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated/*(forRemoval = true)*/
|
|
||||||
public ChannelInitializer<Channel> getOriginal() {
|
|
||||||
return original;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void initChannel(Channel channel) throws Exception {
|
protected void initChannel(Channel channel) throws Exception {
|
||||||
// Add originals
|
// Add originals
|
||||||
|
|
|
@ -70,11 +70,6 @@ public class BukkitViaLoader implements ViaPlatformLoader {
|
||||||
plugin.getServer().getPluginManager().registerEvents(listener, plugin);
|
plugin.getServer().getPluginManager().registerEvents(listener, plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated/*(forRemoval = true)*/
|
|
||||||
public <T extends Listener> T storeListener(T listener) {
|
|
||||||
return listener;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load() {
|
public void load() {
|
||||||
registerListener(new UpdateListener());
|
registerListener(new UpdateListener());
|
||||||
|
|
|
@ -155,7 +155,7 @@ public class Protocol1_9_3To1_9_1_2 extends AbstractProtocol<ClientboundPackets1
|
||||||
@Override
|
@Override
|
||||||
public void init(UserConnection user) {
|
public void init(UserConnection user) {
|
||||||
if (!user.has(ClientWorld.class)) {
|
if (!user.has(ClientWorld.class)) {
|
||||||
user.put(new ClientWorld(user));
|
user.put(new ClientWorld());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,11 +45,6 @@ public class ComponentRewriter<C extends ClientboundPacketType> {
|
||||||
protected final Protocol<C, ?, ?, ?> protocol;
|
protected final Protocol<C, ?, ?, ?> protocol;
|
||||||
protected final ReadType type;
|
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) {
|
public ComponentRewriter(final Protocol<C, ?, ?, ?> protocol, final ReadType type) {
|
||||||
this.protocol = protocol;
|
this.protocol = protocol;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
|
|
|
@ -68,11 +68,6 @@ public class SpongeChannelInitializer extends ChannelInitializer<Channel> implem
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*@Deprecated(forRemoval = true)*/
|
|
||||||
public ChannelInitializer<Channel> getOriginal() {
|
|
||||||
return original;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ChannelInitializer<Channel> original() {
|
public ChannelInitializer<Channel> original() {
|
||||||
return original;
|
return original;
|
||||||
|
|
Loading…
Reference in New Issue