Add better channel switch failure messages

This commit is contained in:
Draycia committed 2020-07-10 01:27:16 -07:00
1 parent 6ca2b9c4c8
commit c351aa5e48
9 files changed
+69 -25

No files matched your search

@@ -3,6 +3,10 @@ package net.draycia.simplechat.managers;
import co.aikar.commands.*;
import net.draycia.simplechat.SimpleChat;
import net.draycia.simplechat.channels.ChatChannel;
import net.draycia.simplechat.channels.impls.AllianceChatChannel;
import net.draycia.simplechat.channels.impls.NationChatChannel;
import net.draycia.simplechat.channels.impls.PartyChatChannel;
import net.draycia.simplechat.channels.impls.TownChatChannel;
import net.draycia.simplechat.commands.*;
import net.draycia.simplechat.storage.ChatUser;
import org.bukkit.Bukkit;
@@ -69,7 +73,17 @@ public class CommandManager {
ChatUser user = simpleChat.getUserService().wrap(context.getIssuer().getPlayer());
if (!value.canPlayerUse(user)) {
throw new ConditionFailedException(simpleChat.getConfig().getString("language.cannot-use-channel"));
if (value.isTownChat() && !((TownChatChannel)value).isInTown(user)) {
throw new ConditionFailedException(simpleChat.getConfig().getString("language.town-cannot-use"));
} else if (value.isNationChat() && !((NationChatChannel)value).isInNation(user)) {
throw new ConditionFailedException(simpleChat.getConfig().getString("language.nation-cannot-use"));
} else if (value.isAllianceChat() && !((AllianceChatChannel)value).isInTown(user)) {
throw new ConditionFailedException(simpleChat.getConfig().getString("alliance-cannot-use"));
} else if (value.isPartyChat() && !((PartyChatChannel)value).isInParty(user)) {
throw new ConditionFailedException(simpleChat.getConfig().getString("party-cannot-use"));
} else {
throw new ConditionFailedException(simpleChat.getConfig().getString("cannot-use-channel"));
}
}
});