@@ -47,27 +47,17 @@ public void onNitroAdd(NitroUserAddEvent event) {
4747 // Print amount of commands to be executed
4848 Bukkit .getConsoleSender ()
4949 .sendMessage ("[Nitro] Executing " + commandsToExecute .length + " command(s)" );
50- // Execute commands
51- if (commandsToExecute .length == 1 ) {
52- Bukkit .getServer ()
53- .dispatchCommand (Bukkit .getConsoleSender (), commandsToExecute [0 ].replace ("%s" , parts [2 ]));
54- } else {
55- Bukkit .getScheduler ()
56- .runTaskLater (
57- plugin ,
58- () ->
59- Bukkit .getServer ()
60- .dispatchCommand (
61- Bukkit .getConsoleSender (), commandsToExecute [0 ].replace ("%s" , parts [2 ])),
62- 20 * 2 );
63- Bukkit .getScheduler ()
64- .runTaskLater (
65- plugin ,
66- () ->
67- Bukkit .getServer ()
68- .dispatchCommand (
69- Bukkit .getConsoleSender (), commandsToExecute [1 ].replace ("%s" , parts [2 ])),
70- 20 * 4 );
50+ // Print the commands
51+ for (int i = 0 ; i < commandsToExecute .length ; i ++) {
52+ Bukkit .getConsoleSender ()
53+ .sendMessage ("[Nitro] Command " + (i + 1 ) + ": " + commandsToExecute [i ]);
54+ // If the command contains the placeholder %s, replace it with the player's name
55+ if (commandsToExecute [i ].contains ("%s" )) {
56+ Bukkit .dispatchCommand (
57+ Bukkit .getConsoleSender (), commandsToExecute [i ].replace ("%s" , parts [2 ]));
58+ } else {
59+ Bukkit .dispatchCommand (Bukkit .getConsoleSender (), commandsToExecute [i ]);
60+ }
7161 }
7262 api .getConfig ().save (plugin .getConfig ());
7363 plugin .saveConfig ();
@@ -103,27 +93,16 @@ public void onNitroRemove(NitroUserRemoveEvent event) {
10393 // Print amount of commands to be executed
10494 Bukkit .getConsoleSender ()
10595 .sendMessage ("[Nitro] Executing " + commandsToExecute .length + " command(s)" );
106- // Execute commands
107- if (commandsToExecute .length == 1 ) {
108- Bukkit .getServer ()
109- .dispatchCommand (Bukkit .getConsoleSender (), commandsToExecute [0 ].replace ("%s" , parts [2 ]));
110- } else {
111- Bukkit .getScheduler ()
112- .runTaskLater (
113- plugin ,
114- () ->
115- Bukkit .getServer ()
116- .dispatchCommand (
117- Bukkit .getConsoleSender (), commandsToExecute [0 ].replace ("%s" , parts [2 ])),
118- 20 * 2 );
119- Bukkit .getScheduler ()
120- .runTaskLater (
121- plugin ,
122- () ->
123- Bukkit .getServer ()
124- .dispatchCommand (
125- Bukkit .getConsoleSender (), commandsToExecute [1 ].replace ("%s" , parts [2 ])),
126- 20 * 4 );
96+ // Print the commands
97+ for (int i = 0 ; i < commandsToExecute .length ; i ++) {
98+ Bukkit .getConsoleSender ()
99+ .sendMessage ("[Nitro] Command " + (i + 1 ) + ": " + commandsToExecute [i ]);
100+ if (commandsToExecute [i ].contains ("%s" )) {
101+ Bukkit .dispatchCommand (
102+ Bukkit .getConsoleSender (), commandsToExecute [i ].replace ("%s" , parts [2 ]));
103+ } else {
104+ Bukkit .dispatchCommand (Bukkit .getConsoleSender (), commandsToExecute [i ]);
105+ }
127106 }
128107 api .getConfig ().removeNitro (event .getUser ());
129108 api .getConfig ().save (plugin .getConfig ());
0 commit comments