|
1 | 1 | --- before/net/minecraft/tileentity/TileEntitySkull.java |
2 | 2 | +++ after/net/minecraft/tileentity/TileEntitySkull.java |
3 | | -@@ -1,14 +1,32 @@ |
| 3 | +@@ -1,14 +1,34 @@ |
4 | 4 | package net.minecraft.tileentity; |
5 | 5 |
|
6 | 6 | +import catserver.server.CatServer; |
|
16 | 16 | +import com.mojang.authlib.ProfileLookupCallback; |
17 | 17 | import com.mojang.authlib.minecraft.MinecraftSessionService; |
18 | 18 | import com.mojang.authlib.properties.Property; |
| 19 | ++ |
| 20 | ++import java.util.Locale; |
19 | 21 | +import java.util.UUID; |
20 | 22 | +import java.util.concurrent.Callable; |
21 | 23 | +import java.util.concurrent.ExecutorService; |
|
33 | 35 | import net.minecraft.server.management.PlayerProfileCache; |
34 | 36 | import net.minecraft.util.EnumFacing; |
35 | 37 | import net.minecraft.util.ITickable; |
36 | | -@@ -21,12 +39,65 @@ |
| 38 | +@@ -21,12 +41,61 @@ |
37 | 39 | public class TileEntitySkull extends TileEntity implements ITickable |
38 | 40 | { |
39 | 41 | private int skullType; |
|
45 | 47 | private static PlayerProfileCache profileCache; |
46 | 48 | private static MinecraftSessionService sessionService; |
47 | 49 | + // Spigot start |
48 | | -+ public static final ExecutorService executor = Executors.newFixedThreadPool(3, |
49 | | -+ new ThreadFactoryBuilder() |
50 | | -+ .setNameFormat("Head Conversion Thread - %1$d") |
51 | | -+ .build() |
52 | | -+ ); |
| 50 | ++ public static final ExecutorService executor = Executors.newThreadPerTaskExecutor(Thread.ofVirtual().name("Head Conversion Thread - %1$d").factory()); |
53 | 51 | + public static final LoadingCache<String, GameProfile> skinCache = CacheBuilder.newBuilder() |
54 | 52 | + .maximumSize( 5000 ) |
55 | 53 | + .expireAfterAccess( 60, TimeUnit.MINUTES ) |
56 | | -+ .build( new CacheLoader<String, GameProfile>() |
| 54 | ++ .build( new CacheLoader<>() |
57 | 55 | + { |
58 | 56 | + @Override |
59 | 57 | + public GameProfile load(String key) throws Exception |
|
100 | 98 |
|
101 | 99 | public static void setProfileCache(PlayerProfileCache profileCacheIn) |
102 | 100 | { |
103 | | -@@ -89,7 +160,7 @@ |
| 101 | +@@ -89,7 +158,7 @@ |
104 | 102 | if (this.world.isBlockPowered(this.pos)) |
105 | 103 | { |
106 | 104 | this.dragonAnimated = true; |
|
109 | 107 | } |
110 | 108 | else |
111 | 109 | { |
112 | | -@@ -138,47 +209,88 @@ |
| 110 | +@@ -138,47 +207,76 @@ |
113 | 111 |
|
114 | 112 | private void updatePlayerProfile() |
115 | 113 | { |
|
118 | 116 | + // Spigot start |
119 | 117 | + GameProfile profile = this.playerProfile; |
120 | 118 | + setType( 0 ); // Work around client bug |
121 | | -+ updateGameprofile(profile, new Predicate<GameProfile>() { |
122 | | -+ |
123 | | -+ @Override |
124 | | -+ public boolean apply(GameProfile input) { |
125 | | -+ setType(3); // Work around client bug |
126 | | -+ playerProfile = input; |
127 | | -+ markDirty(); |
128 | | -+ if (world != null) { |
129 | | -+ world.notifyLightSet(pos); // PAIL: notify |
130 | | -+ } |
131 | | -+ return false; |
| 119 | ++ updateGameprofile(profile, input -> { |
| 120 | ++ setType(3); // Work around client bug |
| 121 | ++ playerProfile = input; |
| 122 | ++ markDirty(); |
| 123 | ++ if (world != null) { |
| 124 | ++ world.notifyLightSet(pos); // PAIL: notify |
132 | 125 | + } |
133 | | -+ }, false); |
| 126 | ++ return false; |
| 127 | ++ }, false); |
134 | 128 | + // Spigot end |
135 | 129 | + |
136 | 130 | } |
|
140 | 134 | + public static Future<GameProfile> updateGameprofile(final GameProfile input, final Predicate<GameProfile> callback, boolean sync) |
141 | 135 | { |
142 | 136 | if (input != null && !StringUtils.isNullOrEmpty(input.getName())) |
143 | | - { |
144 | | - if (input.isComplete() && input.getProperties().containsKey("textures")) |
145 | | - { |
| 137 | +- { |
| 138 | +- if (input.isComplete() && input.getProperties().containsKey("textures")) |
| 139 | +- { |
146 | 140 | - return input; |
147 | 141 | - } |
148 | 142 | - else if (profileCache != null && sessionService != null) |
149 | 143 | - { |
150 | 144 | - GameProfile gameprofile = profileCache.getGameProfileForUsername(input.getName()); |
151 | | -+ callback.apply(input); |
152 | | -+ } else if (MinecraftServer.getServerInst() == null) { |
| 145 | ++ { // TODO: can server instance be null? |
| 146 | ++ if ((input.isComplete() && input.getProperties().containsKey("textures")) || MinecraftServer.getServerInst() == null) |
| 147 | ++ { |
153 | 148 | + callback.apply(input); |
154 | 149 | + } else { |
155 | | -+ GameProfile profile = skinCache.getIfPresent(input.getName().toLowerCase(java.util.Locale.ROOT)); |
| 150 | ++ GameProfile profile = skinCache.getIfPresent(input.getName().toLowerCase(Locale.ROOT)); |
156 | 151 | + if (profile != null && Iterables.getFirst(profile.getProperties().get("textures"), (Object) null) != null) { |
157 | 152 | + callback.apply(profile); |
158 | 153 |
|
|
168 | 163 | - if (property == null) |
169 | 164 | - { |
170 | 165 | - gameprofile = sessionService.fillProfileProperties(gameprofile, true); |
171 | | -+ Callable<GameProfile> callable = new Callable<GameProfile>() { |
172 | | -+ @Override |
173 | | -+ public GameProfile call() { |
174 | | -+ final GameProfile profile = skinCache.getUnchecked(input.getName().toLowerCase(java.util.Locale.ROOT)); |
175 | | -+ MinecraftServer.getServerInst().processQueue.add(new Runnable() { |
176 | | -+ @Override |
177 | | -+ public void run() { |
178 | | -+ if (profile == null) { |
179 | | -+ callback.apply(input); |
180 | | -+ } else { |
181 | | -+ callback.apply(profile); |
182 | | -+ } |
183 | | -+ } |
184 | | -+ }); |
185 | | -+ return profile; |
186 | | -+ } |
| 166 | ++ Callable<GameProfile> callable = () -> { |
| 167 | ++ final GameProfile profile1 = skinCache.getUnchecked(input.getName().toLowerCase(Locale.ROOT)); |
| 168 | ++ MinecraftServer.getServerInst().processQueue.add(() -> { |
| 169 | ++ if (profile1 == null) { |
| 170 | ++ callback.apply(input); |
| 171 | ++ } else { |
| 172 | ++ callback.apply(profile1); |
| 173 | ++ } |
| 174 | ++ }); |
| 175 | ++ return profile1; |
187 | 176 | + }; |
188 | 177 | + if (sync) { |
189 | 178 | + try { |
|
0 commit comments