[FEAT] More Nojang abstractions and compat layers (SDLink)

This commit is contained in:
2024-05-01 18:28:52 +02:00
parent 5166886924
commit 9ffd14d9c1
23 changed files with 292 additions and 10 deletions

View File

@@ -9,8 +9,11 @@ shadowJar {
configurations = [project.configurations.shade] configurations = [project.configurations.shade]
dependencies { dependencies {
exclude(dependency('com.google.code.gson:.*'))
relocate 'me.hypherionmc.moonconfig', 'shadow.hypherionmc.moonconfig' relocate 'me.hypherionmc.moonconfig', 'shadow.hypherionmc.moonconfig'
relocate 'me.hypherionmc.mcdiscordformatter', 'shadow.hypherionmc.mcdiscordformatter' relocate 'me.hypherionmc.mcdiscordformatter', 'shadow.hypherionmc.mcdiscordformatter'
relocate 'net.kyori', 'shadow.kyori'
} }
setArchiveClassifier("dev") setArchiveClassifier("dev")
} }
@@ -43,9 +46,7 @@ processResources {
publishing { publishing {
publications { publications {
mavenCommon(MavenPublication) { mavenCommon(MavenPublication) {
groupId project.group
artifactId project.archivesBaseName artifactId project.archivesBaseName
version project.version
from components.java from components.java
pom.withXml { pom.withXml {

View File

@@ -6,8 +6,8 @@ import com.hypherionmc.craterlib.nojang.world.entity.player.BridgedPlayer;
import com.mojang.brigadier.arguments.ArgumentType; import com.mojang.brigadier.arguments.ArgumentType;
import lombok.Getter; import lombok.Getter;
import net.minecraft.commands.arguments.GameProfileArgument; import net.minecraft.commands.arguments.GameProfileArgument;
import org.apache.commons.lang3.function.TriConsumer;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
import org.apache.logging.log4j.util.TriConsumer;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;

View File

@@ -0,0 +1,13 @@
package com.hypherionmc.craterlib.core.platform;
import com.hypherionmc.craterlib.nojang.world.entity.player.BridgedPlayer;
import com.hypherionmc.craterlib.utils.InternalServiceUtil;
public interface CompatUtils {
public static final CompatUtils INSTANCE = InternalServiceUtil.load(CompatUtils.class);
boolean isPlayerActive(BridgedPlayer player);
String getSkinUUID(BridgedPlayer player);
}

View File

@@ -0,0 +1,55 @@
package com.hypherionmc.craterlib.nojang.commands;
import com.hypherionmc.craterlib.nojang.server.BridgedMinecraftServer;
import com.hypherionmc.craterlib.utils.ChatUtils;
import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.network.chat.Component;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.phys.Vec2;
import net.minecraft.world.phys.Vec3;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Supplier;
public abstract class BridgedFakePlayer {
final MojangBridge internal;
public BridgedFakePlayer(BridgedMinecraftServer server, int perm, String name) {
internal = new MojangBridge(server.toMojang(), perm, name, this::onSuccess, this::onError);
}
public abstract void onSuccess(Supplier<net.kyori.adventure.text.Component> supplier, Boolean aBoolean);
public void onError(net.kyori.adventure.text.Component component) {
this.onSuccess(() -> component, false);
}
public CommandSourceStack toMojang() {
return internal;
}
static class MojangBridge extends CommandSourceStack {
private final BiConsumer<Supplier<net.kyori.adventure.text.Component>, Boolean> successCallback;
public final Consumer<net.kyori.adventure.text.Component> errorCallback;
MojangBridge(MinecraftServer server, int perm, String name, BiConsumer<Supplier<net.kyori.adventure.text.Component>, Boolean> successCallback, Consumer<net.kyori.adventure.text.Component> errorCallback) {
super(CommandSource.NULL, Vec3.ZERO, Vec2.ZERO, server.overworld(), perm, name, Component.literal(name), server, null);
this.successCallback = successCallback;
this.errorCallback = errorCallback;
}
@Override
public void sendSuccess(Supplier<Component> supplier, boolean bl) {
successCallback.accept(() -> ChatUtils.mojangToAdventure(supplier.get()), bl);
}
@Override
public void sendFailure(Component arg) {
errorCallback.accept(ChatUtils.mojangToAdventure(arg));
}
}
}

View File

@@ -47,6 +47,8 @@ public class CommandsRegistry {
cmd.getExecutor().accept(BridgedCommandSourceStack.of(context.getSource())); cmd.getExecutor().accept(BridgedCommandSourceStack.of(context.getSource()));
return 1; return 1;
}); });
dispatcher.register(command);
} }
} }
@@ -74,6 +76,8 @@ public class CommandsRegistry {
return 1; return 1;
}))); })));
dispatcher.register(command);
} }
} }

View File

@@ -1,6 +1,7 @@
package com.hypherionmc.craterlib.nojang.server; package com.hypherionmc.craterlib.nojang.server;
import com.hypherionmc.craterlib.nojang.authlib.BridgedGameProfile; import com.hypherionmc.craterlib.nojang.authlib.BridgedGameProfile;
import com.hypherionmc.craterlib.nojang.commands.BridgedFakePlayer;
import com.hypherionmc.craterlib.nojang.world.entity.player.BridgedPlayer; import com.hypherionmc.craterlib.nojang.world.entity.player.BridgedPlayer;
import com.hypherionmc.craterlib.utils.ChatUtils; import com.hypherionmc.craterlib.utils.ChatUtils;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
@@ -79,6 +80,10 @@ public class BridgedMinecraftServer {
internal.getPlayerList().getBans().add(new UserBanListEntry(profile.toMojang())); internal.getPlayerList().getBans().add(new UserBanListEntry(profile.toMojang()));
} }
public void executeCommand(BridgedMinecraftServer server, BridgedFakePlayer player, String command) {
internal.getCommands().performPrefixedCommand(player.toMojang(), command);
}
public MinecraftServer toMojang() { public MinecraftServer toMojang() {
return internal; return internal;
} }

View File

@@ -4,10 +4,14 @@ dependencies {
// Core // Core
modImplementation "net.fabricmc.fabric-api:fabric-api:${fabric_api}" modImplementation "net.fabricmc.fabric-api:fabric-api:${fabric_api}"
// Compat
modImplementation("com.terraformersmc:modmenu:${mod_menu_version}") { modImplementation("com.terraformersmc:modmenu:${mod_menu_version}") {
exclude(group: "net.fabricmc.fabric-api") 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 // Do not edit or remove
implementation project(":Common") implementation project(":Common")
} }
@@ -17,8 +21,11 @@ shadowJar {
configurations = [project.configurations.shade] configurations = [project.configurations.shade]
dependencies { dependencies {
exclude(dependency('com.google.code.gson:.*'))
relocate 'me.hypherionmc.moonconfig', 'shadow.hypherionmc.moonconfig' relocate 'me.hypherionmc.moonconfig', 'shadow.hypherionmc.moonconfig'
relocate 'me.hypherionmc.mcdiscordformatter', 'shadow.hypherionmc.mcdiscordformatter' relocate 'me.hypherionmc.mcdiscordformatter', 'shadow.hypherionmc.mcdiscordformatter'
relocate 'net.kyori', 'shadow.kyori'
} }
setArchiveClassifier('dev-shadow') setArchiveClassifier('dev-shadow')
@@ -49,6 +56,7 @@ jar {
processResources { processResources {
from project(":Common").sourceSets.main.resources from project(":Common").sourceSets.main.resources
def buildProps = project.properties.clone() def buildProps = project.properties.clone()
println(project.version)
filesMatching(['fabric.mod.json']) { filesMatching(['fabric.mod.json']) {
expand buildProps expand buildProps
@@ -67,9 +75,7 @@ tasks.withType(JavaCompile).configureEach {
publishing { publishing {
publications { publications {
mavenJava(MavenPublication) { mavenJava(MavenPublication) {
groupId project.group
artifactId project.archivesBaseName artifactId project.archivesBaseName
version project.version
from components.java from components.java
artifact(remapJar) { artifact(remapJar) {

View File

@@ -3,9 +3,11 @@ package com.hypherionmc.craterlib;
import com.hypherionmc.craterlib.api.events.server.CraterRegisterCommandEvent; import com.hypherionmc.craterlib.api.events.server.CraterRegisterCommandEvent;
import com.hypherionmc.craterlib.api.events.server.CraterServerLifecycleEvent; import com.hypherionmc.craterlib.api.events.server.CraterServerLifecycleEvent;
import com.hypherionmc.craterlib.common.FabricCommonPlatform; import com.hypherionmc.craterlib.common.FabricCommonPlatform;
import com.hypherionmc.craterlib.compat.Vanish;
import com.hypherionmc.craterlib.core.event.CraterEventBus; import com.hypherionmc.craterlib.core.event.CraterEventBus;
import com.hypherionmc.craterlib.core.networking.CraterPacketNetwork; import com.hypherionmc.craterlib.core.networking.CraterPacketNetwork;
import com.hypherionmc.craterlib.core.networking.data.PacketSide; 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.network.CraterFabricNetworkHandler;
import com.hypherionmc.craterlib.nojang.commands.CommandsRegistry; import com.hypherionmc.craterlib.nojang.commands.CommandsRegistry;
import com.hypherionmc.craterlib.nojang.server.BridgedMinecraftServer; 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_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_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)))); ServerLifecycleEvents.SERVER_STOPPED.register(server -> CraterEventBus.INSTANCE.postEvent(new CraterServerLifecycleEvent.Stopped(BridgedMinecraftServer.of(server))));
if (ModloaderEnvironment.INSTANCE.isModLoaded("melius-vanish")) {
Vanish.register();
}
} }
} }

View File

@@ -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());
}
}

View File

@@ -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();
}
}

View File

@@ -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);
}
}

View File

@@ -0,0 +1 @@
com.hypherionmc.craterlib.common.FabricCompatHelper

View File

@@ -2,6 +2,8 @@
archivesBaseName = "${mod_name.replace(" ", "")}-Forge-${minecraft_version}" archivesBaseName = "${mod_name.replace(" ", "")}-Forge-${minecraft_version}"
dependencies { dependencies {
// Compat
modImplementation("maven.modrinth:vanishmod:1.1.12.1")
// Do not edit or remove // Do not edit or remove
implementation project(":Common") implementation project(":Common")
@@ -12,8 +14,11 @@ shadowJar {
configurations = [project.configurations.shade] configurations = [project.configurations.shade]
dependencies { dependencies {
exclude(dependency('com.google.code.gson:.*'))
relocate 'me.hypherionmc.moonconfig', 'shadow.hypherionmc.moonconfig' relocate 'me.hypherionmc.moonconfig', 'shadow.hypherionmc.moonconfig'
relocate 'me.hypherionmc.mcdiscordformatter', 'shadow.hypherionmc.mcdiscordformatter' relocate 'me.hypherionmc.mcdiscordformatter', 'shadow.hypherionmc.mcdiscordformatter'
relocate 'net.kyori', 'shadow.kyori'
} }
setArchiveClassifier('dev-shadow') setArchiveClassifier('dev-shadow')
@@ -63,9 +68,7 @@ tasks.withType(JavaCompile).configureEach {
publishing { publishing {
publications { publications {
mavenJava(MavenPublication) { mavenJava(MavenPublication) {
groupId project.group
artifactId project.archivesBaseName artifactId project.archivesBaseName
version project.version
from components.java from components.java
artifact(remapJar) { artifact(remapJar) {

View File

@@ -2,9 +2,11 @@ package com.hypherionmc.craterlib;
import com.hypherionmc.craterlib.api.events.client.LateInitEvent; import com.hypherionmc.craterlib.api.events.client.LateInitEvent;
import com.hypherionmc.craterlib.common.ForgeServerEvents; import com.hypherionmc.craterlib.common.ForgeServerEvents;
import com.hypherionmc.craterlib.compat.Vanish;
import com.hypherionmc.craterlib.core.event.CraterEventBus; import com.hypherionmc.craterlib.core.event.CraterEventBus;
import com.hypherionmc.craterlib.core.networking.CraterPacketNetwork; import com.hypherionmc.craterlib.core.networking.CraterPacketNetwork;
import com.hypherionmc.craterlib.core.networking.data.PacketSide; import com.hypherionmc.craterlib.core.networking.data.PacketSide;
import com.hypherionmc.craterlib.core.platform.ModloaderEnvironment;
import com.hypherionmc.craterlib.network.CraterForgeNetworkHandler; import com.hypherionmc.craterlib.network.CraterForgeNetworkHandler;
import com.hypherionmc.craterlib.nojang.client.BridgedMinecraft; import com.hypherionmc.craterlib.nojang.client.BridgedMinecraft;
import com.hypherionmc.craterlib.nojang.client.BridgedOptions; import com.hypherionmc.craterlib.nojang.client.BridgedOptions;
@@ -31,5 +33,9 @@ public class CraterLib {
LateInitEvent event = new LateInitEvent(new BridgedMinecraft(), BridgedOptions.of(Minecraft.getInstance().options)); LateInitEvent event = new LateInitEvent(new BridgedMinecraft(), BridgedOptions.of(Minecraft.getInstance().options));
CraterEventBus.INSTANCE.postEvent(event); CraterEventBus.INSTANCE.postEvent(event);
}); });
if (ModloaderEnvironment.INSTANCE.isModLoaded("vmod")) {
MinecraftForge.EVENT_BUS.register(new Vanish());
}
} }
} }

View File

@@ -0,0 +1,22 @@
package com.hypherionmc.craterlib.common;
import com.hypherionmc.craterlib.core.platform.CompatUtils;
import com.hypherionmc.craterlib.core.platform.ModloaderEnvironment;
import com.hypherionmc.craterlib.nojang.world.entity.player.BridgedPlayer;
import redstonedubstep.mods.vanishmod.VanishUtil;
public class ForgeCompatHelper implements CompatUtils {
@Override
public boolean isPlayerActive(BridgedPlayer player) {
if (!ModloaderEnvironment.INSTANCE.isModLoaded("vmod"))
return true;
return VanishUtil.isVanished(player.toMojangServerPlayer());
}
@Override
public String getSkinUUID(BridgedPlayer player) {
return player.getStringUUID();
}
}

View File

@@ -0,0 +1,24 @@
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 net.minecraftforge.eventbus.api.SubscribeEvent;
import redstonedubstep.mods.vanishmod.api.PlayerVanishEvent;
public class Vanish {
public Vanish() {
}
@SubscribeEvent
public void vanishevent(PlayerVanishEvent event) {
if (event.isVanished()) {
CraterEventBus.INSTANCE.postEvent(new CraterPlayerEvent.PlayerLoggedOut(BridgedPlayer.of(event.getEntity())));
} else {
CraterEventBus.INSTANCE.postEvent(new CraterPlayerEvent.PlayerLoggedIn(BridgedPlayer.of(event.getEntity())));
}
}
}

View File

@@ -0,0 +1 @@
com.hypherionmc.craterlib.common.ForgeCompatHelper

View File

@@ -1,6 +1,8 @@
archivesBaseName = "${mod_name.replace(" ", "")}-NeoForge-${minecraft_version}" archivesBaseName = "${mod_name.replace(" ", "")}-NeoForge-${minecraft_version}"
dependencies { dependencies {
// Compat
modImplementation("maven.modrinth:vanishmod:puxrKAMr")
// Do not edit or remove // Do not edit or remove
implementation project(":Common") implementation project(":Common")
@@ -11,8 +13,11 @@ shadowJar {
configurations = [project.configurations.shade] configurations = [project.configurations.shade]
dependencies { dependencies {
exclude(dependency('com.google.code.gson:.*'))
relocate 'me.hypherionmc.moonconfig', 'shadow.hypherionmc.moonconfig' relocate 'me.hypherionmc.moonconfig', 'shadow.hypherionmc.moonconfig'
relocate 'me.hypherionmc.mcdiscordformatter', 'shadow.hypherionmc.mcdiscordformatter' relocate 'me.hypherionmc.mcdiscordformatter', 'shadow.hypherionmc.mcdiscordformatter'
relocate 'net.kyori', 'shadow.kyori'
} }
setArchiveClassifier('dev-shadow') setArchiveClassifier('dev-shadow')
@@ -62,9 +67,7 @@ tasks.withType(JavaCompile).configureEach {
publishing { publishing {
publications { publications {
mavenJava(MavenPublication) { mavenJava(MavenPublication) {
groupId project.group
artifactId project.archivesBaseName artifactId project.archivesBaseName
version project.version
from components.java from components.java
artifact(remapJar) { artifact(remapJar) {

View File

@@ -2,10 +2,12 @@ package com.hypherionmc.craterlib;
import com.hypherionmc.craterlib.api.events.client.LateInitEvent; import com.hypherionmc.craterlib.api.events.client.LateInitEvent;
import com.hypherionmc.craterlib.common.NeoForgeServerEvents; import com.hypherionmc.craterlib.common.NeoForgeServerEvents;
import com.hypherionmc.craterlib.compat.Vanish;
import com.hypherionmc.craterlib.core.event.CraterEventBus; import com.hypherionmc.craterlib.core.event.CraterEventBus;
import com.hypherionmc.craterlib.core.networking.CraterPacketNetwork; import com.hypherionmc.craterlib.core.networking.CraterPacketNetwork;
import com.hypherionmc.craterlib.core.networking.PacketRegistry; import com.hypherionmc.craterlib.core.networking.PacketRegistry;
import com.hypherionmc.craterlib.core.networking.data.PacketSide; import com.hypherionmc.craterlib.core.networking.data.PacketSide;
import com.hypherionmc.craterlib.core.platform.ModloaderEnvironment;
import com.hypherionmc.craterlib.network.CraterNeoForgeNetworkHandler; import com.hypherionmc.craterlib.network.CraterNeoForgeNetworkHandler;
import com.hypherionmc.craterlib.nojang.client.BridgedMinecraft; import com.hypherionmc.craterlib.nojang.client.BridgedMinecraft;
import com.hypherionmc.craterlib.nojang.client.BridgedOptions; import com.hypherionmc.craterlib.nojang.client.BridgedOptions;
@@ -26,6 +28,10 @@ public class CraterLib {
NeoForge.EVENT_BUS.register(new NeoForgeServerEvents()); NeoForge.EVENT_BUS.register(new NeoForgeServerEvents());
eventBus.addListener(this::commonSetup); eventBus.addListener(this::commonSetup);
handler = new CraterNeoForgeNetworkHandler(FMLLoader.getDist().isClient() ? PacketSide.CLIENT : PacketSide.SERVER); handler = new CraterNeoForgeNetworkHandler(FMLLoader.getDist().isClient() ? PacketSide.CLIENT : PacketSide.SERVER);
if (ModloaderEnvironment.INSTANCE.isModLoaded("vmod")) {
eventBus.register(new Vanish());
}
} }
public void commonSetup(FMLCommonSetupEvent evt) { public void commonSetup(FMLCommonSetupEvent evt) {

View File

@@ -0,0 +1,22 @@
package com.hypherionmc.craterlib.common;
import com.hypherionmc.craterlib.core.platform.CompatUtils;
import com.hypherionmc.craterlib.core.platform.ModloaderEnvironment;
import com.hypherionmc.craterlib.nojang.world.entity.player.BridgedPlayer;
import redstonedubstep.mods.vanishmod.VanishUtil;
public class NeoForgeCompatHelper implements CompatUtils {
@Override
public boolean isPlayerActive(BridgedPlayer player) {
if (!ModloaderEnvironment.INSTANCE.isModLoaded("vmod"))
return true;
return VanishUtil.isVanished(player.toMojangServerPlayer());
}
@Override
public String getSkinUUID(BridgedPlayer player) {
return player.getStringUUID();
}
}

View File

@@ -0,0 +1,24 @@
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 net.neoforged.bus.api.SubscribeEvent;
import redstonedubstep.mods.vanishmod.api.PlayerVanishEvent;
public class Vanish {
public Vanish() {
}
@SubscribeEvent
public void vanishevent(PlayerVanishEvent event) {
if (event.isVanished()) {
CraterEventBus.INSTANCE.postEvent(new CraterPlayerEvent.PlayerLoggedOut(BridgedPlayer.of(event.getEntity())));
} else {
CraterEventBus.INSTANCE.postEvent(new CraterPlayerEvent.PlayerLoggedIn(BridgedPlayer.of(event.getEntity())));
}
}
}

View File

@@ -0,0 +1 @@
com.hypherionmc.craterlib.common.NeoForgeCompatHelper

View File

@@ -3,7 +3,7 @@ plugins {
id 'com.github.johnrengelman.shadow' version '8.1.1' apply false id 'com.github.johnrengelman.shadow' version '8.1.1' apply false
id "xyz.wagyourtail.unimined" version "1.1.0-SNAPSHOT" apply false id "xyz.wagyourtail.unimined" version "1.1.0-SNAPSHOT" apply false
id "me.hypherionmc.modutils.modpublisher" version "1.0.23+" id "me.hypherionmc.modutils.modpublisher" version "1.0.23+"
id "com.hypherionmc.modutils.orion" version "1.0.6" id "com.hypherionmc.modutils.orion" version "1.0.7"
id 'maven-publish' id 'maven-publish'
} }
@@ -33,6 +33,14 @@ subprojects {
repositories { repositories {
mavenCentral() mavenCentral()
maven {
name = "Modrinth"
url = "https://api.modrinth.com/maven"
content {
includeGroup "maven.modrinth"
}
}
} }
configurations { configurations {