- [FEAT] New APIs for Maintenance Mode and rewrite commands system
- [FEAT] Improved config system to fix old loading bugs and support JSON - [FEAT] LuckPerms support for commands
This commit is contained in:
@@ -113,8 +113,8 @@ publisher {
|
||||
setVersionType("release")
|
||||
setChangelog("https://raw.githubusercontent.com/hypherionmc/changelogs/main/craterlib/changelog-fabric.md")
|
||||
setProjectVersion("${minecraft_version}-${project.version}")
|
||||
setDisplayName("[FABRIC/QUILT 1.21.0] CraterLib - ${project.version}")
|
||||
setGameVersions("1.21")
|
||||
setDisplayName("[FABRIC/QUILT 1.21.x] CraterLib - ${project.version}")
|
||||
setGameVersions("1.21", "1.21.1")
|
||||
setLoaders("fabric", "quilt")
|
||||
setArtifact(remapJar)
|
||||
setCurseEnvironment("both")
|
||||
|
@@ -9,7 +9,6 @@ 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;
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
|
||||
@@ -21,8 +20,7 @@ public class CraterLibInitializer implements ModInitializer {
|
||||
public void onInitialize() {
|
||||
new CraterPacketNetwork(new CraterFabricNetworkHandler(PacketSide.SERVER));
|
||||
CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> {
|
||||
CraterEventBus.INSTANCE.postEvent(new CraterRegisterCommandEvent());
|
||||
CommandsRegistry.INSTANCE.registerCommands(dispatcher);
|
||||
CraterEventBus.INSTANCE.postEvent(new CraterRegisterCommandEvent(dispatcher));
|
||||
});
|
||||
|
||||
|
||||
|
@@ -2,7 +2,6 @@ package com.hypherionmc.craterlib;
|
||||
|
||||
import com.hypherionmc.craterlib.client.gui.config.CraterConfigScreen;
|
||||
import com.hypherionmc.craterlib.core.config.ConfigController;
|
||||
import com.hypherionmc.craterlib.core.config.ModuleConfig;
|
||||
import com.hypherionmc.craterlib.core.config.annotations.NoConfigScreen;
|
||||
import com.terraformersmc.modmenu.api.ConfigScreenFactory;
|
||||
import com.terraformersmc.modmenu.api.ModMenuApi;
|
||||
@@ -19,9 +18,9 @@ public class CraterLibModMenuIntegration implements ModMenuApi {
|
||||
public Map<String, ConfigScreenFactory<?>> getProvidedConfigScreenFactories() {
|
||||
Map<String, ConfigScreenFactory<?>> configScreens = new HashMap<>();
|
||||
|
||||
ConfigController.getMonitoredConfigs().forEach((conf, watcher) -> {
|
||||
ConfigController.getWatchedConfigs().forEach((conf, watcher) -> {
|
||||
if (!conf.getClass().isAnnotationPresent(NoConfigScreen.class)) {
|
||||
configScreens.put(((ModuleConfig) conf).getModId(), screen -> new CraterConfigScreen((ModuleConfig) conf, screen));
|
||||
configScreens.put(watcher.getLeft().getModId(), screen -> new CraterConfigScreen(watcher.getLeft(), screen));
|
||||
}
|
||||
});
|
||||
|
||||
|
@@ -27,8 +27,8 @@ public class ServerGamePacketListenerImplMixin {
|
||||
cancellable = true
|
||||
)
|
||||
private void injectChatEvent(PlayerChatMessage arg, Component arg2, FilteredText arg3, CallbackInfo ci) {
|
||||
Component finalArg = arg2 == null ? arg.decoratedContent() : arg2;
|
||||
CraterServerChatEvent event = new CraterServerChatEvent(BridgedPlayer.of(this.player), finalArg.getString(), ChatUtils.mojangToAdventure(finalArg));
|
||||
Component finalcomp = arg2 == null ? arg.decoratedContent() : arg2;
|
||||
CraterServerChatEvent event = new CraterServerChatEvent(BridgedPlayer.of(this.player), finalcomp.getString(), ChatUtils.mojangToAdventure(finalcomp));
|
||||
CraterEventBus.INSTANCE.postEvent(event);
|
||||
if (event.wasCancelled())
|
||||
ci.cancel();
|
||||
|
@@ -0,0 +1,52 @@
|
||||
package com.hypherionmc.craterlib.mixin;
|
||||
|
||||
import com.hypherionmc.craterlib.api.events.server.ServerStatusEvent;
|
||||
import com.hypherionmc.craterlib.core.event.CraterEventBus;
|
||||
import com.hypherionmc.craterlib.utils.ChatUtils;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.minecraft.network.protocol.status.ClientboundStatusResponsePacket;
|
||||
import net.minecraft.network.protocol.status.ServerStatus;
|
||||
import net.minecraft.network.protocol.status.ServerboundStatusRequestPacket;
|
||||
import net.minecraft.server.network.ServerStatusPacketListenerImpl;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(ServerStatusPacketListenerImpl.class)
|
||||
public class ServerStatusPacketListenerMixin {
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
private ServerStatus status;
|
||||
|
||||
@Shadow @Final private Connection connection;
|
||||
|
||||
@Inject(method = "handleStatusRequest",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/network/Connection;send(Lnet/minecraft/network/protocol/Packet;)V",
|
||||
shift = At.Shift.BEFORE),
|
||||
cancellable = true
|
||||
)
|
||||
private void injectHandleStatusRequest(ServerboundStatusRequestPacket arg, CallbackInfo ci) {
|
||||
ServerStatusEvent.StatusRequestEvent event = new ServerStatusEvent.StatusRequestEvent(ChatUtils.mojangToAdventure(status.description()));
|
||||
CraterEventBus.INSTANCE.postEvent(event);
|
||||
|
||||
if (event.getNewStatus() != null) {
|
||||
ci.cancel();
|
||||
this.connection.send(new ClientboundStatusResponsePacket(
|
||||
new ServerStatus(ChatUtils.adventureToMojang(
|
||||
event.getNewStatus()),
|
||||
status.players(),
|
||||
status.version(),
|
||||
status.favicon(),
|
||||
status.enforcesSecureChat()
|
||||
)
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -9,7 +9,8 @@
|
||||
"TutorialMixin"
|
||||
],
|
||||
"server": [
|
||||
"ServerGamePacketListenerImplMixin"
|
||||
"ServerGamePacketListenerImplMixin",
|
||||
"ServerStatusPacketListenerMixin"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
|
Reference in New Issue
Block a user