From: Hendrik B. <nh...@us...> - 2012-06-05 01:19:07
|
Update of /cvsroot/arianne/stendhal/src/games/stendhal/server/entity/npc/action In directory vz-cvs-4.sog:/tmp/cvs-serv25672/src/games/stendhal/server/entity/npc/action Modified Files: NPCSetDirection.java Log Message: added javadoc, implemented toString(), hashCode(), equals() Index: NPCSetDirection.java =================================================================== RCS file: /cvsroot/arianne/stendhal/src/games/stendhal/server/entity/npc/action/NPCSetDirection.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** NPCSetDirection.java 29 May 2012 05:43:17 -0000 1.1 --- NPCSetDirection.java 5 Jun 2012 01:19:05 -0000 1.2 *************** *** 1,2 **** --- 1,13 ---- + /*************************************************************************** + * (C) Copyright 2012 - 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.npc.action; *************** *** 8,21 **** import games.stendhal.server.entity.player.Player; public final class NPCSetDirection implements ChatAction { public NPCSetDirection(Direction direction) { - super(); this.direction = direction; } - private Direction direction; - public void fire(Player player, Sentence sentence, EventRaiser npc) { ! ((ActiveEntity) npc.getEntity()).setDirection(direction); } } \ No newline at end of file --- 19,64 ---- import games.stendhal.server.entity.player.Player; + import org.apache.commons.lang.builder.EqualsBuilder; + import org.apache.commons.lang.builder.HashCodeBuilder; + + /** + * sets the direction of an NPC + * + * @author hendrik + */ public final class NPCSetDirection implements ChatAction { + + private final Direction direction; + + /** + * sets the direction of an NPC + * + * @param direction Direction into which the NPC should look + */ public NPCSetDirection(Direction direction) { this.direction = direction; } public void fire(Player player, Sentence sentence, EventRaiser npc) { ! if (npc.getEntity() instanceof ActiveEntity) { ! ((ActiveEntity) npc.getEntity()).setDirection(direction); ! } ! } ! ! @Override ! public String toString() { ! return "NPC set direction<" + direction + ">"; } + + @Override + public int hashCode() { + return HashCodeBuilder.reflectionHashCode(this); + } + + @Override + public boolean equals(final Object obj) { + return EqualsBuilder.reflectionEquals(this, obj, false, + NPCSetDirection.class); + } + } \ No newline at end of file |