- [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:
@@ -6,7 +6,7 @@
|
||||
-def JDK = "21";
|
||||
-def majorMc = "1.21";
|
||||
-def modLoaders = "neoforge|fabric|quilt";
|
||||
-def supportedMc = "1.21";
|
||||
-def supportedMc = "1.21|1.21.1";
|
||||
-def reltype = "port";
|
||||
+def JDK = "17";
|
||||
+def majorMc = "1.18.2";
|
||||
|
@@ -0,0 +1,77 @@
|
||||
--- a/Common/src/main/java/com/hypherionmc/craterlib/api/commands/CraterCommand.java
|
||||
+++ b/Common/src/main/java/com/hypherionmc/craterlib/api/commands/CraterCommand.java
|
||||
@@ -14,6 +14,7 @@
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.commands.arguments.GameProfileArgument;
|
||||
+import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
@@ -53,7 +54,7 @@
|
||||
public CraterCommand withGameProfilesArgument(String key, CommandExecutorWithArgs<List<BridgedGameProfile>> executor) {
|
||||
this.mojangCommand.then(Commands.argument(key, GameProfileArgument.gameProfile())
|
||||
.executes(context -> executor.run(
|
||||
- BridgedPlayer.of(context.getSource().getPlayer()),
|
||||
+ BridgedPlayer.of(context.getSource().getPlayerOrException()),
|
||||
GameProfileArgument.getGameProfiles(context, key).stream().map(BridgedGameProfile::of).toList(),
|
||||
BridgedCommandSourceStack.of(context.getSource()))
|
||||
));
|
||||
@@ -63,7 +64,7 @@
|
||||
public CraterCommand withBoolArgument(String key, CommandExecutorWithArgs<Boolean> executor) {
|
||||
this.mojangCommand.then(Commands.argument(key, BoolArgumentType.bool())
|
||||
.executes(context -> executor.run(
|
||||
- BridgedPlayer.of(context.getSource().getPlayer()),
|
||||
+ BridgedPlayer.of(context.getSource().getPlayerOrException()),
|
||||
BoolArgumentType.getBool(context, key),
|
||||
BridgedCommandSourceStack.of(context.getSource())
|
||||
)));
|
||||
@@ -73,7 +74,7 @@
|
||||
public CraterCommand withWordArgument(String key, CommandExecutorWithArgs<String> executor) {
|
||||
this.mojangCommand.then(Commands.argument(key, StringArgumentType.word())
|
||||
.executes(context -> executor.run(
|
||||
- BridgedPlayer.of(context.getSource().getPlayer()),
|
||||
+ BridgedPlayer.of(context.getSource().getPlayerOrException()),
|
||||
StringArgumentType.getString(context, key),
|
||||
BridgedCommandSourceStack.of(context.getSource())
|
||||
)));
|
||||
@@ -83,7 +84,7 @@
|
||||
public CraterCommand withStringArgument(String key, CommandExecutorWithArgs<String> executor) {
|
||||
this.mojangCommand.then(Commands.argument(key, StringArgumentType.string())
|
||||
.executes(context -> executor.run(
|
||||
- BridgedPlayer.of(context.getSource().getPlayer()),
|
||||
+ BridgedPlayer.of(context.getSource().getPlayerOrException()),
|
||||
StringArgumentType.getString(context, key),
|
||||
BridgedCommandSourceStack.of(context.getSource())
|
||||
)));
|
||||
@@ -93,7 +94,7 @@
|
||||
public CraterCommand withPhraseArgument(String key, CommandExecutorWithArgs<String> executor) {
|
||||
this.mojangCommand.then(Commands.argument(key, StringArgumentType.greedyString())
|
||||
.executes(context -> executor.run(
|
||||
- BridgedPlayer.of(context.getSource().getPlayer()),
|
||||
+ BridgedPlayer.of(context.getSource().getPlayerOrException()),
|
||||
StringArgumentType.getString(context, key),
|
||||
BridgedCommandSourceStack.of(context.getSource())
|
||||
)));
|
||||
@@ -103,7 +104,7 @@
|
||||
public CraterCommand withIntegerArgument(String key, CommandExecutorWithArgs<Integer> executor) {
|
||||
this.mojangCommand.then(Commands.argument(key, IntegerArgumentType.integer())
|
||||
.executes(context -> executor.run(
|
||||
- BridgedPlayer.of(context.getSource().getPlayer()),
|
||||
+ BridgedPlayer.of(context.getSource().getPlayerOrException()),
|
||||
IntegerArgumentType.getInteger(context, key),
|
||||
BridgedCommandSourceStack.of(context.getSource())
|
||||
)));
|
||||
@@ -137,10 +138,10 @@
|
||||
}
|
||||
|
||||
private boolean checkPermission(CommandSourceStack stack) {
|
||||
- if (!ModloaderEnvironment.INSTANCE.isModLoaded("luckperms") || !stack.isPlayer() || luckPermNode.isEmpty())
|
||||
+ if (!ModloaderEnvironment.INSTANCE.isModLoaded("luckperms") || !(stack.getEntity() instanceof Player) || luckPermNode.isEmpty())
|
||||
return stack.hasPermission(this.permLevel);
|
||||
|
||||
- return LuckPermsCompat.INSTANCE.hasPermission(stack.getPlayer(), this.luckPermNode) || stack.hasPermission(this.permLevel);
|
||||
+ return LuckPermsCompat.INSTANCE.hasPermission((ServerPlayer) stack.getEntity(), this.luckPermNode) || stack.hasPermission(this.permLevel);
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
@@ -26,7 +26,7 @@
|
||||
@@ -49,7 +50,7 @@
|
||||
private boolean dragging;
|
||||
|
||||
public CraterConfigScreen(ModuleConfig config, Screen parent, Object subConfig) {
|
||||
public CraterConfigScreen(AbstractConfig config, Screen parent, Object subConfig) {
|
||||
- super(Component.translatable("cl." + config.getClass().getSimpleName().toLowerCase() + ".title"));
|
||||
+ super(new TranslatableComponent("cl." + config.getClass().getSimpleName().toLowerCase() + ".title"));
|
||||
this.parent = parent;
|
||||
|
@@ -3,7 +3,7 @@
|
||||
@@ -2,12 +2,12 @@
|
||||
|
||||
import com.hypherionmc.craterlib.client.gui.config.CraterConfigScreen;
|
||||
import com.hypherionmc.craterlib.core.config.ModuleConfig;
|
||||
import com.hypherionmc.craterlib.core.config.AbstractConfig;
|
||||
+import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Font;
|
||||
|
@@ -0,0 +1,20 @@
|
||||
--- a/Common/src/main/java/com/hypherionmc/craterlib/mixin/events/ServerStatusMixin.java
|
||||
+++ b/Common/src/main/java/com/hypherionmc/craterlib/mixin/events/ServerStatusMixin.java
|
||||
@@ -14,13 +14,13 @@
|
||||
@Mixin(ServerStatus.class)
|
||||
public class ServerStatusMixin {
|
||||
|
||||
- @Inject(method = "favicon", at = @At("RETURN"), cancellable = true)
|
||||
- private void injectIconEvent(CallbackInfoReturnable<Optional<ServerStatus.Favicon>> cir) {
|
||||
- ServerStatusEvent.FaviconRequestEvent event = new ServerStatusEvent.FaviconRequestEvent(cir.getReturnValue().isEmpty() ? Optional.empty() : Optional.of(new WrappedServerStatus.WrappedFavicon(cir.getReturnValue().get())));
|
||||
+ @Inject(method = "getFavicon", at = @At("RETURN"), cancellable = true)
|
||||
+ private void injectIconEvent(CallbackInfoReturnable<String> cir) {
|
||||
+ ServerStatusEvent.FaviconRequestEvent event = new ServerStatusEvent.FaviconRequestEvent(cir.getReturnValue().isEmpty() ? Optional.empty() : Optional.of(new WrappedServerStatus.WrappedFavicon(cir.getReturnValue())));
|
||||
CraterEventBus.INSTANCE.postEvent(event);
|
||||
|
||||
if (event.getNewIcon().isPresent()) {
|
||||
- cir.setReturnValue(Optional.of(event.getNewIcon().get().toMojang()));
|
||||
+ cir.setReturnValue(event.getNewIcon().get().toMojang());
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,49 @@
|
||||
--- /dev/null
|
||||
+++ b/Common/src/main/java/com/hypherionmc/craterlib/mixin/events/ServerStatusPacketListenerMixin.java
|
||||
@@ -1,0 +1,46 @@
|
||||
+package com.hypherionmc.craterlib.mixin.events;
|
||||
+
|
||||
+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.MinecraftServer;
|
||||
+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 Connection connection;
|
||||
+
|
||||
+ @Shadow @Final private MinecraftServer server;
|
||||
+
|
||||
+ @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(server.getStatus().getDescription()));
|
||||
+ CraterEventBus.INSTANCE.postEvent(event);
|
||||
+
|
||||
+ if (event.getNewStatus() != null) {
|
||||
+ ci.cancel();
|
||||
+ ServerStatus serverStatus = this.server.getStatus();
|
||||
+ serverStatus.setDescription(ChatUtils.adventureToMojang(event.getNewStatus()));
|
||||
+
|
||||
+ this.connection.send(new ClientboundStatusResponsePacket(serverStatus));
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+}
|
@@ -8,4 +8,4 @@
|
||||
+ internal.sendSuccess(ChatUtils.adventureToMojang(supplier.get()), bl);
|
||||
}
|
||||
|
||||
public CommandSourceStack toMojang() {
|
||||
public void sendFailure(Component text) {
|
||||
|
@@ -1,11 +0,0 @@
|
||||
--- a/Common/src/main/java/com/hypherionmc/craterlib/nojang/commands/CommandsRegistry.java
|
||||
+++ b/Common/src/main/java/com/hypherionmc/craterlib/nojang/commands/CommandsRegistry.java
|
||||
@@ -70,7 +70,7 @@
|
||||
profiles.forEach(p -> bridgedGameProfiles.add(BridgedGameProfile.of(p)));
|
||||
|
||||
((TriConsumer<BridgedPlayer, List<BridgedGameProfile>, BridgedCommandSourceStack>) pair.getRight())
|
||||
- .accept(BridgedPlayer.of(context.getSource().getPlayer()), bridgedGameProfiles, BridgedCommandSourceStack.of(context.getSource()));
|
||||
+ .accept(BridgedPlayer.of(context.getSource().getPlayerOrException()), bridgedGameProfiles, BridgedCommandSourceStack.of(context.getSource()));
|
||||
return 1;
|
||||
}
|
||||
|
@@ -0,0 +1,48 @@
|
||||
--- a/Common/src/main/java/com/hypherionmc/craterlib/nojang/network/protocol/status/WrappedServerStatus.java
|
||||
+++ b/Common/src/main/java/com/hypherionmc/craterlib/nojang/network/protocol/status/WrappedServerStatus.java
|
||||
@@ -1,28 +1,39 @@
|
||||
package com.hypherionmc.craterlib.nojang.network.protocol.status;
|
||||
|
||||
-import net.minecraft.network.protocol.status.ServerStatus;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
+import java.nio.charset.StandardCharsets;
|
||||
+import java.util.Base64;
|
||||
+
|
||||
public final class WrappedServerStatus {
|
||||
|
||||
public static final class WrappedFavicon {
|
||||
|
||||
- private final ServerStatus.Favicon internal;
|
||||
+ private final String internal;
|
||||
+ private final byte[] iconBytes;
|
||||
|
||||
public WrappedFavicon(byte[] iconBytes) {
|
||||
- internal = new ServerStatus.Favicon(iconBytes);
|
||||
+ this.iconBytes = iconBytes;
|
||||
+
|
||||
+ if (iconBytes != null) {
|
||||
+ byte[] encoded = Base64.getEncoder().encode(iconBytes);
|
||||
+ internal = "data:image/png;base64," + new String(encoded, StandardCharsets.UTF_8);
|
||||
+ } else {
|
||||
+ internal = null;
|
||||
+ }
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
- public WrappedFavicon(ServerStatus.Favicon internal) {
|
||||
+ public WrappedFavicon(String internal) {
|
||||
this.internal = internal;
|
||||
+ this.iconBytes = new byte[0];
|
||||
}
|
||||
|
||||
public byte[] iconBytes() {
|
||||
- return internal.iconBytes();
|
||||
+ return iconBytes;
|
||||
}
|
||||
|
||||
- public ServerStatus.Favicon toMojang() {
|
||||
+ public String toMojang() {
|
||||
return internal;
|
||||
}
|
||||
|
@@ -73,4 +73,4 @@
|
||||
+ return mojangToAdventure(new TranslatableComponent(Util.makeDescriptionId("biome", identifier.toMojang())));
|
||||
}
|
||||
|
||||
}
|
||||
public static net.kyori.adventure.text.Component format(String value) {
|
||||
|
@@ -0,0 +1,12 @@
|
||||
--- a/Common/src/main/resources/craterlib.mixins.json
|
||||
+++ b/Common/src/main/resources/craterlib.mixins.json
|
||||
@@ -17,7 +17,8 @@
|
||||
"events.PlayerAdvancementsMixin",
|
||||
"events.PlayerListMixin",
|
||||
"events.ServerPlayerMixin",
|
||||
- "events.ServerStatusMixin"
|
||||
+ "events.ServerStatusMixin",
|
||||
+ "events.ServerStatusPacketListenerMixin"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
@@ -4,8 +4,8 @@
|
||||
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")
|
||||
+ setDisplayName("[FABRIC/QUILT 1.18.2] CraterLib - ${project.version}")
|
||||
+ setGameVersions("1.18.2")
|
||||
setLoaders("fabric", "quilt")
|
||||
|
@@ -1,7 +1,7 @@
|
||||
--- a/Fabric/src/main/java/com/hypherionmc/craterlib/CraterLibInitializer.java
|
||||
+++ b/Fabric/src/main/java/com/hypherionmc/craterlib/CraterLibInitializer.java
|
||||
@@ -12,7 +12,7 @@
|
||||
import com.hypherionmc.craterlib.nojang.commands.CommandsRegistry;
|
||||
@@ -11,7 +11,7 @@
|
||||
import com.hypherionmc.craterlib.network.CraterFabricNetworkHandler;
|
||||
import com.hypherionmc.craterlib.nojang.server.BridgedMinecraftServer;
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
-import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
|
||||
@@ -9,12 +9,12 @@
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
|
||||
|
||||
public class CraterLibInitializer implements ModInitializer {
|
||||
@@ -20,7 +20,7 @@
|
||||
@@ -19,7 +19,7 @@
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
new CraterPacketNetwork(new CraterFabricNetworkHandler(PacketSide.SERVER));
|
||||
- CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> {
|
||||
+ CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> {
|
||||
CraterEventBus.INSTANCE.postEvent(new CraterRegisterCommandEvent());
|
||||
CommandsRegistry.INSTANCE.registerCommands(dispatcher);
|
||||
CraterEventBus.INSTANCE.postEvent(new CraterRegisterCommandEvent(dispatcher));
|
||||
});
|
||||
|
||||
|
@@ -24,8 +24,8 @@
|
||||
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));
|
||||
+ private void injectChatEvent(TextFilter.FilteredText arg, CallbackInfo ci) {
|
||||
+ Component message = new TextComponent(arg.getRaw());
|
||||
+ if (message.getString().startsWith("/"))
|
||||
|
@@ -0,0 +1,55 @@
|
||||
--- a/Fabric/src/main/java/com/hypherionmc/craterlib/mixin/ServerStatusPacketListenerMixin.java
|
||||
+++ /dev/null
|
||||
@@ -1,52 +1,0 @@
|
||||
-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()
|
||||
- )
|
||||
- ));
|
||||
- }
|
||||
- }
|
||||
-
|
||||
-}
|
@@ -0,0 +1,12 @@
|
||||
--- a/Fabric/src/main/resources/craterlib.fabric.mixins.json
|
||||
+++ b/Fabric/src/main/resources/craterlib.fabric.mixins.json
|
||||
@@ -9,8 +9,7 @@
|
||||
"TutorialMixin"
|
||||
],
|
||||
"server": [
|
||||
- "ServerGamePacketListenerImplMixin",
|
||||
- "ServerStatusPacketListenerMixin"
|
||||
+ "ServerGamePacketListenerImplMixin"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
@@ -0,0 +1,20 @@
|
||||
--- a/Forge/src/main/java/com/hypherionmc/craterlib/common/ForgeServerEvents.java
|
||||
+++ b/Forge/src/main/java/com/hypherionmc/craterlib/common/ForgeServerEvents.java
|
||||
@@ -3,7 +3,6 @@
|
||||
import com.hypherionmc.craterlib.api.events.server.CraterRegisterCommandEvent;
|
||||
import com.hypherionmc.craterlib.api.events.server.CraterServerLifecycleEvent;
|
||||
import com.hypherionmc.craterlib.core.event.CraterEventBus;
|
||||
-import com.hypherionmc.craterlib.nojang.commands.CommandsRegistry;
|
||||
import com.hypherionmc.craterlib.nojang.server.BridgedMinecraftServer;
|
||||
import net.minecraftforge.event.RegisterCommandsEvent;
|
||||
import net.minecraftforge.event.server.ServerStartedEvent;
|
||||
@@ -36,8 +35,7 @@
|
||||
|
||||
@SubscribeEvent
|
||||
public void onCommandRegister(RegisterCommandsEvent event) {
|
||||
- CraterEventBus.INSTANCE.postEvent(new CraterRegisterCommandEvent());
|
||||
- CommandsRegistry.INSTANCE.registerCommands(event.getDispatcher());
|
||||
+ CraterEventBus.INSTANCE.postEvent(new CraterRegisterCommandEvent(event.getDispatcher()));
|
||||
}
|
||||
|
||||
}
|
@@ -1,6 +1,12 @@
|
||||
--- a/Forge/src/main/java/com/hypherionmc/craterlib/mixin/ConfigScreenHandlerMixin.java
|
||||
+++ b/Forge/src/main/java/com/hypherionmc/craterlib/mixin/ConfigScreenHandlerMixin.java
|
||||
@@ -6,7 +6,7 @@
|
||||
@@ -1,12 +1,12 @@
|
||||
package com.hypherionmc.craterlib.mixin;
|
||||
|
||||
import com.hypherionmc.craterlib.client.gui.config.CraterConfigScreen;
|
||||
+import com.hypherionmc.craterlib.core.config.AbstractConfig;
|
||||
import com.hypherionmc.craterlib.core.config.ConfigController;
|
||||
-import com.hypherionmc.craterlib.core.config.ModuleConfig;
|
||||
import com.hypherionmc.craterlib.core.config.annotations.NoConfigScreen;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
@@ -9,7 +15,7 @@
|
||||
import net.minecraftforge.forgespi.language.IModInfo;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@@ -19,14 +19,14 @@
|
||||
@@ -19,18 +19,18 @@
|
||||
/**
|
||||
* @author HypherionSA
|
||||
*/
|
||||
@@ -24,5 +30,11 @@
|
||||
- @Inject(at = @At("RETURN"), method = "getScreenFactoryFor", cancellable = true, remap = false)
|
||||
+ @Inject(at = @At("RETURN"), method = "getGuiFactoryFor", cancellable = true, remap = false)
|
||||
private static void injectConfigScreen(IModInfo selectedMod, CallbackInfoReturnable<Optional<BiFunction<Minecraft, Screen, Screen>>> cir) {
|
||||
ConfigController.getMonitoredConfigs().forEach((conf, watcher) -> {
|
||||
- ConfigController.getMonitoredConfigs().forEach((conf, watcher) -> {
|
||||
+ ConfigController.getWatchedConfigs().forEach((conf, watcher) -> {
|
||||
if (!conf.getClass().isAnnotationPresent(NoConfigScreen.class)) {
|
||||
- ModuleConfig config = (ModuleConfig) conf;
|
||||
+ AbstractConfig config = watcher.getLeft();
|
||||
if (config.getModId().equals(selectedMod.getModId())) {
|
||||
cir.setReturnValue(
|
||||
Optional.of((minecraft, screen) -> new CraterConfigScreen(config, screen))
|
||||
|
@@ -24,8 +24,8 @@
|
||||
cancellable = true
|
||||
)
|
||||
- private void injectChatEvent(Component component, PlayerChatMessage arg, FilteredText p_296589_, CallbackInfo ci) {
|
||||
- Component finalArg = component == null ? arg.decoratedContent() : component;
|
||||
- CraterServerChatEvent event = new CraterServerChatEvent(BridgedPlayer.of(this.player), finalArg.getString(), ChatUtils.mojangToAdventure(finalArg));
|
||||
- Component finalcomp = component == null ? arg.decoratedContent() : component;
|
||||
- CraterServerChatEvent event = new CraterServerChatEvent(BridgedPlayer.of(this.player), finalcomp.getString(), ChatUtils.mojangToAdventure(finalcomp));
|
||||
+ private void injectChatEvent(TextFilter.FilteredText arg, CallbackInfo ci) {
|
||||
+ Component message = new TextComponent(arg.getRaw());
|
||||
+ if (message.getString().startsWith("/"))
|
||||
|
@@ -0,0 +1,56 @@
|
||||
--- a/Forge/src/main/java/com/hypherionmc/craterlib/mixin/ServerStatusPacketListenerMixin.java
|
||||
+++ /dev/null
|
||||
@@ -1,53 +1,0 @@
|
||||
-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(),
|
||||
- status.isModded()
|
||||
- )
|
||||
- ));
|
||||
- }
|
||||
- }
|
||||
-
|
||||
-}
|
@@ -0,0 +1,12 @@
|
||||
--- a/Forge/src/main/resources/craterlib.forge.mixins.json
|
||||
+++ b/Forge/src/main/resources/craterlib.forge.mixins.json
|
||||
@@ -9,8 +9,7 @@
|
||||
"ConfigScreenHandlerMixin"
|
||||
],
|
||||
"server": [
|
||||
- "ServerGamePacketListenerImplMixin",
|
||||
- "ServerStatusPacketListenerMixin"
|
||||
+ "ServerGamePacketListenerImplMixin"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
@@ -109,8 +109,8 @@
|
||||
- setVersionType("release")
|
||||
- setChangelog("https://raw.githubusercontent.com/hypherionmc/changelogs/main/craterlib/changelog-forge.md")
|
||||
- setProjectVersion("${minecraft_version}-${project.version}")
|
||||
- setDisplayName("[NeoForge 1.21.0] CraterLib - ${project.version}")
|
||||
- setGameVersions("1.21")
|
||||
- setDisplayName("[NeoForge 1.21.x] CraterLib - ${project.version}")
|
||||
- setGameVersions("1.21", "1.21.1")
|
||||
- setLoaders("neoforge")
|
||||
- setArtifact(remapJar)
|
||||
- setCurseEnvironment("both")
|
||||
|
@@ -5,8 +5,8 @@
|
||||
-
|
||||
-import com.hypherionmc.craterlib.api.events.client.LateInitEvent;
|
||||
-import com.hypherionmc.craterlib.client.gui.config.CraterConfigScreen;
|
||||
-import com.hypherionmc.craterlib.core.config.AbstractConfig;
|
||||
-import com.hypherionmc.craterlib.core.config.ConfigController;
|
||||
-import com.hypherionmc.craterlib.core.config.ModuleConfig;
|
||||
-import com.hypherionmc.craterlib.core.config.annotations.NoConfigScreen;
|
||||
-import com.hypherionmc.craterlib.core.event.CraterEventBus;
|
||||
-import com.hypherionmc.craterlib.core.platform.ClientPlatform;
|
||||
@@ -54,9 +54,9 @@
|
||||
- LateInitEvent event = new LateInitEvent(new BridgedMinecraft(), BridgedOptions.of(Minecraft.getInstance().options));
|
||||
- CraterEventBus.INSTANCE.postEvent(event);
|
||||
-
|
||||
- ConfigController.getMonitoredConfigs().forEach((conf, watcher) -> {
|
||||
- ConfigController.getWatchedConfigs().forEach((conf, watcher) -> {
|
||||
- if (!conf.getClass().isAnnotationPresent(NoConfigScreen.class)) {
|
||||
- ModuleConfig config = (ModuleConfig) conf;
|
||||
- AbstractConfig config = watcher.getLeft();
|
||||
- ModList.get().getModContainerById(config.getModId()).ifPresent(c -> c.registerExtensionPoint(IConfigScreenFactory.class, ((minecraft, screen) -> new CraterConfigScreen(config, screen))));
|
||||
- }
|
||||
- });
|
||||
|
@@ -1,12 +1,11 @@
|
||||
--- a/NeoForge/src/main/java/com/hypherionmc/craterlib/common/NeoForgeServerEvents.java
|
||||
+++ /dev/null
|
||||
@@ -1,43 +1,0 @@
|
||||
@@ -1,41 +1,0 @@
|
||||
-package com.hypherionmc.craterlib.common;
|
||||
-
|
||||
-import com.hypherionmc.craterlib.api.events.server.CraterRegisterCommandEvent;
|
||||
-import com.hypherionmc.craterlib.api.events.server.CraterServerLifecycleEvent;
|
||||
-import com.hypherionmc.craterlib.core.event.CraterEventBus;
|
||||
-import com.hypherionmc.craterlib.nojang.commands.CommandsRegistry;
|
||||
-import com.hypherionmc.craterlib.nojang.server.BridgedMinecraftServer;
|
||||
-import net.neoforged.bus.api.SubscribeEvent;
|
||||
-import net.neoforged.neoforge.event.RegisterCommandsEvent;
|
||||
@@ -39,8 +38,7 @@
|
||||
-
|
||||
- @SubscribeEvent
|
||||
- public void onCommandRegister(RegisterCommandsEvent event) {
|
||||
- CraterEventBus.INSTANCE.postEvent(new CraterRegisterCommandEvent());
|
||||
- CommandsRegistry.INSTANCE.registerCommands(event.getDispatcher());
|
||||
- CraterEventBus.INSTANCE.postEvent(new CraterRegisterCommandEvent(event.getDispatcher()));
|
||||
- }
|
||||
-
|
||||
-}
|
||||
|
@@ -30,8 +30,8 @@
|
||||
- cancellable = true
|
||||
- )
|
||||
- private void injectChatEvent(Component component, PlayerChatMessage arg, FilteredText p_296589_, CallbackInfo ci) {
|
||||
- Component finalArg = component == null ? arg.decoratedContent() : component;
|
||||
- CraterServerChatEvent event = new CraterServerChatEvent(BridgedPlayer.of(this.player), finalArg.getString(), ChatUtils.mojangToAdventure(finalArg));
|
||||
- Component finalcomp = component == null ? arg.decoratedContent() : component;
|
||||
- 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,56 @@
|
||||
--- a/NeoForge/src/main/java/com/hypherionmc/craterlib/mixin/ServerStatusPacketListenerMixin.java
|
||||
+++ /dev/null
|
||||
@@ -1,53 +1,0 @@
|
||||
-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(),
|
||||
- status.isModded()
|
||||
- )
|
||||
- ));
|
||||
- }
|
||||
- }
|
||||
-
|
||||
-}
|
@@ -1,6 +1,6 @@
|
||||
--- a/NeoForge/src/main/resources/craterlib.neoforge.mixins.json
|
||||
+++ /dev/null
|
||||
@@ -1,15 +1,0 @@
|
||||
@@ -1,16 +1,0 @@
|
||||
-{
|
||||
- "required": true,
|
||||
- "minVersion": "0.8",
|
||||
@@ -10,7 +10,8 @@
|
||||
- ],
|
||||
- "client": [],
|
||||
- "server": [
|
||||
- "ServerGamePacketListenerImplMixin"
|
||||
- "ServerGamePacketListenerImplMixin",
|
||||
- "ServerStatusPacketListenerMixin"
|
||||
- ],
|
||||
- "injectors": {
|
||||
- "defaultRequire": 1
|
||||
|
@@ -1,12 +1,10 @@
|
||||
--- a/README.md
|
||||
+++ b/README.md
|
||||
@@ -15,8 +15,7 @@
|
||||
@@ -15,7 +15,6 @@
|
||||
| < 1.18.2 | ❌ |
|
||||
| 1.18.2-1.20.2 | ✳️ |
|
||||
| 1.20.4 | ✳️ |
|
||||
-| 1.20.6 | ❌ |
|
||||
-| 1.21 | ✳️ |
|
||||
+| 1.21 | 🚧 |
|
||||
| 1.21.x | ✳️ |
|
||||
|
||||
- ❌ - Not Supported; no bug fixes or new features.
|
||||
- 🚧 - Work in Progress; not ready for release.
|
||||
|
@@ -11,9 +11,9 @@
|
||||
|
||||
group = rootProject.group
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
shade "me.hypherionmc.moon-config:core:${moon_config}"
|
||||
@@ -59,7 +59,7 @@
|
||||
shade "me.hypherionmc.moon-config:toml:${moon_config}"
|
||||
shade "me.hypherionmc.moon-config:json:${moon_config}"
|
||||
shade "com.hypherionmc:rpcsdk:${rpc_sdk}"
|
||||
- shade "me.hypherionmc.sdlink:mcdiscordformatter-1.20.3:${discord_formatter}"
|
||||
+ shade "me.hypherionmc.sdlink:mcdiscordformatter-1.18.1:${discord_formatter}"
|
||||
|
Reference in New Issue
Block a user