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

Finish Tab-Completion Handling #99

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

yodarocks1
Copy link

Documentation

Action: tab_complete

Adds, removes, or otherwise changes the tab completion options returned to the player.

Usage: tab_complete: [<mode>;][<option1>[,<option2>[,<option3>[...]]]]

Where mode is one of: remove, clear, set, add.

Mode examples

Mode: add (default)

Add tab completion options for spawn and fortress. (No semicolon ⇒ add mode)

- "tab_complete: spawn,fortress"
Mode: remove

Remove options for an Acacia Boat or a Bee:

- "tab_complete: remove;minecraft:acacia_boat,minecraft:bee"
Mode: clear

Clear tab completion options. (Note that there must be a semicolon after the keyword)

- "tab_complete: clear;"
Mode: set

Set tab completion options to only an Armor Stand and Area Effect Cloud:

- "tab_complete: set;minecraft:armor_stand,minecraft:area_effect_cloud"

Full example & use case

Allow players without the conditionalevents.fullsummon permission to still summon Item Display and Text Display entities.

Events:
  allow_some_summons:
    type: player_command
    ignore_with_permission: conditionalevents.fullsummon
    conditions:
    - '%maincommand% equalsIgnoreCase /summon'
    - '%arg_1% == minecraft:item_display execute allow'
    - '%arg_1% == minecraft:item_display execute allow'
    actions:
      default:
      - 'jsonmessage: {"text": "You can only summon Item Displays and Text Displays","color":"red"}'
      - 'cancel_event: true'
      allow:
      - 'playsound: ENTITY_PLAYER_TELEPORT;10;1'

But, of course, their /summon tab-complete is still cluttered with everything else. So, let's change that:

  allow_some_summons_tab_complete:
    type: player_tab_complete_event
    ignore_with_permission: conditionalevents.fullsummon
    conditions:
    - '%command% equalsIgnoreCase /summon'
    actions:
      default:
      - "tab_complete: set;minecraft:item_display,minecraft:text_display"

Easy as that!


Action: show_command

Adds a root command to the player's client-side list, making it show up as a valid option during tab completion. Registering the command should be preferred, as it will not show up in the /help menu.

Usage: show_command: <command1>[;<command2>[;<command3>[...]]]

E.g. show_command: hello;john will make /hello and /john appear as valid options when typed by the player, but will not add any functionality to them.


Action: hide_command

Removes a command from the player's client-side list, making it appear to be invalid during tab completion. Deregistering the command or blocking it out with permissions should be preferred, as it will still show up in the /help menu.

Usage: hide_command: <command1>[;<command2>[;<command3>[...]]]

E.g. hide_command: help will make /help appear as an invalid option when typed by the player (red italics), but it will still function normally when run. If you want to stop the command from working, also include a player_command event with a cancel_event action.

Changes

listeners/PlayerEventsListener.java

  • Finished the onTabComplete function.
  • Added the onCommandSend function.

model/EventType.java

  • Added the PLAYER_SEND_COMMAND_EVENT event type

model/ActionType.java

  • Added the TAB_COMPLETION_OPTION action
  • Added the HIDE_COMMAND action
  • Added the SHOW_COMMAND action

model/internal/ExecutedEvent.java

  • Directed TAB_COMPLETION_OPTION to ActionUtils.addTabCompleteOption
  • Directed HIDE_COMMAND to ActionUtils.hideCommand
  • Directed SHOW_COMMAND to ActionUtils.showCommand

utils/ActionUtils.java

  • Added the addTabCompleteOption function
  • Added the hideCommand function
  • Added the showCommand function

Note

I do not have a good way to reliably build or lint this code at the moment. As such, there is a high probability that I missed a semicolon or an import somewhere, and such file will need minor repairs. There is also a decent probability that I misunderstood the purpose of, or simply overlooked an import or usage, and therefore more major repairs will be necessary.

En Español

Documentación

Acción: tab_complete

Agrega, elimina o cambia de alguna otra forma las opciones de finalización de tabulación que se le devuelven al jugador.

Uso: tab_complete: [<modo>;][<opción1>[,<opción2>[,<opción3>[...]]]]

modo es: remove, clear, set, add.

Ejemplos de `modo`

Modo: add (por omisión)

Agrega opciones de la tecla tab para spawn y fortress. (Sin el punto y coma ⇒ modo add)

- "tab_complete: spawn,fortress"
Modo: remove

Eliminar opciones por una Barca de Acacia o una Abeja:

- "tab_complete: remove;minecraft:acacia_boat,minecraft:bee"
Modo: clear

Borrar las opciones de la tecla tab. (Ten en cuenta que debe haber un punto y coma después de la palabra clave)

- "tab_complete: clear;"
Modo: set

Establecer las opciones de la tecla tab solo para el Soporte Para Armadura y la Nube de Efectos de Área:

- "tab_complete: set;minecraft:armor_stand,minecraft:area_effect_cloud"

Ejemplo completo y caso de uso

Permitir que los jugadores sin el permiso conditionalevents.fullsummon sigan invocando entidades de Objecto Holográfico y Texto Holográfico.

Events:
  allow_some_summons:
    type: player_command
    ignore_with_permission: conditionalevents.fullsummon
    conditions:
    - '%maincommand% equalsIgnoreCase /summon'
    - '%arg_1% == minecraft:item_display execute allow'
    - '%arg_1% == minecraft:item_display execute allow'
    actions:
      default:
      - 'jsonmessage: {"text": "You can only summon Item Displays and Text Displays","color":"red"}'
      - 'cancel_event: true'
      allow:
      - 'playsound: ENTITY_PLAYER_TELEPORT;10;1'

Pero, por supuesto, su pestaña de autocompletar (gracias, Google Translate!) /summon todavía está abarrotada de todo lo demás. Entonces, cambiemos eso:

  allow_some_summons_tab_complete:
    type: player_tab_complete_event
    ignore_with_permission: conditionalevents.fullsummon
    conditions:
    - '%command% equalsIgnoreCase /summon'
    actions:
      default:
      - "tab_complete: set;minecraft:item_display,minecraft:text_display"

Acción: show_command

Agrega un comando a la lista del lado del cliente del jugador, haciendo que aparezca como una opción válida en la pestaña de autocompletar. Se recomienda registrar el comando, ya que no aparecerá en el menú /help.

Uso: show_command: <comando1>[;<comando2>[;<comando3>[...]]]

Por ejemplo: show_command: hello;john hará que /hello y /john aparezcan como opciones válidas cuando el jugador las escriba, pero no les agregará ninguna funcionalidad.


Acción: hide_command

Elimina un comando de la lista del lado del cliente del jugador, lo que hace que parezca inválido en la pestaña de autocompletar. Sería preferible anular el registro del comando o bloquearlo con permisos, ya que seguirá apareciendo en el menú /help.

Uso: hide_command: <comando1>[;<comando2>[;<comando3>[...]]]

Por ejemplo, hide_command: help hará que /help aparezca como una opción inválida cuando el jugador la escriba (cursiva roja), pero seguirá funcionando normalmente cuando se ejecute. Si desea que el comando deje de funcionar, incluya también un evento player_command con una acción cancel_event.

Cambios

listeners/PlayerEventsListener.java

  • Se terminó la función onTabComplete.
  • Se agregó la función onCommandSend.

model/EventType.java

  • Se agregó el tipo de evento PLAYER_SEND_COMMAND_EVENT

model/ActionType.java

  • Se agregó la acción TAB_COMPLETION_OPTION
  • Se agregó la acción HIDE_COMMAND
  • Se agregó la acción SHOW_COMMAND

model/internal/ExecutedEvent.java

  • Se dirigió TAB_COMPLETION_OPTION a ActionUtils.addTabCompleteOption
  • Se dirigió HIDE_COMMAND a ActionUtils.hideCommand
  • Se dirigió SHOW_COMMAND a ActionUtils.showCommand

utils/ActionUtils.java

  • Se agregó la función addTabCompleteOption
  • Se agregó la función hideCommand
  • Se agregó la función showCommand

Nota

No tengo una buena manera de compilar o anlizar este código. Entonces, existe una gran probabilidad de que haya pasado por alto un punto y coma o una importación, y ese archivo necesitara reparaciones menores. También existe una probabilidad considerable de que haya entendido mal el propósito de, o simplemente haya pasado por alto una importación o uso, y entonces serán necesarias reparaciones más importantes.

Let me know if you have any questions or suggestions.

@Ajneb97
Copy link
Owner

Ajneb97 commented Oct 31, 2024

Thanks, I will work on it!

Ajneb97 and others added 2 commits October 31, 2024 11:49
- Not fully tested yet.
- I removed the show_command and hide_command actions since CE already has the register_commands options (at least temporarily)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants