feat: add a way to get AccountType

This adds a way to get the logged in players account type.
This commit is contained in:
Joshua Filby
2018-04-25 17:28:09 -05:00
committed by Adam
parent e9d1d7e75f
commit b594c83ab6
4 changed files with 79 additions and 1 deletions

View File

@@ -32,6 +32,7 @@ import javax.annotation.Nullable;
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;
@@ -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();

View File

@@ -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

View File

@@ -0,0 +1,47 @@
/*
* Copyright (c) 2018, Joshua Filby <joshua@filby.me>
* 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();
}
}

View File

@@ -27,6 +27,7 @@ package net.runelite.mixins;
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;
@@ -160,6 +161,25 @@ public abstract class RSClientMixin implements RSClient
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()