Skip to content

GH-930 Msg placeholders & Async placeholder for future #1203

Open
P1otrulla wants to merge 16 commits intomasterfrom
2.0/msg-placeholders
Open

GH-930 Msg placeholders & Async placeholder for future #1203
P1otrulla wants to merge 16 commits intomasterfrom
2.0/msg-placeholders

Conversation

@P1otrulla
Copy link
Member

@P1otrulla P1otrulla commented Oct 12, 2025

* Register new placeholders for `msg_toggle` and `socialspy_status` in `MsgPlaceholderSetup`.
* Extend `MsgMessages` with a `Placeholders` interface and implement language-specific placeholder formats in `ENMsgMessages` and `PLMsgMessages`.
* Add caching logic for `msg_toggle` state in `MsgPlaceholderSetup`.
* Introduce new formatted placeholders for `msg_toggle` and `socialspy_status`.
* Extend `MsgMessages.Placeholders` to support a loading state with translations.
…erAPI`

* Adjust cache duration in `MsgPlaceholderSetup` from 200ms to 5s.
* Rename `msg_toggle` placeholders to `msg_status` for consistency.
* Extend `ENPlaceholders` and `PLPlaceholders` with `OkaeriConfig`.
* Add `PlaceholderAPI` dependency in `runServer` task configuration.
* Replace existing cache in `MsgPlaceholderSetup` with `AsyncPlaceholderCached`.
* Introduce `AsyncPlaceholderCacheRegistry` for managing placeholder caches.
* Add `AsyncPlaceholderCacheController` to handle cache invalidation on player quit.
* Simplify placeholder logic and remove redundant caching methods.
…derCacheRegistry`

* Replace individual `stateCache` with dynamically registered cache in the `AsyncPlaceholderCacheRegistry`.
* Simplify placeholder setup logic and adjust `MsgToggleService` to utilize the registry for cache management.
…lidation

* Add `Subscribe` annotations to invalidate cache on `EternalReloadEvent` and `EternalShutdownEvent`.
* Rename `onEternalDisable` to `onDisable` and `onReload`.
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new asynchronous caching mechanism for placeholders and integrates it with the messaging feature. The changes include a new AsyncPlaceholderCacheRegistry and AsyncPlaceholderCached for managing async data loading, new placeholders for message and social spy status, and refactoring MsgToggleServiceImpl to use the new caching system. The overall implementation is good, but I've found a few areas for improvement. There's a race condition in AsyncPlaceholderCached that could lead to multiple concurrent loads for the same data, some code duplication in MsgPlaceholderSetup when defining similar placeholders, and a minor inconsistency in a comment in one of the message files. I've left specific comments with suggestions on how to address these points.

@P1otrulla P1otrulla changed the title Msg placeholders & Async placeholder for future GH-930 Msg placeholders & Async placeholder for future Oct 12, 2025
@P1otrulla P1otrulla requested a review from noyzys October 12, 2025 12:12
Copy link
Member

@noyzys noyzys left a comment

Choose a reason for hiding this comment

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

Jezeli cos niezrozumialego smialo pytac lub dawac wlasne propozycje zmian ;).
Wszystko mozna podkrecic i jezeli jest jakis problem nie sugerowac sie moimi zmianami bo zawsze jest jakies ala w trakcie review

@P1otrulla P1otrulla requested a review from Qbiterv October 12, 2025 22:37
@vLuckyyy vLuckyyy requested review from Rollczi and removed request for Qbiterv October 19, 2025 12:38
Copy link
Member

@Rollczi Rollczi left a comment

Choose a reason for hiding this comment

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

1 komentarz na razie bo może być dużo do przerobienia

@Rollczi
Copy link
Member

Rollczi commented Feb 21, 2026

nic się nie dzieje to zrobiłem commita

# Conflicts:
#	eternalcore-core/src/main/java/com/eternalcode/core/bridge/BridgeManager.java
#	eternalcore-core/src/main/java/com/eternalcode/core/bridge/placeholderapi/PlaceholderAPIPlaceholder.java
#	eternalcore-core/src/main/java/com/eternalcode/core/placeholder/PlaceholderBukkitRegistryImpl.java
#	eternalcore-core/src/main/java/com/eternalcode/core/placeholder/PlaceholderRaw.java
#	eternalcore-core/src/main/java/com/eternalcode/core/placeholder/PlaceholderRegistry.java
#	eternalcore-core/src/main/java/com/eternalcode/core/placeholder/PlaceholderReplacer.java
#	eternalcore-plugin/build.gradle.kts
Copy link
Member

@CitralFlo CitralFlo left a comment

Choose a reason for hiding this comment

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

-- Polish below --
For me using watcher is a little counterintuitive.
We are using cache in PlaceholderAsync, so maybe moving it to the PlaceholderSetup.class would be a better option.

My idea is creating a interface or abstract that needs to be implemented in PlaceholderSetup for AsyncPlaceholder. Instead of putting the watcher in Repo and then using Repo in setup class. I would suggest using predefined standards with cache (required) in class method for refresh and method used in Service that would update / call update for specific player. Additional fallback option that would display some text before accessing value in db ex. "Loading..." it would not be a problem if the player will get answer from server in next message - when placeholder is ready.

PL:
Tak jak patrze to i tak opiera sie na cache.
Może jakiś standard do tego cache i wołanie do placeholderów z update z serwisu, dodatkowo jakis fallback jakby nie bylo. Raczej nie problem jak sie wyswietli "Loading..." a potem poprawna wartosc w następnej wiadomości.
Tylko wiesz np jako abstract albo interfejs dla PlaceholderAsync. Że wymaga tego placeholder i wszystkie warunki do trzymania tych danych są spełnione
napisze to w review.

Image

}

static <T> Placeholder async(
String target,
Copy link
Member

Choose a reason for hiding this comment

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

I would rename target to sth like "placeholderName"

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.

Add a placeholder for the /msgtoggle command. i.e: %eternalcore_msgtoggle%

8 participants