Jump to content
Existing user? Sign In

Sign In



Sign Up

Vencillio/Valius 'Time Played'


Gildartsthegreat

Recommended Posts

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

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 by Gildartsthegreat
made it look better
Link to comment
Share on other sites

  • 3 months later...
  • 10 months later...
  • 1 month later...
  • 1 year later...
  • 1 month later...
  • 1 month later...
  • 2 weeks later...
  • 5 months later...
  • 6 months later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

Contact

[email protected]

astra.security

What is a RSPS?

A RSPS, also known as RuneScape private server, is an online game based on RuneScape, and controlled by independent individuals.

Popular RSPS Servers

Runewild Ikov RedemptionRSPS

Disclaimer

Runesuite is not affiliated with runescape, jagex in any way & exists solely for educational purposes.

×
×
  • Create New...