Jump to content
Sign in to follow this  
JoeDezzy1

Login Helper

Recommended Posts

In the past, I've experienced consistency issues with certain methods in the API that return false/inconsistent information on certain occasions, especially upon logins.

Here is something I've created a while ago that became very useful to combat that issue.

 

import org.tribot.api.General;
import org.tribot.api2007.Game;
import org.tribot.api2007.Login;

/**
 * @author JDezzy1
 */
public class LoginAccess extends Login implements Access {
	/**
	 * The amount of settings in the gamesettings array to confirm consistency
	 * in ingame data
	 */
	public static final transient int settingsArrayLength = 70;
	/**
	 * The ban message upon logging in
	 */
	public static final transient String BAN_HOOK = "Your account has been disabled. Please check your message-centre for details.";

	/*
	 * (non-Javadoc)
	 * 
	 * @see scripts.dezapi.wrappers.accessor.Access#access()
	 */
	@Override
	public Class<Login> access() {
		return Login.class;
	}

	/**
	 * @return true if in game
	 */
	public static boolean inGame() {
		final STATE ST8 = getLoginState();
		return ST8 != null && ST8.equals(STATE.INGAME);
	}

	/**
	 * @return true if at the login screen
	 */
	public static boolean inLoginScreen() {
		final STATE ST8 = getLoginState();
		return ST8 != null && ST8.equals(STATE.LOGINSCREEN);
	}

	/**
	 * @return true if at the welcome screen
	 */
	public static boolean inWelcomeScreen() {
		final STATE ST8 = getLoginState();
		return ST8 != null && ST8.equals(STATE.WELCOMESCREEN);
	}

	/**
	 * @return true if there is a ban message
	 */
	public static boolean banMessage() {
		final String response = Login.getLoginResponse();
		return response != null && response.equals(BAN_HOOK);
	}

	/**
	 * Does what it says
	 * 
	 * @return Game setting.length > ~70 plus all other hooks
	 */
	public static boolean isEverythingFuckingLoadedAndReadyToBeRead() {
		return !inWelcomeScreen() && inGame() && Game.getGameState() == 30
				&& Game.getSettingsArray().length >= settingsArrayLength;
	}

	/**
	 * @return true if the login was successful
	 */
	public static boolean waitLogin() {
		return Waiting07.waitCondition(() -> {
			return isEverythingFuckingLoadedAndReadyToBeRead();
		}, System.currentTimeMillis() + General.randomSD(35000, 45000, 4250));
	}

	/**
	 * @return true if the logout was successful
	 */
	public static boolean waitLogout() {
		return Waiting07.waitCondition(() -> {
			return inLoginScreen();
		}, System.currentTimeMillis() + General.randomSD(35000, 45000, 4250));
	}

	/**
	 * 
	 * @param user
	 * @param pass
	 * @return
	 */
	public static boolean handleLogin(final String user, final String pass) {
		General.println("Login => attempting login => " + user);
		if (login(user, pass)) {
			General.println("Login => waiting for login...");
			if (waitLogin()) {
				General.println("Login => logging in => successful login");
				return true;
			}
		}
		return false;
	}
}

 

Share this post


Link to post
Share on other sites

Good snippet, but let me add some suggestions.

 

Some of the methods aren't needed. I'm pretty sure "getLoginState" can't return null, so you don't need all that extra calculation. It would make more sense to just do "Login.getLoginState() == [state]". Plus, if you are checking to see what state you're in, calling these methods recalculates the login state each time, when it would be easier to call it once and do a switch statement.

 

Also, not a single comment in this code is needed. Proper policy would suggest you either use them to explain the "why" and "when to use", not the "how". And empty comments or "does what it says" just gets in the way. I know this might sound nitpicky, but it's common courtesy when posting public code. The only comments that do this are your "wait..." method comments.

 

I do quite like the ban-detecting snippet, though. I might add that into my framework.

Share this post


Link to post
Share on other sites

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
Sign in to follow this  

  • Similar Content

    • By grammatoncleric
      Super basic script, I am very very very new to Java, so please be nice... No this script is not finished, but at minimum it should at least gather trout/salmon and bank it, but i cant find the script or it hasnt loaded in tribot.
       
      A picture of my  hierarchy: ImgurLink
      package scripts.LowLevelCooker; import org.tribot.api.DynamicClicking; import org.tribot.api.General; import org.tribot.api.Timing; import org.tribot.api.types.generic.Condition; import org.tribot.api2007.*; import org.tribot.api2007.types.RSObject; import org.tribot.api2007.types.RSTile; import org.tribot.script.Script; import org.tribot.script.ScriptManifest; import org.tribot.script.interfaces.MessageListening07; // import org.tribot.script.interfaces.Painting; import java.awt.*; @ScriptManifest(authors = ("noobalicious"), name = "Low Level Gatherer", category = "Money Making", description = ("gathers trout & salmon")) public class LowLevelCooker extends Script implements MessageListening07 { final String[] AXE_NAMES = { "Bronze axe", "Iron axe", "Black axe", "Steel axe", "Mithril axe", "Adamant axe", "Rune axe", "Dragon axe"}; private final RSTile gatherTile = new RSTile(3100, 3425); private final RSTile bankTile = new RSTile(3094, 3491); private final int MINING_ANIMATION = 625; private RSObject[] depositBox; private final int DEPOSITBOX_ID = 6943; @Override public void run() { while (true) { sleep(100); if (atFood()) { if (Inventory.isFull()) { walkToBank(); } else { gatherFood(); } } else if (atBank()) { if (Inventory.isFull()) { bank(); } else { walkToFood(); } } else { if (Inventory.isFull()) { walkToBank(); } else { walkToFood(); } } } } private boolean walkToBank() { return PathFinding.aStarWalk(bankTile); } private boolean atBank() { return Player.getPosition().distanceTo(bankTile) < 5; } private boolean bank() { depositBox = Objects.findNearest(20, DEPOSITBOX_ID); if (!Banking.isDepositBoxOpen()) { if (depositBox.length > 0) { if (!DynamicClicking.clickRSObject(depositBox[0], "Deposit")) return false; } } else { if (Banking.depositAllExcept(AXE_NAMES) < 1) return false; } return Timing.waitCondition(new Condition() { @Override public boolean active() { return !Inventory.isFull(); } }, General.random(3000, 4000)); } private boolean walkToFood() { return PathFinding.aStarWalk(gatherTile); } private boolean atFood() { return Player.getPosition().distanceTo(gatherTile) < 10; } private void gatherFood() { final RSObject foodID[] = Objects.findNearest(5, 335, 333, 331, 329); RSObject foodToGather = foodID[0]; if (foodToGather.isOnScreen()) { if (DynamicClicking.clickRSObject(foodToGather, "Take")) { Timing.waitCondition(new Condition() { @Override public boolean active() { General.sleep(20, 30); return true; } }, General.random(75, 100)); } } } @Override public void duelRequestReceived(String s, String s1) { } @Override public void personalMessageReceived(String s, String s1) { } @Override public void serverMessageReceived(String s) { } @Override public void playerMessageReceived(String s, String s1) { } @Override public void tradeRequestReceived(String s) { } @Override public void clanMessageReceived(String s, String s1) { } }  
    • By Worthy
      Welcome to Worthy Scripts
      |w| Zulrah Slayer
      Features
      V2 HIGHLIGHTED FEATURES (this script has been fully rewritten) LG Compatible The script now functions smoothly with TRiBot's beta feature Looking Glass Unlimited multi-kill performance The bot will determine if it has enough supplies to start another Zulrah battle after killing the boss the previous time. It can continue doing this until it runs out of food, allowing a single, double, triple, or quad+ kill. Dynamically prioritized combat framework Zulrah fight very CPU efficient! Travel method support update Zul-Andra teleport scrolls Charter Travel Camelot port [via Camelot teleports] Catherby port [via Catherby port lunar teleport] Khazard port [via Khazard port lunar teleport] Fairy Ring Network Fairy ring via Varrock Teleport Fairy ring via Quest Cape Fairy ring via Ardougne Cloak Fairy ring via Salve Graveyard Teleport Fairy ring via slayer ring Fairy ring via House Teleport (mounted) Ornate pool support If so, the script will use castle wars bank instead Jewelry box support If so, the script will use a custom kill / bank loop (with no Ring of Dueling) Or use another player's house! Ability to input a list of names. There are so many customizeable options for every travel method I recommend checking out the documentation thread for a full detailed explanation if you are considering purchasing.
        As of 4/21/2018 the bot now supports resizeable mode!
      This is one of the most human-like antibans any botting client can offer.
        Set range and magic sets  Also supports an optional mage only mode Swaps gear and prays efficiently Prayer flickering for JAD phases Calculates zulrah drop earnings Deathwalk - SAFE BOSS: never lose your items on death Recharges Trident of the Seas, Trident of the Swamp, Toxic Blowpipe, Serpentine Helm (all forms) Tracks arrow count, charge count, and ammo count for all special weapons Repairs barrows armor  Reorganizes inventory! Drags and drops items like a real player Supports serpentine helmets Supports cooked karambwans Supports special attacks Supports ring of suffering Supports prayer potions or super restores Supports stamina potions Supports summer pies for agility boost Supports imbued heart Supports random world hopping Supports new rigour and augury prayers Supports vengeance spell with optimal timing Ability to use rune pouch Requires Earth, Death, and Astral runes Picks up and banks the Zulrah pet Dodges melee phase attacks Sexy loot table. Analyze your drops! Hiscores system (below) Dynamic signatures (below) Automatic screenshot progress report system every hour
      Detailed session log dump. Keep track of exactly how all your bots do!
      ABC V2 Level 10  
      Official Discord Discussion
      http://discord.gg/yeCVsad
       
      External Documentation Thread
      I have moved a large part of the documentation to an external thread which contains how to:
      Create an armor preset Decide what gear to wear Set up the GUI to be tailored to your RuneScape character Start the script correctly Other notable information If you are considering purchasing this script, read the documentation thread.

       
      Proggies





      More: http://imgur.com/a/HNaQZ
      Even more: http://imgur.com/a/lsh82

      Requirements
      - 80 to 85+ range/magic (85+ magic necessary as it is the most important stat). If using LG, have at least 85 of both.
      - High defence and hp (>= 70 for barrows), HP recommend at least 75
      - 43+ prayer
      - Regicide, Underground pass, Biohazard, and Plague City required

      Live Hiscores System
      V1 Hiscores (OLD) V2 Hiscores (CURRENT)
      Dynamic Signatures:
      Automatically load an image of your current stats, which updates as you bot!
      http://www.worthy.rs/tribot-php/ZulrahSlayerV2/sigs/USERNAME_HERE.png Just replace USERNAME_HERE with your TRiBot username (make sure it is all lowercase), and copy and paste it the image link itself into your signature here:
       (should be on the bottom right of your signature edit box).


      Pricing
      The Casual Botter
      - 14.99 CREDITS | 1 auth for 2 weeks
      - 24.99 CREDITS | 1 auth for 1 month

      Gold Farmer's Discount
      - 79.99 CREDITS | 5 auths for 1 month
      - 134.99 CREDITS | 10 auths for 1 month
      - 174.99 CREDITS | 15 auths for 1 month
      - 224.99 CREDITS | 25 auths for 1 month
      - 299.99 CREDITS | 50 auths for 1 month
      Note: the number of auths designates the number of RS accounts you can run on this script at a given time.


      Click below to purchase or for FREE TWO HOUR TRIAL:

       
      Regards,
      Worthy
    • By MilkyWay
      iv never been able to get looking glass working since I joined, but I recently had a bit success and got it to hook on to osbuddy,
      but when I click start scripts nothing happens for me.
    • By Thebot13
      Originally Posted by TRiLeZ  So having something like this: Code: JarURLConnection clientConnection = ((JarURLConnection) getJarURL( world).openConnection()); clientConnection.addRequestProperty("Protocol", "HTTP/1.1"); clientConnection.addRequestProperty("Connection", "keep-alive"); clientConnection.addRequestProperty("Keep-Alive", "200"); clientConnection.addRequestProperty("Referrer", "-"); clientConnection.addRequestProperty("User-Agent", "Mozilla/5.0 (" + System.getProperty("os.name") + " " + System.getProperty("os.version") + ") Java/" + System.getProperty("java.version")); classLoader = AppletClassLoader .newInstance(new URL[] { clientConnection.getJarFileURL() }); Would disguise a bot accessing the loader from the runescape website as a web browser, and it would be undetectable, right? unless jagex analyzes the content of your hdd/ram, which Mopar says they 'could' do.
      ^
      @TRiLeZ "The developer of OSB worked at Jagex"
      If Jagex is able to scan through your running tasks while using the official client, and unsafe to do so,  with their anti-tamper detection software if they worked together with the former employee of Jagex to make Osbuddy, (which I wouldn't doubt they made an agreement to share data privilege due to copyright issues) Wouldn't that allow them to do the same through Osbuddy to detect running tasks etc? even if it's hooked through the LG?
       
       
       
    • By Thebot13
      I think I may have figured out a technique used by the software botwatch they may look at a new account since the new account is at an extremely low ranking of several 100,000 if you continuously train on that account including other methods it uses to detect it must go by ranks as the most primary method of finding and flagging new accounts that are being botted.
       
      This also concerns mains that are botted let's say if you go over an increase of 80,000+ ranks in 24 hours. Then the botWatch system flags or account for a mod to look at. 
       
      I suggest tracking you account closely on CrystalMathlabs and watch your ranking. I would suggest that you stay under the 30,000 rank increase in any given skill
       
      **EDIT This is purely thought based, noone knows how the botwatch programme detects botters.
    • By Rabadon2013
      I dont know if im on the right section but i need help with the paypal payment option.
      I verfied my paypal email address but if i pay with paypal i get this Error message in the top of the website :Connection Exception - Got Http response code 400 when accessing https://api.paypal.com/v1/payments/payment/PAY-6AX07555PM1948029LK322YA/execute.
       pls help i dont have a credit card right now^^
      and sry for my bad english, i only have these basic english skills from the school.
  • Our picks

    • This update will:

      Fix GE inventory item positioning bug


      Fix broken object hooks
        • Like
      • 23 replies
    • This release will:

      Fix some ClosedChannelException bug


      Fix bug in RSObject#getAllTiles


      Add game tab support for "Kourend Favour"
        • Like
      • 15 replies
    • This release will:

      Fix Settings UI placement bug


      Fix game object location bug


      Fix small layout bug making the client shift up and down


      Fix client crashing bug where loading the client with a small display area will cause the client to crash


      Fix annoying Linux bug relating to painting events and peers


      Fix settings saving bug where settings are saved to disk more often than they should


      Fix RSInterface#isBeingDrawn bug affecting a limited amount of people


      Drop Java 1.7 bytecode version for 1.8


      Important: Since the downloadable RS client uses Java 7, it will no longer be compatible with Looking Glass. To make up for this, we will add support for using other clients such as RuneLite (at a later date).


      This change was necessary to allow us to use Java 8 syntax. It also paves the way for Java 9/10/11 support.
        • Like
      • 40 replies
    • This update will:

      Fix the RSMenuNode bug which also fixes the bug with bank opening


      Fix the incorrect object positions bug


      Fix and re-enable the LG Objects API Accelerator


      Fix the RSObject#getAllTiles bug
        • Like
      • 22 replies
    • Try our development release by checking "Development Release" on the TRiBot Loader. Note that these new features are currently in beta.

      This release features:

      Re-sizable mode support for both LG and the regular client


      Slightly improved login bot


      Removed final access modifiers from API classes


      Added RSServer hook wrapper to get the client's cached list of server/world info


      [NEW] Bug fix for intelligent banking


      [NEW] Improvement to the stability of LG over time


      [NEW] Vastly improved the reliability and speed of Screen#getColorAt on both LG and the regular client


      [NEW] Fix LG login problems


      [NEW] Fixed re-sizable mode container bug


      [NEW] Fixed re-sizable mode mouse bug


      [NEW] Use of public constants in the Banking API


      [NEW] Use of other various constants such as Projection#NULL_PT and Screen#EMPTY_COLOR



      More features to come very soon!

      Please test it and let us know here if there are any new bugs introduced in this release.
        • Thanks
        • Like
      • 12 replies
  • Recently Browsing   0 members

    No registered users viewing this page.

×