/
DedicatedPlayerList.java
140 lines (117 loc) · 3.54 KB
/
DedicatedPlayerList.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
package net.minecraft.server;
import java.io.IOException;
import net.minecraft.util.com.mojang.authlib.GameProfile;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class DedicatedPlayerList extends PlayerList {
private static final Logger g = LogManager.getLogger();
public DedicatedPlayerList(DedicatedServer dedicatedserver) {
super(dedicatedserver);
this.a(dedicatedserver.a("view-distance", 10));
this.maxPlayers = dedicatedserver.a("max-players", 20);
this.setHasWhitelist(dedicatedserver.a("white-list", false));
if (!dedicatedserver.N()) {
this.getProfileBans().a(true);
this.getIPBans().a(true);
}
this.y();
this.w();
this.x();
this.v();
this.z();
this.B();
this.A();
if (!this.getWhitelist().c().exists()) {
this.C();
}
}
public void setHasWhitelist(boolean flag) {
super.setHasWhitelist(flag);
this.getServer().a("white-list", Boolean.valueOf(flag));
this.getServer().a();
}
public void addOp(GameProfile gameprofile) {
super.addOp(gameprofile);
this.A();
}
public void removeOp(GameProfile gameprofile) {
super.removeOp(gameprofile);
this.A();
}
public void removeWhitelist(GameProfile gameprofile) {
super.removeWhitelist(gameprofile);
this.C();
}
public void addWhitelist(GameProfile gameprofile) {
super.addWhitelist(gameprofile);
this.C();
}
public void reloadWhitelist() {
this.B();
}
private void v() {
try {
this.getIPBans().save();
} catch (IOException ioexception) {
g.warn("Failed to save ip banlist: ", ioexception);
}
}
private void w() {
try {
this.getProfileBans().save();
} catch (IOException ioexception) {
g.warn("Failed to save user banlist: ", ioexception);
}
}
private void x() {
try {
this.getIPBans().load();
} catch (IOException ioexception) {
g.warn("Failed to load ip banlist: ", ioexception);
}
}
private void y() {
try {
this.getProfileBans().load();
} catch (IOException ioexception) {
g.warn("Failed to load user banlist: ", ioexception);
}
}
private void z() {
try {
this.getOPs().load();
} catch (Exception exception) {
g.warn("Failed to load operators list: ", exception);
}
}
private void A() {
try {
this.getOPs().save();
} catch (Exception exception) {
g.warn("Failed to save operators list: ", exception);
}
}
private void B() {
try {
this.getWhitelist().load();
} catch (Exception exception) {
g.warn("Failed to load white-list: ", exception);
}
}
private void C() {
try {
this.getWhitelist().save();
} catch (Exception exception) {
g.warn("Failed to save white-list: ", exception);
}
}
public boolean isWhitelisted(GameProfile gameprofile) {
return !this.getHasWhitelist() || this.isOp(gameprofile) || this.getWhitelist().isWhitelisted(gameprofile);
}
public DedicatedServer getServer() {
return (DedicatedServer) super.getServer();
}
public MinecraftServer getServer() {
return this.getServer();
}
}