Saber-Factions/src/com/massivecraft/factions/commands/FCommandChat.java

73 lines
1.5 KiB
Java
Raw Normal View History

2011-07-18 22:06:02 +02:00
package com.massivecraft.factions.commands;
import com.massivecraft.factions.Conf;
2011-09-24 12:04:49 +02:00
import com.massivecraft.factions.struct.ChatMode;
import com.massivecraft.factions.struct.Permission;
public class FCommandChat extends FCommand
{
public FCommandChat()
{
super();
this.aliases.add("c");
this.aliases.add("chat");
//this.requiredArgs.add("");
this.optionalArgs.put("mode", "next");
2011-09-24 12:04:49 +02:00
this.permission = Permission.COMMAND_CHAT.node;
senderMustBePlayer = true;
senderMustBeMember = true;
senderMustBeModerator = false;
senderMustBeAdmin = false;
}
@Override
public void perform()
{
if ( ! Conf.factionOnlyChat )
{
sendMessageParsed("<b>Faction-only chat is disabled on this server.");
return;
}
String modeString = this.argAsString(0).toLowerCase();
ChatMode modeTarget = fme.getChatMode().getNext();
if (modeString != null)
{
if(modeString.startsWith("p"))
{
modeTarget = ChatMode.PUBLIC;
}
else if (modeString.startsWith("a"))
{
modeTarget = ChatMode.ALLIANCE;
}
else if(modeString.startsWith("f"))
{
modeTarget = ChatMode.FACTION;
}
sendMessageParsed("<b>Unrecognised chat mode. <i>Please enter either 'a','f' or 'p'");
return;
}
fme.setChatMode(modeTarget);
2011-09-24 12:04:49 +02:00
if(fme.getChatMode() == ChatMode.PUBLIC)
{
sendMessageParsed("<i>Public chat mode.");
}
else if (fme.getChatMode() == ChatMode.ALLIANCE )
{
sendMessageParsed("<i>Alliance only chat mode.");
}
else
{
sendMessageParsed("<i>Faction only chat mode.");
}
}
}