Overhaul event/time management system
1Rogue opened this issue ยท 0 comments
The current system is buggy, and can be off, so it's going to be completely overhauled:
Time System
Previous time system:
- A query would run every minute
- Executed an update method that would insert players with 1 minute, and on dupe keys would append another minute
- Expensive, depended on errors for input
New proposed time system:
- Player times are grabbed from the table on login
- Timestamps are compared between login/logoff
- Login time is appended to total time, and re-submitted
- Much less queries
- A crash would lead to a loss in playtime (possible solution: hourly updates/fixes)
Event System
Previous event system:
SELECT * FROM `playTime` WHERE (`someTimer`%MINIMUM) <= (MINIMUM+INTERVAL) AND `someTimer` >= MINIMUM
- A query would run every x pre-determined minutes to check the SQL database for times. (in the pseudo-query above, where
MINIMUM
is a constant for the trigger time, andINTERVAL
is the time between checks) - All results from this would "fire" the event for the relevant players.
- Each event would have an individual
Runnable
scheduled through theScheduledExecutorService
in thejava.util.concurrent
package. - This lead to a single query for each event every
INTERVAL
minutes
New proposed event system:
- When a player logs on, a single query will grab all their times.
- A new runnable will be scheduled to execute
x
minutes later, when they would "fire" the event normally - There will be a runnable per-event, per-player.
- Events would be able to be "overridden" or bypassed via permissions
- No future SQL queries would be needed, and times would be more accurate