Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added /wiki chat command. #1024

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

AbdielKavash
Copy link
Member

@AbdielKavash AbdielKavash commented Oct 9, 2024

The /wiki chat command allows the player to instantly access the GTNH wiki from the game, and search for specific topics (for example, information about blocks or game features).

Planned options:

  • /wiki - Opens the wiki main page.
  • /wiki <topic> - Searches the wiki for the specified topic. For example, /wiki EBF takes you to https://wiki.gtnewhorizons.com/wiki/Electric_Blast_Furnace.
  • /wiki hand - Searches the wiki for the item currently held in the player's hand.
  • /wiki block - Searches the wiki for the block the player is currently looking at.
  • Enable/disable command via config.
  • Read URLs for search from config (let's say someone wants to use this is a different pack)
  • Sanitize inputs better for characters not valid in URLs.

First two variants are already implemented; the other two are WIP. Any comments/feedback/suggestions are welcome.

Wiki page is open in the player's default browser. The command respects the "Prompt on links" option from vanilla.

java_0uLiTPvOih.mp4

@Dream-Master Dream-Master requested a review from a team October 9, 2024 12:32
@@ -559,5 +560,6 @@ public void serverLoad(FMLServerStartingEvent pEvent) {
if (YAMCore.isDebug()) {
pEvent.registerServerCommand(new AllPurposeDebugCommand());
}
pEvent.registerServerCommand(new WikiCommand());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you need to make it a client command, not a server command otherwise it will crash
register your command in the init block of the client proxy using ClientCommandHandler.instance.registerCommand();


public class WikiCommand implements ICommand {

private List aliases;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't need to allocate a field you can just do

    @Override
    public String getCommandName() {
        return Collections.singletonList("wiki");
    }


@Override
public void processCommand(ICommandSender pCmdSender, String[] pArgs) {
if (!(pCmdSender instanceof EntityPlayerMP)) return;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't need that line once you register on the client command handler

import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayerMP;

public class WikiCommand implements ICommand {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can extend CommandBase instead of ICommand and remove some of the methods you implemented that are the same as the vanilla command base

@Alexdoru
Copy link
Member

Alexdoru commented Oct 9, 2024

also you need to think about adding tabcompletion options so that it's easier to use and we can see everything that's available

@OlliedeLeeuw
Copy link

Looks like a nice addition to the wiki!

@AbdielKavash
Copy link
Member Author

AbdielKavash commented Oct 10, 2024

Looks like a nice addition to the wiki!

One of my goals is to encourage a positive feedback loop: players will have easier access to the wiki, they will see articles that are missing or incomplete or outdated, complain about them on discord, which gives us a chance to fix the wiki. Everyone wins!

@Steelux8
Copy link
Contributor

The more options you add for the command, the higher likelihood of the player stumbling upon more and more pages that don't exist. Having the options is nice, but I'm still not sure about the expectation of /wiki hand or /wiki block returning an empty page most of the time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants