use of net.blay09.mods.chattweaks.event.ChatComponentClickEvent in project ChatTweaks by blay09.
the class GuiChatExt method handleComponentClick.
@Override
public boolean handleComponentClick(ITextComponent component) {
if (component != null) {
if (MinecraftForge.EVENT_BUS.post(new ChatComponentClickEvent(component))) {
return true;
}
ClickEvent clickEvent = component.getStyle().getClickEvent();
if (clickEvent != null) {
if (clickEvent.getAction() == ClickEvent.Action.OPEN_URL) {
String url = clickEvent.getValue();
String directURL = null;
for (Function<String, String> function : ChatTweaks.getImageURLTransformers()) {
directURL = function.apply(url);
if (directURL != null) {
break;
}
}
if (directURL != null) {
try {
Minecraft.getMinecraft().displayGuiScreen(new GuiImagePreview(Minecraft.getMinecraft().currentScreen, new URL(url), new URL(directURL)));
return true;
} catch (MalformedURLException e) {
ChatTweaks.logger.error("Could not open image preview: ", e);
}
}
}
}
}
return super.handleComponentClick(component);
}
Aggregations