Inventory-based name menu

Discussion in 'Plugin Development' started by caseif, Sep 25, 2013.

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

    caseif

    I've been asked to add a feature to a plugin which would allow players to choose a name from an inventory filled with name tags, each given a random name out of maybe 1000. The issue is, I'm horrible with optimization. The way I'm working it is, I'm storing a separate inventory for each player with one open in a HashMap, and to generate the inventory, I use Collections.shuffle() after loading the list of names into a single list, then getting the first 54 entries. The shuffling is done in an async thread. However, this method causes extreme RAM usage and occasionally an OoME. Is there a more efficient alternative to my method of doing this?
     
  2. Offline

    chasechocolate

    How about only generating 54 random names each time instead of choosing 54 out of a list of 1000?
     
  3. Offline

    caseif

    The thing is, I need to pick the names out of a list. They're not just random strings that can be generated. But, my issue right now is the huge memory usage by the plugin.
     
Thread Status:
Not open for further replies.

Share This Page