Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
introducing foodmill a tool to squash apples wish for the moment
- Loading branch information
Astrid Sawatzky
committed
Mar 13, 2009
1 parent
393b15f
commit c96dfcd
Showing
6 changed files
with
89 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package games.stendhal.server.entity.item; | ||
|
||
import games.stendhal.server.core.engine.SingletonRepository; | ||
import games.stendhal.server.core.events.UseListener; | ||
import games.stendhal.server.entity.RPEntity; | ||
|
||
import java.util.Map; | ||
|
||
import marauroa.common.game.RPObject; | ||
|
||
public class FoodMill extends Item implements UseListener { | ||
|
||
public FoodMill(final String name, final String clazz, | ||
final String subclass, final Map<String, String> attributes) { | ||
super(name, clazz, subclass, attributes); | ||
} | ||
|
||
public FoodMill(final FoodMill item) { | ||
super(item); | ||
} | ||
|
||
public boolean onUsed(final RPEntity user) { | ||
if (isContained()) { | ||
final String slotName = getContainerSlot().getName(); | ||
if (slotName.endsWith("hand")) { | ||
String otherhand; | ||
if ("rhand".equals(slotName)) { | ||
otherhand = "lhand"; | ||
} else { | ||
otherhand = "rhand"; | ||
} | ||
final RPObject first = user.getSlot(otherhand).getFirst(); | ||
if (first != null) { | ||
if ("apple".equals(first.get("name"))) { | ||
if (user.isEquipped("flask")) { | ||
|
||
final Item item = SingletonRepository | ||
.getEntityManager().getItem("apple juice"); | ||
|
||
|
||
user.drop("apple"); | ||
user.drop("flask"); | ||
user.equip(item, true); | ||
} | ||
} | ||
} | ||
|
||
} | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
} | ||
|
||
} |