Civcraft / CivMenu

BSD 3-Clause "New" or "Revised" License
0 stars 4 forks source link

Add clickable links and hover information to help messages #16

Closed Maxopoly closed 8 years ago

Maxopoly commented 8 years ago

@TealNerd

Could you add an option to let a message open a link, if you click it or display more information if you hover it?

You can use this api, which is already included in spigoti: https://www.spigotmc.org/wiki/the-chat-component-api/

TealNerd commented 8 years ago

you want me to just add some nice methods into the CivMenuAPI class to easily make TextComponents like below?

public static TextComponent makeLinkComponent(String text, String link, String hoverText, boolean italic, boolean bold, boolean obfuscated, boolean strikethrough, ChatColor color) {
        TextComponent component = new TextComponent(text);
        component.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, link));
        component.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(hoverText).create()));
        component.setItalic(italic);
        component.setBold(bold);
        component.setObfuscated(obfuscated);
        component.setStrikethrough(strikethrough);
        component.setColor(color);
        return component;
}
Maxopoly commented 8 years ago

Yeah

Maxopoly commented 8 years ago

Or actually could you just allow specifying that in the config additionally to the text? Also add a default that reflects the current behavior so the options only have to be specified if you need them

TealNerd commented 8 years ago

I'm a little confused where exactly do you want this to be configured? Are we talking about in the TsS message where you can link the ToS?

    @CivConfig(name = "terms.link", def = "http://www.google.com", type = CivConfigType.String),
    @CivConfig(name = "terms.linkMessage" , def = "You can click this message to open up the terms of service.", type = CivConfigType.String),

do you just want me to add a terms.linkHover?

Maxopoly commented 8 years ago

No, not related to terms at all

I want to be able to make a config like this and just have it work:

http://pastebin.com/3mVMZ7xf

TealNerd commented 8 years ago

currently you can specify a documentation url for a plugin as a whole, but i'll add functionality so you can add a response specific url as well to override the plugin url

Maxopoly commented 8 years ago

Ok, thanks

TealNerd commented 8 years ago

@Maxopoly so @rourke750 and I were talking about making this entirely config based and not making it a dependency in all our other plugins. To do this we think the best way is to override the plugin manager and getting the event from the callEvent method (you can't listen for a generic event it's dumb tbh). So then the issue is how do you get, say, a player out of an event? So we're thinking maybe allow you to define the method/field in the config and using reflection. Thoughts on if this is a good idea and/or how we could improve it?

Maxopoly commented 8 years ago

What would be the advantage of this? Sounds overly complicated imo. How would this work with custom messages that are not associated with an event?

TealNerd commented 8 years ago

What custom messages would there be not associated with events?

Maxopoly commented 8 years ago

Many. For example in FM when someone is creating a factory and he has the wrong block setup I have a help message describing exactly what it should look like or if he inputs the wrong materials I have a help message leading to the docu.

Pretty much none of the stuff I did was bound to events, I used custom names for everything and had like 12 messages just in the method for factory creation.

TealNerd commented 8 years ago

Ok well there goes that idea

Maxopoly commented 8 years ago

https://github.com/Civcraft/CivMenu/commit/a9bc3ea98e2eca1107c5d8eb49f5833e69d8c4a0