Survival Games Chest Randomiser

Discussion in 'Plugin Development' started by poilet66, Jan 17, 2019.

Thread Status:
Not open for further replies.
  1. Offline

    poilet66

    Hi!

    So - quick summary - I'm a super new plugin developer and I'm trying to create a plugin that will allow me to create 3 separate drop tables filled with items, each containing a different weight out of 100 (e.g 10, stick; 5, diamond etc). Then, I will have a command that when I look at the chest (Using getTargetBlock I assume?) I will be able to run a command such as '/droptable add <droptable>' and then on the run of another command e.g /chest refill <droptable> or just /chest refill, it will refill all the chests in that droptable (It doesn't have to be just that table seeing as I'll need to refill them all at the same time).

    I have a rough idea of how do to this and my initial idea was by every time a chunk was loaded, looking for a chest in that chunk and then adding to it (I haven't thought about the droptable part yet :/) and then using something like chest.IventoryGet().add(new ItemStack) or something alone those lines to add the randomized item to it but then I realised that it would refresh the chest every time a player entered its chunk. I know you can run it whenever the chest is opened but I'd have the same issue.

    Summary: Is there a way to check a chest has been opened since the command was last issued? And also would I be able append an item randomly while giving it a weight?

    Many thanks!

    Poilet
     
  2. Offline

    TheWolfBadger

    Instead of searching a whole chunk for a chest and then setting it up. A way more efficient solution would be setting it up as it's opened (checking of course first that it hasn't already been set up).

    I didn't quite understand what your "droptable" idea thing was.. However, if you meant that that's setting up which chests are to be refilled, then you could save the locations of these set up chests to a config file and then go through the chest locations within the config file when needing to refill them.

    These are 2 different solutions to the problem. The 2nd option is probably the most reliable and most efficient, however the 1st option works just as well, but gets rid of having to set up all the different chest locations.

    Good luck!
     
Thread Status:
Not open for further replies.

Share This Page