Opened 4 years ago

Closed 4 years ago

#1021 closed defect (fixed)

Null Sender on Message in MultiModule

Reported by: SpookedOne Owned by: Trancid
Priority: normal Milestone: milestone:
Component: Bots - Multibot Version: Latest version from repository
Severity: major Keywords:
Cc:

Description

On classes that inherit MultiModule and use a CommandInterpreter, the sender String on registered commands will be received as null if the command is done remotely. Review of the following code show's how a sender is usually derived:

/**
     * This method returns the name of the player who sent a message, regardless
     * of the message type. If there is no sender then null is returned.
     *
     * @param event
     *            is the Message event to handle.
     */
    private String getSender(Message event) {
        int messageType = event.getMessageType();
        int playerID;

        if (messageType == Message.ALERT_MESSAGE
         || messageType == Message.CHAT_MESSAGE
         || messageType == Message.REMOTE_PRIVATE_MESSAGE)
            return event.getMessager();

        playerID = event.getPlayerID();
        return m_botAction.getPlayerName(playerID);
    }

Change History (3)

comment:1 Changed 4 years ago by SpookedOne

Looks like the issue is due to the trigger parameter in the registerDefaultCommand in the CommandInterpreter.

see http://twcore.org/changeset/7587

comment:2 Changed 4 years ago by Trancid

  • Owner set to Trancid
  • Status changed from new to assigned

Since this error hasn't occurred anymore since the mentioned changeset, I will resolve this as fixed for now. Perhaps a nice idea for the future to allow multiple message types for the CommandInterpreter in one line.

comment:3 Changed 4 years ago by Trancid

  • Resolution set to fixed
  • Status changed from assigned to closed
Note: See TracTickets for help on using tickets.