Pixelmon Sidemod API - Bug tracker

[Trainer Commands 1.16.5-2.6.0] @pl target selector cannot accept further entity data pending

Ticket description:
Trainer Commands implements the @pl target selector which means "player that interacted with the pixelmon entity".
This provides the advantage over @p that the commands will always be executed on the right player (wheras with @p, a player could stand closer to the NPC than the interacting player, and the command would run on them instead).

Consider the following example - this is designed to give the interacting player a starter pokemon after interacting with an NPC. However, they will not receive additional starters by speaking to the NPC again, as they now have the tag "hasStarter":
Code: Select all/tedit add INTERACT execute at @pl[tag=!hasStarter] run starter @pl
/tedit add INTERACT tag @pl add hasStarter


Unfortunately, the implementation of @pl is achieved by text-replacing any instance of "@pl" with the interacting players username. This results in the first of the above commands attempting to run
Code: Select allexecute at Sophie847[tag=!hasStarter] run starter Sophie847

This is not a valid target selector - a playername selector cannot contain any trailing data. As such, the command fails, and an error is produced in logs:
Code: Select all[Server thread/INFO] [net.minecraft.server.MinecraftServer/]: Expected whitespace to end one argument, but found trailing data
[Server thread/INFO] [net.minecraft.server.MinecraftServer/]: ... Sophie847[tag=!hasStarter] run starter Sophie847<--[HERE]
[Server thread/INFO] [STDOUT/]: [com.pixelmonmod.trainercommands.events.CommandHandler:runCommand:98]: A permission error occurred running a command for TextComponent{text='Sophie847', siblings=[], style=Style{ color=null, bold=null, italic=null, underlined=null, strikethrough=null, obfuscated=null, clickEvent=null, hoverEvent=null, insertion=null, font=minecraft:default}} at -1537, 71, 210


If the above @pl target selectors are swapped to simple @p target selectors, the commands are able to run as expected (however, this runs the risk of running on the wrong player, as mentioned above).

Steps to reproduce the issue:
1. Open a world with pixelmon 9.1.2 and trainer commands 2.6.0 installed
2. Place down an NPC, give them the following command
Code: Select all/tedit add INTERACT execute at @pl[tag=!hasStarter] run starter @pl

3. Interact with this entity, the error above is produced.
4. Place a new NPC and give them the same command as step 2, but this time with @pl arguments swapped for @p arguments
Code: Select all/tedit add INTERACT execute at @p[tag=!hasStarter] run starter @p

5. Interact with this NPC. After a short delay, the starter menu is displayed.

My latest.log from reproducing these steps: https://pastebin.com/fbcqeWuV
This was tested with the official pixelmon modpack, version 9.1.2, with trainercommands 2.6.0 added. Forge version was 36.2.34

Comments

No comments have been made

Ticket details

  • Ticket ID: 19921
  • Project: Pixelmon Sidemod API
  • Status: Pending
  • Component: Trainer Commands
  • Project version: (unknown)
  • Priority: Normal
  • Severity: Normal
  • Forge/Sponge: Forge 36.2.34
  • What else would be useful to know?: Pixelmon modpack version 9.1.2
  • Assigned to: Sophie847
  • Reported by: Sophie847 (Send PM)
  • Reporter's tickets: (List all tickets)
  • Reported on: 19 Jan 2023 11:28
  • Ticket last visited by: WaifuJanna on 22 May 2023 06:34
JOIN THE TEAM