#I know that this isnt good written code

1 messages · Page 1 of 1 (latest)

wide mural
#

Let's move this to a thread

hidden palm
#

Yeah thats better

wide mural
#

Alright so the first thing we can start doing is separating all the credit tracking logic to a separate class

#

It's basically just a fancy Map<UUID, Integer> wrapper

#
public class PlayerCreditTracker {

  private final Map<UUID, DeathCreditData> playerData = new ...;

  // Add the methods you'd like here
}
#

The next thing we should do is stop performing this much IO all the time

#

We can, for example, load all the player data when the server starts (assuming this is a small server) and save it periodically

#

Instead of on every cycle load, modify and save

hidden palm
#

I wanted to do the load and save it something changes, its not meant for big servers so if i change the Credit of a player the player can get back (if the player had 0 ) and not need to wait for next save cycle

wide mural
#

Correct, however when you save data it still remains in the Map

#

So there's no need for at least the loading stage

hidden palm
#

ah ok so i store it to the map instead of loading and saving the file and periodicly and on stop i save the file and on start i load it

wide mural
#

You can save it more often in case the server crashes

#

but yeah that's the idea