mirror of
https://code.chipmunk.land/ChomeNS/chipmunkmod.git
synced 2025-11-13 18:46:15 +00:00
refactor: fix ClickEvent deprecation
This commit is contained in:
parent
8cbe8053c1
commit
335baeeaef
1 changed files with 11 additions and 5 deletions
|
|
@ -74,13 +74,19 @@ public final class CustomChatComponentRenderer extends TranslatableComponentRend
|
|||
private ClickEvent mergeClickEvent (final ClickEvent clickEvent, final CustomChatContext context) {
|
||||
if (clickEvent == null) return null;
|
||||
|
||||
final ClickEvent.Payload payload = clickEvent.payload();
|
||||
if (!(payload instanceof final ClickEvent.Payload.Text text)) return clickEvent;
|
||||
if (!clickEvent.action().supports(ClickEvent.Payload.string(""))) return clickEvent;
|
||||
|
||||
final String arg = context.args().get(text.value());
|
||||
final String value = ((ClickEvent.Payload.Text) clickEvent.payload()).value();
|
||||
final String arg = context.args().get(value);
|
||||
if (arg == null) return clickEvent;
|
||||
|
||||
// TODO: figure out solution for deprecation warning in the future
|
||||
return ClickEvent.clickEvent(clickEvent.action(), arg);
|
||||
return switch (clickEvent.action()) {
|
||||
case OPEN_URL -> ClickEvent.openUrl(arg);
|
||||
case OPEN_FILE -> ClickEvent.openFile(arg);
|
||||
case RUN_COMMAND -> ClickEvent.runCommand(arg);
|
||||
case SUGGEST_COMMAND -> ClickEvent.suggestCommand(arg);
|
||||
case COPY_TO_CLIPBOARD -> ClickEvent.copyToClipboard(arg);
|
||||
default -> clickEvent;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue