From 5648f5ea48cbed0b8c2ff87fda4c3741c1f64134 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Tue, 23 Jun 2020 18:00:24 +0200 Subject: [PATCH] Simplified some code --- .../songoda/skyblock/biome/BiomeManager.java | 19 ++++++++++--------- .../skyblock/island/IslandManager.java | 18 ------------------ 2 files changed, 10 insertions(+), 27 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/biome/BiomeManager.java b/src/main/java/com/songoda/skyblock/biome/BiomeManager.java index eec7b5d0..633aa308 100644 --- a/src/main/java/com/songoda/skyblock/biome/BiomeManager.java +++ b/src/main/java/com/songoda/skyblock/biome/BiomeManager.java @@ -1,5 +1,6 @@ package com.songoda.skyblock.biome; +import com.songoda.core.compatibility.ServerVersion; import com.songoda.skyblock.SkyBlock; import com.songoda.skyblock.island.Island; import com.songoda.skyblock.island.IslandEnvironment; @@ -61,19 +62,19 @@ public class BiomeManager { chunkClass = NMSUtil.getNMSClass("Chunk"); } - for (Player all : skyblock.getIslandManager().getPlayersAtIsland(island, IslandWorld.Normal)) { + for (Player player : skyblock.getIslandManager().getPlayersAtIsland(island, IslandWorld.Normal)) { try { - if (NMSUtil.getVersionNumber() < 9) { - NMSUtil.sendPacket(all, + if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9)) { + NMSUtil.sendPacket(player, + packetPlayOutMapChunkClass.getConstructor(chunkClass, int.class).newInstance(player + .getLocation().getChunk().getClass().getMethod("getHandle").invoke(chunk), + 65535)); + } else { + NMSUtil.sendPacket(player, packetPlayOutMapChunkClass.getConstructor(chunkClass, boolean.class, int.class) - .newInstance(all.getLocation().getChunk().getClass().getMethod("getHandle") + .newInstance(player.getLocation().getChunk().getClass().getMethod("getHandle") .invoke(chunk), true, 20)); - return; } - NMSUtil.sendPacket(all, - packetPlayOutMapChunkClass.getConstructor(chunkClass, int.class).newInstance(all - .getLocation().getChunk().getClass().getMethod("getHandle").invoke(chunk), - 65535)); } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) { e.printStackTrace(); diff --git a/src/main/java/com/songoda/skyblock/island/IslandManager.java b/src/main/java/com/songoda/skyblock/island/IslandManager.java index 7eed545d..87bd9195 100644 --- a/src/main/java/com/songoda/skyblock/island/IslandManager.java +++ b/src/main/java/com/songoda/skyblock/island/IslandManager.java @@ -673,24 +673,6 @@ public class IslandManager { }); }); } - - /*new ChunkLoader(island, IslandWorld.Normal, skyblock.isPaperAsync(), (asyncPositions, syncPositions) -> { - if(skyblock.isPaperAsync()){ - Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> { - List positions = new LinkedList<>(); - for (CompletableFuture chunk : asyncPositions) { - positions.add(chunk.join()); - } - snapshots.put(world, positions.stream().map(Chunk::getChunkSnapshot).collect(Collectors.toList())); - ChunkDeleteSplitter.startDeletion(snapshots); - }); - } else { - final List list = syncPositions.stream().map(Chunk::getChunkSnapshot).collect(Collectors.toList()); - - snapshots.put(world, list); - ChunkDeleteSplitter.startDeletion(snapshots); - } - });*/ } }