2013-03-01 06:52:01 +01:00
|
|
|
package com.gmail.nossr50.commands.party;
|
|
|
|
|
|
|
|
import org.bukkit.ChatColor;
|
|
|
|
import org.bukkit.OfflinePlayer;
|
|
|
|
import org.bukkit.command.Command;
|
|
|
|
import org.bukkit.command.CommandExecutor;
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
2013-04-13 00:41:27 +02:00
|
|
|
import com.gmail.nossr50.mcMMO;
|
2013-03-01 06:52:01 +01:00
|
|
|
import com.gmail.nossr50.config.Config;
|
|
|
|
import com.gmail.nossr50.datatypes.party.Party;
|
|
|
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
|
|
|
import com.gmail.nossr50.locale.LocaleLoader;
|
|
|
|
import com.gmail.nossr50.party.PartyManager;
|
|
|
|
import com.gmail.nossr50.party.ShareHandler;
|
|
|
|
import com.gmail.nossr50.util.player.UserManager;
|
|
|
|
|
|
|
|
public class PartyInfoCommand implements CommandExecutor {
|
|
|
|
private Player player;
|
|
|
|
private Party playerParty;
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
2013-03-28 17:57:49 +01:00
|
|
|
switch (args.length) {
|
|
|
|
case 0:
|
|
|
|
case 1:
|
|
|
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName());
|
|
|
|
player = mcMMOPlayer.getPlayer();
|
|
|
|
playerParty = mcMMOPlayer.getParty();
|
|
|
|
|
|
|
|
displayPartyHeader();
|
|
|
|
displayShareModeInfo();
|
|
|
|
displayMemberInfo();
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "info"));
|
|
|
|
return true;
|
|
|
|
}
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private String createMembersList() {
|
|
|
|
StringBuilder memberList = new StringBuilder();
|
|
|
|
|
2013-04-13 00:41:27 +02:00
|
|
|
for (String memberName : playerParty.getMembers()) {
|
|
|
|
OfflinePlayer member = mcMMO.p.getServer().getOfflinePlayer(memberName);
|
2013-03-12 21:25:42 +01:00
|
|
|
|
|
|
|
if (playerParty.getLeader().equalsIgnoreCase(memberName)) {
|
|
|
|
memberList.append(ChatColor.GOLD);
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
else if (member.isOnline()) {
|
2013-03-12 21:25:42 +01:00
|
|
|
memberList.append(ChatColor.WHITE);
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
else {
|
2013-03-12 21:25:42 +01:00
|
|
|
memberList.append(ChatColor.GRAY);
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
2013-03-12 21:25:42 +01:00
|
|
|
|
|
|
|
memberList.append(memberName).append(" ");
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return memberList.toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void displayShareModeInfo() {
|
|
|
|
boolean xpShareEnabled = Config.getInstance().getExpShareEnabled();
|
|
|
|
boolean itemShareEnabled = Config.getInstance().getItemShareEnabled();
|
2013-03-12 21:25:42 +01:00
|
|
|
boolean itemSharingActive = (playerParty.getItemShareMode() != ShareHandler.ShareMode.NONE);
|
2013-03-01 06:52:01 +01:00
|
|
|
|
|
|
|
if (!xpShareEnabled && !itemShareEnabled) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
String expShareInfo = "";
|
|
|
|
String itemShareInfo = "";
|
|
|
|
String separator = "";
|
|
|
|
|
|
|
|
if (xpShareEnabled) {
|
|
|
|
expShareInfo = LocaleLoader.getString("Commands.Party.ExpShare", playerParty.getXpShareMode().toString());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (itemShareEnabled) {
|
|
|
|
itemShareInfo = LocaleLoader.getString("Commands.Party.ItemShare", playerParty.getItemShareMode().toString());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (xpShareEnabled && itemShareEnabled) {
|
|
|
|
separator = ChatColor.DARK_GRAY + " || ";
|
|
|
|
}
|
|
|
|
|
|
|
|
player.sendMessage(LocaleLoader.getString("Commands.Party.ShareMode") + expShareInfo + separator + itemShareInfo);
|
|
|
|
if (itemSharingActive) {
|
|
|
|
player.sendMessage(LocaleLoader.getString("Commands.Party.ItemShareCategories", playerParty.getItemShareCategories()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void displayPartyHeader() {
|
|
|
|
player.sendMessage(LocaleLoader.getString("Commands.Party.Header"));
|
|
|
|
|
|
|
|
if (playerParty.isLocked()) {
|
|
|
|
player.sendMessage(LocaleLoader.getString("Commands.Party.Status", playerParty.getName(), LocaleLoader.getString("Party.Status.Locked")));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
player.sendMessage(LocaleLoader.getString("Commands.Party.Status", playerParty.getName(), LocaleLoader.getString("Party.Status.Unlocked")));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void displayMemberInfo() {
|
|
|
|
int membersNear = PartyManager.getNearMembers(player, playerParty, Config.getInstance().getPartyShareRange()).size();
|
|
|
|
int membersOnline = playerParty.getOnlineMembers().size() - 1;
|
|
|
|
|
|
|
|
player.sendMessage(LocaleLoader.getString("Commands.Party.Members.Header"));
|
|
|
|
player.sendMessage(LocaleLoader.getString("Commands.Party.MembersNear", membersNear, membersOnline));
|
2013-03-12 02:06:56 +01:00
|
|
|
player.sendMessage(createMembersList());
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
}
|