Split up core gradle project into more subprojects

This commit is contained in:
lax1dude 2025-05-10 20:04:12 -07:00
parent 01c6658646
commit 61c93c4e42
209 changed files with 420 additions and 91 deletions

View File

@ -25,6 +25,9 @@ import net.lax1dude.eaglercraft.backend.server.api.internal.factory.EaglerXServe
public final class EaglerXServerAPI {
@Nonnull
public static final String PLUGIN_NAME = "EaglercraftXServer";
@Nonnull
public static IEaglerXServerAPI<Player> instance() {
return EaglerXServerAPIFactory.INSTANCE.getAPI(Player.class);

View File

@ -24,6 +24,9 @@ import net.md_5.bungee.api.connection.ProxiedPlayer;
public final class EaglerXServerAPI {
@Nonnull
public static final String PLUGIN_NAME = "EaglercraftXServer";
@Nonnull
public static IEaglerXServerAPI<ProxiedPlayer> instance() {
return EaglerXServerAPIFactory.INSTANCE.getAPI(ProxiedPlayer.class);

11
core-config/build.gradle Normal file
View File

@ -0,0 +1,11 @@
plugins {
id "java-library"
}
dependencies {
compileOnly(libs.velocity.nightconfig)
compileOnly(libs.snakeyaml)
compileOnly(libs.gson)
compileOnly(libs.guava)
}

View File

@ -0,0 +1,39 @@
/*
* Copyright (c) 2025 lax1dude. All Rights Reserved.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
package net.lax1dude.eaglercraft.backend.server.config;
import java.lang.reflect.InvocationTargetException;
public class ReflectUtil {
public static RuntimeException propagateReflectThrowable(Exception ex) {
if (ex instanceof InvocationTargetException exx) {
Throwable cause = exx.getCause();
if (cause != null) {
if (cause instanceof RuntimeException cause2) {
return cause2;
}
return new RuntimeException("Encountered an InvocationTargetException while performing reflection",
cause);
}
} else if (ex instanceof RuntimeException exx) {
return exx;
}
return new RuntimeException("Could not perform reflection!", ex);
}
}

View File

@ -17,7 +17,9 @@
package net.lax1dude.eaglercraft.backend.server.config.gson;
import java.util.List;
import java.util.Map;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import com.google.common.collect.ImmutableList;
import com.google.gson.JsonArray;
@ -104,7 +106,8 @@ public class GSONConfigSection implements IEaglerConfSection {
@Override
public List<String> getKeys() {
return ImmutableList.copyOf(json.keySet());
return ImmutableList.copyOf(
json.entrySet().stream().map(Map.Entry<String, JsonElement>::getKey).collect(Collectors.toList()));
}
@Override

View File

@ -29,12 +29,10 @@ import org.yaml.snakeyaml.nodes.ScalarNode;
import org.yaml.snakeyaml.nodes.SequenceNode;
import org.yaml.snakeyaml.nodes.Tag;
import net.lax1dude.eaglercraft.backend.server.util.Util;
import net.lax1dude.eaglercraft.backend.server.config.ReflectUtil;
class LegacyHelper {
// Hey dipshits, ever heard of semantic versioning?
private static final boolean HAS_FLOWSTYLE;
private static final boolean HAS_SCALARSTYLE;
@ -109,7 +107,7 @@ class LegacyHelper {
return ctor_MappingNode.newInstance(tag, lst, Boolean.FALSE);
}
} catch (ReflectiveOperationException ex) {
throw Util.propagateReflectThrowable(ex);
throw ReflectUtil.propagateReflectThrowable(ex);
}
}
@ -121,7 +119,7 @@ class LegacyHelper {
return ctor_SequenceNode.newInstance(tag, lst, Boolean.FALSE);
}
} catch (ReflectiveOperationException ex) {
throw Util.propagateReflectThrowable(ex);
throw ReflectUtil.propagateReflectThrowable(ex);
}
}
@ -133,7 +131,7 @@ class LegacyHelper {
return ctor_ScalarNode.newInstance(tag, value, null, null, style);
}
} catch (ReflectiveOperationException ex) {
throw Util.propagateReflectThrowable(ex);
throw ReflectUtil.propagateReflectThrowable(ex);
}
}

View File

@ -20,6 +20,8 @@ import java.lang.reflect.Method;
import com.google.gson.GsonBuilder;
import net.lax1dude.eaglercraft.backend.server.config.ReflectUtil;
@SuppressWarnings("unchecked")
public class GsonLenient {
@ -59,7 +61,7 @@ public class GsonLenient {
}
return builder;
} catch (ReflectiveOperationException e) {
throw Util.propagateReflectThrowable(e);
throw ReflectUtil.propagateReflectThrowable(e);
}
}

View File

@ -12,18 +12,15 @@ dependencies {
implementation project(":api-bukkit")
implementation project(":api-bungee")
implementation project(":api-velocity")
implementation project(":skin-cache")
implementation(libs.asm)
compileOnly project(":stubs")
compileOnly(libs.bungeecord.api)
compileOnly(libs.velocity.api)
compileOnly(libs.velocity.legacy.serializer)
compileOnly(libs.velocity.nightconfig)
compileOnly(libs.paper.api)
implementation project(":core:core-common")
implementation project(":core:core-platform-bukkit")
implementation project(":core:core-platform-bungee")
implementation project(":core:core-platform-velocity")
compileOnly(libs.bundles.netty.all)
compileOnly(libs.jsr305)
compileOnly(libs.gson)
compileOnly(libs.guava)
compileOnly(libs.skinsrestorer.api)
annotationProcessor(libs.velocity.api)
}
tasks.named("shadowJar", com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) {
@ -35,6 +32,11 @@ tasks.named("shadowJar", com.github.jengelman.gradle.plugins.shadow.tasks.Shadow
dependsOn ":api-bukkit:jar" // Workaround
dependsOn ":api-bungee:jar" // Workaround
dependsOn ":api-velocity:jar" // Workaround
dependsOn ":core:core-common:jar" // Workaround
dependsOn ":core:core-platform-bukkit:jar" // Workaround
dependsOn ":core:core-platform-bungee:jar" // Workaround
dependsOn ":core:core-platform-velocity:jar" // Workaround
dependsOn ":core-config:jar" // Workaround
dependsOn ":skin-cache:jar" // Workaround
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
archiveFileName = "EaglerXServer.jar"

View File

@ -0,0 +1,17 @@
plugins {
id "java-library"
}
dependencies {
api(libs.asm)
api project(":api")
api project(":core-config")
api project(":skin-cache")
api project(":supervisor-protocol")
compileOnly(libs.bundles.netty.all)
compileOnly(libs.guava)
compileOnly(libs.gson)
compileOnly(libs.jsr305)
compileOnly(libs.slf4j)
}

View File

@ -44,7 +44,7 @@ public interface IPlatform<PlayerObject> {
void setConnectionInitializer(IEaglerXServerLoginInitializer<? extends IPipelineData> initializer);
void setPlayerInitializer(IEaglerXServerPlayerInitializer<?, ?, PlayerObject> initializer);
void setPlayerInitializer(IEaglerXServerPlayerInitializer<? extends IPipelineData, ?, PlayerObject> initializer);
void setServerJoinListener(IEaglerXServerJoinListener<PlayerObject> listener);

View File

@ -20,8 +20,7 @@ import net.lax1dude.eaglercraft.backend.server.api.skins.EnumSkinModel;
import net.lax1dude.eaglercraft.backend.server.api.skins.IEaglerPlayerCape;
import net.lax1dude.eaglercraft.backend.server.api.skins.IEaglerPlayerSkin;
public interface IRegisterSkinDelegate extends
net.lax1dude.eaglercraft.backend.server.api.bungee.event.EaglercraftRegisterSkinEvent.IRegisterSkinDelegate {
public interface IRegisterSkinDelegate {
IEaglerPlayerSkin getEaglerSkin();

View File

@ -0,0 +1,37 @@
/*
* Copyright (c) 2025 lax1dude. All Rights Reserved.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
package net.lax1dude.eaglercraft.backend.server.base;
import net.lax1dude.eaglercraft.backend.server.adapter.IEaglerXServerImpl;
import net.lax1dude.eaglercraft.backend.server.util.Util;
/**
* Class to invoke the EaglerXServer constructor without a static dependency
*/
public class EaglerXServerFactory {
@SuppressWarnings("unchecked")
public static <PlayerObject> IEaglerXServerImpl<PlayerObject> create() {
try {
Class<?> clz = Class.forName("net.lax1dude.eaglercraft.backend.server.base.EaglerXServer");
return (IEaglerXServerImpl<PlayerObject>) clz.getConstructor().newInstance();
} catch (ReflectiveOperationException ex) {
throw Util.propagateReflectThrowable(ex);
}
}
}

View File

@ -14,7 +14,7 @@
*
*/
package net.lax1dude.eaglercraft.backend.server.base;
package net.lax1dude.eaglercraft.backend.server.util;
import java.util.function.Consumer;

View File

@ -16,6 +16,9 @@
package net.lax1dude.eaglercraft.backend.server.util;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
import java.lang.reflect.Field;
import java.util.Map;
@ -24,12 +27,15 @@ import com.google.gson.JsonObject;
public class GsonMap {
private static final MethodHandle asMapMethod;
private static final Field mapField;
static {
MethodHandles.Lookup lookup = MethodHandles.lookup();
MethodHandle _asMapMethod = null;
Field _mapField = null;
try {
JsonObject.class.getMethod("asMap");
_asMapMethod = lookup.findVirtual(JsonObject.class, "asMap", MethodType.methodType(Map.class));
} catch (ReflectiveOperationException ex) {
try {
_mapField = JsonObject.class.getDeclaredField("members");
@ -38,12 +44,17 @@ public class GsonMap {
throw new ExceptionInInitializerError(exx);
}
}
asMapMethod = _asMapMethod;
mapField = _mapField;
}
public static Map<String, JsonElement> asMap(JsonObject object) {
if (mapField == null) {
return object.asMap();
if (asMapMethod != null) {
try {
return (Map<String, JsonElement>) asMapMethod.invokeExact(object);
} catch (Throwable e) {
throw Util.propagateInvokeThrowable(e);
}
} else {
try {
return (Map<String, JsonElement>) mapField.get(object);

View File

@ -16,25 +16,33 @@
package net.lax1dude.eaglercraft.backend.server.util;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
import com.google.common.collect.ImmutableList;
public class ImmutableBuilders {
private static final boolean BUILDER_WITH_EXPECTED_SUPPORT;
private static final MethodHandle builderWithExpectedSizeMethod;
static {
boolean b = false;
MethodHandle m = null;
try {
m = MethodHandles.lookup().findStatic(ImmutableList.class, "builderWithExpectedSize", MethodType.methodType(ImmutableList.Builder.class, int.class));
ImmutableList.class.getMethod("builderWithExpectedSize", int.class);
b = true;
} catch (ReflectiveOperationException ex) {
}
BUILDER_WITH_EXPECTED_SUPPORT = b;
builderWithExpectedSizeMethod = m;
}
public static <T> ImmutableList.Builder<T> listBuilderWithExpected(int cnt) {
if (BUILDER_WITH_EXPECTED_SUPPORT) {
return ImmutableList.builderWithExpectedSize(cnt);
if (builderWithExpectedSizeMethod != null) {
try {
return (ImmutableList.Builder<T>) builderWithExpectedSizeMethod.invokeExact(cnt);
} catch (Throwable e) {
throw Util.propagateInvokeThrowable(e);
}
} else {
return ImmutableList.builder();
}

Some files were not shown because too many files have changed in this diff Show More