1

[Request] Daily server login rewards

Myyoyo's Avatar Myyoyo8/8/22 1:26 am
8/8/2022 2:17 am
garlicbreathinator's Avatar garlicbreathinator
Can someone do a data pack that gives daily rewards to players when they join a server?
Posted by Myyoyo's Avatar
Myyoyo
Level 65 : High Grandmaster Wolf Whisperer
606

Create an account or sign in to comment.

1

1
08/08/2022 2:17 am
Level 31 : Artisan Engineer
garlicbreathinator
garlicbreathinator's Avatar
This will require a bit of maintenance by server admins and is unreliable unless you use the worldborder. I guess I could make one but you would need to decide what rewards you want and add them as a function or loot table.

Datapacks for the most part do not have access to a real time clock. They can't tell what time of day it is or how much real time has passed, just the number of game ticks. Since there are usually 20 game ticks in a second, you can do the math and find that 1 day is 1,728,000 game ticks. Or at least, it should be. When the game is lagging, fewer ticks happen and when the server is down no ticks happen at all. You can use /schedule to set up a hidden countdown managed by the server, or use scoreboards which are a tiny bit more work but can be changed or read how much time is left instead of just reset. This is the easiest way to keep track of time, but there are more accurate methods which require more effort.

Remember how I used a "for the most part" up there? The reason for that is the world border. If you set the world border to grow or shrink over time, it actually does that based on the computer's clock instead of the number of ticks. If you say "shrink the world border from 1000 blocks to 900 blocks over 100 seconds" and then the server lags super hard and gets 10 tps, the world border will say 100 seconds passed but a scoreboard or /schedule will only say 50. If the worldborder is growing or shrinking when the server is shut down, it forgets its progress and finishes instantly when the server starts back up but you can use /worldborder query and store it to a scoreboard or NBT to back it up. Of course, this means your world border will growing and shrinking to keep track of the time greatly reduces the playable area of the server.




Both of these still have 1 big issue though: They don't (and cannot) account for downtime. Singleplayer worlds and servers running through services like Aternos and Minehut do not run when nobody is on them, and you can't tell how long that is. No datapack system will work for these servers no matter what, unless an admin manually increased the "day" count by 1 with a command each day to reset the rewards. Any other server will still need to be rebooted after crashes, for updates, and to bail memory leaks. You can add a little bit to the timer to manually compensate for these. Another valid option would be to have your server automatically reboot every day and to have the rewards reset whenever it rebooted with a #minecraft:load function, or to reboot n times a day and reset rewards every n reboots.



Daily rewards with a plugin are much more practical, but if you need to stay vanilla let me know what method would work best for you.
Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome