Changed appearance of party member list

This commit is contained in:
TfT_02 2014-01-17 18:58:07 +01:00
parent 818962e668
commit 6b653fa606
4 changed files with 41 additions and 58 deletions

View File

@ -33,6 +33,7 @@ Version 1.4.08-dev
= Fixed bug where the /ptp request expiration time was checked wrongly - preventing players from using the command
= Fixed bug where Hylian Luck was broken
! Changed party system. Parties now have XP and Levels. Party features such as party teleport and party chat have to be unlocked before they can be used by the party members
! Changed appearance of party member list. Gold = party leader, White = online, Gray = offline, Italic = not nearby
! Updated localization files
! Changed the appearance of /mcmmo commands
! Changed AxesCritical to CriticalHit in config file

View File

@ -9,7 +9,6 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.party.PartyFeature;
@ -126,32 +125,6 @@ public class PartyInfoCommand implements CommandExecutor {
player.sendMessage(LocaleLoader.getString("Commands.Party.Members.Header"));
player.sendMessage(LocaleLoader.getString("Commands.Party.MembersNear", nearMembers.size(), membersOnline));
player.sendMessage(createMembersList(party, nearMembers));
}
private String createMembersList(Party party, List<Player> nearMembers) {
StringBuilder memberList = new StringBuilder();
for (String memberName : party.getMembers()) {
Player member = mcMMO.p.getServer().getPlayerExact(memberName);
if (!nearMembers.contains(member)) {
memberList.append(ChatColor.ITALIC);
}
if (party.getLeader().equalsIgnoreCase(memberName)) {
memberList.append(ChatColor.GOLD);
}
else if (member != null) {
memberList.append(ChatColor.WHITE);
}
else {
memberList.append(ChatColor.GRAY);
}
memberList.append(memberName).append(ChatColor.RESET).append(" ");
}
return memberList.toString();
player.sendMessage(party.createMembersList(player.getName(), nearMembers));
}
}

View File

@ -12,13 +12,12 @@ import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.party.PartyFeature;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.party.PartyFeature;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
@ -61,7 +60,7 @@ public class PartyAllianceCommand implements TabExecutor {
targetParty = playerParty.getAlly();
displayPartyHeader();
displayMemberInfo();
displayMemberInfo(mcMMOPlayer);
return true;
case 2:
@ -91,7 +90,7 @@ public class PartyAllianceCommand implements TabExecutor {
targetParty = playerParty.getAlly();
displayPartyHeader();
displayMemberInfo();
displayMemberInfo(mcMMOPlayer);
return true;
default:
@ -127,32 +126,11 @@ public class PartyAllianceCommand implements TabExecutor {
player.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.Ally", playerParty.getName(), targetParty.getName()));
}
private void displayMemberInfo() {
private void displayMemberInfo(McMMOPlayer mcMMOPlayer) {
List<Player> nearMembers = PartyManager.getNearMembers(mcMMOPlayer);
player.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.Members.Header"));
player.sendMessage(createMembersList(playerParty));
player.sendMessage(playerParty.createMembersList(player.getName(), nearMembers));
player.sendMessage(ChatColor.DARK_GRAY + "----------------------------");
player.sendMessage(createMembersList(targetParty));
}
private String createMembersList(Party party) {
StringBuilder memberList = new StringBuilder();
for (String memberName : party.getMembers()) {
Player member = mcMMO.p.getServer().getPlayerExact(memberName);
if (party.getLeader().equalsIgnoreCase(memberName)) {
memberList.append(ChatColor.GOLD);
}
else if (member != null) {
memberList.append(ChatColor.WHITE);
}
else {
memberList.append(ChatColor.GRAY);
}
memberList.append(memberName).append(" ");
}
return memberList.toString();
player.sendMessage(targetParty.createMembersList(player.getName(), nearMembers));
}
}

View File

@ -5,6 +5,7 @@ import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
@ -286,6 +287,36 @@ public class Party {
}
}
public String createMembersList(String playerName, List<Player> nearMembers) {
StringBuilder memberList = new StringBuilder();
for (String memberName : this.getMembers()) {
Player member = mcMMO.p.getServer().getPlayerExact(memberName);
if (this.getLeader().equalsIgnoreCase(memberName)) {
memberList.append(ChatColor.GOLD);
if (member == null) {
memberName = memberName.substring(0, 1) + ChatColor.GRAY + ChatColor.ITALIC + "" + memberName.substring(1);
}
}
else if (member != null) {
memberList.append(ChatColor.WHITE);
}
else {
memberList.append(ChatColor.GRAY);
}
if (!nearMembers.contains(member) && !playerName.equalsIgnoreCase(memberName)) {
memberList.append(ChatColor.ITALIC + "");
}
memberList.append(memberName).append(ChatColor.RESET).append(" ");
}
return memberList.toString();
}
@Override
public boolean equals(Object obj) {
if (obj == null) {