2016-03-02 19:28:01 +00:00
package me.totalfreedom.totalfreedommod.command ;
2012-12-06 09:32:08 +00:00
2015-11-15 23:32:04 +00:00
import me.totalfreedom.totalfreedommod.rank.PlayerRank ;
2015-10-19 17:43:46 +00:00
import me.totalfreedom.totalfreedommod.player.FPlayer ;
import me.totalfreedom.totalfreedommod.util.FUtil ;
2012-12-06 09:32:08 +00:00
import org.bukkit.command.Command ;
import org.bukkit.command.CommandSender ;
import org.bukkit.entity.Player ;
2015-10-19 17:43:46 +00:00
@CommandPermissions ( level = PlayerRank . SUPER_ADMIN , source = SourceType . BOTH )
2013-04-10 02:05:24 +00:00
@CommandParameters ( description = " Block all commands for a specific player. " , usage = " /<command> <purge | <partialname>> " , aliases = " blockcommands,blockcommand " )
2015-10-19 17:43:46 +00:00
public class Command_blockcmd extends FreedomCommand
2012-12-06 09:32:08 +00:00
{
2015-11-22 18:26:47 +00:00
2012-12-06 09:32:08 +00:00
@Override
2015-11-22 18:26:47 +00:00
public boolean run ( CommandSender sender , Player playerSender , Command cmd , String commandLabel , String [ ] args , boolean senderIsConsole )
2012-12-06 09:32:08 +00:00
{
2012-12-08 01:01:52 +00:00
if ( args . length ! = 1 )
{
2012-12-06 09:32:08 +00:00
return false ;
}
2013-01-07 14:56:53 +00:00
if ( args [ 0 ] . equalsIgnoreCase ( " purge " ) )
{
2015-10-19 17:43:46 +00:00
FUtil . adminAction ( sender . getName ( ) , " Unblocking commands for all players " , true ) ;
2013-01-07 14:56:53 +00:00
int counter = 0 ;
2013-08-14 14:01:42 +00:00
for ( Player player : server . getOnlinePlayers ( ) )
2013-01-07 14:56:53 +00:00
{
2015-10-19 17:43:46 +00:00
FPlayer playerdata = plugin . pl . getPlayer ( player ) ;
2013-01-07 14:56:53 +00:00
if ( playerdata . allCommandsBlocked ( ) )
{
counter + = 1 ;
playerdata . setCommandsBlocked ( false ) ;
}
}
2016-03-02 19:28:01 +00:00
msg ( " Unblocked commands for " + counter + " players. " ) ;
2013-01-07 14:56:53 +00:00
return true ;
}
2014-04-26 11:55:24 +00:00
final Player player = getPlayer ( args [ 0 ] ) ;
2014-05-04 21:03:34 +00:00
2014-04-26 11:55:24 +00:00
if ( player = = null )
2012-12-06 09:32:08 +00:00
{
2016-03-02 19:28:01 +00:00
msg ( FreedomCommand . PLAYER_NOT_FOUND ) ;
2013-01-07 14:56:53 +00:00
return true ;
}
2015-10-19 17:43:46 +00:00
if ( isAdmin ( sender ) )
2013-01-07 14:56:53 +00:00
{
2016-03-02 19:28:01 +00:00
msg ( player . getName ( ) + " is a Superadmin, and cannot have their commands blocked. " ) ;
2012-12-06 09:32:08 +00:00
return true ;
}
2015-10-19 17:43:46 +00:00
FPlayer playerdata = plugin . pl . getPlayer ( player ) ;
2012-12-06 09:32:08 +00:00
2012-12-08 01:01:52 +00:00
playerdata . setCommandsBlocked ( ! playerdata . allCommandsBlocked ( ) ) ;
2012-12-06 09:32:08 +00:00
2015-10-19 17:43:46 +00:00
FUtil . adminAction ( sender . getName ( ) , ( playerdata . allCommandsBlocked ( ) ? " B " : " Unb " ) + " locking all commands for " + player . getName ( ) , true ) ;
2016-03-02 19:28:01 +00:00
msg ( ( playerdata . allCommandsBlocked ( ) ? " B " : " Unb " ) + " locked all commands. " ) ;
2012-12-06 09:32:08 +00:00
return true ;
}
}