public CommandResult execute(CommandSource src, CommandContext ctx) throws CommandException { if (src instanceof Player) { Player player = (Player) src; if (player.getItemInHand().isPresent()) { ItemStack itemInHand = player.getItemInHand().get(); player.sendMessage( Text.of( TextColors.GOLD, "The ID of the item in your hand is: ", TextColors.GRAY, itemInHand.getItem().getName())); player.sendMessage( Text.of( TextColors.GOLD, "The meta of the item in your hand is: ", TextColors.GRAY, itemInHand.toContainer().get(DataQuery.of("UnsafeDamage")).get().toString())); } else { player.sendMessage( Text.of(TextColors.DARK_RED, "Error! ", TextColors.RED, "You must hold an item.")); } } else { src.sendMessage( Text.of( TextColors.DARK_RED, "Error! ", TextColors.RED, "You must be an in-game player to use this command.")); } return CommandResult.success(); }