4646import org .maxgamer .quickshop .util .GameVersion ;
4747import org .maxgamer .quickshop .util .Util ;
4848
49- import java .util .ArrayList ;
50- import java .util .Collection ;
51- import java .util .Collections ;
52- import java .util .Iterator ;
53- import java .util .List ;
54- import java .util .Map ;
55- import java .util .Objects ;
56- import java .util .Optional ;
57- import java .util .Set ;
58- import java .util .UUID ;
49+ import java .util .*;
5950import java .util .concurrent .ConcurrentHashMap ;
6051import java .util .concurrent .ConcurrentSkipListSet ;
6152import java .util .concurrent .atomic .AtomicBoolean ;
@@ -96,7 +87,7 @@ private void load() {
9687 chunkLocation = new SimpleShopChunk (chunk .getWorld ().getName (), chunk .getX (), chunk .getZ ());
9788 VirtualDisplayItemManager .put (chunkLocation , this );
9889 if (Util .isLoaded (shop .getLocation ())) {
99- //Let nearby player can see the fake item
90+ //Let nearby player can saw fake item
10091 Collection <Entity > entityCollection = shop .getLocation ().getWorld ().getNearbyEntities (shop .getLocation (), PLUGIN .getServer ().getViewDistance () * 16 , shop .getLocation ().getWorld ().getMaxHeight (), PLUGIN .getServer ().getViewDistance () * 16 );
10192 for (Entity entity : entityCollection ) {
10293 if (entity instanceof Player ) {
@@ -228,10 +219,6 @@ private void unload() {
228219 VirtualDisplayItemManager .remove (chunkLocation , this );
229220 }
230221
231- public void sendDestroyFakeItemPacket (@ NotNull Player player ) {
232- sendPacket (player , fakeItemDestroyPacket );
233- }
234-
235222 public void sendFakeItem (@ NotNull Player player ) {
236223 sendPacket (player , fakeItemSpawnPacket );
237224 sendPacket (player , fakeItemMetaPacket );
@@ -335,12 +322,8 @@ public void onPacketSending(@NotNull PacketEvent event) {
335322 if (!target .shop .isLoaded () || !target .isDisplay || target .shop .isLeftShop ()) {
336323 continue ;
337324 }
338- if (target .packetSenders .add (player .getUniqueId ())) {
339- target .sendFakeItem (player );
340- } else {
341- target .sendDestroyFakeItemPacket (player );
342- target .sendFakeItem (player );
343- }
325+ target .packetSenders .add (player .getUniqueId ());
326+ target .sendFakeItem (player );
344327 }
345328 return targetList ;
346329 });
@@ -480,7 +463,7 @@ private static PacketContainer createFakeItemMetaPacket(int entityID, ItemStack
480463 }
481464
482465 private static PacketContainer createFakeItemVelocityPacket (int entityID ) {
483- //And, create an entity velocity packet to make it at a proper location (otherwise it will fly randomly)
466+ //And, create a entity velocity packet to make it at a proper location (otherwise it will fly randomly)
484467 PacketContainer fakeItemVelocityPacket = PROTOCOL_MANAGER .createPacket (PacketType .Play .Server .ENTITY_VELOCITY );
485468 fakeItemVelocityPacket .getIntegers ()
486469 //Entity ID
@@ -505,11 +488,11 @@ private static PacketContainer createFakeItemDestroyPacket(int entityID) {
505488 //1.17+
506489 MinecraftVersion minecraftVersion = PROTOCOL_MANAGER .getMinecraftVersion ();
507490 if (minecraftVersion .getMajor () == 1 && minecraftVersion .getMinor () == 17 && minecraftVersion .getBuild () == 0 ) {
508- //On 1.17, just need to write an int
491+ //On 1.17, just need to write a int
509492 //Entity to remove
510493 fakeItemDestroyPacket .getIntegers ().write (0 , entityID );
511494 } else {
512- //On 1.17.1 (maybe 1.17.1+? it's enough, Mojang, stop the changes), we need add the int list
495+ //On 1.17.1 (may be 1.17.1+? it's enough, Mojang, stop the changes), we need add the int list
513496 //Entity to remove
514497 try {
515498 fakeItemDestroyPacket .getIntLists ().write (0 , Collections .singletonList (entityID ));
0 commit comments