Any item can contain one more more commands attached to it and commands will get performed on items usage.
Option to define an items use amount, the amount of times the item can be used before being removed. Currently, it’s only by using /cmi attachcommand command.
In example /cmi attachcommand !limiteduse:5! will set item usage amount to 5. Left usages will be shown in lore and in action bar when using item.
An option to perform commands from the console, in example /cmi attachcommand !cc!cmi fly [playerName]. Yes, you can use variables to insert players name.
Some examples would be:
/cmi attachcommand !limiteduse:3!;;!cc!cmi fly [playerName] true what will toggle players fly mode to true.
/cmi attachcommand !limiteduse:3!;;!cc!cmi tfly [playerName] 60 which will enable fly mode for player for next 60sec and will have 3 uses
/cmi attachcommand !limiteduse:3!;;!cc!cmi heal [playerName] will heal player for 3 times, after that item will disappear.
If item is stacked, then each item in the stack will be consumed one by one after all uses are consumed. So 5 items with 3 uses, will have 15 uses in total.
/cmi attachcommand !left!cmi heal;;!right!cmi feed which will heal player when left clicking and feed when right clicking.
/cmi attachcommand cmi launch [interactedPlayer] a:45 will launch player which one you have interacted while holding this item.
In case you don’t want spam in console when clicking item, use !silent! variable, like /cmi attachcommand !left!!silent!cmi heal;;!right!!silent!cmi feed
/cmi attachcommand !cooldown:60!;;!cc!cmi heal [playerName] will allow user to use this item every 60 seconds to heal himself. Keep in mind that duplicates of this item will share same cooldown, while newly created one, even if its has same exact command will have separate cooldown.
In case you want to perform commands only when player consumes food, then you can use !consume! variable at start. For example
/cmi attachcommand !consume!;;!cc!cmi me [playerName] says helo!;;!cc!cmi panimation circle;c:85,254,254;twist;part:5;r:0.5;pitch:90;move:0,0.33,0;offset:0,-0.2,0;target:[playerName];;cmi sound [playerName] ambient_cave
This will print out message into chat, play out particle effect and play out sound effect when player consumes item.
Keep in mind that you cant have !limiteduse:[amount]! while using this feature, as item should be consumed for commands to be performed.