001package com.github.theholywaffle.teamspeak3.api.wrapper; 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.Date; 032import java.util.Map; 033 034public class Client extends Wrapper { 035 036 public Client(Map<String, String> map) { 037 super(map); 038 } 039 040 public boolean canTalk() { 041 return getBoolean(ClientProperty.CLIENT_IS_TALKER); 042 } 043 044 public String getAwayMessage() { 045 return get(ClientProperty.CLIENT_AWAY_MESSAGE); 046 } 047 048 public int getChannelGroupId() { 049 return getInt(ClientProperty.CLIENT_CHANNEL_GROUP_ID); 050 } 051 052 public int getChannelId() { 053 return getInt(ClientProperty.CID); 054 } 055 056 public String getCountry() { 057 return get(ClientProperty.CLIENT_COUNTRY); 058 } 059 060 public Date getCreatedDate() { 061 return new Date(getLong(ClientProperty.CLIENT_CREATED) * 1000); 062 } 063 064 public int getDatabaseId() { 065 return getInt(ClientProperty.CLIENT_DATABASE_ID); 066 } 067 068 public long getIconId() { 069 return getLong(ClientProperty.CLIENT_ICON_ID); 070 } 071 072 public int getId() { 073 return getInt("clid"); 074 } 075 076 public long getIdleTime() { 077 return getLong(ClientProperty.CLIENT_IDLE_TIME); 078 } 079 080 public int getInheritedChannelGroupId() { 081 return getInt(ClientProperty.CLIENT_CHANNEL_GROUP_INHERITED_CHANNEL_ID); 082 } 083 084 public Date getLastConnectedDate() { 085 return new Date(getLong(ClientProperty.CLIENT_LASTCONNECTED) * 1000); 086 } 087 088 public String getNickname() { 089 return get(ClientProperty.CLIENT_NICKNAME); 090 } 091 092 public String getPlatform() { 093 return get(ClientProperty.CLIENT_PLATFORM); 094 } 095 096 public int[] getServerGroups() { 097 final String str = get(ClientProperty.CLIENT_SERVERGROUPS); 098 final String[] arr = str.split(","); 099 final int[] groups = new int[arr.length]; 100 for (int i = 0; i < groups.length; i++) { 101 groups[i] = Integer.valueOf(arr[i]); 102 } 103 return groups; 104 } 105 106 public int getTalkPower() { 107 return getInt(ClientProperty.CLIENT_TALK_POWER); 108 } 109 110 public int getType() { 111 return getInt(ClientProperty.CLIENT_TYPE); 112 } 113 114 public String getUniqueIdentifier() { 115 return get(ClientProperty.CLIENT_UNIQUE_IDENTIFIER); 116 } 117 118 public String getVersion() { 119 return get(ClientProperty.CLIENT_VERSION); 120 } 121 122 public boolean isAway() { 123 return getBoolean(ClientProperty.CLIENT_AWAY); 124 } 125 126 public boolean isChannelCommander() { 127 return getBoolean(ClientProperty.CLIENT_IS_CHANNEL_COMMANDER); 128 } 129 130 public boolean isInputHardware() { 131 return getBoolean(ClientProperty.CLIENT_INPUT_HARDWARE); 132 } 133 134 public boolean isInputMuted() { 135 return getBoolean(ClientProperty.CLIENT_INPUT_MUTED); 136 } 137 138 public boolean isOutputHardware() { 139 return getBoolean(ClientProperty.CLIENT_OUTPUT_HARDWARE); 140 } 141 142 public boolean isOutputMuted() { 143 return getBoolean(ClientProperty.CLIENT_OUTPUT_MUTED); 144 } 145 146 public boolean isPrioritySpeaker() { 147 return getBoolean(ClientProperty.CLIENT_IS_PRIORITY_SPEAKER); 148 } 149 150 public boolean isRecording() { 151 return getBoolean(ClientProperty.CLIENT_IS_RECORDING); 152 } 153 154 public boolean isRegularClient() { 155 return getType() == 0; 156 } 157 158 public boolean isServerQueryClient() { 159 return getType() == 1; 160 } 161 162 public boolean isTalking() { 163 return getBoolean("client_flag_talking"); 164 } 165}