Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • Play Time Plugin


    Zoe

    Recommended Posts

    Play Time Plugin v1.1

    I'm not sure if anyone uses plugins, but I quickly wrote this while looking at the API.

     

    About This Plugin:

    Adds a simple paint above the chat box to show how long you have been logged into the game for (useful for seeing log in time after breaks, world hopping etc as most scripts just show total run time).

     

    Changelog:

    1.1

    • World hopping support added (Thank you Koschei)

    1.0 

    • Initial release.

     

    Download Link: 

    https://www.dropbox.com/s/tzy223wyu36o3vi/PlayTime.jar?dl=0

     

    Source:

    PlayTime.java

     
    
    package zoe.dreambot.plugin;
    
    import java.awt.Color;
    import java.awt.Font;
    import java.awt.Graphics;
    import java.time.Duration;
    import java.time.Instant;
    import java.time.LocalTime;
    import java.time.format.DateTimeFormatter;
    
    import org.dreambot.api.Client;
    import org.dreambot.api.data.GameState;
    import org.dreambot.api.plugin.Plugin;
    import org.dreambot.api.plugin.PluginManifest;
    
    @PluginManifest(author = "Zoe", name = "Playtime Plugin", version = 1.1)
    public class PlayTime extends Plugin {
    
    	private Instant loginTime;
    	private Font font;
    	private Client c;
    
    	public void onStart() {
    
    		font = new Font("Courier New", 1, 10);
    		c = getClient();
    
    	}
    
    	public void onPaint(Graphics g) {
    
    		if (!c.isLoggedIn() || c.getGameState().equals(GameState.HOPPING)) {
    			loginTime = null;
    			return;
    		}
    
    		if (loginTime == null) {
    			loginTime = Instant.now();
    		}
    
    		g.setFont(font);
    		g.setColor(Color.cyan);
    		g.drawString(getLoginTime(), 10, 330);
    
    	}
    
    	private String getLoginTime() {
    
    		Duration duration = Duration.between(loginTime, Instant.now());
    		LocalTime time = LocalTime.ofSecondOfDay(duration.getSeconds());
    		return time.format(DateTimeFormatter.ofPattern("HH:mm:ss"));
    
    	}
    }

     

    Link to comment
    Share on other sites

    Haven't heard of plugins for a long while now :P 
    You can also check if they're hopping by using 

    if (getClient().getGameState().equals(GameState.HOPPING))
    Link to comment
    Share on other sites

    On 5/21/2018 at 9:41 AM, Koschei said:

    Haven't heard of plugins for a long while now :P 
    You can also check if they're hopping by using 

    
    if (getClient().getGameState().equals(GameState.HOPPING))

    Thanks, I've quickly added it and also changed it to just text above the chat box. I don't see any way to edit widget texts or anything through the plugins though 😕

    Link to comment
    Share on other sites

    Archived

    This topic is now archived and is closed to further replies.

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.