mirror of
https://github.com/TeamMidnightDust/MidnightLib.git
synced 2025-12-15 17:05:09 +01:00
feat: improve URL handling
- Uses the `open` method of `ConfirmLinkScreen` instead of manually instantiating it - Also re-add the `requiredMod` field for `@Comment` to prevent mods that haven't adjusted yet from outright crashing
This commit is contained in:
@@ -494,15 +494,9 @@ public abstract class MidnightConfig {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean mouseClicked(double mouseX, double mouseY, int button) {
|
public boolean mouseClicked(double mouseX, double mouseY, int button) {
|
||||||
boolean result = super.mouseClicked(mouseX, mouseY, button);
|
if (this.info != null && this.info.comment != null && !this.info.comment.url().isBlank())
|
||||||
if (this.info != null && this.info.comment != null && !this.info.comment.url().isBlank()) {
|
ConfirmLinkScreen.open(MinecraftClient.getInstance().currentScreen, this.info.comment.url(), true);
|
||||||
Screen parent = MinecraftClient.getInstance().currentScreen;
|
return super.mouseClicked(mouseX, mouseY, button);
|
||||||
MinecraftClient.getInstance().setScreen(new ConfirmLinkScreen((confirm)->{
|
|
||||||
if (confirm) Util.getOperatingSystem().open(this.info.comment.url());
|
|
||||||
MinecraftClient.getInstance().setScreen(parent);
|
|
||||||
}, this.info.comment.url(), true));
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<? extends Element> children() {return Lists.newArrayList(buttons);}
|
public List<? extends Element> children() {return Lists.newArrayList(buttons);}
|
||||||
@@ -597,6 +591,7 @@ public abstract class MidnightConfig {
|
|||||||
String category() default "default";
|
String category() default "default";
|
||||||
String name() default "";
|
String name() default "";
|
||||||
String url() default "";
|
String url() default "";
|
||||||
|
@Deprecated String requiredMod() default "";
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Condition Annotation<br>
|
* Condition Annotation<br>
|
||||||
|
|||||||
Reference in New Issue
Block a user