Package games.stendhal.server.entity.creature.impl.poison

Source Code of games.stendhal.server.entity.creature.impl.poison.PoisonerFactory

/* $Id: PoisonerFactory.java,v 1.1 2010/12/02 20:45:30 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.entity.creature.impl.poison;

import games.stendhal.server.core.engine.SingletonRepository;
import games.stendhal.server.entity.item.ConsumableItem;

import org.apache.log4j.Logger;

public class PoisonerFactory {
  static final Attacker nonpoisonous = new NonPoisoner();
  private static Logger logger = Logger.getLogger(PoisonerFactory.class);

  public static Attacker get(final String profile) {
    if (profile != null) {
      final String[] poisonparams = profile.split(",");
      final ConsumableItem poison = (ConsumableItem) SingletonRepository.getEntityManager().getItem(poisonparams[1]);

      if (poison == null) {
        logger .error("Cannot create poisoner with " + poisonparams[1]);
        return nonpoisonous;
      }
      return new Poisoner(Integer.parseInt(poisonparams[0]), poison);
    }
    return nonpoisonous;
  }

}
TOP

Related Classes of games.stendhal.server.entity.creature.impl.poison.PoisonerFactory

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.