Solved Is creating an itemstack async safe?

Discussion in 'Plugin Development' started by Tecno_Wizard, Jul 12, 2015.

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


    I am generating a GUI async to prevent lagg, but I noticed that the ItemStack class calls upon Bukkit statically several times. Should I not be doing this?
  2. Offline


    Generating a gui really isnt that laggy
  3. Offline


    @_Filip, it is when you are doing a lot of IO while preparing it. Also, your sig better be sarcastic. Lol.
  4. Offline


    @Tecno_Wizard Just never think about using async on Bukkit methods. The methods are pretty fast already that you don't need to worry about lagging the server and if you have a long operation to do with Bukkit, just span it out over several ticks.
  5. Offline


    @Tecno_Wizard If you're really doing a lot of IO then you should cache your results to avoid getting them the next time, if you really need to read again every time (or it's per-player data so it's hard to cache for everyone) then you better make the preparation asynchronously, but open the GUI in a sync task
  6. Offline


    @teej107 , the Bukkit method isn't the issue.
    Are you a mind reader? Lol. Yes, it's a per-player operation that requires reading quite a bit of data off of a file. Chaching the data is worthless. It's not something that will like be run more than once in a while. Regarding the OP, it seems that the ItemFactory is a safe class to call async. No errors in runtime it seems.

    And yes, the operation is going like this:
    sync- Bukkit.createInventory(blah) (In onCommand)- 0ms
    async- read file and create inventory -20ms
    sync- send inventory back to player- 0-5ms depending on when the next tick is.
    Last edited: Jul 12, 2015
Thread Status:
Not open for further replies.

Share This Page