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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
|
package net.minecraft.server;
import java.io.*;
import java.util.*;
import java.util.logging.Logger;
// CraftBukkit start
import org.bukkit.craftbukkit.CraftPlayer;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.event.Event.Type;
import org.bukkit.event.player.PlayerEvent;
import org.bukkit.event.player.PlayerLoginEvent;
// CraftBukkit end
public class ServerConfigurationManager {
public static Logger a = Logger.getLogger("Minecraft");
public List b;
private MinecraftServer c;
private PlayerManager d;
private int e;
private Set f;
private Set g;
private Set h;
private File i;
private File j;
private File k;
private PlayerNBTManager l;
private CraftServer server; // CraftBukkit
public ServerConfigurationManager(MinecraftServer minecraftserver) {
// CraftBukkit 2 lines!
minecraftserver.server = new CraftServer(minecraftserver, this);
server = minecraftserver.server;
b = ((List) (new ArrayList()));
f = ((Set) (new HashSet()));
g = ((Set) (new HashSet()));
h = ((Set) (new HashSet()));
c = minecraftserver;
i = minecraftserver.a("banned-players.txt");
j = minecraftserver.a("banned-ips.txt");
k = minecraftserver.a("ops.txt");
d = new PlayerManager(minecraftserver);
e = minecraftserver.d.a("max-players", 20);
e();
g();
i();
f();
h();
j();
}
public void a(WorldServer worldserver) {
l = new PlayerNBTManager(new File(worldserver.t, "players"));
}
public int a() {
return d.b();
}
public void a(EntityPlayerMP entityplayermp) {
b.add(((entityplayermp)));
l.b(entityplayermp);
c.e.A.d((int) entityplayermp.p >> 4, (int) entityplayermp.r >> 4);
for (; c.e.a(((Entity) (entityplayermp)), entityplayermp.z).size() != 0; entityplayermp.a(entityplayermp.p, entityplayermp.q + 1.0D, entityplayermp.r)) {
;
}
c.e.a(((Entity) (entityplayermp)));
d.a(entityplayermp);
// CraftBukkit
server.getPluginManager().callEvent(new PlayerEvent(PlayerEvent.Type.PLAYER_JOIN, server.getPlayer(entityplayermp)));
}
public void b(EntityPlayerMP entityplayermp) {
d.c(entityplayermp);
}
public void c(EntityPlayerMP entityplayermp) {
l.a(entityplayermp);
c.e.d(((Entity) (entityplayermp)));
b.remove(((entityplayermp)));
d.b(entityplayermp);
// CraftBukkit
server.getPluginManager().callEvent(new PlayerEvent(PlayerEvent.Type.PLAYER_QUIT, server.getPlayer(entityplayermp)));
}
public EntityPlayerMP a(NetLoginHandler netloginhandler, String s, String s1) {
// CraftBukkit start - note: this entire method needs to be changed
// Instead of kicking then returning, we need to store the kick reason
// in the event, check with plugins to see if it's ok, and THEN kick
// depending on the outcome.
EntityPlayerMP entity = new EntityPlayerMP(c, ((World) (c.e)), s, new ItemInWorldManager(((World) (c.e))));
PlayerLoginEvent event = new PlayerLoginEvent(Type.PLAYER_LOGIN, new CraftPlayer(server, entity));
// CraftBukkit end
String s2 = ((netloginhandler.b.b())).toString();
s2 = s2.substring(s2.indexOf("/") + 1);
s2 = s2.substring(0, s2.indexOf(":"));
// CraftBukkit start
if (f.contains(s.trim().toLowerCase())) {
event.disallow(PlayerLoginEvent.Result.KICK_BANNED, "You are banned from this server!");
} else if (g.contains(s2)) {
event.disallow(PlayerLoginEvent.Result.KICK_BANNED, "Your IP address is banned from this server!");
} else if (b.size() >= e) {
event.disallow(PlayerLoginEvent.Result.KICK_FULL, "The server is full!");
}
server.getPluginManager().callEvent(event);
if (event.getResult() != PlayerLoginEvent.Result.ALLOWED) {
netloginhandler.a(event.getKickMessage());
return null;
}
// CraftBukkit end
for (int i1 = 0; i1 < b.size(); i1++) {
EntityPlayerMP entityplayermp = (EntityPlayerMP) b.get(i1);
if (entityplayermp.aw.equalsIgnoreCase(s)) {
entityplayermp.a.a("You logged in from another location");
}
}
// CraftBukkit
return entity;
}
public EntityPlayerMP d(EntityPlayerMP entityplayermp) {
c.k.a(entityplayermp);
c.k.b(((Entity) (entityplayermp)));
d.b(entityplayermp);
b.remove(((entityplayermp)));
c.e.e(((Entity) (entityplayermp)));
EntityPlayerMP entityplayermp1 = new EntityPlayerMP(c, ((World) (c.e)), entityplayermp.aw, new ItemInWorldManager(((World) (c.e))));
entityplayermp1.g = entityplayermp.g;
entityplayermp1.a = entityplayermp.a;
c.e.A.d((int) entityplayermp1.p >> 4, (int) entityplayermp1.r >> 4);
for (; c.e.a(((Entity) (entityplayermp1)), entityplayermp1.z).size() != 0; entityplayermp1.a(entityplayermp1.p, entityplayermp1.q + 1.0D, entityplayermp1.r)) {
;
}
entityplayermp1.a.b(((Packet) (new Packet9())));
entityplayermp1.a.a(entityplayermp1.p, entityplayermp1.q, entityplayermp1.r, entityplayermp1.v, entityplayermp1.w);
d.a(entityplayermp1);
c.e.a(((Entity) (entityplayermp1)));
b.add(((entityplayermp1)));
entityplayermp1.l();
return entityplayermp1;
}
public void b() {
d.a();
}
public void a(int i1, int j1, int k1) {
d.a(i1, j1, k1);
}
public void a(Packet packet) {
for (int i1 = 0; i1 < b.size(); i1++) {
EntityPlayerMP entityplayermp = (EntityPlayerMP) b.get(i1);
entityplayermp.a.b(packet);
}
}
public String c() {
String s = "";
for (int i1 = 0; i1 < b.size(); i1++) {
if (i1 > 0) {
s = (new StringBuilder()).append(s).append(", ").toString();
}
s = (new StringBuilder()).append(s).append(((EntityPlayerMP) b.get(i1)).aw).toString();
}
return s;
}
public void a(String s) {
f.add(((s.toLowerCase())));
f();
}
public void b(String s) {
f.remove(((s.toLowerCase())));
f();
}
private void e() {
try {
f.clear();
BufferedReader bufferedreader = new BufferedReader(((java.io.Reader) (new FileReader(i))));
for (String s = ""; (s = bufferedreader.readLine()) != null;) {
f.add(((s.trim().toLowerCase())));
}
bufferedreader.close();
} catch (Exception exception) {
a.warning((new StringBuilder()).append("Failed to load ban list: ").append(((exception))).toString());
}
}
private void f() {
try {
PrintWriter printwriter = new PrintWriter(((java.io.Writer) (new FileWriter(i, false))));
String s;
for (Iterator iterator = f.iterator(); iterator.hasNext(); printwriter.println(s)) {
s = (String) iterator.next();
}
printwriter.close();
} catch (Exception exception) {
a.warning((new StringBuilder()).append("Failed to save ban list: ").append(((exception))).toString());
}
}
public void c(String s) {
g.add(((s.toLowerCase())));
h();
}
public void d(String s) {
g.remove(((s.toLowerCase())));
h();
}
private void g() {
try {
g.clear();
BufferedReader bufferedreader = new BufferedReader(((java.io.Reader) (new FileReader(j))));
for (String s = ""; (s = bufferedreader.readLine()) != null;) {
g.add(((s.trim().toLowerCase())));
}
bufferedreader.close();
} catch (Exception exception) {
a.warning((new StringBuilder()).append("Failed to load ip ban list: ").append(((exception))).toString());
}
}
private void h() {
try {
PrintWriter printwriter = new PrintWriter(((java.io.Writer) (new FileWriter(j, false))));
String s;
for (Iterator iterator = g.iterator(); iterator.hasNext(); printwriter.println(s)) {
s = (String) iterator.next();
}
printwriter.close();
} catch (Exception exception) {
a.warning((new StringBuilder()).append("Failed to save ip ban list: ").append(((exception))).toString());
}
}
public void e(String s) {
h.add(((s.toLowerCase())));
j();
}
public void f(String s) {
h.remove(((s.toLowerCase())));
j();
}
private void i() {
try {
h.clear();
BufferedReader bufferedreader = new BufferedReader(((java.io.Reader) (new FileReader(k))));
for (String s = ""; (s = bufferedreader.readLine()) != null;) {
h.add(((s.trim().toLowerCase())));
}
bufferedreader.close();
} catch (Exception exception) {
a.warning((new StringBuilder()).append("Failed to load ip ban list: ").append(((exception))).toString());
}
}
private void j() {
try {
PrintWriter printwriter = new PrintWriter(((java.io.Writer) (new FileWriter(k, false))));
String s;
for (Iterator iterator = h.iterator(); iterator.hasNext(); printwriter.println(s)) {
s = (String) iterator.next();
}
printwriter.close();
} catch (Exception exception) {
a.warning((new StringBuilder()).append("Failed to save ip ban list: ").append(((exception))).toString());
}
}
public boolean g(String s) {
return h.contains(((s.trim().toLowerCase())));
}
public EntityPlayerMP h(String s) {
for (int i1 = 0; i1 < b.size(); i1++) {
EntityPlayerMP entityplayermp = (EntityPlayerMP) b.get(i1);
if (entityplayermp.aw.equalsIgnoreCase(s)) {
return entityplayermp;
}
}
return null;
}
public void a(String s, String s1) {
EntityPlayerMP entityplayermp = h(s);
if (entityplayermp != null) {
entityplayermp.a.b(((Packet) (new Packet3Chat(s1))));
}
}
public void a(double d1, double d2, double d3, double d4, Packet packet) {
for (int i1 = 0; i1 < b.size(); i1++) {
EntityPlayerMP entityplayermp = (EntityPlayerMP) b.get(i1);
double d5 = d1 - entityplayermp.p;
double d6 = d2 - entityplayermp.q;
double d7 = d3 - entityplayermp.r;
if (d5 * d5 + d6 * d6 + d7 * d7 < d4 * d4) {
entityplayermp.a.b(packet);
}
}
}
public void i(String s) {
Packet3Chat packet3chat = new Packet3Chat(s);
for (int i1 = 0; i1 < b.size(); i1++) {
EntityPlayerMP entityplayermp = (EntityPlayerMP) b.get(i1);
if (g(entityplayermp.aw)) {
entityplayermp.a.b(((Packet) (packet3chat)));
}
}
}
public boolean a(String s, Packet packet) {
EntityPlayerMP entityplayermp = h(s);
if (entityplayermp != null) {
entityplayermp.a.b(packet);
return true;
} else {
return false;
}
}
public void d() {
for (int i1 = 0; i1 < b.size(); i1++) {
l.a((EntityPlayerMP) b.get(i1));
}
}
public void a(int i1, int j1, int k1, TileEntity tileentity) {}
}
|