diff --git a/src/main/java/com/alttd/commands/subcommands/CommandPoints.java b/src/main/java/com/alttd/commands/subcommands/CommandPoints.java index 5201936..b8c1e31 100644 --- a/src/main/java/com/alttd/commands/subcommands/CommandPoints.java +++ b/src/main/java/com/alttd/commands/subcommands/CommandPoints.java @@ -16,6 +16,7 @@ import org.bukkit.entity.Player; import java.util.ArrayList; import java.util.List; +import java.util.concurrent.atomic.AtomicBoolean; import java.util.stream.Collectors; public class CommandPoints extends SubCommand { @@ -38,6 +39,9 @@ public class CommandPoints extends SubCommand { Placeholder.unparsed("player", player.getName()))); }; if (args.length == 1) { + + AtomicBoolean allPointsAreZero = new AtomicBoolean(true); + Object2ObjectArrayMap pointsMap = user.getPointsMap(); pointsMap.keySet().forEach(key -> { VillagerType villagerType = VillagerType.getVillagerType(key); @@ -46,21 +50,26 @@ public class CommandPoints extends SubCommand { return; } int currentPoints = pointsMap.getOrDefault(key, 0); - if(currentPoints == 0) return; + if (currentPoints == 0) return; + allPointsAreZero.set(false); ref.message = ref.message.append(miniMessage.deserialize("\n", TagResolver.resolver())); ref.message = ref.message.append(miniMessage.deserialize(Config.POINTS_CONTENT, TagResolver.resolver( Placeholder.unparsed("villager_type", VillagerType.getVillagerType(key).getDisplayName()), Placeholder.unparsed("points", String.valueOf(currentPoints)), Placeholder.unparsed("buy_multiplier", String.valueOf(Price.getCurrentMultiplier(currentPoints, true))), - Placeholder.unparsed("sell_multiplier", String.valueOf(Price.getCurrentMultiplier(currentPoints, false))) - ))); + Placeholder.unparsed("sell_multiplier", String.valueOf(Price.getCurrentMultiplier(currentPoints, false)))))); }); - } else if (args.length == 2){ + if (allPointsAreZero.get()) { + ref.message = miniMessage.deserialize(Config.NO_VILLAGER_POINTS); + } + } else if (args.length == 2) { + + if (args[1].equals("all")) { + for (VillagerType villagerType : VillagerType.getVillagerTypes()) { - if(args[1].equals("all")){ - for(VillagerType villagerType : VillagerType.getVillagerTypes()){ Object2ObjectArrayMap pointsMap = user.getPointsMap(); int currentPoints = pointsMap.getOrDefault(villagerType.getName(), 0); + ref.message = ref.message.append(miniMessage.deserialize("\n", TagResolver.resolver())); ref.message = ref.message.append(miniMessage.deserialize(Config.POINTS_CONTENT, TagResolver.resolver( Placeholder.unparsed("villager_type", villagerType.getDisplayName()), Placeholder.unparsed("points", String.valueOf(currentPoints)), diff --git a/src/main/java/com/alttd/config/Config.java b/src/main/java/com/alttd/config/Config.java index f74a647..1b3e38b 100644 --- a/src/main/java/com/alttd/config/Config.java +++ b/src/main/java/com/alttd/config/Config.java @@ -118,6 +118,7 @@ public final class Config extends AbstractConfig { 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."; public static String LOADING_ECON_DATA = "Loading your economy data, please wait..."; + public static String NO_VILLAGER_POINTS = "You don't have any villager points."; private static void loadMessages() { NOT_ENOUGH_MONEY = config.getString("messages.not-enough-money", NOT_ENOUGH_MONEY); @@ -134,6 +135,7 @@ public final class Config extends AbstractConfig { 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); LOADING_ECON_DATA = config.getString("messages.loading-econ-data", LOADING_ECON_DATA); + NO_VILLAGER_POINTS = config.getString("messages.no-villager-points", NO_VILLAGER_POINTS); } public static boolean DEBUG = false;