/
Region.java
153 lines (139 loc) · 5.5 KB
/
Region.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/*
* Copyright 2015 Austin Keener, Michael Ritter, Florian Spieß, and the JDA contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.dv8tion.jda.api;
import net.dv8tion.jda.internal.utils.EntityString;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
/**
* Represents the Regions used for Audio connections.
* <br>This is used by {@link net.dv8tion.jda.api.entities.channel.middleman.AudioChannel AudioChannels} to define where the audio server that hosts the
* {@link net.dv8tion.jda.api.entities.channel.middleman.AudioChannel} is located.
*/
public enum Region
{
BRAZIL("brazil", "Brazil", "\uD83C\uDDE7\uD83C\uDDF7", false),
HONG_KONG("hongkong", "Hong Kong", "\uD83C\uDDED\uD83C\uDDF0", false),
INDIA("india", "India", "\uD83C\uDDEE\uD83C\uDDF3", false),
JAPAN("japan", "Japan", "\uD83C\uDDEF\uD83C\uDDF5", false),
MILAN("milan", "Milan", "\uD83C\uDDEE\uD83C\uDDF9", false),
ROTTERDAM("rotterdam", "Rotterdam", "\uD83C\uDDF3\uD83C\uDDF1", false),
RUSSIA("russia", "Russia", "\uD83C\uDDF7\uD83C\uDDFA", false),
SINGAPORE("singapore", "Singapore", "\uD83C\uDDF8\uD83C\uDDEC", false),
SOUTH_AFRICA("southafrica", "South Africa", "\uD83C\uDDFF\uD83C\uDDE6", false),
SOUTH_KOREA("south-korea", "South Korea", "\uD83C\uDDF0\uD83C\uDDF7", false),
SYDNEY("sydney", "Sydney", "\uD83C\uDDE6\uD83C\uDDFA", false),
US_CENTRAL("us-central", "US Central", "\uD83C\uDDFA\uD83C\uDDF8", false),
US_EAST("us-east", "US East", "\uD83C\uDDFA\uD83C\uDDF8", false),
US_SOUTH("us-south", "US South", "\uD83C\uDDFA\uD83C\uDDF8", false),
US_WEST("us-west", "US West", "\uD83C\uDDFA\uD83C\uDDF8", false),
VIP_BRAZIL("vip-brazil", "Brazil (VIP)", "\uD83C\uDDE7\uD83C\uDDF7", true),
VIP_HONG_KONG("vip-hongkong", "Hong Kong (VIP)", "\uD83C\uDDED\uD83C\uDDF0", true),
VIP_INDIA("vip-india", "India (VIP)", "\uD83C\uDDEE\uD83C\uDDF3", true),
VIP_JAPAN("vip-japan", "Japan (VIP)", "\uD83C\uDDEF\uD83C\uDDF5", true),
VIP_MILAN("vip-milan", "Milan (VIP)", "\uD83C\uDDEE\uD83C\uDDF9", true),
VIP_ROTTERDAM("vip-rotterdam", "Rotterdam (VIP)", "\uD83C\uDDF3\uD83C\uDDF1", true),
VIP_RUSSIA("vip-russia", "Russia (VIP)", "\uD83C\uDDF7\uD83C\uDDFA", true),
VIP_SINGAPORE("vip-singapore", "Singapore (VIP)", "\uD83C\uDDF8\uD83C\uDDEC", true),
VIP_SOUTH_AFRICA("vip-southafrica", "South Africa (VIP)", "\uD83C\uDDFF\uD83C\uDDE6", true),
VIP_SOUTH_KOREA("vip-south-korea", "South Korea (VIP)", "\uD83C\uDDF0\uD83C\uDDF7", true),
VIP_SYDNEY("vip-sydney", "Sydney (VIP)", "\uD83C\uDDE6\uD83C\uDDFA", true),
VIP_US_CENTRAL("vip-us-central", "US Central (VIP)", "\uD83C\uDDFA\uD83C\uDDF8", true),
VIP_US_EAST("vip-us-east", "US East (VIP)", "\uD83C\uDDFA\uD83C\uDDF8", true),
VIP_US_SOUTH("vip-us-south", "US South (VIP)", "\uD83C\uDDFA\uD83C\uDDF8", true),
VIP_US_WEST("vip-us-west", "US West (VIP)", "\uD83C\uDDFA\uD83C\uDDF8", true),
UNKNOWN("", "Unknown Region", null, false),
AUTOMATIC("automatic", "Automatic", null, false);
private final String key;
private final String name;
private final String emoji;
private final boolean vip;
Region(String key, String name, String emoji, boolean vip)
{
this.key = key;
this.name = name;
this.emoji = emoji;
this.vip = vip;
}
/**
* The human readable region name.
*
* @return The name of this region
*/
@Nonnull
public String getName()
{
return name;
}
/**
* The Region key as defined by Discord.
*
* @return The key (internal name) of this region
*/
@Nonnull
public String getKey()
{
return key;
}
/**
* The unicode flag representative of this Region.
*
* @return Possibly-null unicode for the region's flag
*/
@Nullable
public String getEmoji()
{
return emoji;
}
/**
* Whether or not this Region is a VIP region.
* <br>VIP regions have special perks like higher bitrate in VoiceChannels and priority during times
* of high Discord usage.
*
* @return True if this region is a VIP audio region.
*/
public boolean isVip()
{
return vip;
}
/**
* Retrieves the {@link net.dv8tion.jda.api.Region Region} based on the provided key.
*
* @param key
* The key relating to the {@link net.dv8tion.jda.api.Region Region} we wish to retrieve.
*
* @return The {@link net.dv8tion.jda.api.Region Region} matching the key. If there is no match,
* returns {@link net.dv8tion.jda.api.Region#UNKNOWN UNKNOWN}.
*/
@Nonnull
public static Region fromKey(@Nullable String key)
{
for (Region region : values())
{
if (region.getKey().equals(key))
{
return region;
}
}
return UNKNOWN;
}
@Override
public String toString()
{
return new EntityString(this)
.setType(this)
.toString();
}
}