I made a plugin a while ago that basically turns a specified block into a 'scrap block'. A scrap block can be right clicked and the player receives one of the x specified rewards. There's then a cooldown till the player can rightclick it again. There's also a particle right above the block to indicate that it's a scrap block.
My issue is, right now I can specify all the rewards the player can get, but I want this to include custommodeldata as well, seeing as I'll be working with a bunch of custom items.
Here's the part that lets an admin turn a block into a scrap block:
switch (args[0]) {
case "add" -> {
if (args.length == 4) {
// convert args[1] to particle
Particle particle = validParticles.contains(args[1].toUpperCase()) ? Particle.valueOf(args[1].toUpperCase()) : Particle.ASH;
// convert args[2] to int
int cooldown = Integer.parseInt(args[2]);
// convert args[3] to List<ItemStack>
List<ItemStack> items = new ArrayList<>();
String[] itemStrings = args[3].split(",");
for (String itemString : itemStrings) {
Material material = Material.matchMaterial(itemString.trim());
if (material != null) {
ItemStack item = new ItemStack(material);
items.add(item);
}
}
ChestObject chest = new ChestObject(false, blockLoc, particle, cooldown, items);
pHandler.AddLoc(chest, sender);
return true;
}```
How canI change it so that you can specify custommodeldata per given item? When it's not given it should just be custommodeldata 0.