|
5 | 5 | import java.util.ArrayList; |
6 | 6 | import java.util.HashMap; |
7 | 7 | import java.util.HashSet; |
8 | | -import java.util.Iterator; |
9 | 8 | import java.util.List; |
10 | 9 | import java.util.Map; |
11 | 10 | import java.util.Set; |
@@ -211,8 +210,16 @@ public void teleport(Player player, String landmarkName) { |
211 | 210 | } |
212 | 211 |
|
213 | 212 | // 执行传送 |
214 | | - plugin.getServer().getGlobalRegionScheduler().execute(plugin, () -> { |
215 | | - player.teleportAsync(targetLandmark.getLocation()).thenAccept(result -> { |
| 213 | + Location targetLocation = targetLandmark.getLocation(); |
| 214 | + plugin.getServer().getRegionScheduler().execute(plugin, targetLocation, () -> { |
| 215 | + // 移除所有乘客 |
| 216 | + if (!player.getPassengers().isEmpty()) { |
| 217 | + for (Entity passenger : player.getPassengers()) { |
| 218 | + player.removePassenger(passenger); |
| 219 | + } |
| 220 | + } |
| 221 | + |
| 222 | + player.teleportAsync(targetLocation).thenAccept(result -> { |
216 | 223 | if (result) { |
217 | 224 | plugin.getConfigManager().sendMessage(player, "teleport-success", "", |
218 | 225 | "<landmark>", targetLandmark.getName()); |
@@ -409,27 +416,6 @@ public void cleanupPlayerData(UUID playerId) { |
409 | 416 | } |
410 | 417 | } |
411 | 418 |
|
412 | | - public void cleanupInactivePlayers(long inactiveTime) { |
413 | | - long currentTime = System.currentTimeMillis(); |
414 | | - int cleanedCount = 0; |
415 | | - |
416 | | - for (Iterator<Map.Entry<UUID, Set<String>>> it = unlockedLandmarks.entrySet().iterator(); it.hasNext();) { |
417 | | - Map.Entry<UUID, Set<String>> entry = it.next(); |
418 | | - UUID playerId = entry.getKey(); |
419 | | - |
420 | | - if (Bukkit.getPlayer(playerId) == null |
421 | | - && currentTime - cooldowns.getOrDefault(playerId, currentTime) > inactiveTime) { |
422 | | - cleanupPlayerData(playerId); |
423 | | - it.remove(); |
424 | | - cleanedCount++; |
425 | | - } |
426 | | - } |
427 | | - |
428 | | - if (cleanedCount > 0) { |
429 | | - plugin.getSLF4JLogger().info("已清理 {} 个不活跃玩家的数", cleanedCount); |
430 | | - } |
431 | | - } |
432 | | - |
433 | 419 | public boolean isPlayerNearLandmark(Player player, Location landmarkLoc) { |
434 | 420 | Location playerLoc = player.getLocation(); |
435 | 421 | return playerLoc.getWorld() != null |
|
0 commit comments