mcMMO/src/main/java/com/gmail/nossr50/commands/chat/PartyChatCommand.java

53 lines
1.5 KiB
Java

package com.gmail.nossr50.commands.chat;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.chat.PartyChatManager;
import com.gmail.nossr50.datatypes.chat.ChatMode;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.player.UserManager;
public class PartyChatCommand extends ChatCommand {
public PartyChatCommand() {
super(ChatMode.PARTY);
}
@Override
protected void handleChatSending(CommandSender sender, String[] args) {
Party party;
String message;
if (sender instanceof Player) {
party = UserManager.getPlayer((Player) sender).getParty();
if (party == null) {
sender.sendMessage(LocaleLoader.getString("Commands.Party.None"));
return;
}
message = buildChatMessage(args, 0);
}
else {
if (args.length < 2) {
sender.sendMessage(LocaleLoader.getString("Party.Specify"));
return;
}
party = PartyManager.getParty(args[0]);
if (party == null) {
sender.sendMessage(LocaleLoader.getString("Party.InvalidName"));
return;
}
message = buildChatMessage(args, 1);
}
((PartyChatManager) chatManager).setParty(party);
chatManager.handleChat(sender.getName(), getDisplayName(sender), message);
}
}