PlayerTeleportEvent#setCancelled(true) does not cancel when spectating entity
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 52/100
Hướng nghiên cứu
Bắt đầu bằng cách theo dõi quá trình xử lý PlayerTeleportEvent cho TeleportCause.SPECTATE, đặc biệt là quá trình chuyển từ một mục tiêu spectate hiện có sang một mục tiêu mới được chọn thông qua menu spectate. Tái hiện trường hợp này bằng Java listener, armor stand và các bước trong menu spectate được cung cấp. Được xem là hoàn tất khi việc hủy event ngăn người chơi bị dịch chuyển trong lúc đang spectate một entity khác.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Expected behavior
PlayerTeleportEvent#setCancelled(true) should cancel teleportation at all times
Observed/Actual behavior
Mounted to an entity (spectator target) in spectator gamemode, teleporting using the spectator menu (using mouse wheel or keyboard numbers) does NOT cancel the teleportation event. It teleports the player in spectator to the target player (even if hundreds of blocks apart)
Steps/models to reproduce
- Write some code to cancel PlayerTeleportEvent. I used this:
public class Main extends JavaPlugin implements Listener {
@Override
public void onEnable() {
getServer().getPluginManager().registerEvents(this, this);
}
// i know Entity shouldn't be cached in a field, but this is just for testing
private final AtomicReference<Entity> target = new AtomicReference<>();
@EventHandler
void onEntityTargetEvent(PlayerStartSpectatingEntityEvent event) {
Entity entity = event.getNewSpectatorTarget();
getServer().getScheduler().runTaskLater(this, () -> {
target.set(entity);
getLogger().warning("[DEBUG]PlayerStartSpectatingEntityEvent: target.set(entity)");
}, 1);
}
@EventHandler
void onPlayerTeleportEvent(PlayerTeleportEvent event) {
if (target.get() == null || event.getCause() != PlayerTeleportEvent.TeleportCause.SPECTATE) {
return;
}
event.setCancelled(true);
// my specific use-case cannot use Player#getSpectatorTarget
Entity entity = target.getAndSet(null);
if (entity == null) {
return;
}
getLogger().warning("[DEBUG]PlayerTeleportEvent: setCancelled(true), cause=SPECTATE");
}
}
- Place down an armor stand.
- Get into /gamemode spectator.
- Hit the armor stand so it becomes your spectating target.
- Teleport to another player using the spectator menu (mouse wheel or keyboard numbers).
- See yourself getting teleported to the player, while console logged that the event was canceled.
Plugin and Datapack List
> pl
[17:00:53 INFO]: ℹ Server Plugins (1):
[17:00:53 INFO]: Bukkit Plugins:
[17:00:53 INFO]: - server-testing
'server-testing' only contains code provided at the reproduce steps
Paper version
> ver
[17:02:35 INFO]: Checking version, please wait...
[17:02:35 INFO]: This server is running Paper version 26.1.2-74-ver/26.1.2@e4e17fc (2026-07-06T16:51:09Z) (Implementing API version 26.1.2.build.74-stable)
You are running the latest version
Previous version: 26.2-40-6d23ced (MC: 26.2)
Other
I have used this code for over 6 years without problems until a player recently found out that he was able to teleport using this flaw.
- Ngôn ngữ chính
- Java
- Star
- 12.8k
- Fork
- 3.6k
- Merge trung bình
- 3 ngày 7 giờ
- Pull request đã merge (30 ngày)
- 19
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của PaperMC/Paper
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Add .getIgniter() to ExplosiveMinecartCó thể đã có người làm @WouterGritter đã nhận 61 ngày trước. Đang mởstatus: needs triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
PaperMC/Paper#14097 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
BlockType#isOccluding is incorrectly handledCó thể đã có người làm @ryoji-ikeda đã nhận 205 ngày trước. Đang mởstatus: accepted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
PaperMC/Paper#13790 · 5 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
status: needs triage
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 43/100
PaperMC/Paper#14492 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Checkstyle] Ignore check for javadocs into method-local classesCó thể đã có người làm @Machine-Maker đã nhận 2 ngày trước. Đang mởstatus: accepted
PaperMC/Paper#14490 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của PaperMC/Paper
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
tchiotludo/akhq#3438 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
Paul-Austin-Oswego-CSC480-HCI521/gift-app#266 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
ome/bioformats#4509 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày