list in chat.

This commit is contained in:
Brianna 2019-08-06 22:38:45 -04:00
parent b6f83f9528
commit eca8e186b4
2 changed files with 22 additions and 4 deletions

View File

@ -10,8 +10,10 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.stream.Collectors;
import static com.songoda.epicenchants.enums.EnchantResult.BROKEN_FAILURE; import static com.songoda.epicenchants.enums.EnchantResult.BROKEN_FAILURE;
import static com.songoda.epicenchants.utils.single.GeneralUtils.getMessageFromResult; import static com.songoda.epicenchants.utils.single.GeneralUtils.getMessageFromResult;
@ -24,6 +26,13 @@ public class CommandList extends AbstractCommand {
@Override @Override
protected ReturnType runCommand(EpicEnchants instance, CommandSender sender, String... args) { protected ReturnType runCommand(EpicEnchants instance, CommandSender sender, String... args) {
if (args.length > 1 && args[1].equalsIgnoreCase("chat")) {
instance.getLocale().newMessage(instance.getEnchantManager().getValues().stream()
.sorted(Comparator.comparing(enchant -> enchant.getGroup().getOrder()))
.map(enchant -> enchant.getColoredIdentifier(true)).collect(Collectors.joining("&7, ")))
.sendPrefixedMessage(sender);
return ReturnType.SUCCESS;
}
instance.getInfoManager().getMainInfoMenu().open((Player)sender); instance.getInfoManager().getMainInfoMenu().open((Player)sender);
return ReturnType.SUCCESS; return ReturnType.SUCCESS;
} }
@ -40,7 +49,7 @@ public class CommandList extends AbstractCommand {
@Override @Override
public String getSyntax() { public String getSyntax() {
return "/ee list"; return "/ee list [chat]";
} }
@Override @Override

View File

@ -1,11 +1,9 @@
package com.songoda.epicenchants.objects; package com.songoda.epicenchants.objects;
import com.songoda.epicenchants.EpicEnchants;
import com.songoda.epicenchants.effect.EffectExecutor; import com.songoda.epicenchants.effect.EffectExecutor;
import com.songoda.epicenchants.enums.EventType; import com.songoda.epicenchants.enums.EventType;
import com.songoda.epicenchants.enums.TriggerType; import com.songoda.epicenchants.enums.TriggerType;
import com.songoda.epicenchants.utils.single.RomanNumber; import com.songoda.epicenchants.utils.single.RomanNumber;
import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -29,7 +27,8 @@ public class Enchant {
private Set<EffectExecutor> effectExecutors; private Set<EffectExecutor> effectExecutors;
private List<String> description; private List<String> description;
private String format; private String format;
@Nullable private BookItem bookItem; @Nullable
private BookItem bookItem;
Enchant(String author, String identifier, Group group, int maxLevel, Set<String> conflict, Set<Material> itemWhitelist, Set<EffectExecutor> effectExecutors, List<String> description, String format, BookItem bookItem) { Enchant(String author, String identifier, Group group, int maxLevel, Set<String> conflict, Set<Material> itemWhitelist, Set<EffectExecutor> effectExecutors, List<String> description, String format, BookItem bookItem) {
this.author = author; this.author = author;
@ -75,6 +74,16 @@ public class Enchant {
return this.identifier; return this.identifier;
} }
public String getColoredIdentifier(boolean dulled) {
String colored = this.group.getColor() + this.identifier;
if (dulled) {
colored = colored.replace("&l", "")
.replace("&n", "")
.replace("&o", "");
}
return colored;
}
public Group getGroup() { public Group getGroup() {
return this.group; return this.group;
} }