Closed Kobe024 closed 4 years ago
it seems you would have to loop through each chest placed in a world
that's the problem.
Would adding a radius help in any way? Example "/searchchest radius item" so if you are near a players storage area, you can use /searchchest 20 cobble and it will look in any chests within that radius? Maybe have a configurable default radius in case a radius is not specified?
The best way to go about it would be iterating through tile entities. A radius would be hugely helpful for performance, but for simplicity's sake I would make it a chunk radius.
Entire world check:
// Nonfunctional: A lot of the returns are arrays, not collections, but I don't remember which.
world.getLoadedChunks().flatmap(Chunk::getTileEntities).forEach(tile -> {
if (!(tile instanceof InventoryHolder)) {
return;
}
Inventory inventory = ((InventoryHolder) tile).getInventory();
// Handle search
}
I guess it would fit in with OpenInv's existing functions, I'm not opposed to it. I'm continuously surprised by how many people use the search commands regularly.
Is there any possibility of adding a /seachchest which works similar to /searchinv and /seachender? Seems like it would fit in nicely and complete the set. Or even a /searchcontainer which would include things like hoppers/droppers/dispensers etc...
While I am not a plugin dev myself, it seems you would have to loop through each chest placed in a world and check if it contains the item like you do for the other 2 search commands. If matches are found you could include the co-ords of the chest so staff could tp to it and manually check who owns it via coreprotect or lwc or you could maybe build in supoort for lwc and coreprotect so it automatically shows who placed it or the lwc owner as well as the chest co-ords when a match is found.
I will try this myself since I've been wanting to get into plugin development but I thought I should suggest it so that it could be done properly lol