so , I want to make a plugin that doesn't allow any player to join the server for 15 mins (real life time) after server restart . i've tried but im not able to get it and im no where near it .
Code (Java): private long time; @Override public void onEnable() { time = System.currentTimeMillis(); } @EventHandler public void login(PlayerLoginEvent event) { if(System.currentTimeMillis()<time+(15*60*1000)) event.disallow(PlayerLoginEvent.Result.KICK_FULL, ChatColor.RED + "Connection Lost"); } Thats one way to do it
On my phone so can’t really type code, but just store start time as System.currentTimeMillis, and then on login check whether the currentTimeMillis when the event is handled is greater than start time + 15*60*1000. Then there’s no need for all that parsing.
I have a dumb question. Why use long instead of double? I have never stored time for any of my plugins so that might be why. Does it overload?
Because System.getCurrentTimeMillis returns a long, not a double. Decimals aren’t needed and would introduce imprecision so it wouldn’t make sense for that method to return a double.