Skip to content

Commit e87d3bb

Browse files
committed
fix: rework onChunkLoad
1 parent ea0515f commit e87d3bb

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

spigot/src/main/java/com/sekwah/advancedportals/spigot/Listeners.java

+16-16
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
import com.sekwah.advancedportals.spigot.connector.container.SpigotPlayerContainer;
1010
import com.sekwah.advancedportals.spigot.connector.container.SpigotWorldContainer;
1111
import com.sekwah.advancedportals.spigot.utils.ContainerHelpers;
12+
13+
import java.util.Arrays;
1214
import java.util.List;
1315
import org.bukkit.Location;
1416
import org.bukkit.Material;
@@ -232,21 +234,19 @@ public void onChunkLoad(ChunkLoadEvent event) {
232234
if (!configRepository.getDisableGatewayBeam()) {
233235
return;
234236
}
235-
SpigotWorldContainer world = new SpigotWorldContainer(event.getWorld());
236-
BlockState[] tileEntities = event.getChunk().getTileEntities();
237-
for (BlockState block : tileEntities) {
238-
if (block.getType() == Material.END_GATEWAY) {
239-
Location loc = block.getLocation();
240-
if (portalServices.inPortalRegion(
241-
new BlockLocation(loc.getWorld().getName(),
242-
loc.getBlockX(), loc.getBlockY(),
243-
loc.getBlockZ()),
244-
2)) {
245-
EndGateway tileState = (EndGateway) block;
246-
tileState.setAge(Long.MIN_VALUE);
247-
tileState.update();
248-
}
249-
}
250-
}
237+
Arrays.stream(event.getChunk().getTileEntities())
238+
.filter(blockState -> blockState.getType() == Material.END_GATEWAY)
239+
.forEach(endGatewayPortal -> {
240+
Location loc = endGatewayPortal.getLocation();
241+
if (portalServices.inPortalRegion(
242+
new BlockLocation(loc.getWorld().getName(),
243+
loc.getBlockX(), loc.getBlockY(),
244+
loc.getBlockZ()),
245+
2)) {
246+
EndGateway tileState = (EndGateway) endGatewayPortal;
247+
tileState.setAge(Long.MIN_VALUE);
248+
tileState.update();
249+
}
250+
});
251251
}
252252
}

0 commit comments

Comments
 (0)