mirror of
https://github.com/EarthMC/QuickShop-Reremake.git
synced 2026-11-25 01:49:49 -05:00
Replace stream foreach to normal foreach
Former-commit-id: 56642210cf76520af0d11be3cc07303a8e909fba
This commit is contained in:
1 parent
8075aca499
commit
d52f8b89b5
3 files changed
+25
-9
No files matched your search
@@ -48,8 +48,9 @@ public class ChunkListener implements Listener {
|
||||
if (inChunk == null || inChunk.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
//noinspection unchecked
|
||||
Bukkit.getScheduler().runTaskLater(plugin,()-> ((HashMap<Location, Shop>) inChunk.clone()).values().forEach(Shop::onLoad),1);
|
||||
Bukkit.getScheduler().runTaskLater(plugin,()-> {
|
||||
//noinspection unchecked
|
||||
for(Shop shop:((HashMap<Location, Shop>) inChunk.clone()).values()){shop.onLoad();}},1);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
@@ -61,6 +62,6 @@ public class ChunkListener implements Listener {
|
||||
return;
|
||||
}
|
||||
//noinspection unchecked
|
||||
((HashMap<Location, Shop>) inChunk.clone()).values().forEach(Shop::onUnload);
|
||||
for(Shop shop:((HashMap<Location, Shop>) inChunk.clone()).values()){shop.onUnload();};
|
||||
}
|
||||
}
|
||||
@@ -27,18 +27,23 @@ import com.comphenix.protocol.events.PacketContainer;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.maxgamer.quickshop.QuickShop;
|
||||
import org.maxgamer.quickshop.Util.Util;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ConcurrentSkipListSet;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -82,7 +87,7 @@ public class VirtualDisplayItem extends DisplayItem {
|
||||
protocolManager.removePacketListener(this);
|
||||
return;
|
||||
}
|
||||
if (!isDisplay || !isFull || !Util.isLoaded(shop.getLocation())) {
|
||||
if (!shop.isLoaded()||!isDisplay || !isFull || !Util.isLoaded(shop.getLocation())) {
|
||||
return;
|
||||
}
|
||||
//chunk x
|
||||
@@ -92,10 +97,18 @@ public class VirtualDisplayItem extends DisplayItem {
|
||||
|
||||
//send the packet later to prevent chunk loading deadlock
|
||||
plugin.getServer().getScheduler().runTaskLater(plugin, () -> {
|
||||
if (shop.isLoaded()
|
||||
&& shop.getLocation().getWorld().getName().equals(event.getPlayer().getWorld().getName())
|
||||
&& shop.getLocation().getChunk().getX() == x
|
||||
&& shop.getLocation().getChunk().getZ() == z) {
|
||||
World world=shop.getLocation().getWorld();
|
||||
Chunk chunk;
|
||||
CompletableFuture<Chunk> chunkCompletableFuture=new CompletableFuture<>();
|
||||
QuickShop.instance.getBukkitAPIWrapper().getChunkAt(world,shop.getLocation(),chunkCompletableFuture);
|
||||
try {
|
||||
chunk=chunkCompletableFuture.get();
|
||||
} catch (InterruptedException | ExecutionException ignore) {
|
||||
return;
|
||||
}
|
||||
if(world.getName().equals(event.getPlayer().getWorld().getName())
|
||||
&& chunk.getX() == x
|
||||
&& chunk.getZ() == z) {
|
||||
packetSenders.add(event.getPlayer().getUniqueId());
|
||||
sendFakeItem(event.getPlayer());
|
||||
}
|
||||
|
||||
@@ -60,7 +60,9 @@ public class DisplayWatcher {
|
||||
// if (!Util.isLoaded(shop.getLocation())) {
|
||||
// continue;
|
||||
// }
|
||||
plugin.getShopManager().getLoadedShops().forEach(Shop::checkDisplay);
|
||||
for (Shop shop : plugin.getShopManager().getLoadedShops()) {
|
||||
shop.checkDisplay();
|
||||
}
|
||||
}
|
||||
}.runTaskTimer(plugin, 1L, plugin.getDisplayItemCheckTicks());
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user