J'ai eu exactement le même problème sauf que mon event.setCancelled(true); est bien à sa place. Voici mon code, aidez moi s'il vous plait. Merci beaucoup.
@EventHandler
public void onPlayerClick(InventoryClickEvent event) {
Inventory inv = event.getInventory();
Player player = (Player) event.getWhoClicked();
ItemStack current = event.getCurrentItem();
Location lobby = new Location(player.getWorld(), 0.5, 6.2, 0.5, 180f, 0f);
Location gunarea = new Location(player.getWorld(), 200.5, 6.2, 0.5, 180f, 0f);
if(current == null) {
return;
}
if(inv.getName().equalsIgnoreCase("§bMenu")) {
event.setCancelled(true);
player.closeInventory();
switch(current.getType()) {
case FIREWORK_CHARGE:
player.teleport(gunarea);
break;
case BED:
player.teleport(lobby);
break;
default:
break;
}
}
@EventHandler
public void onPlayerClick(InventoryClickEvent event) {
Inventory inv = event.getInventory();
Player player = (Player) event.getWhoClicked();
ItemStack current = event.getCurrentItem();
Location lobby = new Location(player.getWorld(), 0.5, 6.2, 0.5, 180f, 0f);
Location gunarea = new Location(player.getWorld(), 200.5, 6.2, 0.5, 180f, 0f);
if(current == null) {
return;
}
if(inv.getName().equalsIgnoreCase("§bMenu")) {
event.setCancelled(true);
player.closeInventory();
switch(current.getType()) {
case FIREWORK_CHARGE:
player.teleport(gunarea);
break;
case BED:
player.teleport(lobby);
break;
default:
break;
}
}