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

58 lines
1.4 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;
public class FCommandChat extends FBaseCommand {
public FCommandChat() {
aliases.add("chat");
aliases.add("c");
2011-09-24 12:04:49 +02:00
optionalParameters.add("mode");
helpDescription = "Change chat mode";
}
@Override
public void perform() {
if ( ! Conf.factionOnlyChat ) {
sendMessage("Faction-only chat is disabled on this server.");
return;
}
if ( ! assertHasFaction()) {
return;
}
2011-09-24 12:04:49 +02:00
if( this.parameters.size() >= 1 ) {
String mode = this.parameters.get(0);
if(mode.startsWith("p")) {
me.setChatMode(ChatMode.PUBLIC);
sendMessage("Public chat mode.");
} else if(mode.startsWith("a")) {
me.setChatMode(ChatMode.ALLIANCE);
sendMessage("Alliance only chat mode.");
} else if(mode.startsWith("f")) {
me.setChatMode(ChatMode.FACTION);
sendMessage("Faction only chat mode.");
} else {
sendMessage("Unrecognised chat mode. Please enter either 'a','f' or 'p'");
}
} else {
2011-09-24 12:04:49 +02:00
if(me.getChatMode() == ChatMode.PUBLIC) {
me.setChatMode(ChatMode.ALLIANCE);
sendMessage("Alliance only chat mode.");
} else if (me.getChatMode() == ChatMode.ALLIANCE ) {
me.setChatMode(ChatMode.FACTION);
sendMessage("Faction only chat mode.");
} else {
me.setChatMode(ChatMode.PUBLIC);
sendMessage("Public chat mode.");
}
}
}
}