From f311d62d47c5c8cd10913a1dd15bfb85bbd0a0b0 Mon Sep 17 00:00:00 2001 From: Brianna Date: Mon, 6 May 2019 12:07:45 -0400 Subject: [PATCH] Redid organizing, removed debug. --- .gitlab-ci.yml | 2 +- .../com/songoda/epicheads/gui/GUIHeads.java | 2 - .../songoda/epicheads/gui/GUIOverview.java | 44 ++++++++----------- .../songoda/epicheads/head/HeadManager.java | 15 ++++--- 4 files changed, 29 insertions(+), 34 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1294cfb..f7b5c49 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,7 +4,7 @@ stages: variables: name: "EpicHeads" path: "/builds/$CI_PROJECT_PATH" - version: "3" + version: "3.0.1" build: stage: build diff --git a/src/main/java/com/songoda/epicheads/gui/GUIHeads.java b/src/main/java/com/songoda/epicheads/gui/GUIHeads.java index 4adb39b..996e4ae 100644 --- a/src/main/java/com/songoda/epicheads/gui/GUIHeads.java +++ b/src/main/java/com/songoda/epicheads/gui/GUIHeads.java @@ -40,8 +40,6 @@ public class GUIHeads extends AbstractGUI { List favorites = plugin.getPlayerManager().getPlayer(player).getFavorites(); this.heads = heads.stream() - .sorted(Comparator.comparing(Head::getName)) - .sorted(Comparator.comparingInt(head -> (head.getStaffPicked() == 1 ? 0 : 1))) .sorted(Comparator.comparingInt(head -> (favorites.contains(head.getId()) ? 0 : 1))) .collect(Collectors.toList()); diff --git a/src/main/java/com/songoda/epicheads/gui/GUIOverview.java b/src/main/java/com/songoda/epicheads/gui/GUIOverview.java index 5cbea42..97657f4 100644 --- a/src/main/java/com/songoda/epicheads/gui/GUIOverview.java +++ b/src/main/java/com/songoda/epicheads/gui/GUIOverview.java @@ -12,6 +12,7 @@ import org.bukkit.inventory.ItemStack; import java.util.ArrayList; import java.util.List; +import java.util.Random; public class GUIOverview extends AbstractGUI { @@ -63,16 +64,12 @@ public class GUIOverview extends AbstractGUI { Tag tag = plugin.getHeadManager().getTags().get(i); - player.sendMessage("epicheads.category." + tag.getName()); - if (!player.hasPermission("epicheads.category." + tag.getName())) continue; - TagInfo tagInfo = TagInfo.valueOf(tag.getName().toUpperCase()); - createButton(i + 10 + add, Methods.addTexture(new ItemStack(plugin.isServerVersionAtLeast(ServerVersion.V1_13) ? Material.PLAYER_HEAD : Material.valueOf("SKULL_ITEM"), 1, (byte) 3), - tagInfo.getUrl()), - plugin.getLocale().getMessage("gui.overview.headname", tagInfo.getName()), + plugin.getHeadManager().getHeadsByTag(tag).get(0).getURL()), + plugin.getLocale().getMessage("gui.overview.headname", Color.getRandomColor() + tag.getName()), plugin.getLocale().getMessage("gui.overview.headlore", tag.getCount())); registerClickable(i + 10 + add, ((player1, inventory1, cursor, slot, type) -> @@ -120,31 +117,28 @@ public class GUIOverview extends AbstractGUI { } - public enum TagInfo { - ALPHABET("&9&lAlphabet", "9c60da2944a177dd08268fbec04e40812d1d929650be66529b1ee5e1e7eca"), - HUMANS("&a&lHumans", "b7c224f0453e745c85966025e7767d592feea3ad4c69d2366d94d5e8c9a8c2ce"), - FOOD("&b&lFood", "f7b9f08ada4e8ba586a04ed2e9e25fe8b9d568a665243f9c603799a7c896736"), - MISC("&8&lMisc", "f5612dc7b86d71afc1197301c15fd979e9f39e7b1f41d8f1ebdf8115576e2e"), - ANIMALS("&d&lAnimals", "d8cdd4f285632c25d762ece25f4193b966c2641b15d9bdbc0a113023de76ab"), - GAMES("&b&lGames", "dba8d8e53d8a5a75770b62cce73db6bab701cc3de4a9b654d213d54af9615"), - MONSTERS("&c&lMonsters", "68d2183640218ab330ac56d2aab7e29a9790a545f691619e38578ea4a69ae0b6"), - INTERIOR("&6&lInterior", "ec6d9024fc5412e8e2664123732d2291dfc6bb175f72cf894096f7f313641fd4"), - BLOCKS("&9&lBlocks", "7788f5ddaf52c5842287b9427a74dac8f0919eb2fdb1b51365ab25eb392c47"); + public enum Color { + C9("&9&l"), + CA("&a&l"), + CB("&b&l"), + C8("&8&l"), + CD("&d&l"), + CC("&c&l"), + C6("&6&l"); - String name; - String url; + String color; - TagInfo(String name, String url) { - this.name = name; - this.url = url; + Color(String color) { + this.color = color; } - public String getName() { - return name; + public String getColor() { + return color; } - public String getUrl() { - return url; + public static String getRandomColor() { + Random random = new Random(); + return values()[random.nextInt(values().length)].getColor(); } } diff --git a/src/main/java/com/songoda/epicheads/head/HeadManager.java b/src/main/java/com/songoda/epicheads/head/HeadManager.java index fd0d48f..51f41e6 100644 --- a/src/main/java/com/songoda/epicheads/head/HeadManager.java +++ b/src/main/java/com/songoda/epicheads/head/HeadManager.java @@ -22,16 +22,16 @@ public class HeadManager { } public Head getHead(String name) { - return registeredHeads.stream().filter(head -> head.getName().equals(name)).findFirst().orElse(null); + return getHeads().stream().filter(head -> head.getName().equals(name)).findFirst().orElse(null); } public List getHeadsByQuery(String query) { - List result = registeredHeads.stream().filter(head -> head.getName().contains(query)).collect(Collectors.toList()); + List result = getHeads().stream().filter(head -> head.getName().contains(query)).collect(Collectors.toList()); if (result.isEmpty()) { for (Tag tag : registeredTags) { if (!tag.getName().equalsIgnoreCase(query)) continue; - return registeredHeads.stream().filter(head -> head.getTag() == tag).collect(Collectors.toList()); + return getHeads().stream().filter(head -> head.getTag() == tag).collect(Collectors.toList()); } } @@ -39,11 +39,14 @@ public class HeadManager { } public List getHeadsByTag(Tag tag) { - return registeredHeads.stream().filter(head -> head.getTag() == tag).collect(Collectors.toList()); + return getHeads().stream().filter(head -> head.getTag() == tag).collect(Collectors.toList()); } - public Set getHeads() { - return Collections.unmodifiableSet(registeredHeads); + public List getHeads() { + return Collections.unmodifiableList(registeredHeads.stream() + .sorted(Comparator.comparing(Head::getName)) + .sorted(Comparator.comparingInt(head -> (head.getStaffPicked() == 1 ? 0 : 1))) + .collect(Collectors.toList())); } public Tag addTag(Tag tag) {