- [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:
@@ -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
|
Reference in New Issue
Block a user