2013-03-01 06:52:01 +01:00
|
|
|
package com.gmail.nossr50.commands.chat;
|
|
|
|
|
2013-06-07 00:48:25 +02:00
|
|
|
import com.gmail.nossr50.chat.PartyChatManager;
|
2014-02-10 16:07:43 +01:00
|
|
|
import com.gmail.nossr50.config.Config;
|
2013-07-15 14:44:13 +02:00
|
|
|
import com.gmail.nossr50.datatypes.chat.ChatMode;
|
2013-03-01 06:52:01 +01:00
|
|
|
import com.gmail.nossr50.datatypes.party.Party;
|
2014-02-10 16:07:43 +01:00
|
|
|
import com.gmail.nossr50.datatypes.party.PartyFeature;
|
2013-03-01 06:52:01 +01:00
|
|
|
import com.gmail.nossr50.locale.LocaleLoader;
|
|
|
|
import com.gmail.nossr50.party.PartyManager;
|
|
|
|
import com.gmail.nossr50.util.player.UserManager;
|
2019-01-15 07:11:58 +01:00
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
import org.bukkit.entity.Player;
|
2013-03-01 06:52:01 +01:00
|
|
|
|
|
|
|
public class PartyChatCommand extends ChatCommand {
|
|
|
|
public PartyChatCommand() {
|
|
|
|
super(ChatMode.PARTY);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void handleChatSending(CommandSender sender, String[] args) {
|
2013-06-07 00:48:25 +02:00
|
|
|
Party party;
|
|
|
|
String message;
|
|
|
|
|
2013-03-01 06:52:01 +01:00
|
|
|
if (sender instanceof Player) {
|
2019-04-13 00:17:05 +02:00
|
|
|
//Check if player profile is loaded
|
|
|
|
if(UserManager.getPlayer((Player) sender) == null)
|
|
|
|
return;
|
|
|
|
|
2013-06-07 00:48:25 +02:00
|
|
|
party = UserManager.getPlayer((Player) sender).getParty();
|
2013-03-01 06:52:01 +01:00
|
|
|
|
|
|
|
if (party == null) {
|
|
|
|
sender.sendMessage(LocaleLoader.getString("Commands.Party.None"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-02-10 16:07:43 +01:00
|
|
|
if (party.getLevel() < Config.getInstance().getPartyFeatureUnlockLevel(PartyFeature.CHAT)) {
|
|
|
|
sender.sendMessage(LocaleLoader.getString("Party.Feature.Disabled.1"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-06-07 00:48:25 +02:00
|
|
|
message = buildChatMessage(args, 0);
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (args.length < 2) {
|
|
|
|
sender.sendMessage(LocaleLoader.getString("Party.Specify"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-06-07 00:48:25 +02:00
|
|
|
party = PartyManager.getParty(args[0]);
|
2013-03-01 06:52:01 +01:00
|
|
|
|
|
|
|
if (party == null) {
|
|
|
|
sender.sendMessage(LocaleLoader.getString("Party.InvalidName"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-06-07 00:48:25 +02:00
|
|
|
message = buildChatMessage(args, 1);
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
2013-06-07 00:48:25 +02:00
|
|
|
|
|
|
|
((PartyChatManager) chatManager).setParty(party);
|
|
|
|
chatManager.handleChat(sender.getName(), getDisplayName(sender), message);
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
}
|