Add support for more missing events

This commit is contained in:
Manevolent
2018-08-31 21:54:15 -04:00
parent becc64f297
commit f248faad72
9 changed files with 222 additions and 45 deletions
+1 -1
View File
@@ -10,7 +10,7 @@
<properties> <properties>
<maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.targetId>1.8</maven.compiler.targetId> <maven.compiler.target>1.8</maven.compiler.target>
</properties> </properties>
<build> <build>
@@ -0,0 +1,47 @@
package com.github.manevolent.ts3j.event;
/*
* #%L
* TeamSpeak 3 Java API
* %%
* Copyright (C) 2014 Bert De Geyter
* %%
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
* #L%
*/
import com.github.manevolent.ts3j.api.ChannelProperty;
import java.util.Map;
public class ChannelUnsubscribedEvent extends BaseEvent {
public ChannelUnsubscribedEvent(Map<String, String> map) {
super(map);
}
public int getChannelId() {
return getInt(ChannelProperty.CID);
}
@Override
public void fire(TS3Listener listener) {
listener.onChannelUnsubscribed(this);
}
}
@@ -0,0 +1,14 @@
package com.github.manevolent.ts3j.event;
import java.util.Map;
public class ClientChatComposingEvent extends BaseEvent {
public ClientChatComposingEvent(Map<String, String> map) {
super(map);
}
@Override
public void fire(TS3Listener listener) {
listener.onClientComposing(this);
}
}
@@ -0,0 +1,18 @@
package com.github.manevolent.ts3j.event;
import java.util.Map;
public class ClientPokeEvent extends BaseEvent {
public ClientPokeEvent(Map<String, String> map) {
super(map);
}
public String getMessage() {
return get("msg");
}
@Override
public void fire(TS3Listener listener) {
listener.onClientPoke(this);
}
}
@@ -0,0 +1,53 @@
package com.github.manevolent.ts3j.event;
/*
* #%L
* TeamSpeak 3 Java API
* %%
* Copyright (C) 2014 Bert De Geyter
* %%
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
* #L%
*/
import java.util.Map;
public class ServerGroupClientAddedEvent extends BaseEvent {
public ServerGroupClientAddedEvent(Map<String, String> map) {
super(map);
}
public int getServerGroupId() {
return getInt("sgid");
}
public int getClientId() {
return getInt("clid");
}
public String getName() {
return get("name");
}
@Override
public void fire(TS3Listener listener) {
listener.onServerGroupClientAdded(this);
}
}
@@ -0,0 +1,53 @@
package com.github.manevolent.ts3j.event;
/*
* #%L
* TeamSpeak 3 Java API
* %%
* Copyright (C) 2014 Bert De Geyter
* %%
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
* #L%
*/
import java.util.Map;
public class ServerGroupClientDeletedEvent extends BaseEvent {
public ServerGroupClientDeletedEvent(Map<String, String> map) {
super(map);
}
public int getServerGroupId() {
return getInt("sgid");
}
public int getClientId() {
return getInt("clid");
}
public String getName() {
return get("name");
}
@Override
public void fire(TS3Listener listener) {
listener.onServerGroupClientRemove(this);
}
}
@@ -69,6 +69,16 @@ public interface TS3Event {
return new ClientUpdatedEvent(command.toMap()); return new ClientUpdatedEvent(command.toMap());
case "notifychannelsubscribed": // CLIENT case "notifychannelsubscribed": // CLIENT
return new ChannelSubscribedEvent(command.toMap()); return new ChannelSubscribedEvent(command.toMap());
case "notifychannelunsubscribed": // CLIENT
return new ChannelUnsubscribedEvent(command.toMap());
case "notifyservergroupclientadded": // CLIENT
return new ServerGroupClientAddedEvent(command.toMap());
case "notifyservergroupclientdeleted": // CLIENT
return new ServerGroupClientDeletedEvent(command.toMap());
case "notifyclientpoke": // CLIENT
return new ClientPokeEvent(command.toMap());
case "notifyclientchatcomposing": // CLIENT
return new ClientChatComposingEvent(command.toMap());
default: default:
throw new IllegalArgumentException("unknown event: " + command.getName()); throw new IllegalArgumentException("unknown event: " + command.getName());
} }
@@ -26,48 +26,30 @@ package com.github.manevolent.ts3j.event;
* #L% * #L%
*/ */
import com.github.manevolent.ts3j.audio.Microphone;
public interface TS3Listener { public interface TS3Listener {
default void onTextMessage(TextMessageEvent e) {}
void onTextMessage(TextMessageEvent e); default void onClientJoin(ClientJoinEvent e) {}
default void onClientLeave(ClientLeaveEvent e) {}
void onClientJoin(ClientJoinEvent e); default void onServerEdit(ServerEditedEvent e) {}
default void onChannelEdit(ChannelEditedEvent e) {}
void onClientLeave(ClientLeaveEvent e); default void onChannelDescriptionChanged(ChannelDescriptionEditedEvent e) {}
default void onClientMoved(ClientMovedEvent e) {}
void onServerEdit(ServerEditedEvent e); default void onChannelCreate(ChannelCreateEvent e) {}
default void onChannelDeleted(ChannelDeletedEvent e) {}
void onChannelEdit(ChannelEditedEvent e); default void onChannelMoved(ChannelMovedEvent e) {}
default void onChannelPasswordChanged(ChannelPasswordChangedEvent e) {}
void onChannelDescriptionChanged(ChannelDescriptionEditedEvent e); default void onChannelList(ChannelListEvent e) {}
default void onPrivilegeKeyUsed(PrivilegeKeyUsedEvent e) {}
void onClientMoved(ClientMovedEvent e); default void onChannelGroupList(ChannelGroupListEvent e) {}
default void onServerGroupList(ServerGroupListEvent e) {}
void onChannelCreate(ChannelCreateEvent e); default void onClientNeededPermissions(ClientNeededPermissionsEvent e) {}
default void onClientChannelGroupChanged(ClientChannelGroupChangedEvent e) {}
void onChannelDeleted(ChannelDeletedEvent e); default void onClientChanged(ClientUpdatedEvent e) {}
default void onDisconnected(DisconnectedEvent e) {}
void onChannelMoved(ChannelMovedEvent e); default void onChannelSubscribed(ChannelSubscribedEvent e) {}
default void onChannelUnsubscribed(ChannelUnsubscribedEvent e) {}
void onChannelPasswordChanged(ChannelPasswordChangedEvent e); default void onServerGroupClientAdded(ServerGroupClientAddedEvent e) {}
default void onServerGroupClientRemove(ServerGroupClientDeletedEvent e) {}
void onChannelList(ChannelListEvent e); default void onClientPoke(ClientPokeEvent e) {}
default void onClientComposing(ClientChatComposingEvent e) {}
void onPrivilegeKeyUsed(PrivilegeKeyUsedEvent e);
void onChannelGroupList(ChannelGroupListEvent e);
void onServerGroupList(ServerGroupListEvent e);
void onClientNeededPermissions(ClientNeededPermissionsEvent e);
void onClientChannelGroupChanged(ClientChannelGroupChangedEvent e);
void onClientChanged(ClientUpdatedEvent e);
void onDisconnected(DisconnectedEvent e);
void onChannelSubscribed(ChannelSubscribedEvent e);
} }
@@ -42,7 +42,7 @@ public abstract class LocalClientHandlerFull extends LocalClientHandler {
break; break;
case COMMAND_LOW: case COMMAND_LOW:
Ts3Debugging.debug("[COMMAND] [LOW] " + ((PacketBody2Command) packet.getBody()).getText()); Ts3Debugging.debug("[COMMAND] [LOW] " + ((PacketBody3CommandLow) packet.getBody()).getText());
try { try {
handleCommand(MultiCommand.parse( handleCommand(MultiCommand.parse(