plugins: replace getUsername uses with getAccountHash
This commit is contained in:
@@ -185,7 +185,7 @@ public class GrandExchangePlugin extends Plugin
|
|||||||
private boolean wasFuzzySearch;
|
private boolean wasFuzzySearch;
|
||||||
|
|
||||||
private String machineUuid;
|
private String machineUuid;
|
||||||
private String lastUsername;
|
private long lastAccount;
|
||||||
private int tradeSeq;
|
private int tradeSeq;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -298,7 +298,8 @@ public class GrandExchangePlugin extends Plugin
|
|||||||
clientToolbar.removeNavigation(button);
|
clientToolbar.removeNavigation(button);
|
||||||
mouseManager.unregisterMouseListener(inputListener);
|
mouseManager.unregisterMouseListener(inputListener);
|
||||||
keyManager.unregisterKeyListener(inputListener);
|
keyManager.unregisterKeyListener(inputListener);
|
||||||
lastUsername = machineUuid = null;
|
machineUuid = null;
|
||||||
|
lastAccount = -1L;
|
||||||
tradeSeq = 0;
|
tradeSeq = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -893,13 +894,13 @@ public class GrandExchangePlugin extends Plugin
|
|||||||
|
|
||||||
private String getMachineUuid()
|
private String getMachineUuid()
|
||||||
{
|
{
|
||||||
String username = client.getUsername();
|
long accountHash = client.getAccountHash();
|
||||||
if (lastUsername == username)
|
if (lastAccount == accountHash)
|
||||||
{
|
{
|
||||||
return machineUuid;
|
return machineUuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
lastUsername = username;
|
lastAccount = accountHash;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -922,7 +923,7 @@ public class GrandExchangePlugin extends Plugin
|
|||||||
hasher.putBytes(hardwareAddress);
|
hasher.putBytes(hardwareAddress);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hasher.putUnencodedChars(username);
|
hasher.putLong(accountHash);
|
||||||
machineUuid = hasher.hash().toString();
|
machineUuid = hasher.hash().toString();
|
||||||
tradeSeq = 0;
|
tradeSeq = 0;
|
||||||
return machineUuid;
|
return machineUuid;
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ import java.awt.image.BufferedImage;
|
|||||||
import java.time.temporal.ChronoUnit;
|
import java.time.temporal.ChronoUnit;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import lombok.AccessLevel;
|
import lombok.AccessLevel;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
@@ -123,7 +122,7 @@ public class XpTrackerPlugin extends Plugin
|
|||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
private XpPanel xpPanel;
|
private XpPanel xpPanel;
|
||||||
private XpWorldType lastWorldType;
|
private XpWorldType lastWorldType;
|
||||||
private String lastUsername;
|
private long lastAccount;
|
||||||
private long lastTickMillis = 0;
|
private long lastTickMillis = 0;
|
||||||
private boolean fetchXp; // fetch lastXp for the online xp tracker
|
private boolean fetchXp; // fetch lastXp for the online xp tracker
|
||||||
private long lastXp = 0;
|
private long lastXp = 0;
|
||||||
@@ -162,6 +161,7 @@ public class XpTrackerPlugin extends Plugin
|
|||||||
// Initialize the tracker & last xp if already logged in
|
// Initialize the tracker & last xp if already logged in
|
||||||
fetchXp = true;
|
fetchXp = true;
|
||||||
initializeTracker = true;
|
initializeTracker = true;
|
||||||
|
lastAccount = -1L;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -182,15 +182,15 @@ public class XpTrackerPlugin extends Plugin
|
|||||||
// Check that the username changed or the world type changed.
|
// Check that the username changed or the world type changed.
|
||||||
XpWorldType type = worldSetToType(client.getWorldType());
|
XpWorldType type = worldSetToType(client.getWorldType());
|
||||||
|
|
||||||
if (!Objects.equals(client.getUsername(), lastUsername) || lastWorldType != type)
|
if (client.getAccountHash() != lastAccount || lastWorldType != type)
|
||||||
{
|
{
|
||||||
// Reset
|
// Reset
|
||||||
log.debug("World change: {} -> {}, {} -> {}",
|
log.debug("World change: {} -> {}, {} -> {}",
|
||||||
lastUsername, client.getUsername(),
|
lastAccount, client.getAccountHash(),
|
||||||
firstNonNull(lastWorldType, "<unknown>"),
|
firstNonNull(lastWorldType, "<unknown>"),
|
||||||
firstNonNull(type, "<unknown>"));
|
firstNonNull(type, "<unknown>"));
|
||||||
|
|
||||||
lastUsername = client.getUsername();
|
lastAccount = client.getAccountHash();
|
||||||
// xp is not available until after login is finished, so fetch it on the next gametick
|
// xp is not available until after login is finished, so fetch it on the next gametick
|
||||||
fetchXp = true;
|
fetchXp = true;
|
||||||
lastWorldType = type;
|
lastWorldType = type;
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ package net.runelite.client.plugins.xpupdater;
|
|||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.Objects;
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
@@ -74,7 +73,7 @@ public class XpUpdaterPlugin extends Plugin
|
|||||||
@Inject
|
@Inject
|
||||||
private OkHttpClient okHttpClient;
|
private OkHttpClient okHttpClient;
|
||||||
|
|
||||||
private String lastUsername;
|
private long lastAccount;
|
||||||
private boolean fetchXp;
|
private boolean fetchXp;
|
||||||
private long lastXp;
|
private long lastXp;
|
||||||
|
|
||||||
@@ -88,6 +87,7 @@ public class XpUpdaterPlugin extends Plugin
|
|||||||
protected void startUp()
|
protected void startUp()
|
||||||
{
|
{
|
||||||
fetchXp = true;
|
fetchXp = true;
|
||||||
|
lastAccount = -1L;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
@@ -96,9 +96,9 @@ public class XpUpdaterPlugin extends Plugin
|
|||||||
GameState state = gameStateChanged.getGameState();
|
GameState state = gameStateChanged.getGameState();
|
||||||
if (state == GameState.LOGGED_IN)
|
if (state == GameState.LOGGED_IN)
|
||||||
{
|
{
|
||||||
if (!Objects.equals(client.getUsername(), lastUsername))
|
if (lastAccount != client.getAccountHash())
|
||||||
{
|
{
|
||||||
lastUsername = client.getUsername();
|
lastAccount = client.getAccountHash();
|
||||||
fetchXp = true;
|
fetchXp = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user