I'm in the middle of this minigame plugin, and I'm going to need the map to reset when its finished. I have never been able to successfully reset a map in a plugin, so i decided to ask now, how do I do it? Please put the awnser in code, not just: "Prevent world save, delete world, load world" Cause I've seen that responce way to many times, and still have no idea how I do it. Any help is much appreachiated
@PiggerCast My apologies for not putting this in code, but I have seen a bit of discussion on this before. Some say you should listen for whenever a block is broken, put it in a Map<Location, Block>, then when the match is over go through that Map and put all the blocks back. But then there's things like filled chests that conflict with that way, so that doesn't always work. There's also using schematics, which I can't even begin to explain as I have no idea how, and when the match is over you can load the schematic on top of your destroyed map and then you get a restored map. Anyway, hope you get a better answer than this.
@PiggerCast Well, considering you haven't tried anything at all, we're not going to help. Actually attempt to do something before you come and post here, try what Pookey said, that's probably easier than what you're attempting to do anyway.
@PiggerCast HashMap.clear(); HashMap represents your name for hashmap If that is what you were asking for?
@pookeythekid @ProMCKingz @mythbusterma so now, so far I have it set so that every time a block breaks, it does: map.put(l, l.getBlock()); (l is the location, and map is a HashMap<Location, Block>) Now im having troubles with seeing how I place the blocks? I tried multiple ways, but I cant seem to find out. obviously, i need to have it in the syntax <location>.getBlock().set(<block>) But how i set this up within the hashmap, i dont see :/ Any help would be appreachiated.
@PiggerCast You'd want to get the data & type from your stored block, and then set the block to the right type & data.
Ok so i tried: for(Block b : map.values()){ b.getLocation().getBlock().setType(b.getType()); } and I really thought it would work, but it didnt, so I am now out of ideas on how to do this. Any help is much appreachiated.