Fixed Flags being sorted due to their text color

Colors are now stripped, so that all Flags are properly alphabetically sorted
This commit is contained in:
Florian CUNY 2020-05-19 17:40:51 +02:00
parent 7dc39946f1
commit 4209afaf20
1 changed files with 4 additions and 1 deletions

View File

@ -6,6 +6,8 @@ import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.World;
@ -76,7 +78,8 @@ public class SettingsTab implements Tab, ClickHandler {
protected List<Flag> getFlags() {
// Get a list of flags of the correct type and sort by the translated names
List<Flag> flags = plugin.getFlagsManager().getFlags().stream().filter(f -> f.getType().equals(type))
.sorted(Comparator.comparing(flag -> user.getTranslation(flag.getNameReference())))
// We're stripping colors to avoid weird sorting issues
.sorted(Comparator.comparing(flag -> ChatColor.stripColor(user.getTranslation(flag.getNameReference()))))
.collect(Collectors.toList());
// Remove any that are not for this game mode
plugin.getIWM().getAddon(world).ifPresent(gm -> flags.removeIf(f -> !f.getGameModes().isEmpty() && !f.getGameModes().contains(gm)));