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;
|
2019-12-24 15:19:43 +01:00
|
|
|
import com.massivecraft.factions.FactionsPlugin;
|
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 22:46:18 +02:00
|
|
|
import mkremins.fanciful.FancyMessage;
|
|
|
|
import org.bukkit.ChatColor;
|
2011-03-22 15:45:41 +01:00
|
|
|
|
2014-04-04 20:55:21 +02:00
|
|
|
public class CmdMod extends FCommand {
|
|
|
|
|
2019-12-02 19:55:38 +01:00
|
|
|
/**
|
|
|
|
* @author FactionsUUID Team
|
|
|
|
*/
|
|
|
|
|
2019-09-15 11:19:06 +02:00
|
|
|
public CmdMod() {
|
|
|
|
super();
|
|
|
|
this.aliases.add("mod");
|
|
|
|
this.aliases.add("setmod");
|
|
|
|
this.aliases.add("officer");
|
|
|
|
this.aliases.add("setofficer");
|
2019-08-24 19:18:50 +02:00
|
|
|
|
2019-09-15 11:19:06 +02:00
|
|
|
this.optionalArgs.put("player name", "name");
|
2019-08-24 19:18:50 +02:00
|
|
|
|
2019-09-15 11:19:06 +02:00
|
|
|
this.requirements = new CommandRequirements.Builder(Permission.MOD)
|
|
|
|
.playerOnly()
|
|
|
|
.memberOnly()
|
|
|
|
.build();
|
|
|
|
}
|
2019-08-24 19:18:50 +02:00
|
|
|
|
2019-09-15 11:19:06 +02:00
|
|
|
@Override
|
|
|
|
public void perform(CommandContext context) {
|
2019-12-24 15:19:43 +01:00
|
|
|
FPlayer you = context.argAsBestFPlayerMatch(0);
|
|
|
|
if (you == null) {
|
|
|
|
FancyMessage msg = new FancyMessage(TL.COMMAND_MOD_CANDIDATES.toString()).color(ChatColor.GOLD);
|
|
|
|
for (FPlayer player : context.faction.getFPlayersWhereRole(Role.NORMAL)) {
|
|
|
|
String s = player.getName();
|
|
|
|
msg.then(s + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_MOD_CLICKTOPROMOTE.toString() + s).command("/" + Conf.baseCommandAliases.get(0) + " mod " + s);
|
|
|
|
}
|
2019-08-24 19:18:50 +02:00
|
|
|
|
2019-12-24 15:19:43 +01:00
|
|
|
context.sendFancyMessage(msg);
|
|
|
|
return;
|
|
|
|
}
|
2019-08-24 19:18:50 +02:00
|
|
|
|
2019-12-24 15:19:43 +01:00
|
|
|
boolean permAny = Permission.MOD_ANY.has(context.sender, false);
|
|
|
|
Faction targetFaction = you.getFaction();
|
|
|
|
if (targetFaction != context.faction && !permAny) {
|
|
|
|
context.msg(TL.COMMAND_MOD_NOTMEMBER, you.describeTo(context.fPlayer, true));
|
|
|
|
return;
|
|
|
|
}
|
2019-08-24 19:18:50 +02:00
|
|
|
|
2019-12-24 15:19:43 +01:00
|
|
|
if (context.fPlayer != null && context.fPlayer.getRole() != Role.LEADER && !permAny) {
|
|
|
|
context.msg(TL.COMMAND_MOD_NOTADMIN);
|
|
|
|
return;
|
|
|
|
}
|
2019-08-24 19:18:50 +02:00
|
|
|
|
2019-12-24 15:19:43 +01:00
|
|
|
if (you == context.fPlayer && !permAny) {
|
|
|
|
context.msg(TL.COMMAND_MOD_SELF);
|
|
|
|
return;
|
|
|
|
}
|
2019-08-24 19:18:50 +02:00
|
|
|
|
2019-12-24 15:19:43 +01:00
|
|
|
if (you.getRole() == Role.LEADER) {
|
|
|
|
context.msg(TL.COMMAND_MOD_TARGETISADMIN);
|
|
|
|
return;
|
|
|
|
}
|
2019-08-24 19:18:50 +02:00
|
|
|
|
2019-12-24 15:19:43 +01:00
|
|
|
if (you.getRole() == Role.MODERATOR) {
|
|
|
|
// Revoke
|
|
|
|
you.setRole(Role.NORMAL);
|
|
|
|
targetFaction.msg(TL.COMMAND_MOD_REVOKED, you.describeTo(targetFaction, true));
|
|
|
|
context.msg(TL.COMMAND_MOD_REVOKES, you.describeTo(context.fPlayer, true));
|
|
|
|
} else {
|
|
|
|
// Give
|
|
|
|
you.setRole(Role.MODERATOR);
|
|
|
|
targetFaction.msg(TL.COMMAND_MOD_PROMOTED, you.describeTo(targetFaction, true));
|
|
|
|
context.msg(TL.COMMAND_MOD_PROMOTES, you.describeTo(context.fPlayer, true));
|
|
|
|
}
|
2019-09-15 11:19:06 +02:00
|
|
|
}
|
2019-08-24 19:18:50 +02:00
|
|
|
|
2019-09-15 11:19:06 +02:00
|
|
|
@Override
|
|
|
|
public TL getUsageTranslation() {
|
|
|
|
return TL.COMMAND_MOD_DESCRIPTION;
|
|
|
|
}
|
2015-01-22 00:58:33 +01:00
|
|
|
|
2011-03-22 15:45:41 +01:00
|
|
|
}
|