2011-10-09 21:57:43 +02:00
|
|
|
package com.massivecraft.factions.cmd;
|
2011-03-22 15:45:41 +01:00
|
|
|
|
2011-09-10 06:26:15 +02:00
|
|
|
import com.massivecraft.factions.Conf;
|
2011-09-24 12:04:49 +02:00
|
|
|
import com.massivecraft.factions.struct.ChatMode;
|
2011-10-09 14:53:38 +02:00
|
|
|
import com.massivecraft.factions.struct.Permission;
|
2014-12-08 00:12:52 +01:00
|
|
|
import com.massivecraft.factions.zcore.util.TL;
|
2018-03-26 23:43:15 +02:00
|
|
|
import org.bukkit.Bukkit;
|
2011-09-10 06:26:15 +02:00
|
|
|
|
2014-04-04 20:55:21 +02:00
|
|
|
public class CmdChat extends FCommand {
|
|
|
|
|
|
|
|
public CmdChat() {
|
2014-07-01 22:10:18 +02:00
|
|
|
super();
|
|
|
|
this.aliases.add("c");
|
|
|
|
this.aliases.add("chat");
|
2014-04-04 20:55:21 +02:00
|
|
|
|
|
|
|
//this.requiredArgs.add("");
|
|
|
|
this.optionalArgs.put("mode", "next");
|
|
|
|
|
2014-07-01 22:10:18 +02:00
|
|
|
this.permission = Permission.CHAT.node;
|
|
|
|
this.disableOnLock = false;
|
2014-04-04 20:55:21 +02:00
|
|
|
|
2014-07-01 22:10:18 +02:00
|
|
|
senderMustBePlayer = true;
|
|
|
|
senderMustBeMember = true;
|
|
|
|
senderMustBeModerator = false;
|
2018-03-26 23:43:15 +02:00
|
|
|
senderMustBeColeader = false;
|
2014-07-01 22:10:18 +02:00
|
|
|
senderMustBeAdmin = false;
|
2014-04-04 20:55:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void perform() {
|
|
|
|
if (!Conf.factionOnlyChat) {
|
2014-12-08 00:12:52 +01:00
|
|
|
msg(TL.COMMAND_CHAT_DISABLED.toString());
|
2014-07-01 22:10:18 +02:00
|
|
|
return;
|
2014-04-04 20:55:21 +02:00
|
|
|
}
|
|
|
|
|
2014-07-01 22:10:18 +02:00
|
|
|
String modeString = this.argAsString(0);
|
|
|
|
ChatMode modeTarget = fme.getChatMode().getNext();
|
2014-04-04 20:55:21 +02:00
|
|
|
|
|
|
|
if (modeString != null) {
|
2015-01-06 18:42:56 +01:00
|
|
|
modeString = modeString.toLowerCase();
|
2018-03-26 23:43:15 +02:00
|
|
|
if (modeString.startsWith("m")){
|
2018-03-05 03:57:27 +01:00
|
|
|
modeTarget = ChatMode.MOD;
|
|
|
|
} else if (modeString.startsWith("p")) {
|
2014-04-04 20:55:21 +02:00
|
|
|
modeTarget = ChatMode.PUBLIC;
|
2014-07-01 21:52:40 +02:00
|
|
|
} else if (modeString.startsWith("a")) {
|
2014-04-04 20:55:21 +02:00
|
|
|
modeTarget = ChatMode.ALLIANCE;
|
2014-07-01 21:52:40 +02:00
|
|
|
} else if (modeString.startsWith("f")) {
|
2014-04-04 20:55:21 +02:00
|
|
|
modeTarget = ChatMode.FACTION;
|
2015-01-23 03:30:40 +01:00
|
|
|
} else if (modeString.startsWith("t")) {
|
|
|
|
modeTarget = ChatMode.TRUCE;
|
2014-07-01 21:52:40 +02:00
|
|
|
} else {
|
2014-12-08 00:12:52 +01:00
|
|
|
msg(TL.COMMAND_CHAT_INVALIDMODE);
|
2014-07-01 22:10:18 +02:00
|
|
|
return;
|
2014-04-04 20:55:21 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fme.setChatMode(modeTarget);
|
|
|
|
|
2018-03-26 23:43:15 +02:00
|
|
|
if (fme.getChatMode() == ChatMode.MOD)
|
|
|
|
{
|
2018-03-05 03:57:27 +01:00
|
|
|
msg(TL.COMMAND_CHAT_MODE_MOD);
|
2018-03-26 23:43:15 +02:00
|
|
|
}else if (fme.getChatMode() == ChatMode.PUBLIC) {
|
2014-12-08 00:12:52 +01:00
|
|
|
msg(TL.COMMAND_CHAT_MODE_PUBLIC);
|
2014-07-01 21:52:40 +02:00
|
|
|
} else if (fme.getChatMode() == ChatMode.ALLIANCE) {
|
2014-12-08 00:12:52 +01:00
|
|
|
msg(TL.COMMAND_CHAT_MODE_ALLIANCE);
|
2015-01-23 03:30:40 +01:00
|
|
|
} else if (fme.getChatMode() == ChatMode.TRUCE) {
|
|
|
|
msg(TL.COMMAND_CHAT_MODE_TRUCE);
|
2014-07-01 21:52:40 +02:00
|
|
|
} else {
|
2014-12-08 00:12:52 +01:00
|
|
|
msg(TL.COMMAND_CHAT_MODE_FACTION);
|
2014-04-04 20:55:21 +02:00
|
|
|
}
|
|
|
|
}
|
2015-01-22 00:58:33 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public TL getUsageTranslation() {
|
|
|
|
return TL.COMMAND_CHAT_DESCRIPTION;
|
|
|
|
}
|
2018-03-26 23:43:15 +02:00
|
|
|
}
|