ge plugin: fix adding limit reset timer multiple times

The code was assuming anything added to the examine text was separated
with <br>, however the reset timer doesn't do that.
This commit is contained in:
Adam
2020-06-12 13:28:25 -04:00
parent 40452b2864
commit 3d762d7ca2

View File

@@ -180,6 +180,7 @@ public class GrandExchangePlugin extends Plugin
private Widget grandExchangeText; private Widget grandExchangeText;
private Widget grandExchangeItem; private Widget grandExchangeItem;
private String grandExchangeExamine;
private int osbItem; private int osbItem;
private OSBGrandExchangeResult osbGrandExchangeResult; private OSBGrandExchangeResult osbGrandExchangeResult;
@@ -842,8 +843,13 @@ public class GrandExchangePlugin extends Plugin
return; return;
} }
String[] lines = geText.getText().split("<br>"); if (geText.getText() == grandExchangeExamine)
String text = lines[0]; // remove any limit or OSB ge values {
// if we've already set the text, don't set it again
return;
}
String text = geText.getText();
if (config.enableGELimits()) if (config.enableGELimits())
{ {
@@ -866,6 +872,7 @@ public class GrandExchangePlugin extends Plugin
} }
} }
grandExchangeExamine = text;
geText.setText(text); geText.setText(text);
if (!config.enableOsbPrices()) if (!config.enableOsbPrices())
@@ -876,7 +883,8 @@ public class GrandExchangePlugin extends Plugin
// If we already have the result, use it // If we already have the result, use it
if (osbGrandExchangeResult != null && osbGrandExchangeResult.getItem_id() == itemId && osbGrandExchangeResult.getOverall_average() > 0) if (osbGrandExchangeResult != null && osbGrandExchangeResult.getItem_id() == itemId && osbGrandExchangeResult.getOverall_average() > 0)
{ {
geText.setText(text + OSB_GE_TEXT + QuantityFormatter.formatNumber(osbGrandExchangeResult.getOverall_average())); grandExchangeExamine = text + OSB_GE_TEXT + QuantityFormatter.formatNumber(osbGrandExchangeResult.getOverall_average());
geText.setText(grandExchangeExamine);
} }
if (osbItem == itemId) if (osbItem == itemId)
@@ -895,9 +903,13 @@ public class GrandExchangePlugin extends Plugin
try try
{ {
final OSBGrandExchangeResult result = CLIENT.lookupItem(itemId); final OSBGrandExchangeResult result = CLIENT.lookupItem(itemId);
osbGrandExchangeResult = result; if (result != null && result.getOverall_average() > 0)
// Update the text on the widget too {
geText.setText(start + OSB_GE_TEXT + QuantityFormatter.formatNumber(result.getOverall_average())); osbGrandExchangeResult = result;
// Update the text on the widget too
grandExchangeExamine = start + OSB_GE_TEXT + QuantityFormatter.formatNumber(result.getOverall_average());
geText.setText(grandExchangeExamine);
}
} }
catch (IOException e) catch (IOException e)
{ {