Package games.stendhal.server.script

Source Code of games.stendhal.server.script.OfflineAdminlevel

/* $Id: OfflineAdminlevel.java,v 1.6 2010/09/19 02:36:26 nhnb Exp $ */
/***************************************************************************
*                   (C) Copyright 2003-2010 - Stendhal                    *
***************************************************************************
***************************************************************************
*                                                                         *
*   This program is free software; you can redistribute it and/or modify  *
*   it under the terms of the GNU General Public License as published by  *
*   the Free Software Foundation; either version 2 of the License, or     *
*   (at your option) any later version.                                   *
*                                                                         *
***************************************************************************/
package games.stendhal.server.script;

import games.stendhal.server.core.engine.GameEvent;
import games.stendhal.server.entity.player.Player;

import java.util.List;

import marauroa.common.game.RPObject;

/**
* Changes the admin level of an offline player.
*
* @author hendrik
*/
public class OfflineAdminlevel extends AbstractOfflineAction {

  /**
   * validates the parameters, sends an error message, if something is wrong with them
   *
   * @param admin admin executing the script
   * @param args arguments for the script
   * @return true if the parameters are valid, false otherwise
   */
  @Override
  public boolean validateParameters(final Player admin, final List<String> args) {
    if (args.size() != 2) {
      admin.sendPrivateText("/script OfflineAdminlevel.class <playername> <newlevel>");
      return false;
    }
    return true;
  }

  /**
   * processes the requested operation on the loaded object
   *
   * @param admin admin executing the script
   * @param object the RPObject of the player loaded from the database
   * @param args arguments for the script
   */
  @Override
  public void process(final Player admin, RPObject object, final List<String> args) {
    String playerName = args.get(0);
    String newLevel = args.get(1);

    // do the modifications here
    object.put("adminlevel", Integer.parseInt(newLevel));

    // log game event
    new GameEvent(admin.getName(), "adminlevel", playerName, "adminlevel", newLevel).raise();
  }
}
TOP

Related Classes of games.stendhal.server.script.OfflineAdminlevel

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.