2018-12-21 22:46:10 +01:00
|
|
|
package com.massivecraft.factions.cmd;
|
|
|
|
|
|
|
|
import com.massivecraft.factions.FPlayer;
|
|
|
|
import com.massivecraft.factions.FPlayers;
|
|
|
|
import com.massivecraft.factions.Faction;
|
|
|
|
import com.massivecraft.factions.struct.Permission;
|
|
|
|
import com.massivecraft.factions.zcore.util.TL;
|
|
|
|
|
|
|
|
public class CmdPeaceful extends FCommand {
|
|
|
|
|
2019-12-02 19:55:38 +01:00
|
|
|
/**
|
|
|
|
* @author FactionsUUID Team
|
|
|
|
*/
|
|
|
|
|
2019-09-15 11:19:06 +02:00
|
|
|
public CmdPeaceful() {
|
|
|
|
super();
|
2020-01-02 02:59:31 +01:00
|
|
|
this.aliases.addAll(Aliases.peaceful);
|
2019-09-15 11:19:06 +02:00
|
|
|
this.requiredArgs.add("faction tag");
|
|
|
|
|
|
|
|
this.requirements = new CommandRequirements.Builder(Permission.SET_PEACEFUL)
|
|
|
|
.build();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void perform(CommandContext context) {
|
|
|
|
Faction faction = context.argAsFaction(0);
|
|
|
|
if (faction == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
String change;
|
|
|
|
if (faction.isPeaceful()) {
|
|
|
|
change = TL.COMMAND_PEACEFUL_REVOKE.toString();
|
|
|
|
faction.setPeaceful(false);
|
|
|
|
} else {
|
|
|
|
change = TL.COMMAND_PEACEFUL_GRANT.toString();
|
|
|
|
faction.setPeaceful(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Inform all players
|
|
|
|
for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) {
|
|
|
|
String blame = (context.fPlayer == null ? TL.GENERIC_SERVERADMIN.toString() : context.fPlayer.describeTo(fplayer, true));
|
|
|
|
if (fplayer.getFaction() == faction) {
|
|
|
|
fplayer.msg(TL.COMMAND_PEACEFUL_YOURS, blame, change);
|
|
|
|
} else {
|
|
|
|
fplayer.msg(TL.COMMAND_PEACEFUL_OTHER, blame, change, faction.getTag(fplayer));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public TL getUsageTranslation() {
|
|
|
|
return TL.COMMAND_PEACEFUL_DESCRIPTION;
|
|
|
|
}
|
2018-12-21 22:46:10 +01:00
|
|
|
|
|
|
|
}
|