@@ -211,22 +211,27 @@ public void teleport(Player player, String landmarkName) {
211211
212212 // 执行传送
213213 Location targetLocation = targetLandmark .getLocation ();
214- plugin .getServer ().getRegionScheduler ().execute (plugin , targetLocation , () -> {
215- // 移除所有乘客
214+ Location playerLocation = player .getLocation ();
215+
216+ // 先在玩家当前位置的区域移除乘客
217+ plugin .getServer ().getRegionScheduler ().execute (plugin , playerLocation , () -> {
216218 if (!player .getPassengers ().isEmpty ()) {
217219 for (Entity passenger : player .getPassengers ()) {
218220 player .removePassenger (passenger );
219221 }
220222 }
221223
222- player .teleportAsync (targetLocation ).thenAccept (result -> {
223- if (result ) {
224- plugin .getConfigManager ().sendMessage (player , "teleport-success" , "" ,
225- "<landmark>" , targetLandmark .getName ());
226- cooldowns .put (player .getUniqueId (), System .currentTimeMillis ());
227- } else {
228- plugin .getConfigManager ().sendMessage (player , "teleport-failed" , "" );
229- }
224+ // 然后在目标位置的区域执行传送
225+ plugin .getServer ().getRegionScheduler ().execute (plugin , targetLocation , () -> {
226+ player .teleportAsync (targetLocation ).thenAccept (result -> {
227+ if (result ) {
228+ plugin .getConfigManager ().sendMessage (player , "teleport-success" , "" ,
229+ "<landmark>" , targetLandmark .getName ());
230+ cooldowns .put (player .getUniqueId (), System .currentTimeMillis ());
231+ } else {
232+ plugin .getConfigManager ().sendMessage (player , "teleport-failed" , "" );
233+ }
234+ });
230235 });
231236 });
232237 }
0 commit comments