Package wzhybridbots.tools.actions

Source Code of wzhybridbots.tools.actions.VIEServerCommands

/**
* This source file is part of WZ Hybrid Bots
* For the latest information, see http://sourceforge.net/projects/wzhybridbots
*
* Copyright (c) 2006 - WzCtf
* For more information about WzCtf, see http://www.wzctf.net
* Also see the license in license.txt
*/
package wzhybridbots.tools.actions;


/** The imported classes/interfaces */
import java.util.Iterator;

import frontend.alphaspawn.ASConnection;

import wzhybridbots.tools.actions.ActionTargetPlayer;


/**
* Class that calls a server command for a VIE server type.
*
* @author Witlospock
* @version 1.0
*/
public class VIEServerCommands implements ServerCommands {
 
  /**
   * Calls the command specified by the <i>command</i> parameter using
   * the <i>connection</i> object for the targeted players.
   *
   * @param connection The connection object to use for the command.
   * @param target The players targeted by the action.
   * @param command The server command's name.
   */
  protected void sendCommand ( ASConnection connection, ActionTarget target, String command ) {
    // Iterate through the targets and send the command
    for ( Iterator iter = target.iterator() ; iter.hasNext() ; ) {
      try {
        ActionTargetPlayer player = (ActionTargetPlayer)iter.next();
     
        // Calls the command
        connection.sendPrivateMessage( player.getPlayerName(), command );
      }
      catch ( ClassCastException cce ) {
        // This shouldn't happen since the iterator
        // returns object of type ActionTargetPlayer
      }
    }
  }
 
  /**
   * Calls the "*lag" server command to check for a player's lagging
   * statistics.  The answer from the server will be received via
   * the processEvent of your bot or plugin.
   *
   * @param connection The connection object to use for the command.
   * @param target The players targeted by the action.
   */
  public void checkLag ( ASConnection connection, ActionTarget target ) {
    // Sends the command to the targeted players
    sendCommand( connection, target, "*lag" );
  }
 
  /**
   * Calls the "*info" server command to check for various informations
   * about a player.  The answer from the server will be received via
   * the processEvent of your bot or plugin.
   *
   * @param connection The connection object to use for the command.
   * @param target The players targeted by the action.
   */
  public void checkInfo ( ASConnection connection, ActionTarget target ) {
    // Sends the command to the targeted players
    sendCommand( connection, target, "*info" );   
  }
}
TOP

Related Classes of wzhybridbots.tools.actions.VIEServerCommands

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.