2018-11-22 08:09:58 +01:00
|
|
|
package com.massivecraft.factions.cmd;
|
|
|
|
|
|
|
|
import com.massivecraft.factions.FPlayer;
|
2019-09-14 21:13:01 +02:00
|
|
|
import com.massivecraft.factions.FactionsPlugin;
|
2018-11-22 08:09:58 +01:00
|
|
|
import com.massivecraft.factions.scoreboards.FTeamWrapper;
|
|
|
|
import com.massivecraft.factions.struct.Permission;
|
|
|
|
import com.massivecraft.factions.zcore.util.TL;
|
|
|
|
|
2019-09-14 21:13:01 +02:00
|
|
|
public class CmdFocus extends FCommand {
|
2019-12-02 20:03:27 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @author Driftay
|
|
|
|
*/
|
|
|
|
|
2019-09-15 11:19:06 +02:00
|
|
|
public CmdFocus() {
|
2020-01-02 02:59:31 +01:00
|
|
|
aliases.addAll(Aliases.focus);
|
2019-08-24 19:18:50 +02:00
|
|
|
|
2019-09-15 11:19:06 +02:00
|
|
|
requiredArgs.add("player");
|
2019-08-24 19:18:50 +02:00
|
|
|
|
2019-09-15 11:19:06 +02:00
|
|
|
this.requirements = new CommandRequirements.Builder(Permission.FOCUS)
|
|
|
|
.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) {
|
|
|
|
if (!FactionsPlugin.getInstance().getConfig().getBoolean("ffocus.Enabled")) {
|
2019-12-03 11:16:37 +01:00
|
|
|
context.msg(TL.GENERIC_DISABLED, "Faction Focus");
|
2019-09-15 11:19:06 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
FPlayer target = context.argAsFPlayer(0);
|
|
|
|
if (target == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (target.getFaction().getId().equalsIgnoreCase(context.faction.getId())) {
|
|
|
|
context.msg(TL.COMMAND_FOCUS_SAMEFACTION);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if ((context.faction.getFocused() != null) && (context.faction.getFocused().equalsIgnoreCase(target.getName()))) {
|
|
|
|
context.faction.setFocused(null);
|
|
|
|
context.faction.msg(TL.COMMAND_FOCUS_NO_LONGER, target.getName());
|
|
|
|
FTeamWrapper.updatePrefixes(target.getFaction());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
context.faction.msg(TL.COMMAND_FOCUS_FOCUSING, target.getName());
|
|
|
|
context.faction.setFocused(target.getName());
|
|
|
|
FTeamWrapper.updatePrefixes(target.getFaction());
|
|
|
|
}
|
2019-08-24 19:18:50 +02:00
|
|
|
|
2019-09-15 11:19:06 +02:00
|
|
|
public TL getUsageTranslation() {
|
|
|
|
return TL.COMMAND_FOCUS_DESCRIPTION;
|
|
|
|
}
|
2018-11-22 08:09:58 +01:00
|
|
|
}
|