Gildartsthegreat 2 Posted January 14, 2019 Report Share Posted January 14, 2019 (edited) This is a quick release/tutorial on getting 'Time Played' on a Valius or Vencillio base, only reason im posting it is because I haven't seen anyone release something like this and its my own work. I am OneTrueGodTet on R-S this is my work, Just wanted to post it here as well seeing as im new and not everyone may have access to it there This is the hidden content, please Sign In or Sign Up I'm not saying its perfect or that it dosen't need some tender love and care but here ya go.in rs2\entitiy\playerPlayer.java add the following imports: import com.mayhem.rs2.entity.player.net.TimePlayed import java.util.concurrent.TimeUnit; and add the following under: public class Player extends Entity { private TimePlayed time = new TimePlayed(this); public TimePlayed getTimePlayed(){ return time; } public long timePlayed; And still in Player.java add the following under: public void setShopCollection(long shopCollection) { public void setTimePlayed(long timePlayed) { this.timePlayed = timePlayed; } Next in rs2\entitiy\player\net Create a class called Timeplayed.java and add the following package com.mayhem.rs2.entity.player.net;import java.util.Calendar; import java.util.Date; import com.mayhem.rs2.entity.player.Player; import com.mayhem.rs2.entity.player.net.Client; public class TimePlayed { /** * The player */ private final Player player; /** * Initialized the start date */ private Calendar start = Calendar.getInstance(); /** *Initialized the end date */ private Calendar end = Calendar.getInstance(); /** * Constructor for the time played class * @param player - The player */ public TimePlayed(final Player player){ this.player = player; } /** * Records when the player logs in */ public void initilizeNewStart(){ start.setTime(new Date()); } /** * Records when the player logs out. */ public void initilizeNewEnd(){ end.setTime(new Date()); } /** * Gets the players start date * @return - the start date */ public Calendar getStartDate(){ return start; } /** * Gets the players end date * @return - The end date */ public Calendar getEndDate(){ return end; } /** * Gets the length of time that the player was logged in for * @return - Time */ public long getCurrentSession(){ return end.getTimeInMillis() - start.getTimeInMillis(); } /** * Formats the long into a time format * @return - The new format */ public String formatPlayersTime(){ long minute = (player.timePlayed / (1000 * 60)) % 60; long hour = (player.timePlayed / (1000 * 60 * 60)) % 24; long day = (player.timePlayed / (1000 * 60 * 60 * 24)); String format = day + " days " + hour + " hours " + minute + " min"; return format; } } Next step is optional i guess in playercommand.java add the following command case "playtime": { player.getTimePlayed().initilizeNewEnd(); player.timePlayed += player.getTimePlayed().getCurrentSession(); player.getTimePlayed().initilizeNewStart(); player.send(new SendMessage("You have played for @red@ " + player.getTimePlayed().formatPlayersTime())); } and add the following in CommandInterface.java "::playtime - updates and displays current playtime" in Playersave.java found in rs2\content\io: look for: public PlayerDetails(Player player) { and somewhere under that up to you add: timePlayed = (player.timePlayed + player.getTimePlayed().getCurrentSession()); Lastly in InformationTab.java, rs2\content\interfaces\impl\Quest Under "<col=ff9040>Online Staff: <col=75C934>" + World.getStaff(), Add "<col=ff9040>Time Played: <col=75C934>", "<col=75C934>" + player.getTimePlayed().formatPlayersTime(), Well thats it you should be able to get a decent working time played from that any criticism or improvements are welcome! If you found this helpful please leave a thanks or a rep+ Edited January 14, 2019 by Gildartsthegreat made it look better 2 Link to comment Share on other sites More sharing options...
TehDarker 2 Posted January 15, 2019 Report Share Posted January 15, 2019 sure it will help some, thanks 1 Link to comment Share on other sites More sharing options...
siccoblue 2 Posted May 5, 2019 Report Share Posted May 5, 2019 nice thank you Link to comment Share on other sites More sharing options...
Maulage 0 Posted March 11, 2020 Report Share Posted March 11, 2020 Thanks for this, I used this myself. Link to comment Share on other sites More sharing options...
SpiritOfTheLau 0 Posted May 9, 2020 Report Share Posted May 9, 2020 Pretty sweet snippet. I always found explicit comments on every field a bit obnoxious myself Link to comment Share on other sites More sharing options...
ApplyPressa 1 Posted December 16, 2021 Report Share Posted December 16, 2021 thanks! Link to comment Share on other sites More sharing options...
Ary3x 0 Posted February 14, 2022 Report Share Posted February 14, 2022 Will be using thanks Link to comment Share on other sites More sharing options...
khonqr 0 Posted April 14, 2022 Report Share Posted April 14, 2022 perfect thanks! Link to comment Share on other sites More sharing options...
promahmoud 0 Posted April 28, 2022 Report Share Posted April 28, 2022 Thank you Link to comment Share on other sites More sharing options...
geraldpons97 0 Posted May 6, 2022 Report Share Posted May 6, 2022 thanks Link to comment Share on other sites More sharing options...
Matts0172 1 Posted October 15, 2022 Report Share Posted October 15, 2022 Thanks! Link to comment Share on other sites More sharing options...
cowell75 3 Posted April 18, 2023 Report Share Posted April 18, 2023 thanks Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now