[Plugin] Question about interaction Plugin - Mod

Hello !
I’m implementing a SpongeForge plugin where players are able to create a city trough a command. In a Forge mod, a friend have create an item “money”, how could i consume this money in the player’s inventory when he perform the command “/city create” ?

Thanks for the help !

first of, you will have create a command class

implements CommandCallable

after you get all the methods, you will need to fill out all of them, the one called process

public CommandResult process(CommandSource source, String args){

that is the one that actually runs the command, so then, you will need to add this code (best to type it yourself so you remeber it)

public CommandResult process(CommandSource source, String args1){
  String[] args = args1.spilt(" ");
  if(args.lenth >= 1){
    //command argument 1
    if(args[0].equalsIgnoreCase("create")){
      if(source instanceof Player){
        //your normal code goes here
        Player player = (Player)source;
        Inventory inv = player.getInventory();
        Optional<ItemStack> stack = inv.peek(ItemType);  //item type being the item you want to remove
        int removeCount = 0; //the amount you want to remove
        if(stack.isPresent()){
          if(stack.get().quantity() >= removeCount){
            stack.get().setQuantity(stack.get().quantity() - removeCount);

ill let you do the rest. The inventory API isnt implemented yet (i dont think so anyway) so keep that in mind

My problem is to use an ItemType from an external mod, how could i do that ?

You can fetch itemtypes by their ID like so:

Optional<ItemType> modItem = Sponge.getRegistry().getType(ItemType.class, "modid:item_name");

Instead of implementing CommandCallable, it would probably be easier to just register the CommandSpec and write a CommandExecutor as described here.