Skip to content

Commit

Permalink
Fixed bugs with follow command
Browse files Browse the repository at this point in the history
  • Loading branch information
Devlrxxh committed Apr 1, 2024
1 parent f5965bf commit 7598feb
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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())) {
Expand Down
12 changes: 7 additions & 5 deletions src/main/java/me/lrxh/practice/match/menu/MatchDetailsMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/me/lrxh/practice/profile/ProfileListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/me/lrxh/practice/util/PlaceholderUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static List<String> format(List<String> lines, Player player) {
if (line.contains("<silent>") && !profile.isSilent()) {
continue;
} else {
line = line.replaceAll("<silent>", "&7&lSilent Mode");
line = line.replaceAll("<silent>", "");
}
if (line.contains("<follow>") && profile.getFollowing().isEmpty()) {
continue;
Expand Down

0 comments on commit 7598feb

Please sign in to comment.