diff options
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/server/players/GameProfileCache.java.patch')
-rw-r--r-- | patch-remap/mache-spigotflower/net/minecraft/server/players/GameProfileCache.java.patch | 226 |
1 files changed, 226 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/server/players/GameProfileCache.java.patch b/patch-remap/mache-spigotflower/net/minecraft/server/players/GameProfileCache.java.patch new file mode 100644 index 0000000000..cec110ac1f --- /dev/null +++ b/patch-remap/mache-spigotflower/net/minecraft/server/players/GameProfileCache.java.patch @@ -0,0 +1,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() { |