Skip to content

feat: extra placeholders#156

Merged
MisterJulsen merged 3 commits intoMisterJulsen:mc/1.20.1-C6-DL3from
C1200:placeholders
Mar 19, 2026
Merged

feat: extra placeholders#156
MisterJulsen merged 3 commits intoMisterJulsen:mc/1.20.1-C6-DL3from
C1200:placeholders

Conversation

@C1200
Copy link
Copy Markdown
Contributor

@C1200 C1200 commented Feb 27, 2026

On top of the already existing %time% placeholder, this PR adds:

  • Generic placeholders
    • day - the current in-game day
  • On-board placeholders
    • via - a comma separated list of all stopovers
    • line - the train name or, if defined, the line name
    • carriages - the amount of carriages this train has
    • origin. (where the train started its journey) OR
      destination. (where the train will end its journey) OR
      next. (the next stop, includes the destination) OR
      stopN. (the following stops, where N=0 is the next stop, excludes the destination), followed by:
      • station_name - the arrival station
      • platform - the arrival platform number
      • arrival - arrival time in in-game hh:mm format
      • departure - departure time in in-game hh:mm format
      • arrival_eta - arrival time as an eta
      • departure_eta - departure time as an eta
  • Station placeholders
    • trainN., followed by:
      • station_name - the arrival station
      • platform - the arrival platform number
      • arrival - arrival time in in-game hh:mm format
      • departure - departure time in in-game hh:mm format
      • arrival_eta - arrival time as an eta
      • departure_eta - departure time as an eta
      • via - a comma separated list of all stopovers
      • line - the train name or, if defined, the line name
      • origin - where the train started its journey
      • destination - where the train will end its journey
      • carriages - the amount of carriages a train has
      • stopN - the following stops, where N=0 is the next stop

Todo:

  • fix carriages placeholder only showing 0 on station displays (help would be appreciated, i dont know what ive done wrong)

@MisterJulsen
Copy link
Copy Markdown
Owner

I like the choice of placeholders, especially the stopN placeholders!

I would suggest a small change in the BasicTrainDisplayData class, in the method public static BasicTrainDisplayData of(TrainStop stop).
There, you've retrieved carriages from the TrainStop class. It would be cleaner and simpler to use the TrainData class directly, which is available in the Optional provided by the TrainListener. TrainListener.getTrainData(stop.getTrainId()).map(data -> { ... }

Like this:

return new BasicTrainDisplayData(
    stop.getTrainId(),
    stop.getTrainIcon(),
    new ArrayList<>(data.getStatus()),
    data.isCancelled(),
    dataByState,
    data.getTrain().carriages.size() // <---
);

Regarding the problem with the carriages placeholder: 0 is displayed as long as the train isn't initialized in CRN. You're trying to get the Train class from the CRN TrainData class, which is obtained using TrainListener.getTrainData(stop.getTrainId()). However, the TrainListener doesn't contain any entries for trains, which CRN doesn't work with. If not data is available, the empty() method is used. That's where the 0 comes from.

A different approach would be necessary, maybe directly retrieving the Train class from the GlobalRailwayManager using the Train UUID. It should be doable, though.

@C1200
Copy link
Copy Markdown
Contributor Author

C1200 commented Mar 5, 2026

there wasnt actually an issue with the carriages placeholder, the issue was is that i forgot the train0 bit at the start so it was using the train-only implementation of that placeholder

i should probably try make it so train-only placeholders can't be used on station displays and vice versa

@C1200 C1200 marked this pull request as ready for review March 5, 2026 16:56
@MisterJulsen
Copy link
Copy Markdown
Owner

I fixed the issue with the carriages, because I think it would've been confusing if it remains at 0. Otherwise, I really like the new placeholders :)

@MisterJulsen MisterJulsen merged commit b7afdf1 into MisterJulsen:mc/1.20.1-C6-DL3 Mar 19, 2026
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