44import fr .maxlego08 .essentials .ZEssentialsPlugin ;
55import fr .maxlego08 .essentials .api .configuration .NonLoadable ;
66import fr .maxlego08 .essentials .module .ZModule ;
7+ import fr .maxlego08 .menu .api .requirement .Action ;
8+ import fr .maxlego08 .menu .api .utils .Placeholders ;
79import org .bukkit .configuration .file .YamlConfiguration ;
810
911import java .util .ArrayList ;
@@ -40,11 +42,17 @@ public void loadConfiguration() {
4042
4143 YamlConfiguration configuration = getConfiguration ();
4244 List <Map <?, ?>> messagesList = configuration .getMapList ("messages" );
45+ int index = 0 ;
4346 for (Map <?, ?> map : messagesList ) {
4447 List <String > lines = (List <String >) map .get ("lines" );
4548 if (lines != null ) {
46- this .autoMessages .add (new AutoMessage (lines ));
49+ List <Map <String , Object >> actionElements = (List <Map <String , Object >>) map .get ("actions" );
50+ List <Action > actions = actionElements != null
51+ ? this .plugin .getButtonManager ().loadActions (actionElements , "messages[" + index + "].actions" , getConfigurationFile ())
52+ : new ArrayList <>();
53+ this .autoMessages .add (new AutoMessage (lines , actions ));
4754 }
55+ index ++;
4856 }
4957
5058 if (this .isEnable && !this .autoMessages .isEmpty () && this .interval > 0 ) {
@@ -63,13 +71,17 @@ private void broadcastNextMessage() {
6371 this .currentIndex = (this .currentIndex + 1 ) % this .autoMessages .size ();
6472 }
6573
74+ var fakeInventory = this .plugin .getInventoryManager ().getFakeInventory ();
6675 for (var player : this .plugin .getServer ().getOnlinePlayers ()) {
6776 for (String line : message .lines ()) {
6877 this .componentMessage .sendMessage (player , line );
6978 }
79+ for (Action action : message .actions ()) {
80+ action .preExecute (player , null , fakeInventory , new Placeholders ());
81+ }
7082 }
7183 }
7284
73- private record AutoMessage (List <String > lines ) {
85+ private record AutoMessage (List <String > lines , List < Action > actions ) {
7486 }
7587}
0 commit comments