001package com.github.theholywaffle.teamspeak3.api.event;
002
003/*
004 * #%L
005 * TeamSpeak 3 Java API
006 * %%
007 * Copyright (C) 2014 Bert De Geyter
008 * %%
009 * Permission is hereby granted, free of charge, to any person obtaining a copy
010 * of this software and associated documentation files (the "Software"), to deal
011 * in the Software without restriction, including without limitation the rights
012 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
013 * copies of the Software, and to permit persons to whom the Software is
014 * furnished to do so, subject to the following conditions:
015 * 
016 * The above copyright notice and this permission notice shall be included in
017 * all copies or substantial portions of the Software.
018 * 
019 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
020 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
021 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
022 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
023 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
024 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
025 * THE SOFTWARE.
026 * #L%
027 */
028
029import com.github.theholywaffle.teamspeak3.api.ClientProperty;
030
031import java.util.Map;
032
033public class ClientJoinEvent extends BaseEvent {
034
035        public ClientJoinEvent(Map<String, String> map) {
036                super(map);
037        }
038
039        public int getClientFromId() {
040                return getInt("cfid");
041        }
042
043        public int getClientTargetId() {
044                return getInt("ctid");
045        }
046
047        public int getClientId() {
048                return getInt("clid");
049        }
050
051        public String getUniqueClientIdentifier() {
052                return get(ClientProperty.CLIENT_UNIQUE_IDENTIFIER);
053        }
054
055        public String getClientNickname() {
056                return get(ClientProperty.CLIENT_NICKNAME);
057        }
058
059        public boolean isClientInputMuted() {
060                return getBoolean(ClientProperty.CLIENT_INPUT_MUTED);
061        }
062
063        public boolean isClientOutputMuted() {
064                return getBoolean(ClientProperty.CLIENT_OUTPUT_MUTED);
065        }
066
067        public boolean isClientOutputOnlyMuted() {
068                return getBoolean(ClientProperty.CLIENT_OUTPUTONLY_MUTED);
069        }
070
071        public boolean isClientUsingHardwareInput() {
072                return getBoolean(ClientProperty.CLIENT_INPUT_HARDWARE);
073        }
074
075        public boolean isClientUsingHardwareOutput() {
076                return getBoolean(ClientProperty.CLIENT_OUTPUT_HARDWARE);
077        }
078
079        public String getClientMetadata() {
080                return get(ClientProperty.CLIENT_META_DATA);
081        }
082
083        public boolean isClientRecording() {
084                return getBoolean(ClientProperty.CLIENT_IS_RECORDING);
085        }
086
087        public int getClientDatabaseId() {
088                return getInt(ClientProperty.CLIENT_DATABASE_ID);
089        }
090
091        public int getClientChannelGroupId() {
092                return getInt(ClientProperty.CLIENT_CHANNEL_GROUP_ID);
093        }
094
095        public int getAmountOfServerGroups() {
096                //getInt was turning the String 1,2,3,.. to a int which wasn't right.
097                //Now it gets the Amount even if the ID is <=10
098                String[] split = get(ClientProperty.CLIENT_SERVERGROUPS).split(",");
099                return split.length;
100        }
101
102        public String getClientServerGroups() {
103                //getClientServerGroups returns a string containing the server group ID for example 1,2,3,...
104                return get(ClientProperty.CLIENT_SERVERGROUPS);
105        }
106
107        public boolean isClientAway() {
108                return getBoolean(ClientProperty.CLIENT_AWAY);
109        }
110
111        public String getClientAwayMessage() {
112                return get(ClientProperty.CLIENT_AWAY_MESSAGE);
113        }
114
115        public int getClientType() {
116                return getInt(ClientProperty.CLIENT_TYPE);
117        }
118
119        public String getClientFlagAvatarId() {
120                return get(ClientProperty.CLIENT_FLAG_AVATAR);
121        }
122
123        public int getClientTalkPower() {
124                return getInt(ClientProperty.CLIENT_TALK_POWER);
125        }
126
127        public boolean isClientRequestingToTalk() {
128                return getBoolean(ClientProperty.CLIENT_TALK_REQUEST);
129        }
130
131        public String getClientTalkRequestMessage() {
132                return get(ClientProperty.CLIENT_TALK_REQUEST_MSG);
133        }
134
135        public String getClientDescription() {
136                return get(ClientProperty.CLIENT_DESCRIPTION);
137        }
138
139        public boolean isClientTalking() {
140                return getBoolean(ClientProperty.CLIENT_IS_TALKER);
141        }
142
143        public boolean isClientPrioritySpeaker() {
144                return getBoolean(ClientProperty.CLIENT_IS_PRIORITY_SPEAKER);
145        }
146
147        public int getClientUnreadMessages() {
148                return getInt(ClientProperty.CLIENT_UNREAD_MESSAGES);
149        }
150
151        public String getClientPhoneticNickname() {
152                return get(ClientProperty.CLIENT_NICKNAME_PHONETIC);
153        }
154
155        public int getClientNeededServerQueryViewPower() {
156                return getInt(ClientProperty.CLIENT_NEEDED_SERVERQUERY_VIEW_POWER);
157        }
158
159        public int getClientIconId() {
160                return getInt(ClientProperty.CLIENT_ICON_ID);
161        }
162
163        public boolean isClientChannelCommander() {
164                return getBoolean(ClientProperty.CLIENT_IS_CHANNEL_COMMANDER);
165        }
166
167        public String getClientCountry() {
168                return get(ClientProperty.CLIENT_COUNTRY);
169        }
170
171        public int getClientInheritedChannelGroupId() {
172                return getInt(ClientProperty.CLIENT_CHANNEL_GROUP_INHERITED_CHANNEL_ID);
173        }
174
175        @Override
176        public void fire(TS3Listener listener) {
177                listener.onClientJoin(this);
178        }
179}