Override existing commands (Voiced/User) and Network Packets

HuzarO

Vassal
Customer
Hi,

Is it possible using custom extension, to override logic for existing commands? For example I would like to auto accept party invite if user tries to invite character on his second window (dual box), or for example auto accept trade request for his box. I'm thinking to override for example `/invite` command to check if the character that is being invited is using the same IP address, if yes, then it's dualbox so instead of sending party invite request packet, just create the party or if it exists, just add player to existing one.

Another question I have is related network packets, I know I can write my custom ones using extensions, but what about overwriting existing ones? This one would be helpful for example during trade. Same situation, player trading with his own box, if he confirms the trade in trade window, I would like to auto accept it on his second character.

Is this the correct way of doing this? If yes, then how I could achieve this?
 
Hi,

Is it possible using custom extension, to override logic for existing commands? For example I would like to auto accept party invite if user tries to invite character on his second window (dual box), or for example auto accept trade request for his box. I'm thinking to override for example `/invite` command to check if the character that is being invited is using the same IP address, if yes, then it's dualbox so instead of sending party invite request packet, just create the party or if it exists, just add player to existing one.

Another question I have is related network packets, I know I can write my custom ones using extensions, but what about overwriting existing ones? This one would be helpful for example during trade. Same situation, player trading with his own box, if he confirms the trade in trade window, I would like to auto accept it on his second character.

Is this the correct way of doing this? If yes, then how I could achieve this?
/invite is not classic chat command.
Game client send request RequestJoinParty
You can write your own package, and when the extension is loaded, it will overwrite the existing package, and you can implement any functionality you need there.

You can enable network log at game client and check anythinks about it.
 
Also we have
OnPlayerPartyInviteListener
You can catch it and check/do what you wish. w/o packet rape.

Code:
public interface OnPlayerPartyInviteListener extends PlayerListener
{
    public void onPartyInvite(Player player);
}
public interface OnPlayerPartyLeaveListener extends PlayerListener
{
    public void onPartyLeave(Player player);
}

Code:
    private class PartyListenerImpl implements OnPlayerPartyInviteListener, OnPlayerPartyLeaveListener
    {
        @Override
        public void onPartyInvite(Player player)
        {
            broadcastPlayerUpdate(player);
        }

        @Override
        public void onPartyLeave(Player player)
        {
            broadcastPlayerUpdate(player);
        }
    }

PS, work more with listeners and apply your custom logic on events.
 
Last edited:
Custom command
Code:
public class CustomCommand implements IVoicedCommandHandler, ScriptFile
{
  private final String[] _commandList = new String[]{"mycustom1", "mycustom2"};

  @Override
  public boolean useVoicedCommand(String command, Player activeChar, String args)
  {
    if(!Config.MY_CUSTOM_BLABLABLA)
    {
      return false;
    }
    return doSomething(command, activeChar, args);
  }

  private boolean doSomething(String command, Player activeChar, String args)
  {
    System.out.println("Hello World");
    return true;
  }

  @Override
  public String[] getVoicedCommandList()
  {
    return _commandList;
  }

  @Override
  public void onLoad()
  {
    if(Config.MY_CUSTOM_BLABLABLA)
      VoicedCommandHandler.getInstance().registerVoicedCommandHandler(this);
  }

  @Override
  public void onReload()
  {

  }

  @Override
  public void onShutdown()
  {

  }
}

Here is a load
@Override
public void onLoad()
{
if(Config.MY_CUSTOM_BLABLABLA)
VoicedCommandHandler.getInstance().registerVoicedCommandHandler(this);
}
for /command
UserCommandHandler.getInstance().registerUserCommandHandler(this);

for .command
VoicedCommandHandler.getInstance().registerVoicedCommandHandler(this);
 
Last edited:
Yes, I've did some testing, and listener for party works, but problem with it is, it gets invoked once the user accepts the party. What I need is a listener that gets called right after the `Request` is being sent to the other player and that popup with Accept/Decline appears. Current `onPartyInvite` listener is being called when player clicks `Accept` button, but I need one that is being called when the client sends `RequestJoinParty` packet.

Would you mind adding similar listeners for trade?

Suggestions for new listeners:
- OnPartyInviteRequested (this one should be invoked right after someone uses `/invite` or presses the Party Invite action from Actions window)
- OnTradeRequested (this one should be invoked right after someone uses `/trade` or presses the Trade action from Actions window)
- OnTradeConfirmed (this one should be invoked when one user press `Confirm` button on trade window)

To add extra usability and make it easier for users, these listeners could be added inside server packets implementations, right after initial checks, for example for `OnPartyInviteRequested` when all checks for inDimensionalRift, isPartyLeader etc happens, and they all could return boolean, if listener returns `false` then further execution of the code could be stopped, if it returns `true` then it continues executing.
 
я понимаю что дохуя хочу, но вообще хотелось бы иметь какую нибудь возможность подмены пакетов без костылей с подменой классов в jar'ке
 
Yes, I've did some testing, and listener for party works, but problem with it is, it gets invoked once the user accepts the party. What I need is a listener that gets called right after the `Request` is being sent to the other player and that popup with Accept/Decline appears. Current `onPartyInvite` listener is being called when player clicks `Accept` button, but I need one that is being called when the client sends `RequestJoinParty` packet.

Would you mind adding similar listeners for trade?

Suggestions for new listeners:
- OnPartyInviteRequested (this one should be invoked right after someone uses `/invite` or presses the Party Invite action from Actions window)
- OnTradeRequested (this one should be invoked right after someone uses `/trade` or presses the Trade action from Actions window)
- OnTradeConfirmed (this one should be invoked when one user press `Confirm` button on trade window)

To add extra usability and make it easier for users, these listeners could be added inside server packets implementations, right after initial checks, for example for `OnPartyInviteRequested` when all checks for inDimensionalRift, isPartyLeader etc happens, and they all could return boolean, if listener returns `false` then further execution of the code could be stopped, if it returns `true` then it continues executing.
There's no point in doing that, all logic can be processed at the time of acceptance. What's the point of doing anything beforehand.
 
There's no point in doing that, all logic can be processed at the time of acceptance. What's the point of doing anything beforehand.
The whole point in here is to skip need to switch windows and click the accept buttons. If you have dualbox, you have to request party/trade to your second character, then you have to minimize the game, open up the second game window, and click accept to join party/open trade window. I want to skip this window switching, by checking each user IP address, if it is the same, then automatically accept the party/trade on server side, without user action. The same is for trading itself, If you trading items between dualbox characters, if you click confirm button on trade window, I want to auto confirm it on the second character automatically, skipping the need to switch game windows and clicking the button manually.

On current `OnPartyInvite` event, it is being triggered after the second character hit accept button, which is already too late, because I want to skip that part of accepting and automate it for dualboxes.
 
The whole point in here is to skip need to switch windows and click the accept buttons. If you have dualbox, you have to request party/trade to your second character, then you have to minimize the game, open up the second game window, and click accept to join party/open trade window. I want to skip this window switching, by checking each user IP address, if it is the same, then automatically accept the party/trade on server side, without user action. The same is for trading itself, If you trading items between dualbox characters, if you click confirm button on trade window, I want to auto confirm it on the second character automatically, skipping the need to switch game windows and clicking the button manually.

On current `OnPartyInvite` event, it is being triggered after the second character hit accept button, which is already too late, because I want to skip that part of accepting and automate it for dualboxes.
Are you sure you want to check by IP?
Maybe it would be better to check by hardware? Even the standard one that the admin receives.
There could be issues with IP, since you might have a proxy installed, and all characters will be under the same IP.
 
As a lazy person i would just modify the RequestAskJoinPartyRoom packet directly, if target is same ip then do the rest
 
Back
Top