2011-10-09 21:57:43 +02:00
|
|
|
package com.massivecraft.factions.cmd;
|
2011-03-22 15:45:41 +01:00
|
|
|
|
2014-12-19 13:51:24 +01:00
|
|
|
import com.massivecraft.factions.Conf;
|
2011-07-18 22:06:02 +02:00
|
|
|
import com.massivecraft.factions.FPlayer;
|
2014-04-04 20:55:21 +02:00
|
|
|
import com.massivecraft.factions.Faction;
|
2011-10-09 14:53:38 +02:00
|
|
|
import com.massivecraft.factions.struct.Permission;
|
2011-07-18 22:06:02 +02:00
|
|
|
import com.massivecraft.factions.struct.Role;
|
2014-12-08 00:12:52 +01:00
|
|
|
import com.massivecraft.factions.zcore.util.TL;
|
2015-05-25 01:05:27 +02:00
|
|
|
import net.md_5.bungee.api.chat.BaseComponent;
|
|
|
|
import net.md_5.bungee.api.chat.ClickEvent;
|
|
|
|
import net.md_5.bungee.api.chat.HoverEvent;
|
|
|
|
import net.md_5.bungee.api.chat.TextComponent;
|
2011-03-22 15:45:41 +01:00
|
|
|
|
2014-04-04 20:55:21 +02:00
|
|
|
public class CmdMod extends FCommand {
|
|
|
|
|
|
|
|
public CmdMod() {
|
2014-07-01 22:10:18 +02:00
|
|
|
super();
|
|
|
|
this.aliases.add("mod");
|
2014-04-04 20:55:21 +02:00
|
|
|
|
2014-11-14 16:59:36 +01:00
|
|
|
this.optionalArgs.put("player name", "name");
|
2014-04-04 20:55:21 +02:00
|
|
|
//this.optionalArgs.put("", "");
|
|
|
|
|
2014-07-01 22:10:18 +02:00
|
|
|
this.permission = Permission.MOD.node;
|
|
|
|
this.disableOnLock = true;
|
2014-04-04 20:55:21 +02:00
|
|
|
|
2014-07-01 22:10:18 +02:00
|
|
|
senderMustBePlayer = false;
|
2014-11-14 21:13:51 +01:00
|
|
|
senderMustBeMember = true;
|
2014-07-01 22:10:18 +02:00
|
|
|
senderMustBeModerator = false;
|
2014-11-14 21:13:51 +01:00
|
|
|
senderMustBeAdmin = true;
|
2014-04-04 20:55:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void perform() {
|
2014-07-01 22:10:18 +02:00
|
|
|
FPlayer you = this.argAsBestFPlayerMatch(0);
|
|
|
|
if (you == null) {
|
2015-05-25 01:05:27 +02:00
|
|
|
TextComponent component = new TextComponent(TL.COMMAND_MOD_CANDIDATES.toString());
|
|
|
|
component.setColor(net.md_5.bungee.api.ChatColor.GOLD);
|
2014-11-14 16:59:36 +01:00
|
|
|
for (FPlayer player : myFaction.getFPlayersWhereRole(Role.NORMAL)) {
|
|
|
|
String s = player.getName();
|
2015-05-25 01:05:27 +02:00
|
|
|
TextComponent then = new TextComponent(s + " ");
|
|
|
|
then.setColor(net.md_5.bungee.api.ChatColor.WHITE);
|
|
|
|
then.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new BaseComponent[]{new TextComponent(TL.COMMAND_MOD_CLICKTOPROMOTE.toString() + s)}));
|
|
|
|
then.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, Conf.baseCommandAliases.get(0) + " mod " + s));
|
|
|
|
component.addExtra(then);
|
2014-11-14 16:59:36 +01:00
|
|
|
}
|
2014-11-14 17:03:57 +01:00
|
|
|
|
2015-05-25 01:05:27 +02:00
|
|
|
fme.getPlayer().spigot().sendMessage(component);
|
2015-01-05 17:00:15 +01:00
|
|
|
return;
|
2014-07-01 22:10:18 +02:00
|
|
|
}
|
2014-04-04 20:55:21 +02:00
|
|
|
|
2014-07-01 22:10:18 +02:00
|
|
|
boolean permAny = Permission.MOD_ANY.has(sender, false);
|
|
|
|
Faction targetFaction = you.getFaction();
|
2012-01-18 13:01:29 +01:00
|
|
|
|
2014-04-04 20:55:21 +02:00
|
|
|
if (targetFaction != myFaction && !permAny) {
|
2014-12-08 00:12:52 +01:00
|
|
|
msg(TL.COMMAND_MOD_NOTMEMBER, you.describeTo(fme, true));
|
2014-07-01 22:10:18 +02:00
|
|
|
return;
|
2014-04-04 20:55:21 +02:00
|
|
|
}
|
2012-01-18 13:01:29 +01:00
|
|
|
|
2014-04-04 20:55:21 +02:00
|
|
|
if (fme != null && fme.getRole() != Role.ADMIN && !permAny) {
|
2014-12-08 00:12:52 +01:00
|
|
|
msg(TL.COMMAND_MOD_NOTADMIN);
|
2014-07-01 22:10:18 +02:00
|
|
|
return;
|
2014-04-04 20:55:21 +02:00
|
|
|
}
|
2012-01-18 13:01:29 +01:00
|
|
|
|
2014-04-04 20:55:21 +02:00
|
|
|
if (you == fme && !permAny) {
|
2014-12-08 00:12:52 +01:00
|
|
|
msg(TL.COMMAND_MOD_SELF);
|
2014-07-01 22:10:18 +02:00
|
|
|
return;
|
2014-04-04 20:55:21 +02:00
|
|
|
}
|
2012-01-18 13:01:29 +01:00
|
|
|
|
2014-04-04 20:55:21 +02:00
|
|
|
if (you.getRole() == Role.ADMIN) {
|
2014-12-08 00:12:52 +01:00
|
|
|
msg(TL.COMMAND_MOD_TARGETISADMIN);
|
2014-07-01 22:10:18 +02:00
|
|
|
return;
|
2014-04-04 20:55:21 +02:00
|
|
|
}
|
2011-03-22 15:45:41 +01:00
|
|
|
|
2014-04-04 20:55:21 +02:00
|
|
|
if (you.getRole() == Role.MODERATOR) {
|
|
|
|
// Revoke
|
|
|
|
you.setRole(Role.NORMAL);
|
2014-12-08 00:12:52 +01:00
|
|
|
targetFaction.msg(TL.COMMAND_MOD_REVOKED, you.describeTo(targetFaction, true));
|
|
|
|
msg(TL.COMMAND_MOD_REVOKES, you.describeTo(fme, true));
|
2014-07-01 21:52:40 +02:00
|
|
|
} else {
|
2014-04-04 20:55:21 +02:00
|
|
|
// Give
|
|
|
|
you.setRole(Role.MODERATOR);
|
2014-12-08 00:12:52 +01:00
|
|
|
targetFaction.msg(TL.COMMAND_MOD_PROMOTED, you.describeTo(targetFaction, true));
|
|
|
|
msg(TL.COMMAND_MOD_PROMOTES, you.describeTo(fme, true));
|
2014-04-04 20:55:21 +02:00
|
|
|
}
|
|
|
|
}
|
2012-01-18 13:01:29 +01:00
|
|
|
|
2015-01-22 00:58:33 +01:00
|
|
|
@Override
|
|
|
|
public TL getUsageTranslation() {
|
|
|
|
return TL.COMMAND_MOD_DESCRIPTION;
|
|
|
|
}
|
|
|
|
|
2011-03-22 15:45:41 +01:00
|
|
|
}
|