2010-12-01 05:47:24 +01:00
//=====================================================================
//Class: vMinecraftAnnouncements
//Use: Encapsulates all announcements broadcast when commands are
// run
//Author: nossr50, TrapAlice, cerevisiae
//=====================================================================
2010-12-08 05:24:39 +01:00
public class vMinecraftAnnouncements extends vMinecraftCommands {
2010-12-01 05:47:24 +01:00
//=====================================================================
//Function: onCommand
//Input: Player player: The player calling the command
// String[] split: The arguments
//Output: boolean: If the user has access to the command
// and it is enabled
//Use: Checks if /kick, /ban, /ipban, and /time are run and
// displays a global message
//=====================================================================
public boolean onCommand ( Player player , String [ ] split ) {
if ( ! player . canUseCommand ( split [ 0 ] ) ) {
return false ;
}
//Only run if the global message feature is enabled
if ( vMinecraftSettings . getInstance ( ) . globalmessages ( ) )
{
//Global messages that should only parse when a command can be successful
if ( split [ 0 ] . equalsIgnoreCase ( " /kick " ) ) {
Player playerTarget = etc . getServer ( ) . matchPlayer ( split [ 1 ] ) ;
if ( playerTarget ! = null & & ! playerTarget . hasControlOver ( player ) ) {
2010-12-02 04:25:45 +01:00
vMinecraftChat . gmsg ( player , player . getColor ( ) + player . getName ( ) + Colors . Blue + " has kicked " + Colors . Red + playerTarget . getColor ( ) + playerTarget . getName ( ) ) ;
2010-12-01 05:47:24 +01:00
}
}
if ( split [ 0 ] . equalsIgnoreCase ( " /ban " ) ) {
Player playerTarget = etc . getServer ( ) . matchPlayer ( split [ 1 ] ) ;
if ( playerTarget ! = null & & ! playerTarget . hasControlOver ( player ) ) {
2010-12-02 04:25:45 +01:00
vMinecraftChat . gmsg ( player , player . getColor ( ) + player . getName ( ) + Colors . Blue + " has banned " + Colors . Red + playerTarget . getColor ( ) + playerTarget . getName ( ) ) ;
2010-12-01 05:47:24 +01:00
}
}
if ( split [ 0 ] . equalsIgnoreCase ( " /ipban " ) ) {
Player playerTarget = etc . getServer ( ) . matchPlayer ( split [ 1 ] ) ;
if ( playerTarget ! = null & & ! playerTarget . hasControlOver ( player ) ) {
2010-12-02 04:25:45 +01:00
vMinecraftChat . gmsg ( player , player . getColor ( ) + player . getName ( ) + Colors . Blue + " has IP banned " + Colors . Red + playerTarget . getColor ( ) + playerTarget . getName ( ) ) ;
2010-12-01 05:47:24 +01:00
}
}
if ( split [ 0 ] . equalsIgnoreCase ( " /time " ) ) {
if ( split . length < = 2 ) {
2010-12-02 04:25:45 +01:00
vMinecraftChat . gmsg ( player , Colors . Blue + " Time changes thanks to " + player . getColor ( ) + player . getName ( ) ) ;
2010-12-01 05:47:24 +01:00
}
}
2010-12-08 05:24:39 +01:00
if ( split [ 0 ] . equalsIgnoreCase ( " /tp " ) ) {
if ( player . canUseCommand ( " /tp " ) ) {
if ( etc . getServer ( ) . getPlayer ( split [ 1 ] ) ! = null )
vMinecraftChat . gmsg ( player , player . getName ( ) + Colors . Blue + " has teleported to " + etc . getServer ( ) . getPlayer ( split [ 1 ] ) . getName ( ) ) ;
}
}
2010-12-01 05:47:24 +01:00
}
return true ;
}
}