@@ -140,8 +140,12 @@ private void handleIncomingPacket(Player player, Location loc, String action, in
140140 break ;
141141 case "ready" :
142142 logDebug ("Player " + player .getName () + " is READY. Awaiting first chunk batch..." );
143- awaitingInitialBatch .add (player .getUniqueId ());
144- player .sendPluginMessage (this , CHANNEL , createBelowY0StatusPayload (true ));
143+ if (enabledWorlds .contains (player .getWorld ().getName ())) {
144+ awaitingInitialBatch .add (player .getUniqueId ());
145+ player .sendPluginMessage (this , CHANNEL , createBelowY0StatusPayload (true ));
146+ } else {
147+ logDebug ("Not a supported world!" );
148+ }
145149 break ;
146150 case "use_on_block" :
147151 new BukkitRunnable () {
@@ -163,6 +167,13 @@ private byte[] createBelowY0StatusPayload(boolean status) {
163167 return bout .toByteArray ();
164168 } catch (IOException e ) { return null ; }
165169 }
170+
171+ private byte [] createDimensionPayload () {
172+ try (ByteArrayOutputStream bout = new ByteArrayOutputStream (); DataOutputStream out = new DataOutputStream (bout )) {
173+ out .writeUTF ("dimension_change" );
174+ return bout .toByteArray ();
175+ } catch (IOException e ) { return null ; }
176+ }
166177
167178 private void startProcessorTask () {
168179 this .processorTask = new BukkitRunnable () {
@@ -200,17 +211,18 @@ public void onPlayerChangeWorld(PlayerChangedWorldEvent event) {
200211 UUID playerId = player .getUniqueId ();
201212
202213 Queue <Vector > playerQueue = requestQueue .get (playerId );
203-
204214 if (playerQueue != null && !playerQueue .isEmpty ()) {
205- logDebug ("Player " + player .getName () + " changed worlds. Clearing " + playerQueue .size () + " pending chunk requests from their old world ." );
215+ logDebug ("Player " + player .getName () + " changed worlds. Clearing " + playerQueue .size () + " pending chunk requests." );
206216 playerQueue .clear ();
207217 }
208218
209- if (awaitingInitialBatch .remove (playerId )) {
210- logDebug ("Player " + player .getName () + " changed worlds during initial load. Cancelling." );
219+ if (initialChunksToProcess .remove (playerId ) != null ) {
220+ logDebug ("Player " + player .getName () + " was in the middle of an initial chunk load. The process has been cancelled." );
221+ awaitingInitialBatch .remove (playerId );
211222 player .sendPluginMessage (this , CHANNEL , createLoadFinishedPayload ());
212- initialChunksToProcess .remove (playerId );
213223 }
224+
225+ player .sendPluginMessage (this , CHANNEL , createDimensionPayload ());
214226 }
215227
216228 private void processAndSendChunk (final Player player , final Chunk chunk ) {
0 commit comments