From 27cff851893a04088c531dbd1beee3dfb6079ea5 Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 24 Apr 2017 18:04:16 +0100 Subject: [PATCH] Fix Perk variables being overriden when multiple kits used the same perk --- .../games/smash/perks/PerkSmashStats.java | 8 ++--- .../src/nautilus/game/arcade/kit/Perk.java | 4 +-- .../managers/PerkSpreadsheetModule.java | 34 ++----------------- 3 files changed, 9 insertions(+), 37 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/PerkSmashStats.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/PerkSmashStats.java index a545ca357..07804dab9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/PerkSmashStats.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/smash/perks/PerkSmashStats.java @@ -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) + "%"), diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/Perk.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/Perk.java index 0b26d69b6..a403f675a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/Perk.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/Perk.java @@ -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; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/PerkSpreadsheetModule.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/PerkSpreadsheetModule.java index 7eec2ff42..63e90d8d6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/PerkSpreadsheetModule.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/PerkSpreadsheetModule.java @@ -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> 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 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(); - } - } - }