From aecef3c3f8db69b26617c9d4a0615e52a5bf0b2f Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Tue, 9 Jan 2024 20:51:32 +0100 Subject: [PATCH] Remove a few deprecated methods --- .../com/viaversion/viaversion/api/ViaAPI.java | 2 +- .../viaversion/api/data/FullMappings.java | 5 - .../viaversion/api/data/FullMappingsBase.java | 5 - .../viaversion/api/data/IntArrayMappings.java | 5 - .../api/data/MappingDataLoader.java | 55 -------- .../viaversion/api/data/Mappings.java | 118 ------------------ .../viaversion/api/data/ParticleMappings.java | 15 --- .../viaversion/api/minecraft/ClientWorld.java | 5 - .../api/minecraft/RegistryType.java | 5 - .../api/minecraft/entities/EntityType.java | 10 -- .../handlers/BukkitChannelInitializer.java | 5 - .../bukkit/platform/BukkitViaLoader.java | 5 - .../Protocol1_9_3To1_9_1_2.java | 2 +- .../rewriter/ComponentRewriter.java | 5 - .../handlers/SpongeChannelInitializer.java | 5 - 15 files changed, 2 insertions(+), 245 deletions(-) diff --git a/api/src/main/java/com/viaversion/viaversion/api/ViaAPI.java b/api/src/main/java/com/viaversion/viaversion/api/ViaAPI.java index 251df6e81..feb1d1e6d 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/ViaAPI.java +++ b/api/src/main/java/com/viaversion/viaversion/api/ViaAPI.java @@ -63,7 +63,7 @@ public interface ViaAPI { * @return API version incremented with meaningful API changes */ default int apiVersion() { - return 22; + return 23; } /** diff --git a/api/src/main/java/com/viaversion/viaversion/api/data/FullMappings.java b/api/src/main/java/com/viaversion/viaversion/api/data/FullMappings.java index 7372ccd19..a4b353165 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/data/FullMappings.java +++ b/api/src/main/java/com/viaversion/viaversion/api/data/FullMappings.java @@ -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. * diff --git a/api/src/main/java/com/viaversion/viaversion/api/data/FullMappingsBase.java b/api/src/main/java/com/viaversion/viaversion/api/data/FullMappingsBase.java index be4aa4507..04d5f5116 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/data/FullMappingsBase.java +++ b/api/src/main/java/com/viaversion/viaversion/api/data/FullMappingsBase.java @@ -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)); diff --git a/api/src/main/java/com/viaversion/viaversion/api/data/IntArrayMappings.java b/api/src/main/java/com/viaversion/viaversion/api/data/IntArrayMappings.java index 911ae74df..eb4a101d5 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/data/IntArrayMappings.java +++ b/api/src/main/java/com/viaversion/viaversion/api/data/IntArrayMappings.java @@ -37,11 +37,6 @@ public class IntArrayMappings implements Mappings { return new IntArrayMappings(mappings, mappedIds); } - @Deprecated - public static Builder builder() { - return Mappings.builder(IntArrayMappings::new); - } - @Override public int getNewId(int id) { return id >= 0 && id < mappings.length ? mappings[id] : -1; diff --git a/api/src/main/java/com/viaversion/viaversion/api/data/MappingDataLoader.java b/api/src/main/java/com/viaversion/viaversion/api/data/MappingDataLoader.java index c6dc0e731..282163715 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/data/MappingDataLoader.java +++ b/api/src/main/java/com/viaversion/viaversion/api/data/MappingDataLoader.java @@ -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 newIdentifierMap = MappingDataLoader.indexedObjectToMap(mappedIdentifiers); - for (final Map.Entry 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 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 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. * diff --git a/api/src/main/java/com/viaversion/viaversion/api/data/Mappings.java b/api/src/main/java/com/viaversion/viaversion/api/data/Mappings.java index 7a470b643..53413f5dc 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/data/Mappings.java +++ b/api/src/main/java/com/viaversion/viaversion/api/data/Mappings.java @@ -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 Builder builder(final MappingsSupplier supplier) { - return new Builder<>(supplier); - } - @FunctionalInterface interface MappingsSupplier { T supply(int[] mappings, int mappedIds); } - - @Deprecated - class Builder { - - protected final MappingsSupplier 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 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 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 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 warnOnMissing(final boolean warnOnMissing) { - this.warnOnMissing = warnOnMissing; - return this; - } - - public Builder unmapped(final JsonArray unmappedArray) { - this.unmapped = unmappedArray; - return this; - } - - public Builder unmapped(final JsonObject unmappedObject) { - this.unmapped = unmappedObject; - return this; - } - - public Builder mapped(final JsonArray mappedArray) { - this.mapped = mappedArray; - return this; - } - - public Builder mapped(final JsonObject mappedObject) { - this.mapped = mappedObject; - return this; - } - - public Builder 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; - } - } } diff --git a/api/src/main/java/com/viaversion/viaversion/api/data/ParticleMappings.java b/api/src/main/java/com/viaversion/viaversion/api/data/ParticleMappings.java index 62d5e0414..81427a152 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/data/ParticleMappings.java +++ b/api/src/main/java/com/viaversion/viaversion/api/data/ParticleMappings.java @@ -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"); - } } diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/ClientWorld.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/ClientWorld.java index d104e4a92..f077d736a 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/ClientWorld.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/ClientWorld.java @@ -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() { } diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/RegistryType.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/RegistryType.java index 98a809198..37ae344fc 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/RegistryType.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/RegistryType.java @@ -57,11 +57,6 @@ public enum RegistryType { this.resourceLocation = resourceLocation; } - @Deprecated/*(forRemoval = true)*/ - public String getResourceLocation() { - return resourceLocation; - } - public String resourceLocation() { return resourceLocation; } diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityType.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityType.java index ded1f2b20..dd853658c 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityType.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/EntityType.java @@ -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; } diff --git a/bukkit/src/main/java/com/viaversion/viaversion/bukkit/handlers/BukkitChannelInitializer.java b/bukkit/src/main/java/com/viaversion/viaversion/bukkit/handlers/BukkitChannelInitializer.java index b375d8744..c873d4466 100644 --- a/bukkit/src/main/java/com/viaversion/viaversion/bukkit/handlers/BukkitChannelInitializer.java +++ b/bukkit/src/main/java/com/viaversion/viaversion/bukkit/handlers/BukkitChannelInitializer.java @@ -63,11 +63,6 @@ public final class BukkitChannelInitializer extends ChannelInitializer this.original = oldInit; } - @Deprecated/*(forRemoval = true)*/ - public ChannelInitializer getOriginal() { - return original; - } - @Override protected void initChannel(Channel channel) throws Exception { // Add originals diff --git a/bukkit/src/main/java/com/viaversion/viaversion/bukkit/platform/BukkitViaLoader.java b/bukkit/src/main/java/com/viaversion/viaversion/bukkit/platform/BukkitViaLoader.java index f8ec2b5c8..44a2ef3e7 100644 --- a/bukkit/src/main/java/com/viaversion/viaversion/bukkit/platform/BukkitViaLoader.java +++ b/bukkit/src/main/java/com/viaversion/viaversion/bukkit/platform/BukkitViaLoader.java @@ -70,11 +70,6 @@ public class BukkitViaLoader implements ViaPlatformLoader { plugin.getServer().getPluginManager().registerEvents(listener, plugin); } - @Deprecated/*(forRemoval = true)*/ - public T storeListener(T listener) { - return listener; - } - @Override public void load() { registerListener(new UpdateListener()); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_9_3to1_9_1_2/Protocol1_9_3To1_9_1_2.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_9_3to1_9_1_2/Protocol1_9_3To1_9_1_2.java index 58948eac9..6718f19d3 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_9_3to1_9_1_2/Protocol1_9_3To1_9_1_2.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_9_3to1_9_1_2/Protocol1_9_3To1_9_1_2.java @@ -155,7 +155,7 @@ public class Protocol1_9_3To1_9_1_2 extends AbstractProtocol { protected final Protocol protocol; protected final ReadType type; - @Deprecated/*(forRemoval = true)*/ - public ComponentRewriter(final Protocol protocol) { - this(protocol, ReadType.JSON); - } - public ComponentRewriter(final Protocol protocol, final ReadType type) { this.protocol = protocol; this.type = type; diff --git a/sponge/src/main/java/com/viaversion/viaversion/sponge/handlers/SpongeChannelInitializer.java b/sponge/src/main/java/com/viaversion/viaversion/sponge/handlers/SpongeChannelInitializer.java index 6fdd9d654..a25ec6ed1 100644 --- a/sponge/src/main/java/com/viaversion/viaversion/sponge/handlers/SpongeChannelInitializer.java +++ b/sponge/src/main/java/com/viaversion/viaversion/sponge/handlers/SpongeChannelInitializer.java @@ -68,11 +68,6 @@ public class SpongeChannelInitializer extends ChannelInitializer implem } } - /*@Deprecated(forRemoval = true)*/ - public ChannelInitializer getOriginal() { - return original; - } - @Override public ChannelInitializer original() { return original;