Giter Club home page Giter Club logo

Comments (20)

sshipway avatar sshipway commented on September 23, 2024

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.

sshipway avatar sshipway commented on September 23, 2024

Fix for chests is in #10
No fix yet for dispenser, droppers, furnaces, frames...

from survival-games.

ThunderGemios10 avatar ThunderGemios10 commented on September 23, 2024

@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.

sshipway avatar sshipway commented on September 23, 2024

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.

ThunderGemios10 avatar ThunderGemios10 commented on September 23, 2024

@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.

sshipway avatar sshipway commented on September 23, 2024

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.

ThunderGemios10 avatar ThunderGemios10 commented on September 23, 2024

@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.

sshipway avatar sshipway commented on September 23, 2024

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.

ThunderGemios10 avatar ThunderGemios10 commented on September 23, 2024

JDK 8?
I'm building on Java 8

from survival-games.

sshipway avatar sshipway commented on September 23, 2024

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.

ThunderGemios10 avatar ThunderGemios10 commented on September 23, 2024

@sshipway Ok.

from survival-games.

sshipway avatar sshipway commented on September 23, 2024

(Problem was in ChestReplaceEvent using Inventory.getSize() > 25 where I should have used Inventory.firstEmpty()<0 )

from survival-games.

ThunderGemios10 avatar ThunderGemios10 commented on September 23, 2024

@sshipway Oh!

from survival-games.

sshipway avatar sshipway commented on September 23, 2024

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.

sshipway avatar sshipway commented on September 23, 2024

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.

sshipway avatar sshipway commented on September 23, 2024

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.

ThunderGemios10 avatar ThunderGemios10 commented on September 23, 2024

Nice.. These are very useful..

from survival-games.

XinityDevs avatar XinityDevs commented on September 23, 2024

@sshipway Did you end up coding?

from survival-games.

sshipway avatar sshipway commented on September 23, 2024

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.

sshipway avatar sshipway commented on September 23, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.