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-09-15 11:02:53 +02:00
|
|
|
public CmdFocus() {
|
|
|
|
aliases.add("focus");
|
2019-08-24 19:18:50 +02:00
|
|
|
|
2019-09-15 11:02:53 +02:00
|
|
|
requiredArgs.add("player");
|
2019-08-24 19:18:50 +02:00
|
|
|
|
2019-09-15 11:02:53 +02:00
|
|
|
this.requirements = new CommandRequirements.Builder(Permission.FOCUS)
|
|
|
|
.playerOnly()
|
|
|
|
.memberOnly()
|
|
|
|
.build();
|
|
|
|
}
|
2019-08-24 19:18:50 +02:00
|
|
|
|
2019-09-15 11:02:53 +02:00
|
|
|
@Override
|
|
|
|
public void perform(CommandContext context) {
|
|
|
|
if (!FactionsPlugin.getInstance().getConfig().getBoolean("ffocus.Enabled")) {
|
|
|
|
context.msg(TL.GENERIC_DISABLED);
|
|
|
|
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:02:53 +02:00
|
|
|
public TL getUsageTranslation() {
|
|
|
|
return TL.COMMAND_FOCUS_DESCRIPTION;
|
|
|
|
}
|
2018-11-22 08:09:58 +01:00
|
|
|
}
|