2016-03-02 19:28:01 +00:00
package me.totalfreedom.totalfreedommod.command ;
2011-10-19 00:37:00 +00:00
2015-11-15 23:32:04 +00:00
import me.totalfreedom.totalfreedommod.freeze.FreezeData ;
2016-03-06 15:56:15 +00:00
import me.totalfreedom.totalfreedommod.rank.Rank ;
import me.totalfreedom.totalfreedommod.util.FUtil ;
2014-11-20 22:20:31 +00:00
import org.bukkit.ChatColor ;
2011-10-19 00:37:00 +00:00
import org.bukkit.command.Command ;
import org.bukkit.command.CommandSender ;
import org.bukkit.entity.Player ;
2016-03-06 15:56:15 +00:00
@CommandPermissions ( level = Rank . SUPER_ADMIN , source = SourceType . BOTH )
2020-03-30 23:43:57 +00:00
@CommandParameters ( description = " Freeze/Unfreeze a specified player, or all non-admins on the server. " , usage = " /<command> [target | purge] " , aliases = " fr " )
2016-02-29 21:27:11 +00:00
public class Command_freeze extends FreedomCommand
2011-10-19 00:37:00 +00:00
{
2014-12-21 09:23:50 +00:00
2011-10-19 00:37:00 +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 )
2011-10-19 00:37:00 +00:00
{
2012-11-24 01:22:52 +00:00
if ( args . length = = 0 )
2011-10-19 00:37:00 +00:00
{
2016-03-07 20:32:05 +00:00
boolean gFreeze = ! plugin . fm . isGlobalFreeze ( ) ;
plugin . fm . setGlobalFreeze ( gFreeze ) ;
2012-11-24 01:22:52 +00:00
2016-03-07 20:32:05 +00:00
if ( ! gFreeze )
2012-11-24 01:22:52 +00:00
{
2016-03-07 20:32:05 +00:00
FUtil . adminAction ( sender . getName ( ) , " Disabling global player freeze " , false ) ;
2016-03-02 19:28:01 +00:00
msg ( " Players are now free to move. " ) ;
2015-11-15 23:32:04 +00:00
return true ;
}
2013-07-27 21:49:25 +00:00
2016-03-07 20:32:05 +00:00
FUtil . adminAction ( sender . getName ( ) , " Enabling global player freeze " , false ) ;
2015-11-15 23:32:04 +00:00
for ( Player player : server . getOnlinePlayers ( ) )
{
if ( ! isAdmin ( player ) )
2014-01-15 21:38:35 +00:00
{
2019-12-24 16:08:29 +00:00
player . sendTitle ( ChatColor . RED + " You've been globally frozen. " , ChatColor . YELLOW + " Please be patient and you will be unfrozen shortly. " , 20 , 100 , 60 ) ;
2019-07-28 20:48:34 +00:00
msg ( player , " You have been globally frozen due to an OP breaking the rules, please wait and you will be unfrozen soon. " , ChatColor . RED ) ;
2014-01-15 21:38:35 +00:00
}
2012-11-24 01:22:52 +00:00
}
2016-05-12 19:40:39 +00:00
msg ( " Players are now frozen. " ) ;
2015-11-15 23:32:04 +00:00
return true ;
2012-11-24 01:22:52 +00:00
}
2014-05-04 21:03:34 +00:00
2015-11-15 23:32:04 +00:00
if ( args [ 0 ] . equals ( " purge " ) )
{
FUtil . adminAction ( sender . getName ( ) , " Unfreezing all players " , false ) ;
2019-11-30 17:43:16 +00:00
for ( Player player : server . getOnlinePlayers ( ) )
{
if ( ! isAdmin ( player ) )
{
2020-01-07 04:32:54 +00:00
player . sendTitle ( ChatColor . GREEN + " You've been unfrozen. " , ChatColor . YELLOW + " You may now move again. " , 20 , 100 , 60 ) ;
2019-11-30 17:43:16 +00:00
}
}
2015-11-15 23:32:04 +00:00
plugin . fm . purge ( ) ;
return true ;
2011-10-19 00:37:00 +00:00
}
2015-11-15 23:32:04 +00:00
final Player player = getPlayer ( args [ 0 ] ) ;
2014-12-21 09:23:50 +00:00
2015-11-15 23:32:04 +00:00
if ( player = = null )
2014-12-21 09:23:50 +00:00
{
2016-03-02 19:28:01 +00:00
msg ( FreedomCommand . PLAYER_NOT_FOUND , ChatColor . RED ) ;
2015-11-15 23:32:04 +00:00
return true ;
2014-12-21 09:23:50 +00:00
}
2015-11-15 23:32:04 +00:00
final FreezeData fd = plugin . pl . getPlayer ( player ) . getFreezeData ( ) ;
fd . setFrozen ( ! fd . isFrozen ( ) ) ;
2016-03-02 19:28:01 +00:00
msg ( player . getName ( ) + " has been " + ( fd . isFrozen ( ) ? " frozen " : " unfrozen " ) + " . " ) ;
msg ( player , " You have been " + ( fd . isFrozen ( ) ? " frozen " : " unfrozen " ) + " . " , ChatColor . AQUA ) ;
2015-11-15 23:32:04 +00:00
return true ;
2014-12-21 09:23:50 +00:00
}
2011-10-19 00:37:00 +00:00
}