Added /points all, not tested

This commit is contained in:
Darko 2022-05-09 05:51:16 +02:00
parent 9605c7ac13
commit 82fbe5370c

View File

@ -52,19 +52,33 @@ public class CommandPoints extends SubCommand {
))); )));
}); });
} else if (args.length == 2){ } else if (args.length == 2){
VillagerType villagerType = VillagerType.getVillagerType(args[1].toLowerCase());
Object2ObjectArrayMap<String, Integer> pointsMap = user.getPointsMap(); if(args[1].equals("all")){
if (villagerType == null) { for(VillagerType villagerType : VillagerType.getVillagerTypes()){
player.sendMiniMessage(Config.NOT_A_VILLAGER, TagResolver.resolver(Placeholder.unparsed("villager_type", args[1]))); Object2ObjectArrayMap<String, Integer> pointsMap = user.getPointsMap();
return true; int currentPoints = pointsMap.getOrDefault(villagerType.getName(), 0);
} ref.message = ref.message.append(miniMessage.deserialize(Config.POINTS_CONTENT, TagResolver.resolver(
int currentPoints = pointsMap.getOrDefault(villagerType.getName(), 0); Placeholder.unparsed("villager_type", villagerType.getDisplayName()),
ref.message = ref.message.append(miniMessage.deserialize(Config.POINTS_CONTENT, TagResolver.resolver( Placeholder.unparsed("points", String.valueOf(currentPoints)),
Placeholder.unparsed("villager_type", villagerType.getDisplayName()), Placeholder.unparsed("buy_multiplier", String.valueOf(Price.getCurrentMultiplier(currentPoints, true))),
Placeholder.unparsed("points", String.valueOf(currentPoints)), Placeholder.unparsed("sell_multiplier", String.valueOf(Price.getCurrentMultiplier(currentPoints, false)))
Placeholder.unparsed("buy_multiplier", String.valueOf(Price.getCurrentMultiplier(currentPoints, true))), )));
Placeholder.unparsed("sell_multiplier", String.valueOf(Price.getCurrentMultiplier(currentPoints, false))) }
} else {
VillagerType villagerType = VillagerType.getVillagerType(args[1].toLowerCase());
Object2ObjectArrayMap<String, Integer> pointsMap = user.getPointsMap();
if (villagerType == null) {
player.sendMiniMessage(Config.NOT_A_VILLAGER, TagResolver.resolver(Placeholder.unparsed("villager_type", args[1])));
return true;
}
int currentPoints = pointsMap.getOrDefault(villagerType.getName(), 0);
ref.message = ref.message.append(miniMessage.deserialize(Config.POINTS_CONTENT, TagResolver.resolver(
Placeholder.unparsed("villager_type", villagerType.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)))
))); )));
}
} else } else
player.sendMiniMessage(getHelpMessage(), null); player.sendMiniMessage(getHelpMessage(), null);
@ -84,6 +98,7 @@ public class CommandPoints extends SubCommand {
res.addAll(VillagerType.getVillagerTypes().stream() res.addAll(VillagerType.getVillagerTypes().stream()
.map(VillagerType::getName) .map(VillagerType::getName)
.collect(Collectors.toList())); .collect(Collectors.toList()));
res.add("all");
return res; return res;
} }