From 616fa032d952c3fc1045744f3f2bc172c7749ef4 Mon Sep 17 00:00:00 2001 From: Auxilor Date: Mon, 24 Oct 2022 15:59:41 +0100 Subject: [PATCH] Removed Prices#lookup due to poor usage --- .../com/willfp/eco/core/price/Prices.java | 58 ------------------- 1 file changed, 58 deletions(-) diff --git a/eco-api/src/main/java/com/willfp/eco/core/price/Prices.java b/eco-api/src/main/java/com/willfp/eco/core/price/Prices.java index e4bd7da9..4bcca8c4 100644 --- a/eco-api/src/main/java/com/willfp/eco/core/price/Prices.java +++ b/eco-api/src/main/java/com/willfp/eco/core/price/Prices.java @@ -8,11 +8,9 @@ import com.willfp.eco.core.price.impl.PriceFree; import com.willfp.eco.core.price.impl.PriceItem; import com.willfp.eco.core.recipe.parts.EmptyTestableItem; import com.willfp.eco.util.NumberUtils; -import com.willfp.eco.util.StringUtils; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.Arrays; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; @@ -36,62 +34,6 @@ public final class Prices { } } - /** - * Lookup a price from a string. - *

- * A price string should look like {@code 5000}, {@code 2000 levels}, - * {@code 200 * %level% souls}, {@code 200 crystals}, etc. - *

- * This does not support items as price names. - * - * @param key The key. - * @return The price, or {@link PriceFree} if invalid. - */ - @NotNull - public static Price lookup(@NotNull final String key) { - return lookup(key, MathContext.EMPTY); - } - - /** - * Lookup a price from a string. - *

- * A price string should look like {@code 5000}, {@code 2000 levels}, - * {@code 200 souls}, {@code 200 crystals}, etc. - *

- * This does not support items as price names. - * - * @param key The key. - * @param context The context to do math in. - * @return The price, or {@link PriceFree} if invalid. - */ - @NotNull - public static Price lookup(@NotNull final String key, - @NotNull final MathContext context) { - String[] args = StringUtils.parseTokens(key); - - if (args.length == 0) { - return new PriceFree(); - } - - if (args.length == 1) { - return create(args[0], null, context); - } - - String exprWithName = String.join(" ", Arrays.copyOfRange(args, 0, args.length - 1)); - String priceName = args[args.length - 1]; - - String exprWithoutName = String.join(" ", args); - - Price withName = create(exprWithName, priceName, context); - Price withoutName = create(exprWithoutName, null, context); - - if (withoutName instanceof PriceFree) { - return withName; - } else { - return withoutName; - } - } - /** * Create price from an expression (representing the value), * and a price name.