Hotfix - initalise hidden players w/ refactor user cache system

This commit is contained in:
Sotr
2019-03-24 04:58:06 +08:00
parent bfee6f32c1
commit 71b180df27
14 changed files with 438 additions and 41 deletions

View File

@@ -3,8 +3,12 @@ package com.destroystokyo.paper.profile;
import com.destroystokyo.paper.PaperConfig;
import com.google.common.base.Charsets;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.ProfileLookupCallback;
import com.mojang.authlib.properties.Property;
import com.mojang.authlib.properties.PropertyMap;
import net.minecraft.server.AkarinUserCache;
import net.minecraft.server.EntityHuman;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.UserCache;
import org.bukkit.craftbukkit.entity.CraftPlayer;
@@ -143,7 +147,9 @@ public class CraftPlayerProfile implements PlayerProfile {
}
MinecraftServer server = MinecraftServer.getServer();
String name = profile.getName();
UserCache userCache = server.getUserCache();
// Akarin start
AkarinUserCache userCache = server.getModernUserCache();
/*
if (profile.getId() == null) {
final GameProfile profile;
boolean isOnlineMode = server.getOnlineMode() || (SpigotConfig.bungee && PaperConfig.bungeeOnlineMode);
@@ -165,7 +171,31 @@ public class CraftPlayerProfile implements PlayerProfile {
this.profile = profile;
}
}
return this.profile.isComplete();
*/
ProfileLookupCallback callback = new ProfileLookupCallback() {
@Override
public void onProfileLookupSucceeded(GameProfile gameprofile) {
profile = gameprofile;
}
@Override
public void onProfileLookupFailed(GameProfile gameprofile, Exception ex) {
;
}
};
if (lookupName) {
userCache.acquire(name, callback, true);
} else {
GameProfile peeked = userCache.peek(name);
if (peeked.getName() == null) {
userCache.acquire(name, callback, true);
} else {
this.profile = peeked;
}
}
return true;
// Akarin end
}
public boolean complete(boolean textures) {

View File

@@ -0,0 +1,276 @@
package net.minecraft.server;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.concurrent.TimeUnit;
import javax.annotation.Nullable;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.spigotmc.SpigotConfig;
import com.destroystokyo.paper.PaperConfig;
import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
import com.google.common.base.Charsets;
import com.google.common.collect.Lists;
import com.google.common.io.Files;
import com.google.gson.Gson;
import com.google.gson.JsonParseException;
import com.google.gson.JsonSyntaxException;
import com.mojang.authlib.Agent;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.GameProfileRepository;
import com.mojang.authlib.ProfileLookupCallback;
import io.akarin.server.core.AkarinGlobalConfig;
import net.minecraft.server.UserCache.UserCacheEntry;
public class AkarinUserCache {
private final static Logger LOGGER = LogManager.getLogger("Akarin");
public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z");
// Used to reduce date create
private final static long RECREATE_DATE_INTERVAL = TimeUnit.MILLISECONDS.convert(10, TimeUnit.MINUTES);
private static long lastWarpExpireDate;
private static Date lastExpireDate;
/**
* All user caches, Username -> Entry(profile and expire date included)
*/
private final Cache<String, UserCacheEntry> profiles = Caffeine.newBuilder().maximumSize(SpigotConfig.userCacheCap).build();
private final GameProfileRepository profileHandler;
protected final Gson gson;
private final File userCacheFile;
public static boolean isOnlineMode() {
return UserCache.isOnlineMode() || (SpigotConfig.bungee && PaperConfig.bungeeOnlineMode);
}
public static Date createExpireDate(boolean force) {
long now = System.currentTimeMillis();
if (force || (now - lastWarpExpireDate) > RECREATE_DATE_INTERVAL) {
lastWarpExpireDate = now;
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(now);
calendar.add(Calendar.DAY_OF_YEAR, AkarinGlobalConfig.userCacheExpireDays);
return lastExpireDate = calendar.getTime();
}
return lastExpireDate;
}
public static boolean isExpired(UserCacheEntry entry) {
return System.currentTimeMillis() >= entry.getExpireDate().getTime();
}
public static UserCacheEntry refreshExpireDate(UserCacheEntry entry) {
return new UserCacheEntry(entry.getProfile(), createExpireDate(true));
}
public static GameProfile lookup(GameProfileRepository profileRepo, String keyUsername, ProfileLookupCallback callback, boolean async) {
if (!isOnlineMode())
callback.onProfileLookupSucceeded(new GameProfile(EntityHuman.getOfflineUUID(keyUsername.toLowerCase(Locale.ROOT)), keyUsername));
GameProfile[] gameProfile = new GameProfile[1];
ProfileLookupCallback callbackHandler = new ProfileLookupCallback() {
@Override
public void onProfileLookupSucceeded(GameProfile gameprofile) {
if (async)
callback.onProfileLookupSucceeded(gameprofile);
else
gameProfile[0] = gameprofile;
}
@Override
public void onProfileLookupFailed(GameProfile gameprofile, Exception ex) {
LOGGER.warn("Failed to lookup player {}, using local UUID.", gameprofile.getName());
if (async)
callback.onProfileLookupSucceeded(new GameProfile(EntityHuman.getOfflineUUID(keyUsername), keyUsername));
else
gameProfile[0] = new GameProfile(EntityHuman.getOfflineUUID(keyUsername), keyUsername);
}
};
Runnable find = () -> profileRepo.findProfilesByNames(new String[] { keyUsername }, Agent.MINECRAFT, callbackHandler);
if (async) {
MCUtil.scheduleAsyncTask(find);
return null; // TODO: future
} else {
find.run();
return gameProfile[0];
}
}
public AkarinUserCache(GameProfileRepository repo, File file, Gson gson) {
lastExpireDate = createExpireDate(true);
this.profileHandler = repo;
this.userCacheFile = file;
this.gson = gson;
this.load();
}
GameProfile lookupAndCache(String keyUsername, ProfileLookupCallback callback, boolean async) {
return lookupAndCache(keyUsername, callback, createExpireDate(false), async);
}
GameProfile lookupAndCache(String keyUsername, ProfileLookupCallback callback, Date date, boolean async) {
ProfileLookupCallback callbackHandler = new ProfileLookupCallback() {
@Override
public void onProfileLookupSucceeded(GameProfile gameprofile) {
profiles.put(keyUsername, new UserCacheEntry(gameprofile, date));
if (async)
callback.onProfileLookupSucceeded(gameprofile);
if(!org.spigotmc.SpigotConfig.saveUserCacheOnStopOnly)
save();
}
@Override
public void onProfileLookupFailed(GameProfile gameprofile, Exception ex) {
;
}
};
return lookup(profileHandler, keyUsername, callbackHandler, async);
}
public GameProfile acquire(String username) {
return acquire(username, null, false);
}
public GameProfile acquire(String username, ProfileLookupCallback callback) {
return acquire(username, callback, true);
}
public GameProfile acquire(String username, ProfileLookupCallback callback, boolean async) {
if (StringUtils.isBlank(username))
return null;
String keyUsername = isOnlineMode() ? username : username.toLowerCase(Locale.ROOT);
UserCacheEntry entry = profiles.getIfPresent(keyUsername);
if (entry != null) {
if (isExpired(entry)) {
profiles.invalidate(keyUsername);
return lookupAndCache(keyUsername, callback, async);
} else {
if (async) {
callback.onProfileLookupSucceeded(entry.getProfile());
return null;
} else {
return entry.getProfile();
}
}
}
return lookupAndCache(keyUsername, callback, async);
}
@Nullable
public GameProfile peek(String username) {
String keyUsername = isOnlineMode() ? username : username.toLowerCase(Locale.ROOT);
UserCacheEntry entry = profiles.getIfPresent(keyUsername);
return entry == null ? null : entry.getProfile();
}
void offer(GameProfile profile) {
offer(profile, createExpireDate(false));
}
void offer(GameProfile profile, Date date) {
String keyUsername = isOnlineMode() ? profile.getName() : profile.getName().toLowerCase(Locale.ROOT);
UserCacheEntry entry = profiles.getIfPresent(keyUsername);
if (entry != null) {
// The offered profile may has an raw case, this only happened on offline servers with old caches,
// so replace with an lower-case profile.
if (!UserCache.isOnlineMode() && !entry.getProfile().getName().equals(profile.getName()))
entry = new UserCacheEntry(new GameProfile(entry.getProfile().getId(), keyUsername), date);
else
entry = refreshExpireDate(entry);
} else {
entry = new UserCacheEntry(profile, date);
}
profiles.put(keyUsername, entry);
if (!SpigotConfig.saveUserCacheOnStopOnly)
this.save();
}
void offer(UserCacheEntry entry) {
if (!isExpired(entry))
profiles.put(isOnlineMode() ? entry.getProfile().getName() : entry.getProfile().getName().toLowerCase(Locale.ROOT), entry);
}
String[] usernames() {
return profiles.asMap().keySet().toArray(new String[profiles.asMap().size()]);
}
protected void load() {
BufferedReader reader = null;
try {
reader = Files.newReader(userCacheFile, Charsets.UTF_8);
List<UserCacheEntry> entries = this.gson.fromJson(reader, UserCache.PARAMETERIZED_TYPE);
profiles.invalidateAll();
if (entries != null && !entries.isEmpty())
Lists.reverse(entries).forEach(this::offer);
} catch (FileNotFoundException e) {
;
} catch (JsonSyntaxException e) {
LOGGER.warn("Usercache.json is corrupted or has bad formatting. Deleting it to prevent further issues.");
this.userCacheFile.delete();
} catch (JsonParseException e) {
;
} finally {
IOUtils.closeQuietly(reader);
}
}
public void save() {
save(true);
}
public void save(boolean async) {
Runnable save = () -> {
String jsonString = this.gson.toJson(this.entries());
BufferedWriter writer = null;
try {
writer = Files.newWriter(this.userCacheFile, Charsets.UTF_8);
writer.write(jsonString);
return;
} catch (FileNotFoundException e) {
return;
} catch (IOException io) {
;
} finally {
IOUtils.closeQuietly(writer);
}
};
if (async)
MCUtil.scheduleAsyncTask(save);
else
save.run();
}
List<UserCacheEntry> entries() {
return Lists.newArrayList(profiles.asMap().values());
}
}

View File

@@ -251,7 +251,7 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
}
if (this.aX()) {
this.getUserCache().c();
this.getModernUserCache().load(); // Akarin
}
if (!NameReferencingFileConverter.a(this.propertyManager)) {

View File

@@ -27,7 +27,7 @@ import java.util.concurrent.TimeoutException;
import java.util.function.Supplier;
public final class MCUtil {
private static final Executor asyncExecutor = Executors.newSingleThreadExecutor(new ThreadFactoryBuilder().setNameFormat("Paper Async Task Handler Thread - %1$d").build());
private static final Executor asyncExecutor = Executors.newSingleThreadExecutor(new ThreadFactoryBuilder().setNameFormat("Akarin Async Task Handler Thread - %1$d").build()); // Akarin
private MCUtil() {}

View File

@@ -180,6 +180,7 @@ public abstract class MinecraftServer implements IAsyncTaskHandler, IMojangStati
this.V = minecraftsessionservice;
this.W = gameprofilerepository;
this.X = usercache;
this.userCache = new AkarinUserCache(gameprofilerepository, usercache.file(), usercache.gson()); // Akarin
// this.universe = file; // CraftBukkit
// this.serverConnection = new ServerConnection(this); // CraftBukkit // Spigot
// this.convertable = file == null ? null : new WorldLoaderServer(file.toPath(), file.toPath().resolve("../backups"), datafixer); // CraftBukkit - moved to DedicatedServer.init
@@ -693,7 +694,7 @@ public abstract class MinecraftServer implements IAsyncTaskHandler, IMojangStati
// Spigot start
if (org.spigotmc.SpigotConfig.saveUserCacheOnStopOnly) {
LOGGER.info("Saving usercache.json");
this.getUserCache().c(false); // Paper
this.getModernUserCache().save(false); // Paper // Akarin
}
// Spigot end
}
@@ -1666,6 +1667,13 @@ public abstract class MinecraftServer implements IAsyncTaskHandler, IMojangStati
public UserCache getUserCache() {
return this.X;
}
// Akarin start
private final AkarinUserCache userCache;
public AkarinUserCache getModernUserCache() {
return userCache;
}
// Akarin end
public ServerPing getServerPing() {
return this.m;

View File

@@ -95,7 +95,7 @@ public class NameReferencingFileConverter {
a(NameReferencingFileConverter.b, (Map) map);
ProfileLookupCallback profilelookupcallback = new ProfileLookupCallback() {
public void onProfileLookupSucceeded(GameProfile gameprofile) {
minecraftserver.getUserCache().a(gameprofile);
minecraftserver.getModernUserCache().offer(gameprofile); // Akarin
String[] astring = (String[]) map.get(gameprofile.getName().toLowerCase(Locale.ROOT));
if (astring == null) {
@@ -194,7 +194,7 @@ public class NameReferencingFileConverter {
List<String> list = Files.readLines(NameReferencingFileConverter.c, StandardCharsets.UTF_8);
ProfileLookupCallback profilelookupcallback = new ProfileLookupCallback() {
public void onProfileLookupSucceeded(GameProfile gameprofile) {
minecraftserver.getUserCache().a(gameprofile);
minecraftserver.getModernUserCache().offer(gameprofile); // Akarin
oplist.add(new OpListEntry(gameprofile, minecraftserver.j(), false));
}
@@ -239,7 +239,7 @@ public class NameReferencingFileConverter {
List<String> list = Files.readLines(NameReferencingFileConverter.d, StandardCharsets.UTF_8);
ProfileLookupCallback profilelookupcallback = new ProfileLookupCallback() {
public void onProfileLookupSucceeded(GameProfile gameprofile) {
minecraftserver.getUserCache().a(gameprofile);
minecraftserver.getModernUserCache().offer(gameprofile); // Akarin
whitelist.add(new WhiteListEntry(gameprofile));
}
@@ -277,7 +277,7 @@ public class NameReferencingFileConverter {
final List<GameProfile> list = Lists.newArrayList();
ProfileLookupCallback profilelookupcallback = new ProfileLookupCallback() {
public void onProfileLookupSucceeded(GameProfile gameprofile1) {
minecraftserver.getUserCache().a(gameprofile1);
minecraftserver.getModernUserCache().offer(gameprofile1); // Akarin
list.add(gameprofile1);
}
@@ -324,7 +324,7 @@ public class NameReferencingFileConverter {
final String[] astring = (String[]) list.toArray(new String[list.size()]);
ProfileLookupCallback profilelookupcallback = new ProfileLookupCallback() {
public void onProfileLookupSucceeded(GameProfile gameprofile) {
dedicatedserver.getUserCache().a(gameprofile);
dedicatedserver.getModernUserCache().offer(gameprofile); // Akarin
UUID uuid = gameprofile.getId();
if (uuid == null) {

View File

@@ -97,11 +97,10 @@ public abstract class PlayerList {
public void a(NetworkManager networkmanager, EntityPlayer entityplayer) {
entityplayer.loginTime = System.currentTimeMillis(); // Paper
GameProfile gameprofile = entityplayer.getProfile();
UserCache usercache = this.server.getUserCache();
GameProfile gameprofile1 = usercache.a(gameprofile.getId());
AkarinUserCache usercache = this.server.getModernUserCache(); // Akarin
GameProfile gameprofile1 = usercache.peek(gameprofile.getName()); // Akarin
String s = gameprofile1 == null ? gameprofile.getName() : gameprofile1.getName();
usercache.a(gameprofile);
usercache.offer(gameprofile); // Akarin
NBTTagCompound nbttagcompound = this.a(entityplayer);
// CraftBukkit start - Better rename detection
if (nbttagcompound != null && nbttagcompound.hasKey("bukkit")) {

View File

@@ -47,8 +47,8 @@ public class UserCache {
private final Map<UUID, UserCache.UserCacheEntry> e = Maps.newHashMap();
private final Deque<GameProfile> f = new java.util.concurrent.LinkedBlockingDeque<GameProfile>(); // CraftBukkit
private final GameProfileRepository g;
protected final Gson b;
private final File h;
protected final Gson b; protected Gson gson() { return this.b; } // Akarin - OBFHELPER
private final File h; File file() { return this.h; } // Akarin - OBFHELPER
private static final ParameterizedType i = new ParameterizedType() {
public Type[] getActualTypeArguments() {
return new Type[] { UserCache.UserCacheEntry.class};
@@ -62,6 +62,7 @@ public class UserCache {
return null;
}
};
static final ParameterizedType PARAMETERIZED_TYPE = i; // Akarin - OBFHELPER
public UserCache(GameProfileRepository gameprofilerepository, File file) {
this.g = gameprofilerepository;
@@ -100,6 +101,7 @@ public class UserCache {
UserCache.c = flag;
}
static boolean isOnlineMode() { return d(); } // Akarin - OBFHELPER
private static boolean d() {
return UserCache.c;
}
@@ -279,12 +281,12 @@ public class UserCache {
return list;
}
class UserCacheEntry {
static class UserCacheEntry { // Akarin - static
private final GameProfile b;public GameProfile getProfile() { return b; } // Paper - OBFHELPER
private final Date c;
private final Date c; public Date getExpireDate() { return c; } // Akarin - OBFHELPER
private UserCacheEntry(GameProfile gameprofile, Date date) {
UserCacheEntry(GameProfile gameprofile, Date date) { // Akarin - package
this.b = gameprofile;
this.c = date;
}
@@ -298,7 +300,7 @@ public class UserCache {
}
}
class BanEntrySerializer implements JsonDeserializer<UserCache.UserCacheEntry>, JsonSerializer<UserCache.UserCacheEntry> {
static class BanEntrySerializer implements JsonDeserializer<UserCache.UserCacheEntry>, JsonSerializer<UserCache.UserCacheEntry> { // Akarin - static
private BanEntrySerializer() {}
@@ -342,7 +344,7 @@ public class UserCache {
return null;
}
return UserCache.this.new UserCacheEntry(new GameProfile(uuid, s1), date);
return new UserCacheEntry(new GameProfile(uuid, s1), date); // Akarin - static
} else {
return null;
}

View File

@@ -3,6 +3,10 @@ package net.minecraft.server;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.ProfileLookupCallback;
import net.minecraft.server.UserCache.UserCacheEntry;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -394,8 +398,8 @@ public class Village {
NBTTagCompound nbttagcompound2 = nbttaglist1.getCompound(j);
if (nbttagcompound2.hasKey("UUID") && this.a != null && this.a.getMinecraftServer() != null) {
UserCache usercache = this.a.getMinecraftServer().getUserCache();
GameProfile gameprofile = usercache.a(UUID.fromString(nbttagcompound2.getString("UUID")));
AkarinUserCache usercache = this.a.getMinecraftServer().getModernUserCache(); // Akarin
GameProfile gameprofile = usercache.peek(nbttagcompound2.getString("Name")); // Akarin
if (gameprofile != null) {
this.j.put(gameprofile.getName(), nbttagcompound2.getInt("S"));
@@ -443,16 +447,31 @@ public class Village {
while (iterator1.hasNext()) {
String s = (String) iterator1.next();
NBTTagCompound nbttagcompound2 = new NBTTagCompound();
UserCache usercache = this.a.getMinecraftServer().getUserCache();
AkarinUserCache usercache = this.a.getMinecraftServer().getModernUserCache(); // Akarin
try {
GameProfile gameprofile = usercache.getProfile(s);
// Akarin start
ProfileLookupCallback callback = new ProfileLookupCallback() {
@Override
public void onProfileLookupSucceeded(GameProfile gameprofile) {
nbttagcompound2.setString("UUID", gameprofile.getId().toString());
nbttagcompound2.setInt("S", (Integer) j.get(s));
nbttaglist1.add((NBTBase) nbttagcompound2);
}
if (gameprofile != null) {
nbttagcompound2.setString("UUID", gameprofile.getId().toString());
nbttagcompound2.setInt("S", (Integer) this.j.get(s));
nbttaglist1.add((NBTBase) nbttagcompound2);
}
@Override
public void onProfileLookupFailed(GameProfile gameprofile, Exception ex) {
;
}
};
usercache.acquire(s, callback);
//if (gameprofile != null) {
// nbttagcompound2.setString("UUID", gameprofile.getId().toString());
// nbttagcompound2.setInt("S", (Integer) this.j.get(s));
// nbttaglist1.add((NBTBase) nbttagcompound2);
//}
// Akarin end
} catch (RuntimeException runtimeexception) {
;
}

View File

@@ -14,6 +14,8 @@ import org.apache.commons.lang.Validate;
import com.google.common.collect.ImmutableSet;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.ProfileLookupCallback;
import java.util.logging.Level;
import org.bukkit.Bukkit;
@@ -28,7 +30,7 @@ public class CraftProfileBanList implements org.bukkit.BanList {
public org.bukkit.BanEntry getBanEntry(String target) {
Validate.notNull(target, "Target cannot be null");
GameProfile profile = MinecraftServer.getServer().getUserCache().getProfile(target);
GameProfile profile = MinecraftServer.getServer().getModernUserCache().acquire(target);
if (profile == null) {
return null;
}
@@ -45,7 +47,30 @@ public class CraftProfileBanList implements org.bukkit.BanList {
public org.bukkit.BanEntry addBan(String target, String reason, Date expires, String source) {
Validate.notNull(target, "Ban target cannot be null");
GameProfile profile = MinecraftServer.getServer().getUserCache().getProfile(target);
// Akarin start
ProfileLookupCallback callback = new ProfileLookupCallback() {
@Override
public void onProfileLookupSucceeded(GameProfile profile) {
GameProfileBanEntry entry = new GameProfileBanEntry(profile, new Date(),
StringUtils.isBlank(source) ? null : source, expires,
StringUtils.isBlank(reason) ? null : reason);
list.add(entry);
try {
list.save();
} catch (IOException ex) {
Bukkit.getLogger().log(Level.SEVERE, "Failed to save banned-players.json, {0}", ex.getMessage());
}
}
@Override
public void onProfileLookupFailed(GameProfile gameprofile, Exception ex) {
;
}
};
MinecraftServer.getServer().getModernUserCache().acquire(target, callback);
/*
if (profile == null) {
return null;
}
@@ -61,8 +86,10 @@ public class CraftProfileBanList implements org.bukkit.BanList {
} catch (IOException ex) {
Bukkit.getLogger().log(Level.SEVERE, "Failed to save banned-players.json, {0}", ex.getMessage());
}
*/
return new CraftProfileBanEntry(profile, entry, list);
return null;
// Akarin end
}
@Override
@@ -81,7 +108,7 @@ public class CraftProfileBanList implements org.bukkit.BanList {
public boolean isBanned(String target) {
Validate.notNull(target, "Target cannot be null");
GameProfile profile = MinecraftServer.getServer().getUserCache().getProfile(target);
GameProfile profile = MinecraftServer.getServer().getModernUserCache().acquire(target);// Akarin
if (profile == null) {
return false;
}
@@ -93,7 +120,20 @@ public class CraftProfileBanList implements org.bukkit.BanList {
public void pardon(String target) {
Validate.notNull(target, "Target cannot be null");
GameProfile profile = MinecraftServer.getServer().getUserCache().getProfile(target);
list.remove(profile);
// Akarin start
ProfileLookupCallback callback = new ProfileLookupCallback() {
@Override
public void onProfileLookupSucceeded(GameProfile profile) {
list.remove(profile);
}
@Override
public void onProfileLookupFailed(GameProfile gameprofile, Exception ex) {
;
}
};
GameProfile profile = MinecraftServer.getServer().getModernUserCache().acquire(target, callback);
//list.remove(profile);
// Akarin end
}
}

View File

@@ -1434,7 +1434,7 @@ public final class CraftServer implements Server {
// Only fetch an online UUID in online mode
if (MinecraftServer.getServer().getOnlineMode()
|| (org.spigotmc.SpigotConfig.bungee && com.destroystokyo.paper.PaperConfig.bungeeOnlineMode)) {
profile = console.getUserCache().getProfile( name );
profile = console.getModernUserCache().acquire( name ); // Akarin
} else {
// Make an OfflinePlayer using an offline mode UUID since the name has no profile
profile = new GameProfile(UUID.nameUUIDFromBytes(("OfflinePlayer:" + name).getBytes(Charsets.UTF_8)), name);
@@ -1457,7 +1457,7 @@ public final class CraftServer implements Server {
if ( MinecraftServer.getServer().getOnlineMode()
|| com.destroystokyo.paper.PaperConfig.isProxyOnlineMode()) // Paper - Handle via setting
{
profile = console.getUserCache().getProfile( name );
profile = console.getModernUserCache().acquire( name ); // Akarin
}
// Spigot end
if (profile == null) {

View File

@@ -4,8 +4,11 @@ import com.destroystokyo.paper.profile.CraftPlayerProfile;
import com.destroystokyo.paper.profile.PlayerProfile;
import com.google.common.base.Preconditions;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.ProfileLookupCallback;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.TileEntitySkull;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
@@ -74,12 +77,25 @@ public class CraftSkull extends CraftBlockEntityState<TileEntitySkull> implement
return false;
}
GameProfile profile = MinecraftServer.getServer().getUserCache().getProfile(name);
// Akarin start
ProfileLookupCallback callback = new ProfileLookupCallback() {
@Override
public void onProfileLookupSucceeded(GameProfile gameprofile) {
profile = gameprofile;
}
@Override
public void onProfileLookupFailed(GameProfile gameprofile, Exception ex) {
;
}
};
GameProfile profile = MinecraftServer.getServer().getModernUserCache().acquire(name, callback);
if (profile == null) {
return false;
}
this.profile = profile;
//this.profile = profile;
// Akarin end
return true;
}

View File

@@ -5,6 +5,7 @@ import com.destroystokyo.paper.profile.CraftPlayerProfile;
import com.destroystokyo.paper.profile.PlayerProfile;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
import com.google.common.io.BaseEncoding;
import com.koloboke.collect.map.hash.HashObjObjMap;
import com.koloboke.collect.map.hash.HashObjObjMaps;
@@ -18,6 +19,7 @@ import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
@@ -124,7 +126,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
private boolean hasPlayedBefore = false;
private final ConversationTracker conversationTracker = new ConversationTracker();
private final Set<String> channels = new HashSet<String>();
private Map<UUID, Set<WeakReference<Plugin>>> hiddenPlayers; // Akarin
private Map<UUID, Set<WeakReference<Plugin>>> hiddenPlayers = Collections.emptyMap(); // Akarin
private static final WeakHashMap<Plugin, WeakReference<Plugin>> pluginWeakReferences = new WeakHashMap<>();
private int hash = 0;
private double health = 20;