replaced IllegalArgumentException with an UnknownTeamspeakEvent if the event is not registered
This commit is contained in:
@@ -88,7 +88,7 @@ public interface TS3Event {
|
||||
case "notifychannelpermhints": // CLIENT
|
||||
return new ChannelPermHintsEvent(command.toMap());
|
||||
default:
|
||||
throw new IllegalArgumentException("unknown event: " + command.getName());
|
||||
return new UnknownTeamspeakEvent(command.getName(),command.toMap());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,4 +57,5 @@ public interface TS3Listener {
|
||||
default void onClientChatClosed(ClientChatClosedEvent e) {}
|
||||
default void onClientPermHints(ClientPermHintsEvent e) {}
|
||||
default void onChannelPermHints(ChannelPermHintsEvent e) {}
|
||||
default void onUnknownEvent(UnknownTeamspeakEvent e){}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.github.manevolent.ts3j.event;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class UnknownTeamspeakEvent extends BaseEvent {
|
||||
String command;
|
||||
|
||||
public UnknownTeamspeakEvent(String command, Map<String, String> map) {
|
||||
super(map);
|
||||
this.command = command;
|
||||
}
|
||||
|
||||
public String getCommand() {
|
||||
return command;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fire(TS3Listener listener) {
|
||||
listener.onUnknownEvent(this);
|
||||
}
|
||||
}
|
||||
+2
-7
@@ -433,13 +433,8 @@ public class LocalTeamspeakClientSocket
|
||||
if (processor != null) {
|
||||
processor.process(client, singleCommand);
|
||||
} else if (singleCommand.getName().startsWith("notify")) {
|
||||
try {
|
||||
TS3Event event = TS3Event.createEvent(singleCommand);
|
||||
commandExecutionService.submit(() -> listeners.forEach(event::fire));
|
||||
} catch (IllegalArgumentException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
|
||||
TS3Event event = TS3Event.createEvent(singleCommand);
|
||||
commandExecutionService.submit(() -> listeners.forEach(event::fire));
|
||||
} else {
|
||||
CommandProcessor awaitingCommandProcessor;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user