Skip to content

Commit

Permalink
feat: add a way to get AccountType
Browse files Browse the repository at this point in the history
This adds a way to get the logged in players account type.
  • Loading branch information
Joshua-F authored and Adam- committed May 2, 2018
1 parent f37dda9 commit 61ec959
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 1 deletion.
6 changes: 6 additions & 0 deletions runelite-api/src/main/java/net/runelite/api/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import net.runelite.api.annotations.VisibleForDevtools;
import net.runelite.api.coords.LocalPoint;
import net.runelite.api.coords.WorldPoint;
import net.runelite.api.vars.AccountType;
import net.runelite.api.widgets.Widget;
import net.runelite.api.widgets.WidgetInfo;

Expand All @@ -57,6 +58,11 @@ public interface Client extends GameEngine

void setUsername(String name);

/**
* Gets the account type for the logged in player.
*/
AccountType getAccountType();

Canvas getCanvas();

int getFPS();
Expand Down
7 changes: 6 additions & 1 deletion runelite-api/src/main/java/net/runelite/api/Varbits.java
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,12 @@ public enum Varbits
/**
* Automatically weed farming patches
*/
AUTOWEED(5557);
AUTOWEED(5557),

/**
* The varbit that stores the players {@code AccountType}.
*/
ACCOUNT_TYPE(1777);

/**
* varbit id
Expand Down
47 changes: 47 additions & 0 deletions runelite-api/src/main/java/net/runelite/api/vars/AccountType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright (c) 2018, Joshua Filby <[email protected]>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.api.vars;

/**
* An enumeration of possible account types.
*/
public enum AccountType
{
NORMAL,
IRONMAN,
ULTIMATE_IRONMAN,
HARDCORE_IRONMAN;

/**
* Check if the {@code AccountType} is any of the possible ironman types.
*
* @return {@code true} if the type is any of the ironman types.
*/
public boolean isIronman()
{
return this.ordinal() >= IRONMAN.ordinal() && this.ordinal() <= HARDCORE_IRONMAN.ordinal();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Nullable;
import net.runelite.api.vars.AccountType;
import net.runelite.api.ChatMessageType;
import net.runelite.api.ClanMember;
import net.runelite.api.GameState;
Expand Down Expand Up @@ -160,6 +161,25 @@ public void setInterpolateObjectAnimations(boolean interpolate)
interpolateObjectAnimations = interpolate;
}

@Inject
@Override
public AccountType getAccountType()
{
int varbit = getVar(Varbits.ACCOUNT_TYPE);

switch (varbit)
{
case 1:
return AccountType.IRONMAN;
case 2:
return AccountType.ULTIMATE_IRONMAN;
case 3:
return AccountType.HARDCORE_IRONMAN;
}

return AccountType.NORMAL;
}

@Inject
@Override
public Tile getSelectedRegionTile()
Expand Down

0 comments on commit 61ec959

Please sign in to comment.