Comments (20)
Here's how my fix works.
- The FIRST time a chest is opened in a game, its contents is copied to a cache.
-- If the chest contains a wool block in slot 0, then 1 is added to the DV to give the base level, else base level is 1
-- The wool block (if any) is removed
-- If the clear-chest option is TRUE, all the other items are removed as well
-- The base level is increased by up to 4 on a 1-in-ratio basis (where ratio is set for the level in the chest.yml)
-- Randomly 0-7 items are added to the chest, randomly selected from the level in chest.yml with each line of equal weight. Selections are independent so you can have multiple copies of the same thing
-- These items can be specified as text or as number, with quantity, DV, enchantments and names - The next time the chest is opened, nothing is changed
- If the restock-chest is set, then the chests are all reset after 1 day.
-- This will remove any current content and replace it, not add to it - If restock-chest-repeat is set, this happens EVERY day (14400 ticks)
- When the arena is reset,
-- All the previously-opened chests revert to their previous content, including any wool block in slot 0
-- All entities are removed apart from the ones listed in entities.keep in the config.yml (this includes dropped items and xp orbs) Default is to exclude pictures, frames, minecarts and armour stands.
-- All modified blocks revert to their previous state - Arena resets on shutdown, game end, and on new
/sg resetarena
command
This does not fix frames, droppers, or dispensers. Kept entities are not moved back to their original locations if they moved.
Thus, in your HG world, you can place a block of coloured wool in every chest slot0 to indicate what tier of loot it should contain. You can also place special items into specific chests and set clear-chest=false so that they are kept on randomisation.
Obviously this needs a bit of testing. There may be a race condition in the reset code, and the original author did not put in much in the way of error trapping and debug messages, so I'm going to let the kids loose on it and see what happens. They want "opey loot" and since the default chest level is 1 they wont get this until I prime all the chests with a wool block.
from survival-games.
Fix for chests is in #10
No fix yet for dispenser, droppers, furnaces, frames...
from survival-games.
@sshipway It seems chests still won't restock.. Players have been receiving an error.
[15:37:18] [Server thread/INFO]: [SurvivalGames] [Debug] ChestReplaceEvent: 485,30,540
[15:37:18] [Server thread/INFO]: [SurvivalGames] [Debug] Clearing initial content
[15:37:18] [Server thread/INFO]: [SurvivalGames] Chest at 485,30,540 is full: cannot add items
from survival-games.
That message is produced when the system tries 10 times to find an empty slot to put the new item into, but cannot, and so gives up. Strangely, the clearing content should ensure lots of free spaces...
The original code simply tried forever; all I added was the 10-attempt limit in case a chest started with a lot of items in it.
The players reporting the error, did they say which version of MC they are playing -- Bukkit, Spigot, 1.8.x, 1.9.x ? It may be that they are using the bleeding-edge spigot 1.9 (I tested against Spigot 1.8) and this has changes in the way the Inventory object works. Also, is this happening on initial stock, or on midnight restock, or on recurring restock event? As I mentioned previously, Java is not really my language, and I had a lot of confusion about object copies and object references; possibly there are some places where objects have not been properly deep-copied and this problem shows up on the 2nd or 3rd refill event
tl;dr - moar info!
from survival-games.
@sshipway They are using Spigot x1.9, And since i want this plugin to work in 1.9, This needs to be addressed.
from survival-games.
I'm not able to duplicate this with my 1.8 setup; did you do anything special when creating the release JAR file? I'll pull down a copy of the release and try it against a 1.9 Spigot this week and see if that duplicates it for me; if so I will have a fix out soon...
from survival-games.
@sshipway No.. These jars were actually compiled at my jenkins CI Server:
http://ci.thundergemios10.com
They are compiled normally in Maven.
from survival-games.
The release is definitely different in size from the one I built here. Which version of Java are you running? I've noticed that can cause issues
from survival-games.
JDK 8?
I'm building on Java 8
from survival-games.
Found it. When getting inventory contents, 1.8 returns itemstacks only for occupied inventory positions; 1.9 returns one itemstack for each slot, even if it is empty. So the code to detect a full inventory always thinks chest is full even when it is not. Fairly easy fix in ChestReplaceEvent, have someting to test in place now.
At the same time also found a minor bug when deleting an arena (cant reset chests when arena has been deleted!) and in the "/sg reload" help text. I think I've fixed it all but Im too tired to test now (10pm here in NZ), will try to find time Tue or Wed evening.
from survival-games.
@sshipway Ok.
from survival-games.
(Problem was in ChestReplaceEvent using Inventory.getSize() > 25
where I should have used Inventory.firstEmpty()<0
)
from survival-games.
@sshipway Oh!
from survival-games.
Fixed in pull req #12
This also adds a new command /sg refill
to make refill testing easier!
All tested now -- sorry for the wait, but mon/tue are scouting nights so no free time for coding. Please test yourself as well, in case there is something that makes it work on my system but not on yours...
from survival-games.
It occurs to me that it should be possible to use the same chest hook to handle access to droppers, dispensers and furnaces, though we would also need to trap the event for dropper/dispenser trigger and for furnace changes. Then also a special tier would be needed for these as they could not use chest loot tiers -- maybe create a chest.furnace0 etc and chest.dropper0, or simply not have randomisation on these entities at all, just inventory resetting.
from survival-games.
Furnace change Events: FurnaceBurnEvent, FurnaceSmeltEvent, FurnaceExtractEvent
Dispenser event: BlockDispenseEvent
All of them can catch the same inventory open event as the chests.
This should make it pretty simple to have inventories reset on all these inventory blocks. Might try coding something later this week.
from survival-games.
Nice.. These are very useful..
from survival-games.
@sshipway Did you end up coding?
from survival-games.
Sorry, just no time recently; I've been buried under all my other projects. I would think the best way to do droppers/dispensers/furnaces is to not have randomisation on them, but hook into the listed events, plus the existing inventory open event, to store the inventories and restore with the normal function. The current inventory open hook ignores non-chest items so it would need to be expanded; other hooks could be made the same way. I still have this in my 'to look at' list but if someone else picks it up and runs with it I won't be upset ;)
from survival-games.
Probably, support for disp/drop/furn should be moved to s separate ticket as this tickets main issue has alreayd been addressed
from survival-games.
Related Issues (20)
- Are signs editable HOT 1
- Sign wall not allowing warps
- Can you put a thing in the config saying none oped people can join please!!!!!!!! HOT 5
- Radom Join Command HOT 6
- Chest tier change HOT 1
- Support for 1.8 on newer builds HOT 3
- Can't seem to whitelist items (change from getMaterial to matchMaterial) HOT 23
- NullPointerException when starting server HOT 2
- Add potions to chests, is it possible at the moment? HOT 1
- Game not starting, task #26 generated an exception HOT 4
- problem with config/bandage not disappearing HOT 15
- Non-OP Player Permissions? HOT 1
- Permissions issues still persist? HOT 7
- Break and placing blocks HOT 5
- Plugin Survival games! HOT 1
- New experimental release HOT 1
- Non-Op cannot join the survival games match. HOT 4
- Chest Restocking Time
- 1.16 update???
- Help! HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from survival-games.