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” ?
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