@@ -77,8 +77,6 @@ public abstract class AbstractRobot implements ISendable, SessionProvider, IOpti
7777 @ Setter
7878 protected @ Getter GameMode serverGamemode = GameMode .ADVENTURE ;
7979 @ Getter
80- private ChatMessageManager messageManager ;
81- @ Getter
8280 private BotManager botManager = BotManager .getInstance ();
8381 protected ProxyInfo proxyInfo ;
8482 protected @ Getter ProfileObject infoHelper = new ProfileObject ();
@@ -159,7 +157,6 @@ public void connect(){
159157 this .serverSession = new TcpClientSession (serverIP , serverPort , minecraftProtocol );
160158 }
161159
162- this .messageManager = new ChatMessageManager (this );
163160 this .serverSession .addListener ((IConnectListener ) event -> onJoin ());
164161 this .serverSession .addListener (new DisconnectReasonHandler (this ));
165162 this .serverSession .addListener (new ServerChatCommandHandler (this .commands ));
@@ -172,45 +169,12 @@ public void connect(){
172169 this .serverSession .connect (true , false );
173170
174171 this .connectDuration = System .currentTimeMillis ();
175- try {
176- boolean connect = true ;
177- boolean shouldWait = false ;
178-
179- while (true ) {
180- try {
181- Thread .sleep (20L );
182- if (!this .serverSession .isConnected ()){
183- this .connectDuration = System .currentTimeMillis ();
184- break ;
185- } else if (connect ) {
186- if (System .currentTimeMillis () - this .connectDuration > 100L ){
187- this .pluginManager .loadAllPlugins (this );
188- connect = false ;
189- }
190- } else if (!shouldWait ) {
191- if (this .messageManager .pollMessage ()) {
192- shouldWait = true ;
193- }
194- } else if (canSendMessages ()) {
195- shouldWait = false ;
196- }
197- }
198- catch (InterruptedException e ){
199- continue ;
200- } catch (IllegalArgumentException e ) {
201- TranslatableUtil .warnTranslatableOf (EnumSystemEvents .PACKET_ERROR , e );
202- } catch (Exception e ) {
203- TranslatableUtil .warnTranslatableOf (EnumSystemEvents .PLUGIN_ERROR , e );
204- }
205- }
206- } finally {
207- this .serverSession .disconnect ("" );
208- if (BotManager .getBotByProfileName (getProfileName ()) != null ){
209- scheduleReconnect ();
210- }
211- }
172+
173+ this .mainTickingEventLoop ();
212174 }
213175
176+ public abstract void mainTickingEventLoop ();
177+
214178 public abstract boolean canSendMessages ();
215179
216180 public void scheduleReconnect () {
0 commit comments