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
|
--- a/net/minecraft/server/players/GameProfileCache.java
+++ b/net/minecraft/server/players/GameProfileCache.java
@@ -1,3 +1,4 @@
+// mc-dev import
package net.minecraft.server.players;
import com.google.common.collect.ImmutableList;
@@ -60,41 +61,39 @@
@Nullable
private Executor executor;
- public GameProfileCache(GameProfileRepository gameprofilerepository, File file) {
- this.profileRepository = gameprofilerepository;
+ public GameProfileCache(GameProfileRepository profileRepository, File file) {
+ this.profileRepository = profileRepository;
this.file = file;
Lists.reverse(this.load()).forEach(this::safeAdd);
}
- private void safeAdd(GameProfileCache.GameProfileInfo gameprofilecache_gameprofileinfo) {
- GameProfile gameprofile = gameprofilecache_gameprofileinfo.getProfile();
+ private void safeAdd(GameProfileCache.GameProfileInfo profile) {
+ GameProfile gameprofile = profile.getProfile();
- gameprofilecache_gameprofileinfo.setLastAccess(this.getNextOperation());
- this.profilesByName.put(gameprofile.getName().toLowerCase(Locale.ROOT), gameprofilecache_gameprofileinfo);
- this.profilesByUUID.put(gameprofile.getId(), gameprofilecache_gameprofileinfo);
+ profile.setLastAccess(this.getNextOperation());
+ this.profilesByName.put(gameprofile.getName().toLowerCase(Locale.ROOT), profile);
+ this.profilesByUUID.put(gameprofile.getId(), profile);
}
- private static Optional<GameProfile> lookupGameProfile(GameProfileRepository gameprofilerepository, String s) {
- if (!Player.isValidUsername(s)) {
- return createUnknownProfile(s);
+ private static Optional<GameProfile> lookupGameProfile(GameProfileRepository profileRepo, String name) {
+ if (!Player.isValidUsername(name)) {
+ return createUnknownProfile(name);
} else {
final AtomicReference<GameProfile> atomicreference = new AtomicReference();
ProfileLookupCallback profilelookupcallback = new ProfileLookupCallback() {
- @Override
public void onProfileLookupSucceeded(GameProfile gameprofile) {
atomicreference.set(gameprofile);
}
- @Override
public void onProfileLookupFailed(String s1, Exception exception) {
- atomicreference.set((Object) null);
+ atomicreference.set(null); // CraftBukkit - decompile error
}
};
- gameprofilerepository.findProfilesByNames(new String[]{s}, profilelookupcallback);
+ profileRepo.findProfilesByNames(new String[]{name}, profilelookupcallback);
GameProfile gameprofile = (GameProfile) atomicreference.get();
- return gameprofile != null ? Optional.of(gameprofile) : createUnknownProfile(s);
+ return gameprofile != null ? Optional.of(gameprofile) : createUnknownProfile(name);
}
}
@@ -102,23 +101,23 @@
return usesAuthentication() ? Optional.empty() : Optional.of(UUIDUtil.createOfflineProfile(s));
}
- public static void setUsesAuthentication(boolean flag) {
- GameProfileCache.usesAuthentication = flag;
+ public static void setUsesAuthentication(boolean onlineMode) {
+ GameProfileCache.usesAuthentication = onlineMode;
}
private static boolean usesAuthentication() {
return GameProfileCache.usesAuthentication;
}
- public void add(GameProfile gameprofile) {
+ public void add(GameProfile gameProfile) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date());
calendar.add(2, 1);
Date date = calendar.getTime();
- GameProfileCache.GameProfileInfo gameprofilecache_gameprofileinfo = new GameProfileCache.GameProfileInfo(gameprofile, date);
+ GameProfileCache.GameProfileInfo usercache_usercacheentry = new GameProfileCache.GameProfileInfo(gameProfile, date);
- this.safeAdd(gameprofilecache_gameprofileinfo);
+ this.safeAdd(usercache_usercacheentry);
this.save();
}
@@ -126,23 +125,23 @@
return this.operationCount.incrementAndGet();
}
- public Optional<GameProfile> get(String s) {
- String s1 = s.toLowerCase(Locale.ROOT);
- GameProfileCache.GameProfileInfo gameprofilecache_gameprofileinfo = (GameProfileCache.GameProfileInfo) this.profilesByName.get(s1);
+ public Optional<GameProfile> get(String name) {
+ String s1 = name.toLowerCase(Locale.ROOT);
+ GameProfileCache.GameProfileInfo usercache_usercacheentry = (GameProfileCache.GameProfileInfo) this.profilesByName.get(s1);
boolean flag = false;
- if (gameprofilecache_gameprofileinfo != null && (new Date()).getTime() >= gameprofilecache_gameprofileinfo.expirationDate.getTime()) {
- this.profilesByUUID.remove(gameprofilecache_gameprofileinfo.getProfile().getId());
- this.profilesByName.remove(gameprofilecache_gameprofileinfo.getProfile().getName().toLowerCase(Locale.ROOT));
+ if (usercache_usercacheentry != null && (new Date()).getTime() >= usercache_usercacheentry.expirationDate.getTime()) {
+ this.profilesByUUID.remove(usercache_usercacheentry.getProfile().getId());
+ this.profilesByName.remove(usercache_usercacheentry.getProfile().getName().toLowerCase(Locale.ROOT));
flag = true;
- gameprofilecache_gameprofileinfo = null;
+ usercache_usercacheentry = null;
}
Optional optional;
- if (gameprofilecache_gameprofileinfo != null) {
- gameprofilecache_gameprofileinfo.setLastAccess(this.getNextOperation());
- optional = Optional.of(gameprofilecache_gameprofileinfo.getProfile());
+ if (usercache_usercacheentry != null) {
+ usercache_usercacheentry.setLastAccess(this.getNextOperation());
+ optional = Optional.of(usercache_usercacheentry.getProfile());
} else {
optional = lookupGameProfile(this.profileRepository, s1);
if (optional.isPresent()) {
@@ -180,18 +179,18 @@
}
public Optional<GameProfile> get(UUID uuid) {
- GameProfileCache.GameProfileInfo gameprofilecache_gameprofileinfo = (GameProfileCache.GameProfileInfo) this.profilesByUUID.get(uuid);
+ GameProfileCache.GameProfileInfo usercache_usercacheentry = (GameProfileCache.GameProfileInfo) this.profilesByUUID.get(uuid);
- if (gameprofilecache_gameprofileinfo == null) {
+ if (usercache_usercacheentry == null) {
return Optional.empty();
} else {
- gameprofilecache_gameprofileinfo.setLastAccess(this.getNextOperation());
- return Optional.of(gameprofilecache_gameprofileinfo.getProfile());
+ usercache_usercacheentry.setLastAccess(this.getNextOperation());
+ return Optional.of(usercache_usercacheentry.getProfile());
}
}
- public void setExecutor(Executor executor) {
- this.executor = executor;
+ public void setExecutor(Executor exectutor) {
+ this.executor = exectutor;
}
public void clearExecutor() {
@@ -263,8 +262,8 @@
JsonArray jsonarray = new JsonArray();
DateFormat dateformat = createDateFormat();
- this.getTopMRUProfiles(1000).forEach((gameprofilecache_gameprofileinfo) -> {
- jsonarray.add(writeGameProfile(gameprofilecache_gameprofileinfo, dateformat));
+ this.getTopMRUProfiles(1000).forEach((usercache_usercacheentry) -> {
+ jsonarray.add(writeGameProfile(usercache_usercacheentry, dateformat));
});
String s = this.gson.toJson(jsonarray);
@@ -294,22 +293,22 @@
}
- private Stream<GameProfileCache.GameProfileInfo> getTopMRUProfiles(int i) {
- return ImmutableList.copyOf(this.profilesByUUID.values()).stream().sorted(Comparator.comparing(GameProfileCache.GameProfileInfo::getLastAccess).reversed()).limit((long) i);
+ private Stream<GameProfileCache.GameProfileInfo> getTopMRUProfiles(int limit) {
+ return ImmutableList.copyOf(this.profilesByUUID.values()).stream().sorted(Comparator.comparing(GameProfileCache.GameProfileInfo::getLastAccess).reversed()).limit((long) limit);
}
- private static JsonElement writeGameProfile(GameProfileCache.GameProfileInfo gameprofilecache_gameprofileinfo, DateFormat dateformat) {
+ private static JsonElement writeGameProfile(GameProfileCache.GameProfileInfo profileInfo, DateFormat dateFormat) {
JsonObject jsonobject = new JsonObject();
- jsonobject.addProperty("name", gameprofilecache_gameprofileinfo.getProfile().getName());
- jsonobject.addProperty("uuid", gameprofilecache_gameprofileinfo.getProfile().getId().toString());
- jsonobject.addProperty("expiresOn", dateformat.format(gameprofilecache_gameprofileinfo.getExpirationDate()));
+ jsonobject.addProperty("name", profileInfo.getProfile().getName());
+ jsonobject.addProperty("uuid", profileInfo.getProfile().getId().toString());
+ jsonobject.addProperty("expiresOn", dateFormat.format(profileInfo.getExpirationDate()));
return jsonobject;
}
- private static Optional<GameProfileCache.GameProfileInfo> readGameProfile(JsonElement jsonelement, DateFormat dateformat) {
- if (jsonelement.isJsonObject()) {
- JsonObject jsonobject = jsonelement.getAsJsonObject();
+ private static Optional<GameProfileCache.GameProfileInfo> readGameProfile(JsonElement json, DateFormat dateFormat) {
+ if (json.isJsonObject()) {
+ JsonObject jsonobject = json.getAsJsonObject();
JsonElement jsonelement1 = jsonobject.get("name");
JsonElement jsonelement2 = jsonobject.get("uuid");
JsonElement jsonelement3 = jsonobject.get("expiresOn");
@@ -321,7 +320,7 @@
if (jsonelement3 != null) {
try {
- date = dateformat.parse(jsonelement3.getAsString());
+ date = dateFormat.parse(jsonelement3.getAsString());
} catch (ParseException parseexception) {
;
}
@@ -354,9 +353,9 @@
final Date expirationDate;
private volatile long lastAccess;
- GameProfileInfo(GameProfile gameprofile, Date date) {
- this.profile = gameprofile;
- this.expirationDate = date;
+ GameProfileInfo(GameProfile profile, Date expirationDate) {
+ this.profile = profile;
+ this.expirationDate = expirationDate;
}
public GameProfile getProfile() {
@@ -367,8 +366,8 @@
return this.expirationDate;
}
- public void setLastAccess(long i) {
- this.lastAccess = i;
+ public void setLastAccess(long lastAccess) {
+ this.lastAccess = lastAccess;
}
public long getLastAccess() {
|