arianne / stendhal

Stendhal is a fun friendly and free multiplayer online adventure game with an old school feel.
https://arianne-project.org
GNU General Public License v2.0
577 stars 200 forks source link

Administration: Using /summon to Summon Stackable Item Throws Error #702

Closed AntumDeluge closed 2 months ago

AntumDeluge commented 2 months ago

🐞 Describe the bug

Using /summon slash command to summon a stackable item without quantity parameter causes an error to be thrown. It appears that the quantity value defaults to "0" expecting the summoned entity to be a creature.

πŸ”₯ How to reproduce

Steps to reproduce the behavior:

  1. As admin/GM execute /summon <item_name> without quantity parameter.
  2. See console error.

Executed example /summon leather thread:

ERROR [verManager] StackableItem            (85  ) Player [deluge, -1335443416] Attributes of Class(): [sourceid=9][quantity=0][x=13][y=15][zoneid=int_ados_town_hall_2][type=summon][creature=leather thread]- Trying to set invalid quantity: 0
java.lang.Throwable
        at games.stendhal.server.entity.item.StackableItem.setQuantity(StackableItem.java:85)
        at games.stendhal.server.actions.admin.SummonAction$1.found(SummonAction.java:152)
        at games.stendhal.server.actions.admin.SummonAction$EntityFactory.createEntity(SummonAction.java:79)
        at games.stendhal.server.actions.admin.SummonAction$EntityFactory.access$000(SummonAction.java:53)
        at games.stendhal.server.actions.admin.SummonAction.perform(SummonAction.java:177)
        at games.stendhal.server.actions.admin.AdministrationAction.onAction(AdministrationAction.java:120)
        at games.stendhal.server.actions.CommandCenter.execute(CommandCenter.java:155)
        at games.stendhal.server.core.engine.StendhalRPRuleProcessor.execute(StendhalRPRuleProcessor.java:274)
        at marauroa.server.game.rp.RPScheduler.visit(RPScheduler.java:113)
        at marauroa.server.game.rp.RPServerManager.run(RPServerManager.java:649)

🌍 Environment

πŸ› οΈ Suggested fixes

Check if the name of the entity to be summoned is a registered stackable item & set default quantity to 1.

It turns out the server is not at fault. The web client is sending a default value of "0" for "quantity" attribute when it should be leaving it undefined.