@@ -47,17 +47,27 @@ 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- // 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- }
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 );
6171 }
6272 api .getConfig ().save (plugin .getConfig ());
6373 plugin .saveConfig ();
@@ -93,16 +103,27 @@ public void onNitroRemove(NitroUserRemoveEvent event) {
93103 // Print amount of commands to be executed
94104 Bukkit .getConsoleSender ()
95105 .sendMessage ("[Nitro] Executing " + commandsToExecute .length + " command(s)" );
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- }
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 );
106127 }
107128 api .getConfig ().removeNitro (event .getUser ());
108129 api .getConfig ().save (plugin .getConfig ());
0 commit comments