@@ -133,7 +133,6 @@ public void onDisconnect(PlayerDisconnectEvent event) {
133133 UUID uuid = event .getPlayer ().getUniqueId ();
134134
135135 for (QueueType type : QueueType .values ()) {
136- type .getQueueMap ().remove (uuid );
137136 type .getPositionCache ().remove (uuid );
138137 }
139138 }
@@ -187,44 +186,42 @@ private void moveVeteran(boolean canMoveRegular) {
187186 }
188187
189188 private void connectPlayer (QueueType type ) {
190- Optional <Entry <UUID , String >> optional = type .getQueueMap ().entrySet ().stream ().findFirst ();
191- if (!optional .isPresent ())
192- return ;
189+ for (Entry <UUID , String > entry : type .getQueueMap ().entrySet ()) {
190+ ProxiedPlayer player = plugin .getProxy ().getPlayer (entry .getKey ());
191+ if (player == null || !player .isConnected ()) {
192+ continue ;
193+ }
193194
194- Entry <UUID , String > entry = optional .get ();
195- ProxiedPlayer player = plugin .getProxy ().getPlayer (entry .getKey ());
195+ type .getQueueMap ().remove (entry .getKey ());
196196
197- type .getQueueMap ().remove (entry .getKey ());
198- if (player == null || !player .isConnected ())
199- return ;
197+ player .sendMessage (ChatMessageType .CHAT , ChatUtils .parseToComponent (Config .JOININGMAINSERVER .replace ("%server%" , entry .getValue ())));
198+ player .resetTabHeader ();
200199
201- player .sendMessage (ChatMessageType .CHAT , ChatUtils .parseToComponent (Config .JOININGMAINSERVER .replace ("%server%" , entry .getValue ())));
202- player .resetTabHeader ();
200+ if (StorageTool .isShadowBanned (player )
201+ && (plugin .getBanType () == BanType .LOOP
202+ || (plugin .getBanType () == BanType .TENPERCENT && new Random ().nextInt (100 ) >= 10 ))) {
203+ player .sendMessage (ChatMessageType .CHAT , ChatUtils .parseToComponent (Config .SHADOWBANMESSAGE ));
203204
204- if (StorageTool .isShadowBanned (player )
205- && (plugin .getBanType () == BanType .LOOP
206- || (plugin .getBanType () == BanType .TENPERCENT && new Random ().nextInt (100 ) >= 10 ))) {
207- player .sendMessage (ChatMessageType .CHAT , ChatUtils .parseToComponent (Config .SHADOWBANMESSAGE ));
205+ type .getQueueMap ().put (entry .getKey (), entry .getValue ());
208206
209- type .getQueueMap ().put (entry .getKey (), entry .getValue ());
207+ return ;
208+ }
210209
211- return ;
212- }
210+ indexPositionTime ();
213211
214- indexPositionTime ( );
212+ List < Pair < Integer , Instant >> cache = type . getPositionCache (). get ( entry . getKey () );
215213
216- List <Pair <Integer , Instant >> cache = type .getPositionCache ().get (entry .getKey ());
214+ if (cache != null ) {
215+ cache .forEach (pair -> type .getDurationToPosition ().put (pair .getLeft (), Duration .between (pair .getRight (), Instant .now ())));
216+ }
217217
218- if (cache != null ) {
219- cache .forEach (pair -> type .getDurationToPosition ().put (pair .getLeft (), Duration .between (pair .getRight (), Instant .now ())));
218+ player .connect (plugin .getProxy ().getServerInfo (entry .getValue ()), (result , error ) -> {
219+ if (Config .RECOVERY && !Boolean .TRUE .equals (result )) {
220+ player .sendMessage (ChatMessageType .CHAT , ChatUtils .parseToComponent (Config .RECOVERYMESSAGE ));
221+ type .getQueueMap ().put (entry .getKey (), entry .getValue ());
222+ }
223+ });
220224 }
221-
222- player .connect (plugin .getProxy ().getServerInfo (entry .getValue ()), (result , error ) -> {
223- if (Config .RECOVERY && !Boolean .TRUE .equals (result )) {
224- player .sendMessage (ChatMessageType .CHAT , ChatUtils .parseToComponent (Config .RECOVERYMESSAGE ));
225- type .getQueueMap ().put (entry .getKey (), entry .getValue ());
226- }
227- });
228225 }
229226
230227 private void putQueueAuthFirst (ProxiedPlayer player , List <String > header , List <String > footer , Map <UUID , String > queueMap ) {
0 commit comments