[FEAT] More Nojang abstractions and compat layers (SDLink)
This commit is contained in:
@@ -4,10 +4,14 @@ dependencies {
|
||||
// Core
|
||||
modImplementation "net.fabricmc.fabric-api:fabric-api:${fabric_api}"
|
||||
|
||||
// Compat
|
||||
modImplementation("com.terraformersmc:modmenu:${mod_menu_version}") {
|
||||
exclude(group: "net.fabricmc.fabric-api")
|
||||
}
|
||||
|
||||
modImplementation "maven.modrinth:fabrictailor:2.1.2"
|
||||
modImplementation "maven.modrinth:vanish:1.4.2+1.20"
|
||||
|
||||
// Do not edit or remove
|
||||
implementation project(":Common")
|
||||
}
|
||||
@@ -17,8 +21,11 @@ shadowJar {
|
||||
configurations = [project.configurations.shade]
|
||||
|
||||
dependencies {
|
||||
exclude(dependency('com.google.code.gson:.*'))
|
||||
|
||||
relocate 'me.hypherionmc.moonconfig', 'shadow.hypherionmc.moonconfig'
|
||||
relocate 'me.hypherionmc.mcdiscordformatter', 'shadow.hypherionmc.mcdiscordformatter'
|
||||
relocate 'net.kyori', 'shadow.kyori'
|
||||
}
|
||||
|
||||
setArchiveClassifier('dev-shadow')
|
||||
@@ -49,6 +56,7 @@ jar {
|
||||
processResources {
|
||||
from project(":Common").sourceSets.main.resources
|
||||
def buildProps = project.properties.clone()
|
||||
println(project.version)
|
||||
|
||||
filesMatching(['fabric.mod.json']) {
|
||||
expand buildProps
|
||||
@@ -67,9 +75,7 @@ tasks.withType(JavaCompile).configureEach {
|
||||
publishing {
|
||||
publications {
|
||||
mavenJava(MavenPublication) {
|
||||
groupId project.group
|
||||
artifactId project.archivesBaseName
|
||||
version project.version
|
||||
from components.java
|
||||
|
||||
artifact(remapJar) {
|
||||
|
@@ -3,9 +3,11 @@ package com.hypherionmc.craterlib;
|
||||
import com.hypherionmc.craterlib.api.events.server.CraterRegisterCommandEvent;
|
||||
import com.hypherionmc.craterlib.api.events.server.CraterServerLifecycleEvent;
|
||||
import com.hypherionmc.craterlib.common.FabricCommonPlatform;
|
||||
import com.hypherionmc.craterlib.compat.Vanish;
|
||||
import com.hypherionmc.craterlib.core.event.CraterEventBus;
|
||||
import com.hypherionmc.craterlib.core.networking.CraterPacketNetwork;
|
||||
import com.hypherionmc.craterlib.core.networking.data.PacketSide;
|
||||
import com.hypherionmc.craterlib.core.platform.ModloaderEnvironment;
|
||||
import com.hypherionmc.craterlib.network.CraterFabricNetworkHandler;
|
||||
import com.hypherionmc.craterlib.nojang.commands.CommandsRegistry;
|
||||
import com.hypherionmc.craterlib.nojang.server.BridgedMinecraftServer;
|
||||
@@ -32,5 +34,9 @@ public class CraterLibInitializer implements ModInitializer {
|
||||
ServerLifecycleEvents.SERVER_STARTED.register(li -> CraterEventBus.INSTANCE.postEvent(new CraterServerLifecycleEvent.Started(BridgedMinecraftServer.of(li))));
|
||||
ServerLifecycleEvents.SERVER_STOPPING.register(server -> CraterEventBus.INSTANCE.postEvent(new CraterServerLifecycleEvent.Stopping(BridgedMinecraftServer.of(server))));
|
||||
ServerLifecycleEvents.SERVER_STOPPED.register(server -> CraterEventBus.INSTANCE.postEvent(new CraterServerLifecycleEvent.Stopped(BridgedMinecraftServer.of(server))));
|
||||
|
||||
if (ModloaderEnvironment.INSTANCE.isModLoaded("melius-vanish")) {
|
||||
Vanish.register();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,23 @@
|
||||
package com.hypherionmc.craterlib.common;
|
||||
|
||||
import com.hypherionmc.craterlib.compat.FabricTailor;
|
||||
import com.hypherionmc.craterlib.compat.Vanish;
|
||||
import com.hypherionmc.craterlib.core.platform.CompatUtils;
|
||||
import com.hypherionmc.craterlib.core.platform.ModloaderEnvironment;
|
||||
import com.hypherionmc.craterlib.nojang.world.entity.player.BridgedPlayer;
|
||||
|
||||
public class FabricCompatHelper implements CompatUtils {
|
||||
|
||||
@Override
|
||||
public boolean isPlayerActive(BridgedPlayer player) {
|
||||
if (!ModloaderEnvironment.INSTANCE.isModLoaded("melius-vanish"))
|
||||
return true;
|
||||
|
||||
return Vanish.isPlayerVanished(player.toMojangServerPlayer());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSkinUUID(BridgedPlayer player) {
|
||||
return FabricTailor.getTailorSkin(player.toMojangServerPlayer());
|
||||
}
|
||||
}
|
@@ -0,0 +1,23 @@
|
||||
package com.hypherionmc.craterlib.compat;
|
||||
|
||||
import com.hypherionmc.craterlib.core.platform.ModloaderEnvironment;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import org.samo_lego.fabrictailor.casts.TailoredPlayer;
|
||||
public class FabricTailor {
|
||||
|
||||
public static String getTailorSkin(ServerPlayer player) {
|
||||
if (!ModloaderEnvironment.INSTANCE.isModLoaded("fabrictailor"))
|
||||
return player.getStringUUID();
|
||||
|
||||
try {
|
||||
if (player instanceof TailoredPlayer tp) {
|
||||
return tp.getSkinId();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return player.getStringUUID();
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,25 @@
|
||||
package com.hypherionmc.craterlib.compat;
|
||||
|
||||
import com.hypherionmc.craterlib.api.events.server.CraterPlayerEvent;
|
||||
import com.hypherionmc.craterlib.core.event.CraterEventBus;
|
||||
import com.hypherionmc.craterlib.nojang.world.entity.player.BridgedPlayer;
|
||||
import me.drex.vanish.api.VanishAPI;
|
||||
import me.drex.vanish.api.VanishEvents;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
||||
public class Vanish {
|
||||
|
||||
public static void register() {
|
||||
VanishEvents.VANISH_EVENT.register((serverPlayer, b) -> {
|
||||
if (b) {
|
||||
CraterEventBus.INSTANCE.postEvent(new CraterPlayerEvent.PlayerLoggedOut(BridgedPlayer.of(serverPlayer)));
|
||||
} else {
|
||||
CraterEventBus.INSTANCE.postEvent(new CraterPlayerEvent.PlayerLoggedIn(BridgedPlayer.of(serverPlayer)));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static boolean isPlayerVanished(ServerPlayer player) {
|
||||
return VanishAPI.isVanished(player);
|
||||
}
|
||||
}
|
@@ -0,0 +1 @@
|
||||
com.hypherionmc.craterlib.common.FabricCompatHelper
|
Reference in New Issue
Block a user