Tweaks to the party info commands

This commit is contained in:
nossr50 2019-02-03 17:44:10 -08:00
parent 371a3ceec7
commit 025183d434
5 changed files with 17 additions and 17 deletions

View File

@ -9,6 +9,7 @@ Key:
Version 2.1.7 Version 2.1.7
Fixed an almost 6 year old bug where Salvage materials did not have a defined material count so they defaulted to 2 (which could lead to shovels giving back more diamonds than normal) Fixed an almost 6 year old bug where Salvage materials did not have a defined material count so they defaulted to 2 (which could lead to shovels giving back more diamonds than normal)
Added spam detection for Unarmed's bonus damage and disarm Added spam detection for Unarmed's bonus damage and disarm
Corrected an error where master angler for retro only required level 150 instead of 500 (update your skillranks.yml)
(API) Added addXpFromBlocks to ExperienceAPI to help make adding XP for a player easier (API) Added addXpFromBlocks to ExperienceAPI to help make adding XP for a player easier
(API) Added addXpFromBlocksBySkill to ExperienceAPI to help make adding XP for a player easier (API) Added addXpFromBlocksBySkill to ExperienceAPI to help make adding XP for a player easier
(API) Added addXpFromBlock to ExperienceAPI to help make adding XP for a player easier (API) Added addXpFromBlock to ExperienceAPI to help make adding XP for a player easier

View File

@ -120,10 +120,10 @@ public class PartyInfoCommand implements CommandExecutor {
*/ */
List<Player> nearMembers = PartyManager.getNearVisibleMembers(mcMMOPlayer); List<Player> nearMembers = PartyManager.getNearVisibleMembers(mcMMOPlayer);
int membersOnline = party.getVisibleMembers(player).size() - 1; int membersOnline = party.getVisibleMembers(player).size();
player.sendMessage(LocaleLoader.getString("Commands.Party.Members.Header")); player.sendMessage(LocaleLoader.getString("Commands.Party.Members.Header"));
player.sendMessage(LocaleLoader.getString("Commands.Party.MembersNear", nearMembers.size(), membersOnline)); player.sendMessage(LocaleLoader.getString("Commands.Party.MembersNear", nearMembers.size(), membersOnline));
player.sendMessage(party.createMembersList(player.getName(), nearMembers)); player.sendMessage(party.createMembersList(player));
} }
} }

View File

@ -126,8 +126,8 @@ public class PartyAllianceCommand implements TabExecutor {
private void displayMemberInfo(McMMOPlayer mcMMOPlayer) { private void displayMemberInfo(McMMOPlayer mcMMOPlayer) {
List<Player> nearMembers = PartyManager.getNearMembers(mcMMOPlayer); List<Player> nearMembers = PartyManager.getNearMembers(mcMMOPlayer);
player.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.Members.Header")); player.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.Members.Header"));
player.sendMessage(playerParty.createMembersList(player.getName(), nearMembers)); player.sendMessage(playerParty.createMembersList(player));
player.sendMessage(ChatColor.DARK_GRAY + "----------------------------"); player.sendMessage(ChatColor.DARK_GRAY + "----------------------------");
player.sendMessage(targetParty.createMembersList(player.getName(), nearMembers)); player.sendMessage(targetParty.createMembersList(player));
} }
} }

View File

@ -76,13 +76,13 @@ public class Party {
return onlineMembers; return onlineMembers;
} }
public List<Player> getVisibleMembers(Player commandSender) public List<Player> getVisibleMembers(Player player)
{ {
ArrayList<Player> visibleMembers = new ArrayList<>(); ArrayList<Player> visibleMembers = new ArrayList<>();
for(Player p : onlineMembers) for(Player p : onlineMembers)
{ {
if(commandSender.canSee(p)) if(player.canSee(p) && p.canSee(p))
visibleMembers.add(p); visibleMembers.add(p);
} }
@ -325,30 +325,27 @@ public class Party {
return this.getMembers().keySet().contains(uuid); return this.getMembers().keySet().contains(uuid);
} }
public String createMembersList(String playerName, List<Player> nearMembers) { public String createMembersList(Player player) {
StringBuilder memberList = new StringBuilder(); StringBuilder memberList = new StringBuilder();
for (Entry<UUID, String> memberEntry : this.getMembers().entrySet()) { for (Player otherPlayer : this.getVisibleMembers(player)) {
UUID uuid = memberEntry.getKey(); String memberName = otherPlayer.getName();
String memberName = memberEntry.getValue();
Player member = mcMMO.p.getServer().getPlayer(uuid); if (this.getLeader().getUniqueId().equals(player.getUniqueId())) {
if (this.getLeader().getUniqueId().equals(uuid)) {
memberList.append(ChatColor.GOLD); memberList.append(ChatColor.GOLD);
if (member == null) { if (otherPlayer == null) {
memberName = memberName.substring(0, 1) + ChatColor.GRAY + ChatColor.ITALIC + "" + memberName.substring(1); memberName = memberName.substring(0, 1) + ChatColor.GRAY + ChatColor.ITALIC + "" + memberName.substring(1);
} }
} }
else if (member != null) { else if (otherPlayer != null) {
memberList.append(ChatColor.WHITE); memberList.append(ChatColor.WHITE);
} }
else { else {
memberList.append(ChatColor.GRAY); memberList.append(ChatColor.GRAY);
} }
if (!nearMembers.contains(member) && !playerName.equalsIgnoreCase(memberName)) { if (player.getName().equalsIgnoreCase(otherPlayer.getName())) {
memberList.append(ChatColor.ITALIC); memberList.append(ChatColor.ITALIC);
} }

View File

@ -152,7 +152,9 @@ public final class PartyManager {
double range = Config.getInstance().getPartyShareRange(); double range = Config.getInstance().getPartyShareRange();
for (Player member : party.getVisibleMembers(player)) { for (Player member : party.getVisibleMembers(player)) {
if (!player.equals(member) && member.isValid() && Misc.isNear(player.getLocation(), member.getLocation(), range)) { if (!player.equals(member)
&& member.isValid()
&& Misc.isNear(player.getLocation(), member.getLocation(), range)) {
nearMembers.add(member); nearMembers.add(member);
} }
} }