Fix points command

This commit is contained in:
Teriuihi 2022-01-13 23:53:32 +01:00
parent f85f3633fb
commit 647fcd389a
2 changed files with 11 additions and 4 deletions

View File

@ -51,14 +51,19 @@ public class CommandPoints extends SubCommand {
)));
});
} else if (args.length == 2){
VillagerType villagerType = VillagerType.getVillagerType(args[1].toLowerCase());
Object2ObjectArrayMap<String, Integer> 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);

View File

@ -116,6 +116,7 @@ public final class Config extends AbstractConfig {
public static String SELL_ITEM_MESSAGE = "<green><material> can be sold to spawn at the <villager_type> villager for $<price> and <points> points per item " +
"at your current amount of points (<current_points>).</green>";
public static String NO_SELL_AT_SPAWN = "<red><material> can not be sold to spawn, try a player shop!</red>";
public static String NOT_A_VILLAGER = "<red><villager_type> is not a valid villager type.</red>";
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;