Got all individual stats to work for self and other player

This commit is contained in:
Artemis-the-gr8 2022-05-06 01:16:17 +02:00
parent b28a1ffd40
commit d1f78210d0
2 changed files with 39 additions and 20 deletions

View File

@ -36,23 +36,49 @@ public class StatCommand implements CommandExecutor {
item = EnumHandler.getItem(arg);
}
else if (EnumHandler.getEntityNames().contains(arg)) {
entity = EnumHandler.getEntityType(arg);
if (arg.equalsIgnoreCase("player")) {
if (!playerFlag) {
entity = (entity == null) ? EnumHandler.getEntityType(arg.toUpperCase()) : entity;
playerFlag = true;
}
else {
entity = EnumHandler.getEntityType(arg.toUpperCase());
doublePlayerFlag = true;
}
}
else {
entity = EnumHandler.getEntityType(arg.toUpperCase());
}
}
else if (arg.equalsIgnoreCase("me") && sender instanceof Player) {
playerName = sender.getName();
}
else if (arg.equalsIgnoreCase("player")) {
if (!playerFlag) playerFlag = true;
else doublePlayerFlag = true;
}
else if (OfflinePlayerHandler.getAllOfflinePlayerNames().stream().anyMatch(arg::equalsIgnoreCase)) {
playerName = arg;
}
}
if (playerName != null && stat != null) {
if (stat.getType() == Statistic.Type.UNTYPED) {
sender.sendMessage(stat + " for " + playerName + ": " + OfflinePlayerHandler.getOfflinePlayer(playerName).getStatistic(stat));
switch (stat.getType()) {
case UNTYPED:
sender.sendMessage(stat + " for " + playerName + ": " + OfflinePlayerHandler.getOfflinePlayer(playerName).getStatistic(stat));
break;
case BLOCK:
if (block != null) {
sender.sendMessage(stat + " " + block + " for " + playerName + ": " + OfflinePlayerHandler.getOfflinePlayer(playerName).getStatistic(stat, block));
}
break;
case ITEM:
if (item != null) {
sender.sendMessage(stat + " " + item + " for " + playerName + ": " + OfflinePlayerHandler.getOfflinePlayer(playerName).getStatistic(stat, item));
}
case ENTITY:
if (entity != null) {
sender.sendMessage(stat + " " + entity + " for " + playerName + ": " + OfflinePlayerHandler.getOfflinePlayer(playerName).getStatistic(stat, entity));
}
}
}
}

View File

@ -64,19 +64,12 @@ public class TabCompleter implements org.bukkit.command.TabCompleter {
}
if (stat != null) {
if (stat.getType() == Statistic.Type.UNTYPED) {
tabSuggestions = commandOptions;
}
else if (stat.getType() == Statistic.Type.BLOCK) {
tabSuggestions = blockNames.stream().filter(block -> block.contains(args[args.length-1])).collect(Collectors.toList());
}
else if (stat.getType() == Statistic.Type.ITEM) {
tabSuggestions = itemNames.stream().filter(item -> item.contains(args[args.length-1])).collect(Collectors.toList());
}
else if (stat.getType() == Statistic.Type.ENTITY) {
tabSuggestions = entityNames.stream().filter(entity -> entity.contains(args[args.length-1])).collect(Collectors.toList());
}
tabSuggestions = switch (stat.getType()) {
case UNTYPED -> commandOptions;
case BLOCK -> blockNames.stream().filter(block -> block.contains(args[args.length - 1])).collect(Collectors.toList());
case ITEM -> itemNames.stream().filter(item -> item.contains(args[args.length - 1])).collect(Collectors.toList());
case ENTITY -> entityNames.stream().filter(entity -> entity.contains(args[args.length - 1])).collect(Collectors.toList());
};
}
}