2016-03-02 19:28:01 +00:00
package me.totalfreedom.totalfreedommod.command ;
2013-05-15 21:05:20 +00:00
2016-03-06 15:56:15 +00:00
import me.totalfreedom.totalfreedommod.rank.Rank ;
2015-10-19 17:43:46 +00:00
import me.totalfreedom.totalfreedommod.util.FUtil ;
2018-02-22 01:22:13 +00:00
import org.bukkit.ChatColor ;
2013-05-15 21:05:20 +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 )
2018-07-28 07:11:48 +00:00
@CommandParameters ( description = " Sets everyone's WorldEdit block modification limit to the default limit or to a custom limit. " , usage = " /<command> [limit] " , aliases = " setl,swl " )
2016-05-12 19:40:39 +00:00
public class Command_setlimit extends FreedomCommand
2013-05-15 21:05:20 +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 )
2013-05-15 21:05:20 +00:00
{
2018-05-19 02:08:08 +00:00
int amount = 100000 ;
2018-02-22 01:22:13 +00:00
if ( args . length > 0 )
{
try
{
2018-05-19 02:10:18 +00:00
amount = Math . max ( 1 , Math . min ( 200000 , Integer . parseInt ( args [ 0 ] ) ) ) ;
2018-02-22 01:22:13 +00:00
}
catch ( NumberFormatException ex )
{
msg ( " Invalid number: " + args [ 0 ] , ChatColor . RED ) ;
return true ;
}
}
2018-07-30 07:23:01 +00:00
boolean success = false ;
2013-08-14 14:01:42 +00:00
for ( final Player player : server . getOnlinePlayers ( ) )
2013-07-02 23:08:31 +00:00
{
2018-07-30 07:23:01 +00:00
try
{
plugin . web . setLimit ( player , amount ) ;
success = true ;
}
catch ( NoClassDefFoundError | NullPointerException ex )
{
msg ( " WorldEdit is not enabled on this server. " ) ;
success = false ;
}
}
if ( success )
{
FUtil . adminAction ( sender . getName ( ) , " Setting everyone's WorldEdit block modification limit to " + amount + " . " , true ) ;
2013-07-02 23:08:31 +00:00
}
2013-05-15 21:05:20 +00:00
return true ;
}
}