From 647fcd389a5f0658736178fdc537d797acc00b6a Mon Sep 17 00:00:00 2001 From: Teriuihi Date: Thu, 13 Jan 2022 23:53:32 +0100 Subject: [PATCH] Fix points command --- .../alttd/commands/subcommands/CommandPoints.java | 13 +++++++++---- src/main/java/com/alttd/config/Config.java | 2 ++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/alttd/commands/subcommands/CommandPoints.java b/src/main/java/com/alttd/commands/subcommands/CommandPoints.java index 7aff619..e0d2fb4 100644 --- a/src/main/java/com/alttd/commands/subcommands/CommandPoints.java +++ b/src/main/java/com/alttd/commands/subcommands/CommandPoints.java @@ -51,14 +51,19 @@ public class CommandPoints extends SubCommand { ))); }); } else if (args.length == 2){ + VillagerType villagerType = VillagerType.getVillagerType(args[1].toLowerCase()); Object2ObjectArrayMap pointsMap = user.getPointsMap(); - if (!pointsMap.containsKey(args[1])) { - player.sendMessage(ref.message); + if (villagerType == null) { + player.sendMiniMessage(Config.NOT_A_VILLAGER, List.of(Template.template("villager_type", args[1]))); return true; } + int currentPoints = pointsMap.getOrDefault(villagerType.getName(), 0); ref.message = ref.message.append(miniMessage.deserialize(Config.POINTS_CONTENT, TemplateResolver.resolving( - Template.template("villager_type", VillagerType.getVillagerType(args[1]).getDisplayName()), - Template.template("points", String.valueOf(pointsMap.get(args[1])))))); + Template.template("villager_type", villagerType.getDisplayName()), + Template.template("points", String.valueOf(currentPoints)), + Template.template("buy_multiplier", String.valueOf(Price.getCurrentMultiplier(currentPoints, true))), + Template.template("sell_multiplier", String.valueOf(Price.getCurrentMultiplier(currentPoints, true))) + ))); } else player.sendMiniMessage(getHelpMessage(), null); diff --git a/src/main/java/com/alttd/config/Config.java b/src/main/java/com/alttd/config/Config.java index 531c624..75ca9a0 100644 --- a/src/main/java/com/alttd/config/Config.java +++ b/src/main/java/com/alttd/config/Config.java @@ -116,6 +116,7 @@ public final class Config extends AbstractConfig { public static String SELL_ITEM_MESSAGE = " can be sold to spawn at the villager for $ and points per item " + "at your current amount of points ()."; public static String NO_SELL_AT_SPAWN = " can not be sold to spawn, try a player shop!"; + public static String NOT_A_VILLAGER = " is not a valid villager type."; private static void loadMessages() { NOT_ENOUGH_MONEY = config.getString("messages.not-enough-money", NOT_ENOUGH_MONEY); @@ -130,6 +131,7 @@ public final class Config extends AbstractConfig { NO_BUY_AT_SPAWN = config.getString("messages.no-buy-at-spawn", NO_BUY_AT_SPAWN); SELL_ITEM_MESSAGE = config.getString("messages.sell-item-message", SELL_ITEM_MESSAGE); NO_SELL_AT_SPAWN = config.getString("messages.no-sell-at-spawn", NO_SELL_AT_SPAWN); + NOT_A_VILLAGER = config.getString("messages.not-a-villager", NOT_A_VILLAGER); } public static boolean DEBUG = false;