Fix Perk variables being overriden when multiple kits used the same perk
This commit is contained in:
parent
5bc2b9d34c
commit
27cff85189
@ -42,10 +42,10 @@ public class PerkSmashStats extends Perk
|
||||
@Override
|
||||
public void setupValues()
|
||||
{
|
||||
_damage = getPerkDouble("Damage");
|
||||
_knockbackTaken = getPerkPercentage("Knockback Taken");
|
||||
_regen = getPerkDouble("Regeneration");
|
||||
_armor = getPerkDouble("Armor");
|
||||
_damage = getPerkDouble("Damage", _damage);
|
||||
_knockbackTaken = getPerkPercentage("Knockback Taken", _knockbackTaken);
|
||||
_regen = getPerkDouble("Regeneration", _regen);
|
||||
_armor = getPerkDouble("Armor", _armor);
|
||||
|
||||
setDesc(
|
||||
(C.cAqua + "Damage: " + C.cWhite + _damage) + C.cWhite + " " + (C.cAqua + "Knockback Taken: " + C.cWhite + (int) (_knockbackTaken * 100) + "%"),
|
||||
|
@ -115,8 +115,8 @@ public abstract class Perk implements Listener
|
||||
|
||||
private String getPerkObject(String id)
|
||||
{
|
||||
String key = _spreadsheet.getKey(this, id);
|
||||
|
||||
String key = _spreadsheet.getKey(Kit, this, id);
|
||||
|
||||
if (!_spreadsheet.getDataMap().containsKey(key))
|
||||
{
|
||||
return null;
|
||||
|
@ -24,11 +24,6 @@ import java.util.Objects;
|
||||
public class PerkSpreadsheetModule implements Listener
|
||||
{
|
||||
|
||||
private static final String SLACK_CHANNEL_NAME = "#google-sheet-errors";
|
||||
private static final String SLACK_USERNAME = "Google Sheets";
|
||||
private static final String SLACK_ICON = "http://moppletop.github.io/mineplex/google-sheets-image.png";
|
||||
private static boolean _reportedError;
|
||||
|
||||
private static final SheetObjectDeserialiser<Pair<String, String>> DESERIALISER = values -> Pair.create(values[0], values.length == 1 ? "" : values[1]);
|
||||
|
||||
private final Game _game;
|
||||
@ -98,7 +93,7 @@ public class PerkSpreadsheetModule implements Listener
|
||||
|
||||
if (currentPerk != null)
|
||||
{
|
||||
String id = getKey(currentPerk, pair.getLeft());
|
||||
String id = getKey(kit, currentPerk, pair.getLeft());
|
||||
_dataMap.put(id, pair.getRight());
|
||||
}
|
||||
}
|
||||
@ -144,9 +139,9 @@ public class PerkSpreadsheetModule implements Listener
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getKey(Perk perk, String value)
|
||||
public String getKey(Kit kit, Perk perk, String value)
|
||||
{
|
||||
return perk.GetName() + "." + value;
|
||||
return kit.GetName() + "." + perk.GetName() + "." + value;
|
||||
}
|
||||
|
||||
public Map<String, String> getDataMap()
|
||||
@ -154,27 +149,4 @@ public class PerkSpreadsheetModule implements Listener
|
||||
return _dataMap;
|
||||
}
|
||||
|
||||
public void reportError(Exception exception, String sheetName, String dataKey)
|
||||
{
|
||||
// Only allow one error report per lifetime, as the game causes an infinite loop.
|
||||
if (_reportedError)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_reportedError = true;
|
||||
|
||||
String message = "A parsing error has occurred on spreadsheet *" + sheetName + "* with data key *" + dataKey + "*.\n Details: " + exception.getMessage();
|
||||
|
||||
System.out.println(message);
|
||||
try
|
||||
{
|
||||
SlackAPI.getInstance().sendMessage(SlackTeam.DEVELOPER, SLACK_CHANNEL_NAME, new SlackMessage(SLACK_USERNAME, new URL(SLACK_ICON), message), true);
|
||||
}
|
||||
catch (MalformedURLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user