Saber-Factions/src/main/java/com/massivecraft/factions/cmd/CmdChat.java
eueln 5799a0480b Fix String-related bugs
The result of a call to String#toLowerCase() was ignored, and two
Strings were being compared with ==
2015-01-06 11:59:15 -06:00

62 lines
1.8 KiB
Java

package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.struct.ChatMode;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL;
public class CmdChat extends FCommand {
public CmdChat() {
super();
this.aliases.add("c");
this.aliases.add("chat");
//this.requiredArgs.add("");
this.optionalArgs.put("mode", "next");
this.permission = Permission.CHAT.node;
this.disableOnLock = false;
senderMustBePlayer = true;
senderMustBeMember = true;
senderMustBeModerator = false;
senderMustBeAdmin = false;
}
@Override
public void perform() {
if (!Conf.factionOnlyChat) {
msg(TL.COMMAND_CHAT_DISABLED.toString());
return;
}
String modeString = this.argAsString(0);
ChatMode modeTarget = fme.getChatMode().getNext();
if (modeString != null) {
modeString = modeString.toLowerCase();
if (modeString.startsWith("p")) {
modeTarget = ChatMode.PUBLIC;
} else if (modeString.startsWith("a")) {
modeTarget = ChatMode.ALLIANCE;
} else if (modeString.startsWith("f")) {
modeTarget = ChatMode.FACTION;
} else {
msg(TL.COMMAND_CHAT_INVALIDMODE);
return;
}
}
fme.setChatMode(modeTarget);
if (fme.getChatMode() == ChatMode.PUBLIC) {
msg(TL.COMMAND_CHAT_MODE_PUBLIC);
} else if (fme.getChatMode() == ChatMode.ALLIANCE) {
msg(TL.COMMAND_CHAT_MODE_ALLIANCE);
} else {
msg(TL.COMMAND_CHAT_MODE_FACTION);
}
}
}