|
77 | 77 | import it.unimi.dsi.fastutil.ints.IntArrayList; |
78 | 78 | import it.unimi.dsi.fastutil.ints.IntOpenHashSet; |
79 | 79 | import it.unimi.dsi.fastutil.longs.Long2ObjectLinkedOpenHashMap; |
80 | | -import it.unimi.dsi.fastutil.longs.Long2ObjectMap; |
81 | 80 | import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; |
82 | 81 | import it.unimi.dsi.fastutil.longs.LongIterator; |
83 | | -import it.unimi.dsi.fastutil.objects.ObjectIterator; |
| 82 | +import it.unimi.dsi.fastutil.longs.LongLinkedOpenHashSet; |
84 | 83 | import lombok.Getter; |
85 | 84 | import lombok.Setter; |
86 | 85 | import lombok.extern.log4j.Log4j2; |
|
90 | 89 | import java.awt.image.BufferedImage; |
91 | 90 | import java.io.File; |
92 | 91 | import java.io.IOException; |
93 | | -import java.lang.reflect.Field; |
94 | 92 | import java.net.InetSocketAddress; |
95 | 93 | import java.nio.ByteOrder; |
96 | 94 | import java.util.*; |
|
101 | 99 | import java.util.concurrent.TimeUnit; |
102 | 100 | import java.util.concurrent.atomic.AtomicReference; |
103 | 101 | import java.util.function.Consumer; |
104 | | -import java.util.stream.Stream; |
105 | 102 |
|
106 | 103 | /** |
107 | 104 | * The Player class |
@@ -200,7 +197,7 @@ public class Player extends EntityHuman implements CommandSender, InventoryHolde |
200 | 197 | protected int chunkRadius; |
201 | 198 | protected int viewDistance; |
202 | 199 | public final Map<Long, Boolean> usedChunks = new Long2ObjectOpenHashMap<>(); |
203 | | - protected final Long2ObjectLinkedOpenHashMap<Boolean> loadQueue = new Long2ObjectLinkedOpenHashMap<>(); |
| 200 | + protected final LongLinkedOpenHashSet loadQueue = new LongLinkedOpenHashSet(); |
204 | 201 |
|
205 | 202 | protected final Map<UUID, Player> hiddenPlayers = new HashMap<>(); |
206 | 203 |
|
@@ -269,8 +266,6 @@ public class Player extends EntityHuman implements CommandSender, InventoryHolde |
269 | 266 | private AsyncTask preLoginEventTask; |
270 | 267 | protected boolean shouldLogin; |
271 | 268 |
|
272 | | - private static Stream<Field> pkIDs; |
273 | | - |
274 | 269 | protected int startAction = -1; |
275 | 270 | private int lastEmote; |
276 | 271 | protected int lastEnderPearl = 20; |
@@ -1135,14 +1130,13 @@ protected void sendNextChunk() { |
1135 | 1130 |
|
1136 | 1131 | if (!loadQueue.isEmpty()) { |
1137 | 1132 | int count = 0; |
1138 | | - ObjectIterator<Long2ObjectMap.Entry<Boolean>> iter = loadQueue.long2ObjectEntrySet().fastIterator(); |
| 1133 | + LongIterator iter = loadQueue.longIterator(); |
1139 | 1134 | while (iter.hasNext()) { |
1140 | 1135 | if (count >= server.chunksPerTick) { |
1141 | 1136 | break; |
1142 | 1137 | } |
1143 | 1138 |
|
1144 | | - Long2ObjectMap.Entry<Boolean> entry = iter.next(); |
1145 | | - long index = entry.getLongKey(); |
| 1139 | + long index = iter.nextLong(); |
1146 | 1140 | int chunkX = Level.getHashX(index); |
1147 | 1141 | int chunkZ = Level.getHashZ(index); |
1148 | 1142 |
|
@@ -1284,43 +1278,43 @@ protected boolean orderChunks() { |
1284 | 1278 |
|
1285 | 1279 | /* Top right quadrant */ |
1286 | 1280 | if (this.usedChunks.get(index = Level.chunkHash(centerX + x, centerZ + z)) != Boolean.TRUE) { |
1287 | | - this.loadQueue.put(index, Boolean.TRUE); |
| 1281 | + this.loadQueue.add(index); |
1288 | 1282 | } |
1289 | 1283 | lastChunk.remove(index); |
1290 | 1284 | /* Top left quadrant */ |
1291 | 1285 | if (this.usedChunks.get(index = Level.chunkHash(centerX - x - 1, centerZ + z)) != Boolean.TRUE) { |
1292 | | - this.loadQueue.put(index, Boolean.TRUE); |
| 1286 | + this.loadQueue.add(index); |
1293 | 1287 | } |
1294 | 1288 | lastChunk.remove(index); |
1295 | 1289 | /* Bottom right quadrant */ |
1296 | 1290 | if (this.usedChunks.get(index = Level.chunkHash(centerX + x, centerZ - z - 1)) != Boolean.TRUE) { |
1297 | | - this.loadQueue.put(index, Boolean.TRUE); |
| 1291 | + this.loadQueue.add(index); |
1298 | 1292 | } |
1299 | 1293 | lastChunk.remove(index); |
1300 | 1294 | /* Bottom left quadrant */ |
1301 | 1295 | if (this.usedChunks.get(index = Level.chunkHash(centerX - x - 1, centerZ - z - 1)) != Boolean.TRUE) { |
1302 | | - this.loadQueue.put(index, Boolean.TRUE); |
| 1296 | + this.loadQueue.add(index); |
1303 | 1297 | } |
1304 | 1298 | lastChunk.remove(index); |
1305 | 1299 | if (x != z) { |
1306 | 1300 | /* Top right quadrant mirror */ |
1307 | 1301 | if (this.usedChunks.get(index = Level.chunkHash(centerX + z, centerZ + x)) != Boolean.TRUE) { |
1308 | | - this.loadQueue.put(index, Boolean.TRUE); |
| 1302 | + this.loadQueue.add(index); |
1309 | 1303 | } |
1310 | 1304 | lastChunk.remove(index); |
1311 | 1305 | /* Top left quadrant mirror */ |
1312 | 1306 | if (this.usedChunks.get(index = Level.chunkHash(centerX - z - 1, centerZ + x)) != Boolean.TRUE) { |
1313 | | - this.loadQueue.put(index, Boolean.TRUE); |
| 1307 | + this.loadQueue.add(index); |
1314 | 1308 | } |
1315 | 1309 | lastChunk.remove(index); |
1316 | 1310 | /* Bottom right quadrant mirror */ |
1317 | 1311 | if (this.usedChunks.get(index = Level.chunkHash(centerX + z, centerZ - x - 1)) != Boolean.TRUE) { |
1318 | | - this.loadQueue.put(index, Boolean.TRUE); |
| 1312 | + this.loadQueue.add(index); |
1319 | 1313 | } |
1320 | 1314 | lastChunk.remove(index); |
1321 | 1315 | /* Bottom left quadrant mirror */ |
1322 | 1316 | if (this.usedChunks.get(index = Level.chunkHash(centerX - z - 1, centerZ - x - 1)) != Boolean.TRUE) { |
1323 | | - this.loadQueue.put(index, Boolean.TRUE); |
| 1317 | + this.loadQueue.add(index); |
1324 | 1318 | } |
1325 | 1319 | lastChunk.remove(index); |
1326 | 1320 | } |
@@ -4667,19 +4661,7 @@ public void onCompletion(Server server) { |
4667 | 4661 | } |
4668 | 4662 | return; |
4669 | 4663 | case ProtocolInfo.PACKET_VIOLATION_WARNING_PACKET: |
4670 | | - PacketViolationWarningPacket PVWpk = (PacketViolationWarningPacket) packet; |
4671 | | - if (pkIDs == null) { |
4672 | | - pkIDs = Arrays.stream(ProtocolInfo.class.getDeclaredFields()).filter(field -> field.getType() == Byte.TYPE); |
4673 | | - } |
4674 | | - Optional<String> PVWpkName = pkIDs |
4675 | | - .filter(field -> { |
4676 | | - try { |
4677 | | - return field.getByte(null) == ((PacketViolationWarningPacket) packet).packetId; |
4678 | | - } catch (IllegalAccessException e) { |
4679 | | - return false; |
4680 | | - } |
4681 | | - }).map(Field::getName).findFirst(); |
4682 | | - this.getServer().getLogger().warning("PacketViolationWarningPacket" + PVWpkName.map(name -> " for " + name).orElse(" UNKNOWN") + " from " + this.username + ": " + PVWpk.toString()); |
| 4664 | + this.getServer().getLogger().warning("Packet violation warning 0x" + Integer.toHexString(((PacketViolationWarningPacket) packet).packetId) + " from " + this.username + ": " + packet); |
4683 | 4665 | return; |
4684 | 4666 | case ProtocolInfo.EMOTE_PACKET: |
4685 | 4667 | if (!this.spawned || server.getTick() - this.lastEmote < 20 || this.isSpectator()) { |
|
0 commit comments