Slimefun4 icon indicating copy to clipboard operation
Slimefun4 copied to clipboard

feat: allow addons to add wiki pages to items

Open ybw0014 opened this issue 2 years ago • 33 comments
trafficstars

Description

Nowadays there are more and more Slimefun addons, but only Slimefun items can have the wiki item in the recipe display. Some addons already have wiki, but players may not be able to know the wiki's existence, unless the developer add the wiki link via FlexItemGroup or using other ways. I think the wiki page item should be available to all the items that have wiki for them.

Tested with https://github.com/Sefiraat/Networks/pull/152.

Proposed changes

  • Add getWikiURL() in SlimefunAddon to provide a base URL for addon wiki.
  • Add getWikiPage(String) in SlimefunItem to allow items to have wiki pages.
  • Deprecate addOfficialWikipage in favor of getWikiPage.
  • Display a different wiki icon for all addons.
  • Move the code that setups wiki from wiki.json to WikiUtils.

Related Issues (if applicable)

N/A

Checklist

  • [x] I have fully tested the proposed changes and promise that they will not break everything into chaos.
  • [x] I have also tested the proposed changes in combination with various popular addons and can confirm my changes do not break them.
  • [x] I have made sure that the proposed changes do not break compatibility across the supported Minecraft versions (1.16.* - 1.20.*).
  • [x] I followed the existing code standards and didn't mess up the formatting.
  • [x] I did my best to add documentation to any public classes or methods I added.
  • [x] I have added Nonnull and Nullable annotations to my methods to indicate their behaviour for null values
  • [x] I added sufficient Unit Tests to cover my code.

ybw0014 avatar Aug 06 '23 01:08 ybw0014

Pro Tip! You can help us label your Pull Requests by using the following branch naming convention next time you create a pull request. ❤️

Branch naming convention Label
feature/** 🎈 Feature
fix/** ✨ Fix
chore/** 🧹 Chores
api/** 🔧 API
performance/** 💡 Performance Optimization
compatibility/** 🤝 Compatibility

If your changes do not fall into any of these categories, don't worry. You can just ignore this message in that case! 👀

github-actions[bot] avatar Aug 06 '23 01:08 github-actions[bot]

Slimefun preview build

A Slimefun preview build is available for testing! Commit: 663c9a1c

https://preview-builds.walshy.dev/download/Slimefun/3937/663c9a1c

Note: This is not a supported build and is only here for the purposes of testing. Do not run this on a live server and do not report bugs anywhere but this PR!

github-actions[bot] avatar Aug 06 '23 01:08 github-actions[bot]

I like the idea but limiting the addon to be under one url + a placeholder imo isn't ideal. If there was a way to add a full link to an item on top of this I think it would be a good addition

Yea i agree with this, maybe we can have the wiki link be defaulted to the repo as how you have it now but allow it to be overridable with custom links. this will allow sites like gitbook to be used

J3fftw1 avatar Aug 06 '23 08:08 J3fftw1

For anyone would like to test this build using the preview jar, here is the modified Networks that utilized the methods added in this PR. Download link: https://cloud.ybw0014.net/s/PwTr (my own cloudreve instance) If you want to compile it by yourself, the PR link is here: https://github.com/Sefiraat/Networks/pull/152

ybw0014 avatar Aug 06 '23 18:08 ybw0014

I'm not fully opposed to giving a way to provide wiki links for addons.

However...

Arbitrary links doesn't feel good. Domains will be bought, not renewed and snatched by others. I think we need to figure out the right approach to this rather than just throw this out there. We do not want to be the ones responsible for someone getting malware on their system or seeing adult material due to a snatched domain.

Maybe add a warning message before sending the link in the chat?

ybw0014 avatar Aug 07 '23 02:08 ybw0014

Warnings don’t mean much and are almost always ignored

J3fftw1 avatar Aug 07 '23 04:08 J3fftw1

Warnings don’t mean much and are almost always ignored

It is the player's choice to ignore the warning.

ybw0014 avatar Aug 07 '23 13:08 ybw0014

i dont think this is the right approach we will still be kept accountable if someone gets a virus or something else. I do really like this feature, but i do agree with Walshy completely

J3fftw1 avatar Aug 07 '23 13:08 J3fftw1

Maintaining a list of trusted wiki domain names could be a compromise, since no official addon wiki provided.

StarWishsama avatar Aug 07 '23 13:08 StarWishsama

Is creating a second repository for all addons an option?

On 8/7/23, NoRainCity @.***> wrote:

Maintaining a list of trusted wiki domain names could be a compromise, since no official addon wiki provided.

-- Reply to this email directly or view it on GitHub: https://github.com/Slimefun/Slimefun4/pull/3937#issuecomment-1667893532 You are receiving this because you are subscribed to this thread.

Message ID: @.***>

Phoenix-Starlight avatar Aug 07 '23 15:08 Phoenix-Starlight

Whoops miss clicked

J3fftw1 avatar Aug 07 '23 15:08 J3fftw1

I'm not fully opposed to giving a way to provide wiki links for addons.

However...

Arbitrary links doesn't feel good. Domains will be bought, not renewed and snatched by others. I think we need to figure out the right approach to this rather than just throw this out there. We do not want to be the ones responsible for someone getting malware on their system or seeing adult material due to a snatched domain.

Sf could have a list of whitelisted links, GitHub, gitbook and other docs hosting platforms. In addition to a warn that the files hosted are not officially by slimefun and made by the addon developer if that makes sense.

PhoenixCodingStuff avatar Aug 07 '23 15:08 PhoenixCodingStuff

I'm not fully opposed to giving a way to provide wiki links for addons.

However...

Arbitrary links doesn't feel good. Domains will be bought, not renewed and snatched by others. I think we need to figure out the right approach to this rather than just throw this out there. We do not want to be the ones responsible for someone getting malware on their system or seeing adult material due to a snatched domain.

Sf could have a list of whitelisted links, GitHub, gitbook and other docs hosting platforms. In addition to a warn that the files hosted are not officially by slimefun and made by the addon developer if that makes sense.

PhoenixCodingStuff avatar Aug 07 '23 15:08 PhoenixCodingStuff

I'd like @TheBusyBiscuit's views too

GitHub only definitely helps limit the scope. It doesn't solve the issue but it does help + I like the additional messaging.

WalshyDev avatar Aug 07 '23 16:08 WalshyDev

I remember this being hard denied in the past.

J3fftw1 avatar Aug 07 '23 16:08 J3fftw1

Yeah I submitted a PR before: https://github.com/Slimefun/Slimefun4/pull/3397

ybw0014 avatar Aug 07 '23 16:08 ybw0014

I will add a "wiki control panel" for server owners to control what wiki link the players can access.

ybw0014 avatar Aug 07 '23 19:08 ybw0014

I will add a "wiki control panel" for server owners to control what wiki link the players can access.

Thanks for being a good sport while this is all being discussed Yb. Appreciated <3

Sefiraat avatar Aug 07 '23 19:08 Sefiraat

I will add a "wiki control panel" for server owners to control what wiki link the players can access.

I feel like if we opt for a control panel it should be a general control panel for various settings concerning addons, not just wiki-specific. Perhaps it may be a good idea to put this PR on hold for now and create such a panel first and then come back to this?

TheBusyBiscuit avatar Aug 07 '23 19:08 TheBusyBiscuit

I will add a "wiki control panel" for server owners to control what wiki link the players can access.

I feel like if we opt for a control panel it should be a general control panel for various settings concerning addons, not just wiki-specific. Perhaps it may be a good idea to put this PR on hold for now and create such a panel first and then come back to this?

Anything u can come up with that should be in the panel besides addon wiki control?

ybw0014 avatar Aug 07 '23 23:08 ybw0014

Would still love this feature. its now getting stale and definitely since cookie is gone and isnt looking into this anymore.

Minecraft has its own warning system already inplace for external links, If that fires im fine with this being in place.

J3fftw1 avatar Dec 31 '23 09:12 J3fftw1

Minecraft has its own warning system already inplace for external links, If that fires im fine with this being in place.

Slimefun displays a message that contains the link when you click on the wiki button, so that will be fired.

ybw0014 avatar Dec 31 '23 14:12 ybw0014

As I didnt get any response for panel thing, I just merged commits and resolved merge conflicts. As Jeff mentioned, Minecraft has its warning system, as we just send the link to users and users will be warned when they click on a link in the chat.

ybw0014 avatar Jan 06 '24 22:01 ybw0014

Have you tested this with an addon that uses this? Would love to see the button working.

J3fftw1 avatar Jan 07 '24 17:01 J3fftw1

Have you tested this with an addon that uses this? Would love to see the button working.

I tested this earlier with Networks (https://github.com/Sefiraat/Networks/pull/152), now I'm gonna test this again.

ybw0014 avatar Jan 07 '24 17:01 ybw0014

Just tested and it still works. However, the item name seems to be a bit long, should we move some parts into item lore?

image image

ybw0014 avatar Jan 07 '24 18:01 ybw0014

Yea let’s just call it wiki

J3fftw1 avatar Jan 07 '24 18:01 J3fftw1

Agreed with Jeff, the item name can be Wiki to make it smaller while the error message is shown in chat.

PhoenixCodingStuff avatar Jan 07 '24 18:01 PhoenixCodingStuff

I changed the wiki button name to 'View this item on the %addon% wiki', where %addon% will be replaced by addon name. And add a line to show if it is official Slimefun wiki, or third party wiki.

ybw0014 avatar Jan 07 '24 18:01 ybw0014

image image

ybw0014 avatar Jan 07 '24 18:01 ybw0014