- Tham gia
- 09/05/2020
- Bài viết
- 29
Chào ae khi mình code event thì mình hay bị Could not pass event thường thì mình không quan tâm lắm do plugin vẫn hoạt động tốt nhưng gây lag cho server mình mình muốn hỏi cách fix. Giả sử có một đoạn code event PlayerInteractEvent
@EventHandler
public void onClick(PlayerInteractEvent e) {
Action action = e.getAction();
Player p = e.getPlayer();
ItemStack item = p.getInventory().getItemInMainHand();
ItemMeta meta = item.getItemMeta();
assert meta != null;
String name = meta.getDisplayName();
if(name.equals("Test")) {
if(action.equals(Action.RIGHT_CLICK_AIR)) {
p.sendMessage("Bạn đang click bằng item tên là test")
}
}
Khi mình click bằng item tên test thì không sao nhưng khi click bằng tay không hoặc vật dụng khác thì lập tức xảy ra Could not pass event PlayerInteractEvent
Mong ae sẽ giúp mình khắc phục lỗi này!
@EventHandler
public void onClick(PlayerInteractEvent e) {
Action action = e.getAction();
Player p = e.getPlayer();
ItemStack item = p.getInventory().getItemInMainHand();
ItemMeta meta = item.getItemMeta();
assert meta != null;
String name = meta.getDisplayName();
if(name.equals("Test")) {
if(action.equals(Action.RIGHT_CLICK_AIR)) {
p.sendMessage("Bạn đang click bằng item tên là test")
}
}
Khi mình click bằng item tên test thì không sao nhưng khi click bằng tay không hoặc vật dụng khác thì lập tức xảy ra Could not pass event PlayerInteractEvent
Mong ae sẽ giúp mình khắc phục lỗi này!


