From 7598febf7188ed04abef63dd9a0b9c3712267f13 Mon Sep 17 00:00:00 2001 From: devlrxxh Date: Tue, 2 Apr 2024 00:44:47 +0200 Subject: [PATCH] Fixed bugs with follow command --- .../commands/admin/general/FollowCommand.java | 5 +++-- .../lrxh/practice/match/menu/MatchDetailsMenu.java | 12 +++++++----- .../me/lrxh/practice/profile/ProfileListener.java | 2 ++ .../lrxh/practice/queue/menu/QueueSelectKitMenu.java | 5 ++++- .../java/me/lrxh/practice/util/PlaceholderUtil.java | 2 +- 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/main/java/me/lrxh/practice/commands/admin/general/FollowCommand.java b/src/main/java/me/lrxh/practice/commands/admin/general/FollowCommand.java index 9613445..113f91c 100644 --- a/src/main/java/me/lrxh/practice/commands/admin/general/FollowCommand.java +++ b/src/main/java/me/lrxh/practice/commands/admin/general/FollowCommand.java @@ -26,13 +26,14 @@ public void pingOthers(Player player, String otherPlayer) { player.sendMessage(CC.translate("&4ERROR - &cYou can't follow yourself!")); return; } + Player otherP = Bukkit.getPlayer(otherPlayer); + Profile playerProfile = Profile.getProfiles().get(player.getUniqueId()); - if (!playerProfile.getFollowing().isEmpty() && !playerProfile.getFollowing().contains(player.getUniqueId())) { + if (!playerProfile.getFollowing().isEmpty() && !playerProfile.getFollowing().contains(otherP.getUniqueId())) { player.sendMessage(CC.translate("&4ERROR - &cYou can't follow multiple players!")); return; } - Player otherP = Bukkit.getPlayer(otherPlayer); Profile profile = Profile.getProfiles().get(otherP.getUniqueId()); if (profile.getFollowers().contains(player.getUniqueId())) { diff --git a/src/main/java/me/lrxh/practice/match/menu/MatchDetailsMenu.java b/src/main/java/me/lrxh/practice/match/menu/MatchDetailsMenu.java index c7a5ac3..d50db5b 100644 --- a/src/main/java/me/lrxh/practice/match/menu/MatchDetailsMenu.java +++ b/src/main/java/me/lrxh/practice/match/menu/MatchDetailsMenu.java @@ -150,11 +150,13 @@ public ItemStack getButtonItem(Player player) { return new ItemBuilder(Material.PAPER) .name("&bMatch Stats") .lore(Arrays.asList( - "&bHits: &f" + snapshot.getTotalHits(), - "&bLongest Combo: &f" + snapshot.getLongestCombo(), - "&bPotions Thrown: &f" + snapshot.getPotionsThrown(), - "&bPotions Missed: &f" + snapshot.getPotionsMissed(), - "&bPotion Accuracy: &f" + snapshot.getPotionAccuracy() + "&7• &bHits: &f" + snapshot.getTotalHits(), + "&7• &bLongest Combo: &f" + snapshot.getLongestCombo(), + "", + "&bPotions: ", + "&7• &bPotions Thrown: &f" + snapshot.getPotionsThrown(), + "&7• &bPotions Missed: &f" + snapshot.getPotionsMissed(), + "&7• &bPotion Accuracy: &f" + snapshot.getPotionAccuracy() )) .clearFlags() .build(); diff --git a/src/main/java/me/lrxh/practice/profile/ProfileListener.java b/src/main/java/me/lrxh/practice/profile/ProfileListener.java index f3a207f..2549630 100644 --- a/src/main/java/me/lrxh/practice/profile/ProfileListener.java +++ b/src/main/java/me/lrxh/practice/profile/ProfileListener.java @@ -165,7 +165,9 @@ public void onPlayerQuitEvent(PlayerQuitEvent event) { if (!profile.getFollowers().isEmpty()) { for (UUID playerUUID : profile.getFollowers()) { + Bukkit.getPlayer(playerUUID).sendMessage(Locale.FOLLOW_END.format(Bukkit.getPlayer(playerUUID), event.getPlayer().getName())); Bukkit.getPlayer(playerUUID).sendMessage(Locale.FOLLOWED_LEFT.format(Bukkit.getPlayer(playerUUID), event.getPlayer().getName())); + Profile.getByUuid(playerUUID).getFollowing().remove(event.getPlayer().getUniqueId()); } } diff --git a/src/main/java/me/lrxh/practice/queue/menu/QueueSelectKitMenu.java b/src/main/java/me/lrxh/practice/queue/menu/QueueSelectKitMenu.java index 78ecd01..ecb71a6 100644 --- a/src/main/java/me/lrxh/practice/queue/menu/QueueSelectKitMenu.java +++ b/src/main/java/me/lrxh/practice/queue/menu/QueueSelectKitMenu.java @@ -160,7 +160,10 @@ private String replaceLeaderboardPlaceholders(String line, Queue queue) { @Override public void clicked(Player player, ClickType clickType) { Profile profile = Profile.getByUuid(player.getUniqueId()); - + if(!profile.getFollowing().isEmpty()){ + player.sendMessage(CC.translate("&4ERROR - &cYou can't queue while following someone!")); + return; + } if (player.hasMetadata("frozen")) { player.sendMessage(CC.RED + "You cannot queue while frozen."); return; diff --git a/src/main/java/me/lrxh/practice/util/PlaceholderUtil.java b/src/main/java/me/lrxh/practice/util/PlaceholderUtil.java index 9e7feb1..443aca8 100644 --- a/src/main/java/me/lrxh/practice/util/PlaceholderUtil.java +++ b/src/main/java/me/lrxh/practice/util/PlaceholderUtil.java @@ -31,7 +31,7 @@ public static List format(List lines, Player player) { if (line.contains("") && !profile.isSilent()) { continue; } else { - line = line.replaceAll("", "&7&lSilent Mode"); + line = line.replaceAll("", ""); } if (line.contains("") && profile.getFollowing().isEmpty()) { continue;