From e736097cd2a90c467c84d7fa941aacaea6d5fe7b Mon Sep 17 00:00:00 2001 From: Roman / Linnea Gräf Date: Fri, 13 Jan 2023 19:36:39 +0100 Subject: Add nopos xdg-open link opener to vanilla GUIs (#542) --- .../moulberry/notenoughupdates/mixins/MixinGuiScreen.java | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/main/java/io') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiScreen.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiScreen.java index b978b433..8baa2bef 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiScreen.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinGuiScreen.java @@ -20,16 +20,26 @@ package io.github.moulberry.notenoughupdates.mixins; import io.github.moulberry.notenoughupdates.util.SBInfo; +import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.gui.GuiScreen; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import java.net.URI; + @Mixin(GuiScreen.class) public class MixinGuiScreen { @Inject(method = "sendChatMessage(Ljava/lang/String;Z)V", at = @At("HEAD")) public void onSendChatMessage(String message, boolean addToChat, CallbackInfo ci) { SBInfo.getInstance().onSendChatMessage(message); } + + @Inject(method = "openWebLink", at = @At("HEAD"), cancellable = true) + public void onOpenWebLink(URI url, CallbackInfo ci) { + if (Utils.openUrl(url.toString())) { + ci.cancel(); + } + } } -- cgit