From eb91a5b87566a1fb4979d221a57a905921dbd18e Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Wed, 20 Sep 2017 12:47:30 -0700 Subject: [PATCH] Fix a bug that made some same-priority implementations not convert. --- .../nwapw/abacus/exception/PromotionException.java | 2 +- .../org/nwapw/abacus/number/PromotionManager.kt | 12 +++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/core/src/main/java/org/nwapw/abacus/exception/PromotionException.java b/core/src/main/java/org/nwapw/abacus/exception/PromotionException.java index 057d6c8..82670db 100644 --- a/core/src/main/java/org/nwapw/abacus/exception/PromotionException.java +++ b/core/src/main/java/org/nwapw/abacus/exception/PromotionException.java @@ -18,7 +18,7 @@ public class PromotionException extends AbacusException { * @param message the additional message to include with the error. */ public PromotionException(String message) { - super("Failed to promote number instances.", message); + super("Failed to promote number instances", message); } } diff --git a/core/src/main/kotlin/org/nwapw/abacus/number/PromotionManager.kt b/core/src/main/kotlin/org/nwapw/abacus/number/PromotionManager.kt index e259446..548bee6 100644 --- a/core/src/main/kotlin/org/nwapw/abacus/number/PromotionManager.kt +++ b/core/src/main/kotlin/org/nwapw/abacus/number/PromotionManager.kt @@ -59,14 +59,12 @@ class PromotionManager(val abacus: Abacus) : PluginListener { override fun onLoad(manager: PluginManager) { val implementations = manager.allNumberImplementations.map { manager.numberImplementationFor(it) } - for((index, value) in implementations.withIndex()){ - for(i in index until implementations.size){ - val other = implementations[i] - - val promoteFrom = if(other.priority > value.priority) value else other - val promoteTo = if(other.priority > value.priority) other else value + for(first in implementations) { + for(second in implementations) { + val promoteFrom = if(second.priority > first.priority) first else second + val promoteTo = if(second.priority > first.priority) second else first val path = computePathBetween(promoteFrom, promoteTo) - computePaths.put(promoteFrom to promoteTo, path) + computePaths[promoteFrom to promoteTo] = path } } }