From 86060b4d6281f76f1255a5946c9c8e15dedb3387 Mon Sep 17 00:00:00 2001 From: FlorianMichael Date: Sat, 28 Dec 2024 12:06:45 +0100 Subject: [PATCH] Finalize legacy compatibility layer --- api-legacy/build.gradle | 3 ++ .../viafabricplus/LegacyCompatBridge.java | 50 +++++++++++++++++++ .../viafabricplus/ViaFabricPlus.java | 3 +- .../event/ChangeProtocolVersionCallback.java | 44 ++++++++++++++++ .../viafabricplus/event/EventBridge.java | 37 ++++++++++++++ .../viafabricplus/event/LoadCallback.java | 48 ++++++++++++++++++ .../LoadClassicProtocolExtensionCallback.java | 45 +++++++++++++++++ .../event/LoadSaveFilesCallback.java | 49 ++++++++++++++++++ .../event/PostGameLoadCallback.java | 43 ++++++++++++++++ .../event/PostViaVersionLoadCallback.java | 43 ++++++++++++++++ .../event/RegisterSettingsCallback.java | 49 ++++++++++++++++++ .../viafabricplus/fixes/ClientsideFixes.java | 2 + .../fixes/data/ItemRegistryDiff.java | 3 ++ .../ProtocolTranslator.java | 9 +++- .../viafabricplus/api/ViaFabricPlusBase.java | 1 - build.gradle | 7 +-- docs/DEVELOPER_API.md | 7 +-- 17 files changed, 432 insertions(+), 11 deletions(-) create mode 100644 api-legacy/src/main/java/de/florianmichael/viafabricplus/LegacyCompatBridge.java create mode 100644 api-legacy/src/main/java/de/florianmichael/viafabricplus/event/ChangeProtocolVersionCallback.java create mode 100644 api-legacy/src/main/java/de/florianmichael/viafabricplus/event/EventBridge.java create mode 100644 api-legacy/src/main/java/de/florianmichael/viafabricplus/event/LoadCallback.java create mode 100644 api-legacy/src/main/java/de/florianmichael/viafabricplus/event/LoadClassicProtocolExtensionCallback.java create mode 100644 api-legacy/src/main/java/de/florianmichael/viafabricplus/event/LoadSaveFilesCallback.java create mode 100644 api-legacy/src/main/java/de/florianmichael/viafabricplus/event/PostGameLoadCallback.java create mode 100644 api-legacy/src/main/java/de/florianmichael/viafabricplus/event/PostViaVersionLoadCallback.java create mode 100644 api-legacy/src/main/java/de/florianmichael/viafabricplus/event/RegisterSettingsCallback.java diff --git a/api-legacy/build.gradle b/api-legacy/build.gradle index d18e5aa9..ef0aa2d3 100644 --- a/api-legacy/build.gradle +++ b/api-legacy/build.gradle @@ -4,4 +4,7 @@ plugins { dependencies { compileOnly project(":viafabricplus-api") + + modCompileOnly fabricApi.module("fabric-api-base", project.fabric_api_version) + modCompileOnly fabricApi.module("fabric-lifecycle-events-v1", project.fabric_api_version) } \ No newline at end of file diff --git a/api-legacy/src/main/java/de/florianmichael/viafabricplus/LegacyCompatBridge.java b/api-legacy/src/main/java/de/florianmichael/viafabricplus/LegacyCompatBridge.java new file mode 100644 index 00000000..6f760e88 --- /dev/null +++ b/api-legacy/src/main/java/de/florianmichael/viafabricplus/LegacyCompatBridge.java @@ -0,0 +1,50 @@ +/* + * This file is part of ViaFabricPlus - https://github.com/ViaVersion/ViaFabricPlus + * Copyright (C) 2021-2024 the original authors + * - FlorianMichael/EnZaXD + * - RK_01/RaphiMC + * Copyright (C) 2023-2024 ViaVersion and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package de.florianmichael.viafabricplus; + +import net.fabricmc.fabric.api.event.Event; +import net.fabricmc.fabric.impl.base.event.EventFactoryImpl; + +import java.util.function.Function; + +public class LegacyCompatBridge { + + private static boolean warned = false; + + public static Event createArrayBacked(Class type, Function invokerFactory) { + warn(); + return EventFactoryImpl.createArrayBacked(type, invokerFactory); + } + + public static void warn() { + if (!warned) { + warned = true; + ViaFabricPlus.INSTANCE.getLogger().warn("==========================================="); + ViaFabricPlus.INSTANCE.getLogger().warn("A mod is using deprecated ViaFabricPlus internals which will be removed in the future."); + ViaFabricPlus.INSTANCE.getLogger().warn("Please contact the mod author to update their code to use the general API point added in 4.0.0."); + ViaFabricPlus.INSTANCE.getLogger().warn("The error below will point to the mod calling the deprecated API."); + Thread.dumpStack(); + ViaFabricPlus.INSTANCE.getLogger().warn("==========================================="); + } + } + +} diff --git a/api-legacy/src/main/java/de/florianmichael/viafabricplus/ViaFabricPlus.java b/api-legacy/src/main/java/de/florianmichael/viafabricplus/ViaFabricPlus.java index 0ec25a73..dc484fa7 100644 --- a/api-legacy/src/main/java/de/florianmichael/viafabricplus/ViaFabricPlus.java +++ b/api-legacy/src/main/java/de/florianmichael/viafabricplus/ViaFabricPlus.java @@ -34,7 +34,7 @@ import java.io.File; @Deprecated public class ViaFabricPlus { - private static final ViaFabricPlus INSTANCE = new ViaFabricPlus(); + static final ViaFabricPlus INSTANCE = new ViaFabricPlus(); private final Logger logger = LogManager.getLogger("ViaFabricPlus-Legacy"); @@ -43,6 +43,7 @@ public class ViaFabricPlus { @Deprecated public static ViaFabricPlus global() { + LegacyCompatBridge.warn(); return INSTANCE; } diff --git a/api-legacy/src/main/java/de/florianmichael/viafabricplus/event/ChangeProtocolVersionCallback.java b/api-legacy/src/main/java/de/florianmichael/viafabricplus/event/ChangeProtocolVersionCallback.java new file mode 100644 index 00000000..8ce09e2c --- /dev/null +++ b/api-legacy/src/main/java/de/florianmichael/viafabricplus/event/ChangeProtocolVersionCallback.java @@ -0,0 +1,44 @@ +/* + * This file is part of ViaFabricPlus - https://github.com/ViaVersion/ViaFabricPlus + * Copyright (C) 2021-2024 the original authors + * - FlorianMichael/EnZaXD + * - RK_01/RaphiMC + * Copyright (C) 2023-2024 ViaVersion and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package de.florianmichael.viafabricplus.event; + +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import de.florianmichael.viafabricplus.LegacyCompatBridge; +import net.fabricmc.fabric.api.event.Event; + +/** + * Please migrate to the general {@link com.viaversion.viafabricplus.ViaFabricPlus} API point. + */ +@Deprecated +public interface ChangeProtocolVersionCallback { + + @Deprecated + Event EVENT = LegacyCompatBridge.createArrayBacked(ChangeProtocolVersionCallback.class, listeners -> (oldVersion, newVersion) -> { + for (ChangeProtocolVersionCallback listener : listeners) { + listener.onChangeProtocolVersion(oldVersion, newVersion); + } + }); + + @Deprecated + void onChangeProtocolVersion(final ProtocolVersion oldVersion, final ProtocolVersion newVersion); + +} \ No newline at end of file diff --git a/api-legacy/src/main/java/de/florianmichael/viafabricplus/event/EventBridge.java b/api-legacy/src/main/java/de/florianmichael/viafabricplus/event/EventBridge.java new file mode 100644 index 00000000..a0d6fbc2 --- /dev/null +++ b/api-legacy/src/main/java/de/florianmichael/viafabricplus/event/EventBridge.java @@ -0,0 +1,37 @@ +/* + * This file is part of ViaFabricPlus - https://github.com/ViaVersion/ViaFabricPlus + * Copyright (C) 2021-2024 the original authors + * - FlorianMichael/EnZaXD + * - RK_01/RaphiMC + * Copyright (C) 2023-2024 ViaVersion and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package de.florianmichael.viafabricplus.event; + +import com.viaversion.viafabricplus.ViaFabricPlus; +import com.viaversion.viafabricplus.api.events.LoadingCycleCallback; +import net.fabricmc.fabric.api.event.Event; +import net.fabricmc.fabric.api.event.EventFactory; + +import java.util.function.Function; + +public class EventBridge { + + public static Event createArrayBacked(Class type, Function invokerFactory) { + return EventFactory.createArrayBacked(type, invokerFactory); + } + +} diff --git a/api-legacy/src/main/java/de/florianmichael/viafabricplus/event/LoadCallback.java b/api-legacy/src/main/java/de/florianmichael/viafabricplus/event/LoadCallback.java new file mode 100644 index 00000000..5ca5d59c --- /dev/null +++ b/api-legacy/src/main/java/de/florianmichael/viafabricplus/event/LoadCallback.java @@ -0,0 +1,48 @@ +/* + * This file is part of ViaFabricPlus - https://github.com/ViaVersion/ViaFabricPlus + * Copyright (C) 2021-2024 the original authors + * - FlorianMichael/EnZaXD + * - RK_01/RaphiMC + * Copyright (C) 2023-2024 ViaVersion and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package de.florianmichael.viafabricplus.event; + +import de.florianmichael.viafabricplus.LegacyCompatBridge; +import net.fabricmc.fabric.api.event.Event; + +/** + * Please migrate to the general {@link com.viaversion.viafabricplus.ViaFabricPlus} API point. + */ +@Deprecated +public interface LoadCallback { + + @Deprecated + Event EVENT = LegacyCompatBridge.createArrayBacked(LoadCallback.class, listeners -> state -> { + for (LoadCallback listener : listeners) { + listener.onLoad(state); + } + }); + + @Deprecated + void onLoad(final State state); + + @Deprecated + enum State { + PRE, POST + } + +} \ No newline at end of file diff --git a/api-legacy/src/main/java/de/florianmichael/viafabricplus/event/LoadClassicProtocolExtensionCallback.java b/api-legacy/src/main/java/de/florianmichael/viafabricplus/event/LoadClassicProtocolExtensionCallback.java new file mode 100644 index 00000000..1b9f8c85 --- /dev/null +++ b/api-legacy/src/main/java/de/florianmichael/viafabricplus/event/LoadClassicProtocolExtensionCallback.java @@ -0,0 +1,45 @@ +/* + * This file is part of ViaFabricPlus - https://github.com/ViaVersion/ViaFabricPlus + * Copyright (C) 2021-2024 the original authors + * - FlorianMichael/EnZaXD + * - RK_01/RaphiMC + * Copyright (C) 2023-2024 ViaVersion and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package de.florianmichael.viafabricplus.event; + +import de.florianmichael.viafabricplus.LegacyCompatBridge; +import net.fabricmc.fabric.api.event.Event; +import net.raphimc.vialegacy.protocol.classic.c0_30cpetoc0_28_30.data.ClassicProtocolExtension; + + +/** + * Please migrate to the general {@link com.viaversion.viafabricplus.ViaFabricPlus} API point. + */ +@Deprecated +public interface LoadClassicProtocolExtensionCallback { + + @Deprecated + Event EVENT = LegacyCompatBridge.createArrayBacked(LoadClassicProtocolExtensionCallback.class, listeners -> classicProtocolExtension -> { + for (LoadClassicProtocolExtensionCallback listener : listeners) { + listener.onLoadClassicProtocolExtension(classicProtocolExtension); + } + }); + + @Deprecated + void onLoadClassicProtocolExtension(final ClassicProtocolExtension classicProtocolExtension); + +} \ No newline at end of file diff --git a/api-legacy/src/main/java/de/florianmichael/viafabricplus/event/LoadSaveFilesCallback.java b/api-legacy/src/main/java/de/florianmichael/viafabricplus/event/LoadSaveFilesCallback.java new file mode 100644 index 00000000..b7981c07 --- /dev/null +++ b/api-legacy/src/main/java/de/florianmichael/viafabricplus/event/LoadSaveFilesCallback.java @@ -0,0 +1,49 @@ +/* + * This file is part of ViaFabricPlus - https://github.com/ViaVersion/ViaFabricPlus + * Copyright (C) 2021-2024 the original authors + * - FlorianMichael/EnZaXD + * - RK_01/RaphiMC + * Copyright (C) 2023-2024 ViaVersion and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package de.florianmichael.viafabricplus.event; + +import de.florianmichael.viafabricplus.LegacyCompatBridge; +import de.florianmichael.viafabricplus.save.SaveManager; +import net.fabricmc.fabric.api.event.Event; + +/** + * Please migrate to the general {@link com.viaversion.viafabricplus.ViaFabricPlus} API point. + */ +@Deprecated +public interface LoadSaveFilesCallback { + + @Deprecated + Event EVENT = LegacyCompatBridge.createArrayBacked(LoadSaveFilesCallback.class, listeners -> (saveManager, state) -> { + for (LoadSaveFilesCallback listener : listeners) { + listener.onLoadSaveFiles(saveManager, state); + } + }); + + @Deprecated + void onLoadSaveFiles(final SaveManager saveManager, final State state); + + @Deprecated + enum State { + PRE, POST, POST_INIT + } + +} \ No newline at end of file diff --git a/api-legacy/src/main/java/de/florianmichael/viafabricplus/event/PostGameLoadCallback.java b/api-legacy/src/main/java/de/florianmichael/viafabricplus/event/PostGameLoadCallback.java new file mode 100644 index 00000000..b40538b9 --- /dev/null +++ b/api-legacy/src/main/java/de/florianmichael/viafabricplus/event/PostGameLoadCallback.java @@ -0,0 +1,43 @@ +/* + * This file is part of ViaFabricPlus - https://github.com/ViaVersion/ViaFabricPlus + * Copyright (C) 2021-2024 the original authors + * - FlorianMichael/EnZaXD + * - RK_01/RaphiMC + * Copyright (C) 2023-2024 ViaVersion and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package de.florianmichael.viafabricplus.event; + +import de.florianmichael.viafabricplus.LegacyCompatBridge; +import net.fabricmc.fabric.api.event.Event; + +/** + * Please migrate to the general {@link com.viaversion.viafabricplus.ViaFabricPlus} API point. + */ +@Deprecated +public interface PostGameLoadCallback { + + @Deprecated + Event EVENT = LegacyCompatBridge.createArrayBacked(PostGameLoadCallback.class, listeners -> () -> { + for (PostGameLoadCallback listener : listeners) { + listener.postGameLoad(); + } + }); + + @Deprecated + void postGameLoad(); + +} \ No newline at end of file diff --git a/api-legacy/src/main/java/de/florianmichael/viafabricplus/event/PostViaVersionLoadCallback.java b/api-legacy/src/main/java/de/florianmichael/viafabricplus/event/PostViaVersionLoadCallback.java new file mode 100644 index 00000000..1781d269 --- /dev/null +++ b/api-legacy/src/main/java/de/florianmichael/viafabricplus/event/PostViaVersionLoadCallback.java @@ -0,0 +1,43 @@ +/* + * This file is part of ViaFabricPlus - https://github.com/ViaVersion/ViaFabricPlus + * Copyright (C) 2021-2024 the original authors + * - FlorianMichael/EnZaXD + * - RK_01/RaphiMC + * Copyright (C) 2023-2024 ViaVersion and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package de.florianmichael.viafabricplus.event; + +import de.florianmichael.viafabricplus.LegacyCompatBridge; +import net.fabricmc.fabric.api.event.Event; + +/** + * Please migrate to the general {@link com.viaversion.viafabricplus.ViaFabricPlus} API point. + */ +@Deprecated +public interface PostViaVersionLoadCallback { + + @Deprecated + Event EVENT = LegacyCompatBridge.createArrayBacked(PostViaVersionLoadCallback.class, listeners -> () -> { + for (PostViaVersionLoadCallback listener : listeners) { + listener.onPostViaVersionLoad(); + } + }); + + @Deprecated + void onPostViaVersionLoad(); + +} \ No newline at end of file diff --git a/api-legacy/src/main/java/de/florianmichael/viafabricplus/event/RegisterSettingsCallback.java b/api-legacy/src/main/java/de/florianmichael/viafabricplus/event/RegisterSettingsCallback.java new file mode 100644 index 00000000..e01b4754 --- /dev/null +++ b/api-legacy/src/main/java/de/florianmichael/viafabricplus/event/RegisterSettingsCallback.java @@ -0,0 +1,49 @@ +/* + * This file is part of ViaFabricPlus - https://github.com/ViaVersion/ViaFabricPlus + * Copyright (C) 2021-2024 the original authors + * - FlorianMichael/EnZaXD + * - RK_01/RaphiMC + * Copyright (C) 2023-2024 ViaVersion and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package de.florianmichael.viafabricplus.event; + +import de.florianmichael.viafabricplus.LegacyCompatBridge; +import de.florianmichael.viafabricplus.settings.SettingsManager; +import net.fabricmc.fabric.api.event.Event; + +/** + * Please migrate to the general {@link com.viaversion.viafabricplus.ViaFabricPlus} API point. + */ +@Deprecated +public interface RegisterSettingsCallback { + + @Deprecated + Event EVENT = LegacyCompatBridge.createArrayBacked(RegisterSettingsCallback.class, listeners -> (settingsManager, state) -> { + for (RegisterSettingsCallback listener : listeners) { + listener.onRegisterSettings(settingsManager, state); + } + }); + + @Deprecated + void onRegisterSettings(final SettingsManager settingsManager, final State state); + + @Deprecated + enum State { + PRE, POST + } + +} \ No newline at end of file diff --git a/api-legacy/src/main/java/de/florianmichael/viafabricplus/fixes/ClientsideFixes.java b/api-legacy/src/main/java/de/florianmichael/viafabricplus/fixes/ClientsideFixes.java index 448d021d..7d70432e 100644 --- a/api-legacy/src/main/java/de/florianmichael/viafabricplus/fixes/ClientsideFixes.java +++ b/api-legacy/src/main/java/de/florianmichael/viafabricplus/fixes/ClientsideFixes.java @@ -22,6 +22,7 @@ package de.florianmichael.viafabricplus.fixes; import com.viaversion.viafabricplus.ViaFabricPlus; +import de.florianmichael.viafabricplus.LegacyCompatBridge; /** * Please migrate to the general {@link com.viaversion.viafabricplus.ViaFabricPlus} API point. @@ -31,6 +32,7 @@ public class ClientsideFixes { @Deprecated public static int getChatLength() { + LegacyCompatBridge.warn(); return ViaFabricPlus.getImpl().getMaxChatLength(ViaFabricPlus.getImpl().getTargetVersion()); } diff --git a/api-legacy/src/main/java/de/florianmichael/viafabricplus/fixes/data/ItemRegistryDiff.java b/api-legacy/src/main/java/de/florianmichael/viafabricplus/fixes/data/ItemRegistryDiff.java index 2a7578fa..5c07920e 100644 --- a/api-legacy/src/main/java/de/florianmichael/viafabricplus/fixes/data/ItemRegistryDiff.java +++ b/api-legacy/src/main/java/de/florianmichael/viafabricplus/fixes/data/ItemRegistryDiff.java @@ -23,6 +23,7 @@ package de.florianmichael.viafabricplus.fixes.data; import com.viaversion.viafabricplus.ViaFabricPlus; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import de.florianmichael.viafabricplus.LegacyCompatBridge; import net.minecraft.item.Item; /** @@ -33,11 +34,13 @@ public class ItemRegistryDiff { @Deprecated public static boolean keepItem(final Item item) { + LegacyCompatBridge.warn(); return ViaFabricPlus.getImpl().itemExistsInConnection(item); } @Deprecated public static boolean contains(final Item item, final ProtocolVersion version) { + LegacyCompatBridge.warn(); return ViaFabricPlus.getImpl().itemExists(item, version); } diff --git a/api-legacy/src/main/java/de/florianmichael/viafabricplus/protocoltranslator/ProtocolTranslator.java b/api-legacy/src/main/java/de/florianmichael/viafabricplus/protocoltranslator/ProtocolTranslator.java index 62f2ae40..e2fd979f 100644 --- a/api-legacy/src/main/java/de/florianmichael/viafabricplus/protocoltranslator/ProtocolTranslator.java +++ b/api-legacy/src/main/java/de/florianmichael/viafabricplus/protocoltranslator/ProtocolTranslator.java @@ -24,6 +24,7 @@ package de.florianmichael.viafabricplus.protocoltranslator; import com.viaversion.viafabricplus.ViaFabricPlus; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import de.florianmichael.viafabricplus.LegacyCompatBridge; import io.netty.channel.Channel; /** @@ -34,31 +35,37 @@ public class ProtocolTranslator { @Deprecated public static ProtocolVersion getTargetVersion() { + LegacyCompatBridge.warn(); return ViaFabricPlus.getImpl().getTargetVersion(); } @Deprecated public static ProtocolVersion getTargetVersion(final Channel channel) { + LegacyCompatBridge.warn(); return ViaFabricPlus.getImpl().getTargetVersion(channel); } @Deprecated public static void setTargetVersion(final ProtocolVersion newVersion) { + LegacyCompatBridge.warn(); ViaFabricPlus.getImpl().setTargetVersion(newVersion); } @Deprecated public static void setTargetVersion(final ProtocolVersion newVersion, final boolean revertOnDisconnect) { + LegacyCompatBridge.warn(); ViaFabricPlus.getImpl().setTargetVersion(newVersion, revertOnDisconnect); } @Deprecated public static UserConnection createDummyUserConnection(final ProtocolVersion clientVersion, final ProtocolVersion serverVersion) { - throw new UnsupportedOperationException("This method is not supported anymore"); + LegacyCompatBridge.warn(); + return null; } @Deprecated public static UserConnection getPlayNetworkUserConnection() { + LegacyCompatBridge.warn(); return ViaFabricPlus.getImpl().getPlayNetworkUserConnection(); } diff --git a/api/src/main/java/com/viaversion/viafabricplus/api/ViaFabricPlusBase.java b/api/src/main/java/com/viaversion/viafabricplus/api/ViaFabricPlusBase.java index 2ff5703e..54781a04 100644 --- a/api/src/main/java/com/viaversion/viafabricplus/api/ViaFabricPlusBase.java +++ b/api/src/main/java/com/viaversion/viafabricplus/api/ViaFabricPlusBase.java @@ -33,7 +33,6 @@ import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.network.ServerInfo; import net.minecraft.item.ItemStack; import net.minecraft.network.ClientConnection; -import org.apache.logging.log4j.Logger; import org.jetbrains.annotations.Nullable; import java.nio.file.Path; diff --git a/build.gradle b/build.gradle index c20fce76..80f8e2a6 100644 --- a/build.gradle +++ b/build.gradle @@ -18,6 +18,7 @@ configurations { modImplementation.extendsFrom modJij modCompileOnlyApi.extendsFrom modJij + // Include VV dependencies as jij jij.extendsFrom vvDependencies } @@ -33,9 +34,9 @@ dependencies { // Sub projects, since they are Fabric mods as well (mainly to access the game code) we have to first // implement the namedElements (raw output) to compile against, then include the mappedElements into the output jar - implementation project(path: ":viafabricplus-api", configuration: "namedElements") - implementation project(path: ":viafabricplus-api-legacy", configuration: "namedElements") - implementation project(path: ":viafabricplus-visuals", configuration: "namedElements") + implementation compileOnlyApi(project(path: ":viafabricplus-api", configuration: "namedElements")) + implementation compileOnlyApi(project(path: ":viafabricplus-api-legacy", configuration: "namedElements")) + implementation compileOnlyApi(project(path: ":viafabricplus-visuals", configuration: "namedElements")) include project(":viafabricplus-api") include project(":viafabricplus-api-legacy") diff --git a/docs/DEVELOPER_API.md b/docs/DEVELOPER_API.md index ce8e0bca..af27fdd4 100644 --- a/docs/DEVELOPER_API.md +++ b/docs/DEVELOPER_API.md @@ -4,9 +4,6 @@ ViaFabricPlus in your project comes with some requirements: - The target version is Java 17 - Fabric loom setup (As ViaFabricPlus is a Minecraft mod and has no API-only dependency like other projects) -Since the API is not exposed as standalone submodule (yet), functions that shouldn't be used are marked with -`ApiStatus.Internal`. Further information about certain functions can be found in the Javadoc in the corresponding file. - ## How to include the mod as dependency ### Gradle ```groovy @@ -31,7 +28,7 @@ repositories { } dependencies { - modImplementation("com.viaversion:viafabricplus:x.x.x") // Get the latest version from releases + modImplementation("com.viaversion:viafabricplus-api:x.x.x") // Get the latest version from releases } ``` @@ -55,7 +52,7 @@ dependencies { com.viaversion - viafabricplus + viafabricplus-api x.x.x