Package games.stendhal.server.core.engine.dbcommand

Source Code of games.stendhal.server.core.engine.dbcommand.WriteReachedAchievementCommand

/* $Id: WriteReachedAchievementCommand.java,v 1.8 2011/02/25 07:46:44 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.core.engine.dbcommand;

import games.stendhal.server.core.engine.db.AchievementDAO;
import games.stendhal.server.core.rp.achievement.Category;

import java.io.IOException;
import java.sql.SQLException;

import marauroa.server.db.DBTransaction;
import marauroa.server.db.command.AbstractDBCommand;
import marauroa.server.game.db.DAORegister;
/**
* command to log a reached achievement to the database
*
* @author madmetzger
*/
public class WriteReachedAchievementCommand extends AbstractDBCommand {

  private final Integer id;
  private final String playerName;

  /**
   * create a new command
   * @param id database id of the achievement
   * @param playerName name of player who has reached it
   */
  public WriteReachedAchievementCommand(Integer id, String title, Category category, String playerName) {
    this.id = id;
    this.playerName = playerName;
  }

  @Override
  public void execute(DBTransaction transaction) throws SQLException,
      IOException {
    AchievementDAO dao = DAORegister.get().get(AchievementDAO.class);
    dao.saveReachedAchievement(transaction, id, playerName);
  }

  /**
   * returns a string suitable for debug output of this DBCommand.
   *
   * @return debug string
   */
  @Override
  public String toString() {
    return "WriteReachedAchievementCommand [id=" + id + ", playerName="
        + playerName + "]";
  }
}
TOP

Related Classes of games.stendhal.server.core.engine.dbcommand.WriteReachedAchievementCommand

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.