niccholaspage / Fe

An economy plugin
17 stars 43 forks source link

fixed shutdown bug. #51

Closed shawshark closed 10 years ago

shawshark commented 10 years ago

save players accounts on shutdown.

niccholaspage commented 10 years ago

This should already happen, look at this method: https://github.com/niccholaspage/Fe/blob/master/src/org/melonbrew/fe/database/Database.java#L148

Relicum commented 10 years ago

What will failure due to the way HashSet and sets in general work. You need to use a Iterator. In my fork I fixed here is the code to fix the method.

    public void close()
     {
        Iterator<Account> iterator= cachedAccounts.iterator();

       while(iterator.hasNext())
        {
            Account account = iterator.next();
            account.save(account.getMoney());
            iterator.remove();

        }