Skip to content

Commit a761513

Browse files
Update PeekStateHandler.java
1 parent 85d9747 commit a761513

1 file changed

Lines changed: 25 additions & 27 deletions

File tree

src/main/java/ict/minesunshineone/peek/handler/PeekStateHandler.java

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -217,35 +217,33 @@ public void restorePlayerState(Player peeker, PeekData data) {
217217
// 在传送前先清除动量
218218
peeker.setVelocity(new Vector(0, 0, 0));
219219

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-
});
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+
}
243241
});
244-
}
245-
plugin.getMessages().send(peeker, "teleport-failed");
242+
});
246243
}
247-
});
248-
}, 2L);
244+
plugin.getMessages().send(peeker, "teleport-failed");
245+
}
246+
});
249247
});
250248
}
251249

0 commit comments

Comments
 (0)