2019-03-03 04:51:21 +01:00
package com.massivecraft.factions.cmd ;
import com.massivecraft.factions.FPlayer ;
import com.massivecraft.factions.FPlayers ;
import com.massivecraft.factions.Faction ;
2019-09-14 21:13:01 +02:00
import com.massivecraft.factions.FactionsPlugin ;
2019-03-03 04:51:21 +01:00
import com.massivecraft.factions.struct.Permission ;
import com.massivecraft.factions.zcore.util.TL ;
public class CmdPermanent extends FCommand {
2019-08-24 19:18:50 +02:00
public CmdPermanent ( ) {
super ( ) ;
this . aliases . add ( " permanent " ) ;
this . requiredArgs . add ( " faction tag " ) ;
2019-09-14 21:13:01 +02:00
this . requirements = new CommandRequirements . Builder ( Permission . SET_PERMANENT )
. build ( ) ;
2019-08-24 19:18:50 +02:00
}
@Override
2019-09-14 21:13:01 +02:00
public void perform ( CommandContext context ) {
Faction faction = context . argAsFaction ( 0 ) ;
2019-08-24 19:18:50 +02:00
if ( faction = = null ) {
return ;
}
String change ;
if ( faction . isPermanent ( ) ) {
change = TL . COMMAND_PERMANENT_REVOKE . toString ( ) ;
faction . setPermanent ( false ) ;
} else {
change = TL . COMMAND_PERMANENT_GRANT . toString ( ) ;
faction . setPermanent ( true ) ;
}
2019-09-14 21:13:01 +02:00
FactionsPlugin . getInstance ( ) . log ( ( context . fPlayer = = null ? " A server admin " : context . fPlayer . getName ( ) ) + " " + change + " the faction \" " + faction . getTag ( ) + " \" . " ) ;
2019-08-24 19:18:50 +02:00
// Inform all players
for ( FPlayer fplayer : FPlayers . getInstance ( ) . getOnlinePlayers ( ) ) {
2019-09-14 21:13:01 +02:00
String blame = ( context . fPlayer = = null ? TL . GENERIC_SERVERADMIN . toString ( ) : context . fPlayer . describeTo ( fplayer , true ) ) ;
2019-08-24 19:18:50 +02:00
if ( fplayer . getFaction ( ) = = faction ) {
fplayer . msg ( TL . COMMAND_PERMANENT_YOURS , blame , change ) ;
} else {
fplayer . msg ( TL . COMMAND_PERMANENT_OTHER , blame , change , faction . getTag ( fplayer ) ) ;
}
}
}
@Override
public TL getUsageTranslation ( ) {
return TL . COMMAND_PERMANENT_DESCRIPTION ;
}
2019-03-03 04:51:21 +01:00
}
2019-09-14 21:13:01 +02:00