@@ -217,33 +217,35 @@ public void restorePlayerState(Player peeker, PeekData data) {
217217 // 在传送前先清除动量
218218 peeker .setVelocity (new Vector (0 , 0 , 0 ));
219219
220- // 直接传送
221- peeker .teleportAsync (data .getOriginalLocation ()).thenAccept (success -> {
222- if (!success ) {
223- plugin .getLogger ().warning (String .format (
224- "无法将玩家 %s 传送回原位置,正在尝试传送到重生点" ,
225- peeker .getName ()
226- ));
227-
228- Location spawnLoc = peeker .getBedSpawnLocation () != null
229- ? peeker .getBedSpawnLocation ()
230- : peeker .getWorld ().getSpawnLocation ();
231-
232- if (spawnLoc != null ) {
233- plugin .getServer ().getRegionScheduler ().run (plugin , spawnLoc , spawnTask -> {
234- peeker .teleportAsync (spawnLoc ).thenAccept (spawnSuccess -> {
235- if (!spawnSuccess ) {
236- plugin .getLogger ().severe (String .format (
237- "无法将玩家 %s 传送到任何安全位置" ,
238- peeker .getName ()
239- ));
240- }
220+ // 延迟2tick后传送
221+ plugin .getServer ().getRegionScheduler ().runDelayed (plugin , data .getOriginalLocation (), delayedTask -> {
222+ peeker .teleportAsync (data .getOriginalLocation ()).thenAccept (success -> {
223+ if (!success ) {
224+ plugin .getLogger ().warning (String .format (
225+ "无法将玩家 %s 传送回原位置,正在尝试传送到重生点" ,
226+ peeker .getName ()
227+ ));
228+
229+ Location spawnLoc = peeker .getBedSpawnLocation () != null
230+ ? peeker .getBedSpawnLocation ()
231+ : peeker .getWorld ().getSpawnLocation ();
232+
233+ if (spawnLoc != null ) {
234+ plugin .getServer ().getRegionScheduler ().run (plugin , spawnLoc , spawnTask -> {
235+ peeker .teleportAsync (spawnLoc ).thenAccept (spawnSuccess -> {
236+ if (!spawnSuccess ) {
237+ plugin .getLogger ().severe (String .format (
238+ "无法将玩家 %s 传送到任何安全位置" ,
239+ peeker .getName ()
240+ ));
241+ }
242+ });
241243 });
242- });
244+ }
245+ plugin .getMessages ().send (peeker , "teleport-failed" );
243246 }
244- plugin .getMessages ().send (peeker , "teleport-failed" );
245- }
246- });
247+ });
248+ }, 2L );
247249 });
248250 }
249251
0 commit comments