This repository was archived by the owner on Nov 25, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathChatServer.java
More file actions
153 lines (137 loc) · 3.88 KB
/
ChatServer.java
File metadata and controls
153 lines (137 loc) · 3.88 KB
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
package com.github.theholywaffle.lolchatapi;
/*
* #%L
* League of Legends XMPP Chat Library
* %%
* 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 static com.github.theholywaffle.lolchatapi.ChatServer.LoginMethod.GARENA;
import static com.github.theholywaffle.lolchatapi.ChatServer.LoginMethod.RIOT;
import org.jivesoftware.smack.XMPPConnection;
/**
* Represents a regions chatserver.
*
*/
public enum ChatServer {
/**
* Brazil
*/
BR("chat.br.lol.riotgames.com", "br.api.pvp.net", RIOT),
/**
* Europe Nordic and East
*/
EUNE("chat.eun1.lol.riotgames.com", "eune.api.pvp.net", RIOT),
/**
* Europe West
*/
EUW("chat.euw1.lol.riotgames.com", "euw.api.pvp.net", RIOT),
/**
* Indonesia
*/
ID("chatid.lol.garenanow.com", null, GARENA),
/**
* Korea
*/
KR("chat.kr.lol.riotgames.com", "kr.api.pvp.net", RIOT),
/**
* Latin America North
*/
LAN("chat.la1.lol.riotgames.com", "lan.api.pvp.net", RIOT),
/**
* Latin America South
*/
LAS("chat.la2.lol.riotgames.com", "las.api.pvp.net", RIOT),
/**
* North-America
*/
NA("chat.na1.lol.riotgames.com", "na.api.pvp.net", RIOT),
/**
* North-America #2
*/
NA2("chat.na2.lol.riotgames.com", "na.api.pvp.net", RIOT),
/**
* Oceania
*/
OCE("chat.oc1.lol.riotgames.com", "oce.api.pvp.net", RIOT),
/**
* Public Beta Environment
*/
PBE("chat.pbe1.lol.riotgames.com", null, RIOT),
/**
* Phillipines
*/
PH("chatph.lol.garenanow.com", null, GARENA),
/**
* Russia
*/
RU("chat.ru.lol.riotgames.com", "ru.api.pvp.net", RIOT),
/**
* South-East Asia
*/
SEA("chat.lol.garenanow.com", null, GARENA),
/**
* Thailand
*/
TH("chatth.lol.garenanow.com", null, GARENA),
/**
* Turkey
*/
TR("chat.tr.lol.riotgames.com", "tr.api.pvp.net", RIOT),
/**
* Taiwan
*/
TW("chattw.lol.garenanow.com", null, GARENA),
/**
* Vietnam
*/
VN("chatvn.lol.garenanow.com", null, GARENA);
public String api;
public String host;
public LoginMethod loginMethod;
ChatServer(String host, String api, LoginMethod loginMethod) {
this.host = host;
this.api = api;
this.loginMethod = loginMethod;
}
public String getApiRegion()
{
if (api == null)
throw new NullPointerException("Riot API is not supported for this region.");
return api.split("\\.")[0].toLowerCase();
}
@Override
public String toString() {
return name().toLowerCase();
}
public enum LoginMethod {
GARENA(new GarenaLogin()),
RIOT(new RiotLogin());
public ILoginMethod method;
LoginMethod(ILoginMethod method) {
this.method = method;
}
public void login(XMPPConnection connection, String username,
String password, boolean replaceLeague) {
method.login(connection, username, password, replaceLeague);
}
}
}