Skip to content

Commit

Permalink
Cleanup build files, improve legacy compat layer
Browse files Browse the repository at this point in the history
Also don't expose the logger/some weird functions to the public API
  • Loading branch information
FlorianMichael committed Dec 27, 2024
1 parent 454cc22 commit b1c6f7e
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 46 deletions.
1 change: 1 addition & 0 deletions api-legacy/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
maven_description=Legacy compatibility for mods using the ViaFabricPlus pre 4.0.0 API.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@

package de.florianmichael.viafabricplus;

import de.florianmichael.viafabricplus.save.SaveManager;
import de.florianmichael.viafabricplus.settings.SettingsManager;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.io.File;
Expand All @@ -34,7 +36,10 @@ public class ViaFabricPlus {

private static final ViaFabricPlus INSTANCE = new ViaFabricPlus();

private final Logger logger = LogManager.getLogger("ViaFabricPlus-Legacy");

private final SettingsManager settingsManager = new SettingsManager();
private final SaveManager saveManager = new SaveManager();

@Deprecated
public static ViaFabricPlus global() {
Expand All @@ -43,7 +48,7 @@ public static ViaFabricPlus global() {

@Deprecated
public Logger getLogger() {
return com.viaversion.viafabricplus.ViaFabricPlus.getImpl().logger();
return logger;
}

@Deprecated
Expand All @@ -52,13 +57,13 @@ public File getDirectory() {
}

@Deprecated
public Object getSettingsManager() {
public SettingsManager getSettingsManager() {
return settingsManager;
}

@Deprecated
public Object getSaveManager() {
throw new IllegalArgumentException("ViaFabricPlus#getSaveManager is not supported anymore.");
public SaveManager getSaveManager() {
return saveManager;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* This file is part of ViaFabricPlus - https://github.com/ViaVersion/ViaFabricPlus
* Copyright (C) 2021-2024 the original authors
* - FlorianMichael/EnZaXD <[email protected]>
* - 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 <http://www.gnu.org/licenses/>.
*/

package de.florianmichael.viafabricplus.save;

/**
* Please migrate to the general {@link com.viaversion.viafabricplus.ViaFabricPlus} API point.
*/
@Deprecated
public class SaveManager {

}
1 change: 1 addition & 0 deletions api/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
maven_description=Interface for third-party mods to interact with ViaFabricPlus internals.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
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;
Expand All @@ -51,13 +50,6 @@ default int apiVersion() {
return 1;
}

/**
* Get the logger for this mod.
*
* @return The logger
*/
Logger logger();

/**
* Get the root path of the mod.
*
Expand Down Expand Up @@ -103,13 +95,6 @@ default int apiVersion() {
*/
void setTargetVersion(final ProtocolVersion newVersion, final boolean revertOnDisconnect);

/**
* @param clientVersion The client version
* @param serverVersion The server version
* @return Creates a dummy UserConnection class with a valid protocol pipeline to emulate packets
*/
UserConnection createDummyUserConnection(final ProtocolVersion clientVersion, final ProtocolVersion serverVersion);

/**
* @return the current UserConnection of the connection to the server, if the player isn't connected to a server it will return null
*/
Expand Down
9 changes: 9 additions & 0 deletions build-logic/src/main/groovy/vfp.base-conventions.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@ java {
targetCompatibility = JavaVersion.VERSION_21
}

processResources {
filesMatching("fabric.mod.json") {
expand(
"version": project.version,
"description": project.description
)
}
}

publishing {
repositories {
maven {
Expand Down
16 changes: 8 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,14 @@ loom {
}

configurations {
pij // project in jar configuration
jij // jar in jar configuration
modJij // jar in jar configuration for mods

include.extendsFrom pij
implementation.extendsFrom pij
compileOnlyApi.extendsFrom pij

include.extendsFrom modJij
modImplementation.extendsFrom modJij
modCompileOnlyApi.extendsFrom modJij
Expand All @@ -28,12 +33,9 @@ dependencies {
modJij fabricApi.module("fabric-particles-v1", project.fabric_api_version)
modJij fabricApi.module("fabric-registry-sync-v0", project.fabric_api_version)

// Manually include to ignore dependencies
include implementation(compileOnlyApi(project(path: ":viafabricplus-api", configuration: "namedElements")))
include implementation(compileOnlyApi(project(path: ":viafabricplus-visuals", configuration: "namedElements")))

// Will be removed in future versions
include implementation(compileOnlyApi(project(":viafabricplus-api-legacy")))
pij project(path: ":viafabricplus-api", configuration: "namedElements")
pij project(path: ":viafabricplus-api-legacy", configuration: "namedElements")
pij project(path: ":viafabricplus-visuals", configuration: "namedElements")

jij "com.viaversion:viaversion-common:${project.viaversion_version}"
jij "com.viaversion:viabackwards-common:${project.viabackwards_version}"
Expand Down Expand Up @@ -77,8 +79,6 @@ dependencies {
processResources {
filesMatching("fabric.mod.json") {
expand(
"version": project.version,
"description": project.description,
"implVersion": "git-${project.name}-${project.version}:${latestCommitHash().get()}",
"mcVersion": mcVersion()
)
Expand Down
10 changes: 0 additions & 10 deletions src/main/java/com/viaversion/viafabricplus/ViaFabricPlusImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,6 @@ public void init() {
// --------------------------------------------------------------------------------------------
// Proxy the most important/used internals to a general API point for mods

@Override
public Logger logger() {
return logger;
}

@Override
public Path rootPath() {
return path;
Expand Down Expand Up @@ -179,11 +174,6 @@ public void setTargetVersion(ProtocolVersion newVersion, boolean revertOnDisconn
ProtocolTranslator.setTargetVersion(newVersion, revertOnDisconnect);
}

@Override
public UserConnection createDummyUserConnection(ProtocolVersion clientVersion, ProtocolVersion serverVersion) {
return ProtocolTranslator.createDummyUserConnection(clientVersion, serverVersion);
}

@Override
public UserConnection getPlayNetworkUserConnection() {
return ProtocolTranslator.getPlayNetworkUserConnection();
Expand Down
9 changes: 0 additions & 9 deletions visuals/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,3 @@ dependencies {
compileOnly "net.raphimc:ViaLoader:${project.vialoader_version}"
compileOnly "net.raphimc:ViaLegacy:${project.vialegacy_version}"
}

processResources {
filesMatching("fabric.mod.json") {
expand(
"version": project.version,
"description": project.description
)
}
}

0 comments on commit b1c6f7e

Please sign in to comment.