#Hardcore Timer
1 messages · Page 1 of 1 (latest)
not granted
I have a server, I coded it so when a player dies they turn into spectator mode
Now another player can either redeem their totem at the hub to respawn them or they respawn automatically after 24 hours
I already did the totem part, I just need some help knowing how I can check and run something after 24 hours
If the player is offline or online
to respawn them automatically after 24 hours, I'd just use a scheduled timer that runs every second and checks if any "ban" has expired
Would that cause performance?
no
it's no problem. you're simply comparing a few numbers every second
you will not notice ANY performance problems
every few seconds or minute would be fine. You don;t need such accuracy
But how would I have a timer for each player
Because they don't all get the same timer
you only use one timer
you should make sure to cache it instead of rereading the file every second
e.g, a HashMap<UUID,Long>
where Long is the timestamp when the ban expires
Ok thank you all
yeah of course, I didn't mean to read a file every second
So with a HashMap
load the file on startup and save it on shutdown
So I also have to create a file for the players?
only 1
kk
Spigot has built in support for YAML and Json
What is "YAML"?
YAML would be easier to implement as its in teh API, Json is shaded in Spigot but no API
YAML is the language used for Spigots configs and plugin.yml files
Ok so everytime a player dies, I add them to my file and cache from the file to check if their timer is up every minute or so
FileConfiguration
YAML is easier to use within spigot. I'd simply use a YamlConfiguration object
of course JSON is fine too
but if you never used neither of them, I'd start with YAML
If their timer has expired, yes
Is this correct?
Is your respawn event somethign you manually trigger?
What I'm sayign is, after the 24 hours are up for a player, shoudl they automatically respawn, or are they stuck in spectator untill an event happens>?
They should automatically respawn
So I can run the respawn event in the part I check if their time is up
ok, so respawn happens when their timer expires, OR they are revived, or you run a respawn for everyone?
No they respawn automatically
I already have a respawn event
Because of my totem system, when another player claims a players totem I make them respawn
So I think in my checking if timer is up event
I can run the respawn function right? @delicate prairie
And I will also remove them from the map if someone else claims their totem
Ok thank you
and pls remember: iterating over a small map (I assume that you do not have more than 10,000 players) and comparing some timestamps is really no problem at all performance-wise
so no problem in doing it every second or every X seconds
Ok thank you :))
np!
I will check it every minute it doesn't need to be that accurate
okidoki