2013-12-16 21:21:32 +01:00
package com.graywolf336.jail.command.commands ;
import org.bukkit.command.CommandSender ;
import org.bukkit.entity.Player ;
2013-12-19 00:26:39 +01:00
import com.beust.jcommander.JCommander ;
import com.beust.jcommander.ParameterException ;
2013-12-16 21:21:32 +01:00
import com.graywolf336.jail.JailManager ;
import com.graywolf336.jail.command.Command ;
import com.graywolf336.jail.command.CommandInfo ;
2013-12-19 00:26:39 +01:00
import com.graywolf336.jail.command.parameters.JailParameters ;
2013-12-16 21:21:32 +01:00
@CommandInfo (
maxArgs = - 1 ,
minimumArgs = 1 ,
needsPlayer = false ,
pattern = " jail|j " ,
permission = " jail.command.jail " ,
2013-12-19 00:26:39 +01:00
usage = " /jail [-p name] (-t time) (-j JailName) (-c CellName) (-m Muted) (-r A reason for jailing) "
2013-12-16 21:21:32 +01:00
)
public class JailCommand implements Command {
public boolean execute ( JailManager jm , CommandSender sender , String . . . args ) {
2013-12-19 00:26:39 +01:00
JailParameters params = new JailParameters ( ) ;
2013-12-16 21:32:06 +01:00
2013-12-19 00:26:39 +01:00
try {
new JCommander ( params , args ) ;
} catch ( ParameterException e ) {
return false ;
2013-12-16 21:32:06 +01:00
}
2013-12-19 00:26:39 +01:00
Player p = jm . getPlugin ( ) . getServer ( ) . getPlayer ( params . player ( ) ) ;
2013-12-16 21:21:32 +01:00
//Player is not online
if ( p = = null ) {
2013-12-19 00:26:39 +01:00
sender . sendMessage ( params . player ( ) + " is offline and will be jailed for " + params . time ( ) + " minutes in the jail " + params . jail ( ) + " in the cell " + params . cell ( ) + " and will be muted: " + params . muted ( ) + " . " ) ;
2013-12-16 21:21:32 +01:00
} else {
//Player *is* online
2013-12-19 00:26:39 +01:00
sender . sendMessage ( params . player ( ) + " is online and will be jailed for " + params . time ( ) + " minutes in the jail " + params . jail ( ) + " in the cell " + params . cell ( ) + " and will be muted: " + params . muted ( ) + " . " ) ;
2013-12-16 21:21:32 +01:00
}
return true ;
}
}