diff --git a/build.gradle.kts b/build.gradle.kts index 2a74cef1..5a1604fb 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,7 +1,7 @@ import java.util.* @Suppress("PropertyName") -var VERSION = "3.4.0.14" +var VERSION = "3.4.1.0" plugins { // needed for the subprojects section to work id("java") diff --git a/spigot-nms/api/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/NMSChunk.java b/spigot-nms/api/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/NMSChunk.java index 228ce537..d984f765 100644 --- a/spigot-nms/api/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/NMSChunk.java +++ b/spigot-nms/api/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/NMSChunk.java @@ -1,12 +1,14 @@ package com.kamikazejam.kamicommon.nms.wrappers.chunk; import com.kamikazejam.kamicommon.nms.wrappers.NMSObject; +import org.bukkit.Chunk; import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; @SuppressWarnings("unused") public interface NMSChunk extends NMSObject { @NotNull NMSChunkProvider getNMSChunkProvider(); + @NotNull Chunk getBukkitChunk(); @NotNull NMSChunkSection getSection(int y); diff --git a/spigot-nms/api/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/NMSChunkProvider.java b/spigot-nms/api/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/NMSChunkProvider.java index 85cfaae2..c6a90a5a 100644 --- a/spigot-nms/api/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/NMSChunkProvider.java +++ b/spigot-nms/api/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/NMSChunkProvider.java @@ -18,9 +18,6 @@ default void setForceChunkLoad(boolean value) { // Do nothing (most versions can't change this) } - @NotNull - NMSChunk getOrCreateChunk(int x, int z); - void saveChunk(@NotNull NMSChunk chunk); @NotNull diff --git a/spigot-nms/api/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/impl/NMSChunkDef.java b/spigot-nms/api/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/impl/NMSChunkDef.java index 18fe32d6..376474b2 100644 --- a/spigot-nms/api/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/impl/NMSChunkDef.java +++ b/spigot-nms/api/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/impl/NMSChunkDef.java @@ -1,11 +1,17 @@ package com.kamikazejam.kamicommon.nms.wrappers.chunk.impl; +import com.cryptomorin.xseries.XMaterial; +import com.kamikazejam.kamicommon.nms.abstraction.block.PlaceType; import com.kamikazejam.kamicommon.nms.wrappers.chunk.NMSChunk; +import com.kamikazejam.kamicommon.nms.wrappers.world.NMSWorld; import org.bukkit.Bukkit; +import org.bukkit.Chunk; +import org.bukkit.Material; import org.bukkit.World; +import org.bukkit.block.Block; import org.bukkit.entity.Player; -import org.jetbrains.annotations.ApiStatus; +@SuppressWarnings("unused") public interface NMSChunkDef extends NMSChunk { @Override @@ -16,8 +22,24 @@ default void saveAndRefresh(boolean withUpdatePackets) { // Create a default inside this internal interface, to not expose this method @SuppressWarnings("deprecation") default void saveAndRefreshI(boolean withUpdatePackets) { - World world = this.getNMSChunkProvider().getNMSWorld().getBukkitWorld(); + // Higher versions are lazy about saving chunks, relying on dirty flags + // We can set one block in the chunk in order to flag it as dirty, ensuring it saves + // We select a block at the minimum y, since it's likely to be BEDROCK + // Technically if there is a block data type here it will get overwritten, but this is unlikely + NMSWorld nmsWorld = this.getNMSChunkProvider().getNMSWorld(); + Chunk chunk = this.getBukkitChunk(); + int minY = nmsWorld.getMinHeight(); + + // Update, then revert the block (sufficient to trigger a 'dirty' state for this chunk) + Block block = chunk.getBlock(0, minY, 0); + Material prev = block.getType(); + nmsWorld.getBlockUtil().setBlockSuperFast(block, XMaterial.AIR, PlaceType.NMS); + nmsWorld.getBlockUtil().setBlockSuperFast(block, XMaterial.matchXMaterial(prev), PlaceType.NMS); + + // Refresh the chunk + World world = chunk.getWorld(); world.refreshChunk(this.getX(), this.getZ()); + // Use the unload method with save world.unloadChunk(this.getX(), this.getZ(), true); diff --git a/spigot-nms/api/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld.java b/spigot-nms/api/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld.java index c57602af..e57493be 100644 --- a/spigot-nms/api/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld.java +++ b/spigot-nms/api/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld.java @@ -1,5 +1,6 @@ package com.kamikazejam.kamicommon.nms.wrappers.world; +import com.kamikazejam.kamicommon.nms.abstraction.block.AbstractBlockUtil; import com.kamikazejam.kamicommon.nms.wrappers.NMSObject; import com.kamikazejam.kamicommon.nms.wrappers.chunk.NMSChunkProvider; import org.bukkit.Location; @@ -21,4 +22,8 @@ public interface NMSWorld extends NMSObject { @NotNull T spawnEntity(@NotNull Location loc, @NotNull Class clazz, @NotNull CreatureSpawnEvent.SpawnReason reason); + + // Internal API method + @NotNull + AbstractBlockUtil getBlockUtil(); } diff --git a/spigot-nms/src/main/java/com/kamikazejam/kamicommon/nms/wrapper/NMSWorldWrapper.java b/spigot-nms/src/main/java/com/kamikazejam/kamicommon/nms/wrapper/NMSWorldWrapper.java index 44822bd9..7c305ec6 100644 --- a/spigot-nms/src/main/java/com/kamikazejam/kamicommon/nms/wrapper/NMSWorldWrapper.java +++ b/spigot-nms/src/main/java/com/kamikazejam/kamicommon/nms/wrapper/NMSWorldWrapper.java @@ -1,5 +1,6 @@ package com.kamikazejam.kamicommon.nms.wrapper; +import com.kamikazejam.kamicommon.nms.NmsAPI; import com.kamikazejam.kamicommon.nms.wrappers.NMSWrapper; import com.kamikazejam.kamicommon.nms.wrappers.world.*; import org.bukkit.World; @@ -14,55 +15,55 @@ public class NMSWorldWrapper extends NMSWrapper { } if (ver == f("1.8")) { - return new NMSWorld_1_8_R1(world); + return new NMSWorld_1_8_R1(world, NmsAPI.getBlockUtilProvider()); }else if (ver <= f("1.8.3")) { - return new NMSWorld_1_8_R2(world); + return new NMSWorld_1_8_R2(world, NmsAPI.getBlockUtilProvider()); }else if (ver <= f("1.8.8")) { - return new NMSWorld_1_8_R3(world); + return new NMSWorld_1_8_R3(world, NmsAPI.getBlockUtilProvider()); }else if (ver <= f("1.9.2")) { - return new NMSWorld_1_9_R1(world); + return new NMSWorld_1_9_R1(world, NmsAPI.getBlockUtilProvider()); }else if (ver <= f("1.9.4")) { - return new NMSWorld_1_9_R2(world); + return new NMSWorld_1_9_R2(world, NmsAPI.getBlockUtilProvider()); }else if (ver <= f("1.10.2")) { - return new NMSWorld_1_10_R1(world); + return new NMSWorld_1_10_R1(world, NmsAPI.getBlockUtilProvider()); }else if (ver <= f("1.11.2")) { - return new NMSWorld_1_11_R1(world); + return new NMSWorld_1_11_R1(world, NmsAPI.getBlockUtilProvider()); }else if (ver <= f("1.12.2")) { - return new NMSWorld_1_12_R1(world); + return new NMSWorld_1_12_R1(world, NmsAPI.getBlockUtilProvider()); }else if (ver <= f("1.13")) { - return new NMSWorld_1_13_R1(world); + return new NMSWorld_1_13_R1(world, NmsAPI.getBlockUtilProvider()); }else if (ver <= f("1.13.2")) { - return new NMSWorld_1_13_R2(world); + return new NMSWorld_1_13_R2(world, NmsAPI.getBlockUtilProvider()); }else if (ver <= f("1.14.4")) { - return new NMSWorld_1_14_R1(world); + return new NMSWorld_1_14_R1(world, NmsAPI.getBlockUtilProvider()); }else if (ver <= f("1.15.2")) { - return new NMSWorld_1_15_R1(world); + return new NMSWorld_1_15_R1(world, NmsAPI.getBlockUtilProvider()); }else if (ver <= f("1.16.1")) { - return new NMSWorld_1_16_R1(world); + return new NMSWorld_1_16_R1(world, NmsAPI.getBlockUtilProvider()); }else if (ver <= f("1.16.3")) { - return new NMSWorld_1_16_R2(world); + return new NMSWorld_1_16_R2(world, NmsAPI.getBlockUtilProvider()); }else if (ver <= f("1.16.5")) { - return new NMSWorld_1_16_R3(world); + return new NMSWorld_1_16_R3(world, NmsAPI.getBlockUtilProvider()); }else if (ver <= f("1.17.1")) { - return new NMSWorld_1_17_R1(world); + return new NMSWorld_1_17_R1(world, NmsAPI.getBlockUtilProvider()); }else if (ver <= f("1.18.1")) { - return new NMSWorld_1_18_R1(world); + return new NMSWorld_1_18_R1(world, NmsAPI.getBlockUtilProvider()); }else if (ver <= f("1.18.2")) { - return new NMSWorld_1_18_R2(world); + return new NMSWorld_1_18_R2(world, NmsAPI.getBlockUtilProvider()); }else if (ver <= f("1.19.2")) { - return new NMSWorld_1_19_R1(world); + return new NMSWorld_1_19_R1(world, NmsAPI.getBlockUtilProvider()); }else if (ver <= f("1.19.3")) { - return new NMSWorld_1_19_R2(world); + return new NMSWorld_1_19_R2(world, NmsAPI.getBlockUtilProvider()); }else if (ver <= f("1.19.4")) { - return new NMSWorld_1_19_R3(world); + return new NMSWorld_1_19_R3(world, NmsAPI.getBlockUtilProvider()); }else if (ver <= f("1.20.1")) { - return new NMSWorld_1_20_R1(world); + return new NMSWorld_1_20_R1(world, NmsAPI.getBlockUtilProvider()); }else if (ver <= f("1.20.2")) { - return new NMSWorld_1_20_R2(world); + return new NMSWorld_1_20_R2(world, NmsAPI.getBlockUtilProvider()); }else if (ver <= f("1.20.4")) { - return new NMSWorld_1_20_R3(world); + return new NMSWorld_1_20_R3(world, NmsAPI.getBlockUtilProvider()); } // With the mojang-mapped paper nms now, we might be good to use this version indefinitely - return new NMSWorld_1_21_CB(world); // Confirmed for 1.20.5, 1.20.6, 1.21 + return new NMSWorld_1_21_CB(world, NmsAPI.getBlockUtilProvider()); // Confirmed for 1.20.5, 1.20.6, 1.21 } } diff --git a/spigot-nms/v1_10_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_10_R1.java b/spigot-nms/v1_10_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_10_R1.java index d1321e28..c6aa4b3a 100644 --- a/spigot-nms/v1_10_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_10_R1.java +++ b/spigot-nms/v1_10_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_10_R1.java @@ -4,7 +4,6 @@ import com.kamikazejam.kamicommon.nms.wrappers.world.NMSWorld_1_10_R1; import net.minecraft.server.v1_10_R1.Chunk; import net.minecraft.server.v1_10_R1.ChunkProviderServer; -import org.bukkit.craftbukkit.v1_10_R1.CraftChunk; import org.jetbrains.annotations.NotNull; public class ChunkProvider_1_10_R1 implements NMSChunkProvider { @@ -25,11 +24,6 @@ public ChunkProvider_1_10_R1(@NotNull NMSWorld_1_10_R1 world, @NotNull ChunkProv return this.handle; } - @Override - public @NotNull NMSChunk getOrCreateChunk(int x, int z) { - return new Chunk_1_10_R1(this, this.handle.getChunkAt(x, z)); - } - @Override public void saveChunk(NMSChunk chunk) { this.handle.saveChunk((Chunk) chunk.getHandle()); @@ -37,6 +31,6 @@ public void saveChunk(NMSChunk chunk) { @Override public @NotNull NMSChunk wrap(org.bukkit.@NotNull Chunk chunk) { - return new Chunk_1_10_R1(this, ((CraftChunk) chunk).getHandle()); + return new Chunk_1_10_R1(this, chunk); } } diff --git a/spigot-nms/v1_10_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_10_R1.java b/spigot-nms/v1_10_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_10_R1.java index 517fc643..cdc54a61 100644 --- a/spigot-nms/v1_10_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_10_R1.java +++ b/spigot-nms/v1_10_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_10_R1.java @@ -4,16 +4,19 @@ import net.minecraft.server.v1_10_R1.Chunk; import net.minecraft.server.v1_10_R1.ChunkSection; import net.minecraft.server.v1_10_R1.PacketPlayOutMapChunk; +import org.bukkit.craftbukkit.v1_10_R1.CraftChunk; import org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer; import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; public class Chunk_1_10_R1 implements NMSChunkDef { private final @NotNull ChunkProvider_1_10_R1 provider; + private final @NotNull org.bukkit.Chunk bukkitChunk; private final @NotNull Chunk chunk; - public Chunk_1_10_R1(@NotNull ChunkProvider_1_10_R1 provider, @NotNull Chunk chunk) { + public Chunk_1_10_R1(@NotNull ChunkProvider_1_10_R1 provider, @NotNull org.bukkit.Chunk bukkitChunk) { this.provider = provider; - this.chunk = chunk; + this.bukkitChunk = bukkitChunk; + this.chunk = ((CraftChunk) bukkitChunk).getHandle(); } @Override @@ -21,6 +24,11 @@ public Chunk_1_10_R1(@NotNull ChunkProvider_1_10_R1 provider, @NotNull Chunk chu return this.provider; } + @Override + public @NotNull org.bukkit.Chunk getBukkitChunk() { + return bukkitChunk; + } + @Override public @NotNull Object getHandle() { return this.chunk; diff --git a/spigot-nms/v1_10_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_10_R1.java b/spigot-nms/v1_10_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_10_R1.java index 6bb298bc..8a94c280 100644 --- a/spigot-nms/v1_10_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_10_R1.java +++ b/spigot-nms/v1_10_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_10_R1.java @@ -1,5 +1,7 @@ package com.kamikazejam.kamicommon.nms.wrappers.world; +import com.kamikazejam.kamicommon.nms.abstraction.block.AbstractBlockUtil; +import com.kamikazejam.kamicommon.nms.provider.Provider; import com.kamikazejam.kamicommon.nms.wrappers.chunk.ChunkProvider_1_10_R1; import com.kamikazejam.kamicommon.nms.wrappers.chunk.NMSChunkProvider; import lombok.Getter; @@ -20,10 +22,12 @@ public class NMSWorld_1_10_R1 implements NMSWorld { private final @NotNull World bukkitWorld; private final @NotNull WorldServer worldServer; private final @NotNull CraftWorld craftWorld; - public NMSWorld_1_10_R1(@NotNull World world) { + private final @NotNull Provider provider; + public NMSWorld_1_10_R1(@NotNull World world, @NotNull Provider provider) { this.bukkitWorld = world; this.craftWorld = (CraftWorld) world; this.worldServer = this.craftWorld.getHandle(); + this.provider = provider; } @Override @@ -31,6 +35,11 @@ public NMSWorld_1_10_R1(@NotNull World world) { return this.worldServer; } + @Override + public @NotNull AbstractBlockUtil getBlockUtil() { + return this.provider.get(); + } + @Override public int getMinHeight() { return 0; diff --git a/spigot-nms/v1_11_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_11_R1.java b/spigot-nms/v1_11_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_11_R1.java index 164fb2db..9b1c0ba0 100644 --- a/spigot-nms/v1_11_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_11_R1.java +++ b/spigot-nms/v1_11_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_11_R1.java @@ -4,7 +4,6 @@ import com.kamikazejam.kamicommon.nms.wrappers.world.NMSWorld_1_11_R1; import net.minecraft.server.v1_11_R1.Chunk; import net.minecraft.server.v1_11_R1.ChunkProviderServer; -import org.bukkit.craftbukkit.v1_11_R1.CraftChunk; import org.jetbrains.annotations.NotNull; public class ChunkProvider_1_11_R1 implements NMSChunkProvider { @@ -25,11 +24,6 @@ public ChunkProvider_1_11_R1(@NotNull NMSWorld_1_11_R1 world, @NotNull ChunkProv return this.handle; } - @Override - public @NotNull NMSChunk getOrCreateChunk(int x, int z) { - return new Chunk_1_11_R1(this, this.handle.getChunkAt(x, z)); - } - @Override public void saveChunk(NMSChunk chunk) { this.handle.saveChunk((Chunk) chunk.getHandle()); @@ -37,6 +31,6 @@ public void saveChunk(NMSChunk chunk) { @Override public @NotNull NMSChunk wrap(org.bukkit.@NotNull Chunk chunk) { - return new Chunk_1_11_R1(this, ((CraftChunk) chunk).getHandle()); + return new Chunk_1_11_R1(this, chunk); } } diff --git a/spigot-nms/v1_11_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_11_R1.java b/spigot-nms/v1_11_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_11_R1.java index 87650113..efd9a698 100644 --- a/spigot-nms/v1_11_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_11_R1.java +++ b/spigot-nms/v1_11_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_11_R1.java @@ -4,16 +4,19 @@ import net.minecraft.server.v1_11_R1.Chunk; import net.minecraft.server.v1_11_R1.ChunkSection; import net.minecraft.server.v1_11_R1.PacketPlayOutMapChunk; +import org.bukkit.craftbukkit.v1_11_R1.CraftChunk; import org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer; import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; public class Chunk_1_11_R1 implements NMSChunkDef { private final @NotNull ChunkProvider_1_11_R1 provider; + private final @NotNull org.bukkit.Chunk bukkitChunk; private final @NotNull Chunk chunk; - public Chunk_1_11_R1(@NotNull ChunkProvider_1_11_R1 provider, @NotNull Chunk chunk) { + public Chunk_1_11_R1(@NotNull ChunkProvider_1_11_R1 provider, @NotNull org.bukkit.Chunk bukkitChunk) { this.provider = provider; - this.chunk = chunk; + this.bukkitChunk = bukkitChunk; + this.chunk = ((CraftChunk) bukkitChunk).getHandle(); } @Override @@ -21,6 +24,11 @@ public Chunk_1_11_R1(@NotNull ChunkProvider_1_11_R1 provider, @NotNull Chunk chu return this.chunk; } + @Override + public @NotNull org.bukkit.Chunk getBukkitChunk() { + return bukkitChunk; + } + @Override public @NotNull NMSChunkProvider getNMSChunkProvider() { return this.provider; diff --git a/spigot-nms/v1_11_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_11_R1.java b/spigot-nms/v1_11_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_11_R1.java index 67926ecd..d1f16c6a 100644 --- a/spigot-nms/v1_11_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_11_R1.java +++ b/spigot-nms/v1_11_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_11_R1.java @@ -1,5 +1,7 @@ package com.kamikazejam.kamicommon.nms.wrappers.world; +import com.kamikazejam.kamicommon.nms.abstraction.block.AbstractBlockUtil; +import com.kamikazejam.kamicommon.nms.provider.Provider; import com.kamikazejam.kamicommon.nms.wrappers.chunk.ChunkProvider_1_11_R1; import com.kamikazejam.kamicommon.nms.wrappers.chunk.NMSChunkProvider; import lombok.Getter; @@ -20,10 +22,12 @@ public class NMSWorld_1_11_R1 implements NMSWorld { private final @NotNull World bukkitWorld; private final @NotNull WorldServer worldServer; private final @NotNull CraftWorld craftWorld; - public NMSWorld_1_11_R1(@NotNull World world) { + private final @NotNull Provider provider; + public NMSWorld_1_11_R1(@NotNull World world, @NotNull Provider provider) { this.bukkitWorld = world; this.craftWorld = (CraftWorld) world; this.worldServer = this.craftWorld.getHandle(); + this.provider = provider; } @Override @@ -31,6 +35,11 @@ public NMSWorld_1_11_R1(@NotNull World world) { return this.worldServer; } + @Override + public @NotNull AbstractBlockUtil getBlockUtil() { + return this.provider.get(); + } + @Override public int getMinHeight() { return 0; diff --git a/spigot-nms/v1_12_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_12_R1.java b/spigot-nms/v1_12_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_12_R1.java index bab2b9ef..bcb8db9b 100644 --- a/spigot-nms/v1_12_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_12_R1.java +++ b/spigot-nms/v1_12_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_12_R1.java @@ -4,7 +4,6 @@ import com.kamikazejam.kamicommon.nms.wrappers.world.NMSWorld_1_12_R1; import net.minecraft.server.v1_12_R1.Chunk; import net.minecraft.server.v1_12_R1.ChunkProviderServer; -import org.bukkit.craftbukkit.v1_12_R1.CraftChunk; import org.jetbrains.annotations.NotNull; public class ChunkProvider_1_12_R1 implements NMSChunkProvider { @@ -25,11 +24,6 @@ public ChunkProvider_1_12_R1(@NotNull NMSWorld_1_12_R1 world, @NotNull ChunkProv return this.world; } - @Override - public @NotNull NMSChunk getOrCreateChunk(int x, int z) { - return new Chunk_1_12_R1(this, this.handle.getChunkAt(x, z)); - } - @Override public void saveChunk(NMSChunk chunk) { this.handle.saveChunk((Chunk) chunk.getHandle(), false); @@ -37,6 +31,6 @@ public void saveChunk(NMSChunk chunk) { @Override public @NotNull NMSChunk wrap(org.bukkit.@NotNull Chunk chunk) { - return new Chunk_1_12_R1(this, ((CraftChunk) chunk).getHandle()); + return new Chunk_1_12_R1(this, chunk); } } diff --git a/spigot-nms/v1_12_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_12_R1.java b/spigot-nms/v1_12_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_12_R1.java index c19e988b..0f830235 100644 --- a/spigot-nms/v1_12_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_12_R1.java +++ b/spigot-nms/v1_12_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_12_R1.java @@ -4,16 +4,19 @@ import net.minecraft.server.v1_12_R1.Chunk; import net.minecraft.server.v1_12_R1.ChunkSection; import net.minecraft.server.v1_12_R1.PacketPlayOutMapChunk; +import org.bukkit.craftbukkit.v1_12_R1.CraftChunk; import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer; import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; public class Chunk_1_12_R1 implements NMSChunkDef { private final @NotNull ChunkProvider_1_12_R1 provider; + private final @NotNull org.bukkit.Chunk bukkitChunk; private final @NotNull Chunk chunk; - public Chunk_1_12_R1(@NotNull ChunkProvider_1_12_R1 provider, @NotNull Chunk chunk) { + public Chunk_1_12_R1(@NotNull ChunkProvider_1_12_R1 provider, @NotNull org.bukkit.Chunk bukkitChunk) { this.provider = provider; - this.chunk = chunk; + this.bukkitChunk = bukkitChunk; + this.chunk = ((CraftChunk) bukkitChunk).getHandle(); } @Override @@ -21,6 +24,11 @@ public Chunk_1_12_R1(@NotNull ChunkProvider_1_12_R1 provider, @NotNull Chunk chu return this.provider; } + @Override + public @NotNull org.bukkit.Chunk getBukkitChunk() { + return bukkitChunk; + } + @Override public @NotNull Object getHandle() { return this.chunk; diff --git a/spigot-nms/v1_12_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_12_R1.java b/spigot-nms/v1_12_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_12_R1.java index 0d38ee36..1304b5a2 100644 --- a/spigot-nms/v1_12_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_12_R1.java +++ b/spigot-nms/v1_12_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_12_R1.java @@ -1,5 +1,7 @@ package com.kamikazejam.kamicommon.nms.wrappers.world; +import com.kamikazejam.kamicommon.nms.abstraction.block.AbstractBlockUtil; +import com.kamikazejam.kamicommon.nms.provider.Provider; import com.kamikazejam.kamicommon.nms.wrappers.chunk.ChunkProvider_1_12_R1; import com.kamikazejam.kamicommon.nms.wrappers.chunk.NMSChunkProvider; import lombok.Getter; @@ -20,10 +22,17 @@ public class NMSWorld_1_12_R1 implements NMSWorld { private final @NotNull World bukkitWorld; private final @NotNull WorldServer worldServer; private final @NotNull CraftWorld craftWorld; - public NMSWorld_1_12_R1(@NotNull World world) { + private final @NotNull Provider provider; + public NMSWorld_1_12_R1(@NotNull World world, @NotNull Provider provider) { this.bukkitWorld = world; this.craftWorld = (CraftWorld) world; this.worldServer = this.craftWorld.getHandle(); + this.provider = provider; + } + + @Override + public @NotNull AbstractBlockUtil getBlockUtil() { + return this.provider.get(); } @Override diff --git a/spigot-nms/v1_13_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_13_R1.java b/spigot-nms/v1_13_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_13_R1.java index 0cdc02ba..1e6e2478 100644 --- a/spigot-nms/v1_13_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_13_R1.java +++ b/spigot-nms/v1_13_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_13_R1.java @@ -4,7 +4,6 @@ import com.kamikazejam.kamicommon.nms.wrappers.world.NMSWorld_1_13_R1; import net.minecraft.server.v1_13_R1.Chunk; import net.minecraft.server.v1_13_R1.ChunkProviderServer; -import org.bukkit.craftbukkit.v1_13_R1.CraftChunk; import org.jetbrains.annotations.NotNull; public class ChunkProvider_1_13_R1 implements NMSChunkProvider { @@ -25,11 +24,6 @@ public ChunkProvider_1_13_R1(@NotNull NMSWorld_1_13_R1 world, @NotNull ChunkProv return this.handle; } - @Override - public @NotNull NMSChunk getOrCreateChunk(int x, int z) { - return new Chunk_1_13_R1(this, this.handle.getChunkAt(x, z)); - } - @Override public void saveChunk(NMSChunk chunk) { this.handle.saveChunk((Chunk) chunk.getHandle(), false); @@ -37,6 +31,6 @@ public void saveChunk(NMSChunk chunk) { @Override public @NotNull NMSChunk wrap(org.bukkit.@NotNull Chunk chunk) { - return new Chunk_1_13_R1(this, ((CraftChunk) chunk).getHandle()); + return new Chunk_1_13_R1(this, chunk); } } diff --git a/spigot-nms/v1_13_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_13_R1.java b/spigot-nms/v1_13_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_13_R1.java index b86a4514..4850bdc8 100644 --- a/spigot-nms/v1_13_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_13_R1.java +++ b/spigot-nms/v1_13_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_13_R1.java @@ -4,16 +4,19 @@ import net.minecraft.server.v1_13_R1.Chunk; import net.minecraft.server.v1_13_R1.ChunkSection; import net.minecraft.server.v1_13_R1.PacketPlayOutMapChunk; +import org.bukkit.craftbukkit.v1_13_R1.CraftChunk; import org.bukkit.craftbukkit.v1_13_R1.entity.CraftPlayer; import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; public class Chunk_1_13_R1 implements NMSChunkDef { private final @NotNull ChunkProvider_1_13_R1 provider; + private final @NotNull org.bukkit.Chunk bukkitChunk; private final @NotNull Chunk chunk; - public Chunk_1_13_R1(@NotNull ChunkProvider_1_13_R1 provider, @NotNull Chunk chunk) { + public Chunk_1_13_R1(@NotNull ChunkProvider_1_13_R1 provider, @NotNull org.bukkit.Chunk bukkitChunk) { this.provider = provider; - this.chunk = chunk; + this.bukkitChunk = bukkitChunk; + this.chunk = ((CraftChunk) bukkitChunk).getHandle(); } @Override @@ -21,6 +24,11 @@ public Chunk_1_13_R1(@NotNull ChunkProvider_1_13_R1 provider, @NotNull Chunk chu return this.provider; } + @Override + public @NotNull org.bukkit.Chunk getBukkitChunk() { + return bukkitChunk; + } + @Override public @NotNull Object getHandle() { return this.chunk; diff --git a/spigot-nms/v1_13_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_13_R1.java b/spigot-nms/v1_13_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_13_R1.java index 48ec68a3..a061bb62 100644 --- a/spigot-nms/v1_13_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_13_R1.java +++ b/spigot-nms/v1_13_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_13_R1.java @@ -1,5 +1,7 @@ package com.kamikazejam.kamicommon.nms.wrappers.world; +import com.kamikazejam.kamicommon.nms.abstraction.block.AbstractBlockUtil; +import com.kamikazejam.kamicommon.nms.provider.Provider; import com.kamikazejam.kamicommon.nms.wrappers.chunk.ChunkProvider_1_13_R1; import com.kamikazejam.kamicommon.nms.wrappers.chunk.NMSChunkProvider; import lombok.Getter; @@ -20,10 +22,12 @@ public class NMSWorld_1_13_R1 implements NMSWorld { private final @NotNull World bukkitWorld; private final @NotNull WorldServer worldServer; private final @NotNull CraftWorld craftWorld; - public NMSWorld_1_13_R1(@NotNull World world) { + private final @NotNull Provider provider; + public NMSWorld_1_13_R1(@NotNull World world, @NotNull Provider provider) { this.bukkitWorld = world; this.craftWorld = (CraftWorld) world; this.worldServer = this.craftWorld.getHandle(); + this.provider = provider; } @Override @@ -31,6 +35,11 @@ public NMSWorld_1_13_R1(@NotNull World world) { return this.worldServer; } + @Override + public @NotNull AbstractBlockUtil getBlockUtil() { + return this.provider.get(); + } + @Override public int getMinHeight() { return 0; diff --git a/spigot-nms/v1_13_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_13_R2.java b/spigot-nms/v1_13_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_13_R2.java index 994c350c..3ec675f9 100644 --- a/spigot-nms/v1_13_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_13_R2.java +++ b/spigot-nms/v1_13_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_13_R2.java @@ -4,11 +4,8 @@ import com.kamikazejam.kamicommon.nms.wrappers.world.NMSWorld_1_13_R2; import net.minecraft.server.v1_13_R2.Chunk; import net.minecraft.server.v1_13_R2.ChunkProviderServer; -import org.bukkit.craftbukkit.v1_13_R2.CraftChunk; import org.jetbrains.annotations.NotNull; -import java.util.Objects; - public class ChunkProvider_1_13_R2 implements NMSChunkProvider { private final @NotNull NMSWorld_1_13_R2 world; private final @NotNull ChunkProviderServer handle; @@ -27,11 +24,6 @@ public ChunkProvider_1_13_R2(@NotNull NMSWorld_1_13_R2 world, @NotNull ChunkProv return this.handle; } - @Override - public @NotNull NMSChunk getOrCreateChunk(int x, int z) { - return new Chunk_1_13_R2(this, Objects.requireNonNull(this.handle.getChunkAt(x, z, true, true))); - } - @Override public void saveChunk(NMSChunk chunk) { this.handle.saveChunk((Chunk) chunk.getHandle(), false); @@ -39,6 +31,6 @@ public void saveChunk(NMSChunk chunk) { @Override public @NotNull NMSChunk wrap(org.bukkit.@NotNull Chunk chunk) { - return new Chunk_1_13_R2(this, ((CraftChunk) chunk).getHandle()); + return new Chunk_1_13_R2(this, chunk); } } diff --git a/spigot-nms/v1_13_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_13_R2.java b/spigot-nms/v1_13_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_13_R2.java index 2c432155..3453c4bf 100644 --- a/spigot-nms/v1_13_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_13_R2.java +++ b/spigot-nms/v1_13_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_13_R2.java @@ -4,16 +4,19 @@ import net.minecraft.server.v1_13_R2.Chunk; import net.minecraft.server.v1_13_R2.ChunkSection; import net.minecraft.server.v1_13_R2.PacketPlayOutMapChunk; +import org.bukkit.craftbukkit.v1_13_R2.CraftChunk; import org.bukkit.craftbukkit.v1_13_R2.entity.CraftPlayer; import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; public class Chunk_1_13_R2 implements NMSChunkDef { private final @NotNull ChunkProvider_1_13_R2 provider; + private final @NotNull org.bukkit.Chunk bukkitChunk; private final @NotNull Chunk chunk; - public Chunk_1_13_R2(@NotNull ChunkProvider_1_13_R2 provider, @NotNull Chunk chunk) { + public Chunk_1_13_R2(@NotNull ChunkProvider_1_13_R2 provider, @NotNull org.bukkit.Chunk bukkitChunk) { this.provider = provider; - this.chunk = chunk; + this.bukkitChunk = bukkitChunk; + this.chunk = ((CraftChunk) bukkitChunk).getHandle(); } @Override @@ -21,6 +24,11 @@ public Chunk_1_13_R2(@NotNull ChunkProvider_1_13_R2 provider, @NotNull Chunk chu return this.provider; } + @Override + public @NotNull org.bukkit.Chunk getBukkitChunk() { + return bukkitChunk; + } + @Override public @NotNull Object getHandle() { return this.chunk; diff --git a/spigot-nms/v1_13_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_13_R2.java b/spigot-nms/v1_13_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_13_R2.java index 2108b475..8f2d8f4f 100644 --- a/spigot-nms/v1_13_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_13_R2.java +++ b/spigot-nms/v1_13_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_13_R2.java @@ -1,5 +1,7 @@ package com.kamikazejam.kamicommon.nms.wrappers.world; +import com.kamikazejam.kamicommon.nms.abstraction.block.AbstractBlockUtil; +import com.kamikazejam.kamicommon.nms.provider.Provider; import com.kamikazejam.kamicommon.nms.wrappers.chunk.ChunkProvider_1_13_R2; import com.kamikazejam.kamicommon.nms.wrappers.chunk.NMSChunkProvider; import lombok.Getter; @@ -20,10 +22,12 @@ public class NMSWorld_1_13_R2 implements NMSWorld { private final @NotNull World bukkitWorld; private final @NotNull WorldServer worldServer; private final @NotNull CraftWorld craftWorld; - public NMSWorld_1_13_R2(@NotNull World world) { + private final @NotNull Provider provider; + public NMSWorld_1_13_R2(@NotNull World world, @NotNull Provider provider) { this.bukkitWorld = world; this.craftWorld = (CraftWorld) world; this.worldServer = this.craftWorld.getHandle(); + this.provider = provider; } @Override @@ -31,6 +35,11 @@ public NMSWorld_1_13_R2(@NotNull World world) { return this.worldServer; } + @Override + public @NotNull AbstractBlockUtil getBlockUtil() { + return this.provider.get(); + } + @Override public int getMinHeight() { return 0; diff --git a/spigot-nms/v1_14_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_14_R1.java b/spigot-nms/v1_14_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_14_R1.java index 5e214064..4ba1710b 100644 --- a/spigot-nms/v1_14_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_14_R1.java +++ b/spigot-nms/v1_14_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_14_R1.java @@ -3,11 +3,8 @@ import com.kamikazejam.kamicommon.nms.wrappers.world.NMSWorld; import com.kamikazejam.kamicommon.nms.wrappers.world.NMSWorld_1_14_R1; import net.minecraft.server.v1_14_R1.ChunkProviderServer; -import org.bukkit.craftbukkit.v1_14_R1.CraftChunk; import org.jetbrains.annotations.NotNull; -import java.util.Objects; - public class ChunkProvider_1_14_R1 implements NMSChunkProvider { private final @NotNull NMSWorld_1_14_R1 world; private final @NotNull ChunkProviderServer handle; @@ -26,17 +23,12 @@ public ChunkProvider_1_14_R1(@NotNull NMSWorld_1_14_R1 world, @NotNull ChunkProv return this.handle; } - @Override - public @NotNull NMSChunk getOrCreateChunk(int x, int z) { - return new Chunk_1_14_R1(this, Objects.requireNonNull(this.handle.getChunkAt(x, z, true))); - } - @Override public void saveChunk(@NotNull NMSChunk chunk) { } @Override public @NotNull NMSChunk wrap(org.bukkit.@NotNull Chunk chunk) { - return new Chunk_1_14_R1(this, ((CraftChunk) chunk).getHandle()); + return new Chunk_1_14_R1(this, chunk); } } diff --git a/spigot-nms/v1_14_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_14_R1.java b/spigot-nms/v1_14_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_14_R1.java index d3866e4f..de4fbb59 100644 --- a/spigot-nms/v1_14_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_14_R1.java +++ b/spigot-nms/v1_14_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_14_R1.java @@ -4,16 +4,19 @@ import net.minecraft.server.v1_14_R1.Chunk; import net.minecraft.server.v1_14_R1.ChunkSection; import net.minecraft.server.v1_14_R1.PacketPlayOutMapChunk; +import org.bukkit.craftbukkit.v1_14_R1.CraftChunk; import org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer; import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; public class Chunk_1_14_R1 implements NMSChunkDef { private final @NotNull ChunkProvider_1_14_R1 provider; + private final @NotNull org.bukkit.Chunk bukkitChunk; private final @NotNull Chunk chunk; - public Chunk_1_14_R1(@NotNull ChunkProvider_1_14_R1 provider, @NotNull Chunk chunk) { + public Chunk_1_14_R1(@NotNull ChunkProvider_1_14_R1 provider, @NotNull org.bukkit.Chunk bukkitChunk) { this.provider = provider; - this.chunk = chunk; + this.bukkitChunk = bukkitChunk; + this.chunk = ((CraftChunk) bukkitChunk).getHandle(); } @Override @@ -21,6 +24,11 @@ public Chunk_1_14_R1(@NotNull ChunkProvider_1_14_R1 provider, @NotNull Chunk chu return this.provider; } + @Override + public @NotNull org.bukkit.Chunk getBukkitChunk() { + return bukkitChunk; + } + @Override public @NotNull Object getHandle() { return this.chunk; diff --git a/spigot-nms/v1_14_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_14_R1.java b/spigot-nms/v1_14_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_14_R1.java index d986e756..4bdfcf04 100644 --- a/spigot-nms/v1_14_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_14_R1.java +++ b/spigot-nms/v1_14_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_14_R1.java @@ -1,5 +1,7 @@ package com.kamikazejam.kamicommon.nms.wrappers.world; +import com.kamikazejam.kamicommon.nms.abstraction.block.AbstractBlockUtil; +import com.kamikazejam.kamicommon.nms.provider.Provider; import com.kamikazejam.kamicommon.nms.wrappers.chunk.ChunkProvider_1_14_R1; import com.kamikazejam.kamicommon.nms.wrappers.chunk.NMSChunkProvider; import lombok.Getter; @@ -20,10 +22,12 @@ public class NMSWorld_1_14_R1 implements NMSWorld { private final @NotNull World bukkitWorld; private final @NotNull WorldServer worldServer; private final @NotNull CraftWorld craftWorld; - public NMSWorld_1_14_R1(@NotNull World world) { + private final @NotNull Provider provider; + public NMSWorld_1_14_R1(@NotNull World world, @NotNull Provider provider) { this.bukkitWorld = world; this.craftWorld = (CraftWorld) world; this.worldServer = this.craftWorld.getHandle(); + this.provider = provider; } @Override @@ -31,6 +35,11 @@ public NMSWorld_1_14_R1(@NotNull World world) { return this.worldServer; } + @Override + public @NotNull AbstractBlockUtil getBlockUtil() { + return this.provider.get(); + } + @Override public int getMinHeight() { return 0; diff --git a/spigot-nms/v1_15_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_15_R1.java b/spigot-nms/v1_15_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_15_R1.java index baced693..5de1f69a 100644 --- a/spigot-nms/v1_15_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_15_R1.java +++ b/spigot-nms/v1_15_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_15_R1.java @@ -3,11 +3,8 @@ import com.kamikazejam.kamicommon.nms.wrappers.world.NMSWorld; import com.kamikazejam.kamicommon.nms.wrappers.world.NMSWorld_1_15_R1; import net.minecraft.server.v1_15_R1.ChunkProviderServer; -import org.bukkit.craftbukkit.v1_15_R1.CraftChunk; import org.jetbrains.annotations.NotNull; -import java.util.Objects; - public class ChunkProvider_1_15_R1 implements NMSChunkProvider { private final @NotNull NMSWorld_1_15_R1 world; private final @NotNull ChunkProviderServer handle; @@ -26,17 +23,12 @@ public ChunkProvider_1_15_R1(@NotNull NMSWorld_1_15_R1 world, @NotNull ChunkProv return this.handle; } - @Override - public @NotNull NMSChunk getOrCreateChunk(int x, int z) { - return new Chunk_1_15_R1(this, Objects.requireNonNull(this.handle.getChunkAt(x, z, true))); - } - @Override public void saveChunk(@NotNull NMSChunk chunk) { } @Override public @NotNull NMSChunk wrap(org.bukkit.@NotNull Chunk chunk) { - return new Chunk_1_15_R1(this, ((CraftChunk) chunk).getHandle()); + return new Chunk_1_15_R1(this, chunk); } } diff --git a/spigot-nms/v1_15_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_15_R1.java b/spigot-nms/v1_15_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_15_R1.java index 42275ffe..3ebe82da 100644 --- a/spigot-nms/v1_15_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_15_R1.java +++ b/spigot-nms/v1_15_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_15_R1.java @@ -4,16 +4,19 @@ import net.minecraft.server.v1_15_R1.Chunk; import net.minecraft.server.v1_15_R1.ChunkSection; import net.minecraft.server.v1_15_R1.PacketPlayOutMapChunk; +import org.bukkit.craftbukkit.v1_15_R1.CraftChunk; import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer; import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; public class Chunk_1_15_R1 implements NMSChunkDef { private final @NotNull ChunkProvider_1_15_R1 provider; + private final @NotNull org.bukkit.Chunk bukkitChunk; private final @NotNull Chunk chunk; - public Chunk_1_15_R1(@NotNull ChunkProvider_1_15_R1 provider, @NotNull Chunk chunk) { + public Chunk_1_15_R1(@NotNull ChunkProvider_1_15_R1 provider, @NotNull org.bukkit.Chunk bukkitChunk) { this.provider = provider; - this.chunk = chunk; + this.bukkitChunk = bukkitChunk; + this.chunk = ((CraftChunk) bukkitChunk).getHandle(); } @Override @@ -21,6 +24,11 @@ public Chunk_1_15_R1(@NotNull ChunkProvider_1_15_R1 provider, @NotNull Chunk chu return this.provider; } + @Override + public @NotNull org.bukkit.Chunk getBukkitChunk() { + return bukkitChunk; + } + @Override public @NotNull Object getHandle() { return this.chunk; diff --git a/spigot-nms/v1_15_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_15_R1.java b/spigot-nms/v1_15_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_15_R1.java index d0f97865..59ec0fc7 100644 --- a/spigot-nms/v1_15_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_15_R1.java +++ b/spigot-nms/v1_15_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_15_R1.java @@ -1,5 +1,7 @@ package com.kamikazejam.kamicommon.nms.wrappers.world; +import com.kamikazejam.kamicommon.nms.abstraction.block.AbstractBlockUtil; +import com.kamikazejam.kamicommon.nms.provider.Provider; import com.kamikazejam.kamicommon.nms.wrappers.chunk.ChunkProvider_1_15_R1; import com.kamikazejam.kamicommon.nms.wrappers.chunk.NMSChunkProvider; import lombok.Getter; @@ -20,10 +22,12 @@ public class NMSWorld_1_15_R1 implements NMSWorld { private final @NotNull World bukkitWorld; private final @NotNull WorldServer worldServer; private final @NotNull CraftWorld craftWorld; - public NMSWorld_1_15_R1(@NotNull World world) { + private final @NotNull Provider provider; + public NMSWorld_1_15_R1(@NotNull World world, @NotNull Provider provider) { this.bukkitWorld = world; this.craftWorld = (CraftWorld) world; this.worldServer = this.craftWorld.getHandle(); + this.provider = provider; } @Override @@ -31,6 +35,11 @@ public NMSWorld_1_15_R1(@NotNull World world) { return this.worldServer; } + @Override + public @NotNull AbstractBlockUtil getBlockUtil() { + return this.provider.get(); + } + @Override public int getMinHeight() { return 0; diff --git a/spigot-nms/v1_16_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_16_R1.java b/spigot-nms/v1_16_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_16_R1.java index 8c2e1d2a..e5588b69 100644 --- a/spigot-nms/v1_16_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_16_R1.java +++ b/spigot-nms/v1_16_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_16_R1.java @@ -3,11 +3,8 @@ import com.kamikazejam.kamicommon.nms.wrappers.world.NMSWorld; import com.kamikazejam.kamicommon.nms.wrappers.world.NMSWorld_1_16_R1; import net.minecraft.server.v1_16_R1.ChunkProviderServer; -import org.bukkit.craftbukkit.v1_16_R1.CraftChunk; import org.jetbrains.annotations.NotNull; -import java.util.Objects; - public class ChunkProvider_1_16_R1 implements NMSChunkProvider { private final @NotNull NMSWorld_1_16_R1 world; private final @NotNull ChunkProviderServer handle; @@ -26,17 +23,12 @@ public ChunkProvider_1_16_R1(@NotNull NMSWorld_1_16_R1 world, @NotNull ChunkProv return this.handle; } - @Override - public @NotNull NMSChunk getOrCreateChunk(int x, int z) { - return new Chunk_1_16_R1(this, Objects.requireNonNull(this.handle.getChunkAt(x, z, true))); - } - @Override public void saveChunk(@NotNull NMSChunk chunk) { } @Override public @NotNull NMSChunk wrap(org.bukkit.@NotNull Chunk chunk) { - return new Chunk_1_16_R1(this, ((CraftChunk) chunk).getHandle()); + return new Chunk_1_16_R1(this, chunk); } } diff --git a/spigot-nms/v1_16_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_16_R1.java b/spigot-nms/v1_16_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_16_R1.java index 9cfd72a9..f81fb76d 100644 --- a/spigot-nms/v1_16_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_16_R1.java +++ b/spigot-nms/v1_16_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_16_R1.java @@ -4,16 +4,19 @@ import net.minecraft.server.v1_16_R1.Chunk; import net.minecraft.server.v1_16_R1.ChunkSection; import net.minecraft.server.v1_16_R1.PacketPlayOutMapChunk; +import org.bukkit.craftbukkit.v1_16_R1.CraftChunk; import org.bukkit.craftbukkit.v1_16_R1.entity.CraftPlayer; import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; public class Chunk_1_16_R1 implements NMSChunkDef { private final @NotNull ChunkProvider_1_16_R1 provider; + private final @NotNull org.bukkit.Chunk bukkitChunk; private final @NotNull Chunk chunk; - public Chunk_1_16_R1(@NotNull ChunkProvider_1_16_R1 provider, @NotNull Chunk chunk) { + public Chunk_1_16_R1(@NotNull ChunkProvider_1_16_R1 provider, @NotNull org.bukkit.Chunk bukkitChunk) { this.provider = provider; - this.chunk = chunk; + this.bukkitChunk = bukkitChunk; + this.chunk = ((CraftChunk) bukkitChunk).getHandle(); } @Override @@ -21,6 +24,11 @@ public Chunk_1_16_R1(@NotNull ChunkProvider_1_16_R1 provider, @NotNull Chunk chu return this.provider; } + @Override + public @NotNull org.bukkit.Chunk getBukkitChunk() { + return bukkitChunk; + } + @Override public @NotNull Object getHandle() { return this.chunk; diff --git a/spigot-nms/v1_16_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_16_R1.java b/spigot-nms/v1_16_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_16_R1.java index 5084f078..e6122fc1 100644 --- a/spigot-nms/v1_16_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_16_R1.java +++ b/spigot-nms/v1_16_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_16_R1.java @@ -1,5 +1,7 @@ package com.kamikazejam.kamicommon.nms.wrappers.world; +import com.kamikazejam.kamicommon.nms.abstraction.block.AbstractBlockUtil; +import com.kamikazejam.kamicommon.nms.provider.Provider; import com.kamikazejam.kamicommon.nms.wrappers.chunk.ChunkProvider_1_16_R1; import com.kamikazejam.kamicommon.nms.wrappers.chunk.NMSChunkProvider; import lombok.Getter; @@ -20,10 +22,12 @@ public class NMSWorld_1_16_R1 implements NMSWorld { private final @NotNull World bukkitWorld; private final @NotNull WorldServer worldServer; private final @NotNull CraftWorld craftWorld; - public NMSWorld_1_16_R1(@NotNull World world) { + private final @NotNull Provider provider; + public NMSWorld_1_16_R1(@NotNull World world, @NotNull Provider provider) { this.bukkitWorld = world; this.craftWorld = (CraftWorld) world; this.worldServer = this.craftWorld.getHandle(); + this.provider = provider; } @Override @@ -31,6 +35,11 @@ public NMSWorld_1_16_R1(@NotNull World world) { return this.worldServer; } + @Override + public @NotNull AbstractBlockUtil getBlockUtil() { + return this.provider.get(); + } + @Override public int getMinHeight() { return 0; diff --git a/spigot-nms/v1_16_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_16_R2.java b/spigot-nms/v1_16_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_16_R2.java index ded6a5d8..0653ef36 100644 --- a/spigot-nms/v1_16_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_16_R2.java +++ b/spigot-nms/v1_16_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_16_R2.java @@ -3,11 +3,8 @@ import com.kamikazejam.kamicommon.nms.wrappers.world.NMSWorld; import com.kamikazejam.kamicommon.nms.wrappers.world.NMSWorld_1_16_R2; import net.minecraft.server.v1_16_R2.ChunkProviderServer; -import org.bukkit.craftbukkit.v1_16_R2.CraftChunk; import org.jetbrains.annotations.NotNull; -import java.util.Objects; - public class ChunkProvider_1_16_R2 implements NMSChunkProvider { private final @NotNull NMSWorld_1_16_R2 world; private final @NotNull ChunkProviderServer handle; @@ -26,17 +23,12 @@ public ChunkProvider_1_16_R2(@NotNull NMSWorld_1_16_R2 world, @NotNull ChunkProv return this.handle; } - @Override - public @NotNull NMSChunk getOrCreateChunk(int x, int z) { - return new Chunk_1_16_R2(this, Objects.requireNonNull(this.handle.getChunkAt(x, z, true))); - } - @Override public void saveChunk(@NotNull NMSChunk chunk) { } @Override public @NotNull NMSChunk wrap(org.bukkit.@NotNull Chunk chunk) { - return new Chunk_1_16_R2(this, ((CraftChunk) chunk).getHandle()); + return new Chunk_1_16_R2(this, chunk); } } diff --git a/spigot-nms/v1_16_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_16_R2.java b/spigot-nms/v1_16_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_16_R2.java index 86872838..5c693d41 100644 --- a/spigot-nms/v1_16_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_16_R2.java +++ b/spigot-nms/v1_16_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_16_R2.java @@ -4,16 +4,19 @@ import net.minecraft.server.v1_16_R2.Chunk; import net.minecraft.server.v1_16_R2.ChunkSection; import net.minecraft.server.v1_16_R2.PacketPlayOutMapChunk; +import org.bukkit.craftbukkit.v1_16_R2.CraftChunk; import org.bukkit.craftbukkit.v1_16_R2.entity.CraftPlayer; import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; public class Chunk_1_16_R2 implements NMSChunkDef { private final @NotNull ChunkProvider_1_16_R2 provider; + private final @NotNull org.bukkit.Chunk bukkitChunk; private final @NotNull Chunk chunk; - public Chunk_1_16_R2(@NotNull ChunkProvider_1_16_R2 provider, @NotNull Chunk chunk) { + public Chunk_1_16_R2(@NotNull ChunkProvider_1_16_R2 provider, @NotNull org.bukkit.Chunk bukkitChunk) { this.provider = provider; - this.chunk = chunk; + this.bukkitChunk = bukkitChunk; + this.chunk = ((CraftChunk) bukkitChunk).getHandle(); } @Override @@ -21,6 +24,11 @@ public Chunk_1_16_R2(@NotNull ChunkProvider_1_16_R2 provider, @NotNull Chunk chu return this.provider; } + @Override + public @NotNull org.bukkit.Chunk getBukkitChunk() { + return bukkitChunk; + } + @Override public @NotNull Object getHandle() { return this.chunk; diff --git a/spigot-nms/v1_16_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_16_R2.java b/spigot-nms/v1_16_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_16_R2.java index c7dc44e5..649d33c0 100644 --- a/spigot-nms/v1_16_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_16_R2.java +++ b/spigot-nms/v1_16_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_16_R2.java @@ -1,5 +1,7 @@ package com.kamikazejam.kamicommon.nms.wrappers.world; +import com.kamikazejam.kamicommon.nms.abstraction.block.AbstractBlockUtil; +import com.kamikazejam.kamicommon.nms.provider.Provider; import com.kamikazejam.kamicommon.nms.wrappers.chunk.ChunkProvider_1_16_R2; import com.kamikazejam.kamicommon.nms.wrappers.chunk.NMSChunkProvider; import lombok.Getter; @@ -20,10 +22,12 @@ public class NMSWorld_1_16_R2 implements NMSWorld { private final @NotNull World bukkitWorld; private final @NotNull WorldServer worldServer; private final @NotNull CraftWorld craftWorld; - public NMSWorld_1_16_R2(@NotNull World world) { + private final @NotNull Provider provider; + public NMSWorld_1_16_R2(@NotNull World world, @NotNull Provider provider) { this.bukkitWorld = world; this.craftWorld = (CraftWorld) world; this.worldServer = this.craftWorld.getHandle(); + this.provider = provider; } @Override @@ -31,6 +35,11 @@ public NMSWorld_1_16_R2(@NotNull World world) { return this.worldServer; } + @Override + public @NotNull AbstractBlockUtil getBlockUtil() { + return this.provider.get(); + } + @Override public int getMinHeight() { return 0; diff --git a/spigot-nms/v1_16_R3/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_16_R3.java b/spigot-nms/v1_16_R3/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_16_R3.java index ee9b82d8..ef6a5f79 100644 --- a/spigot-nms/v1_16_R3/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_16_R3.java +++ b/spigot-nms/v1_16_R3/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_16_R3.java @@ -3,11 +3,8 @@ import com.kamikazejam.kamicommon.nms.wrappers.world.NMSWorld; import com.kamikazejam.kamicommon.nms.wrappers.world.NMSWorld_1_16_R3; import net.minecraft.server.v1_16_R3.ChunkProviderServer; -import org.bukkit.craftbukkit.v1_16_R3.CraftChunk; import org.jetbrains.annotations.NotNull; -import java.util.Objects; - public class ChunkProvider_1_16_R3 implements NMSChunkProvider { private final @NotNull NMSWorld_1_16_R3 world; private final @NotNull ChunkProviderServer handle; @@ -26,17 +23,12 @@ public ChunkProvider_1_16_R3(@NotNull NMSWorld_1_16_R3 world, @NotNull ChunkProv return this.handle; } - @Override - public @NotNull NMSChunk getOrCreateChunk(int x, int z) { - return new Chunk_1_16_R3(this, Objects.requireNonNull(this.handle.getChunkAt(x, z, true))); - } - @Override public void saveChunk(@NotNull NMSChunk chunk) { } @Override public @NotNull NMSChunk wrap(org.bukkit.@NotNull Chunk chunk) { - return new Chunk_1_16_R3(this, ((CraftChunk) chunk).getHandle()); + return new Chunk_1_16_R3(this, chunk); } } diff --git a/spigot-nms/v1_16_R3/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_16_R3.java b/spigot-nms/v1_16_R3/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_16_R3.java index 29a77cf9..4e1dd6ee 100644 --- a/spigot-nms/v1_16_R3/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_16_R3.java +++ b/spigot-nms/v1_16_R3/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_16_R3.java @@ -4,16 +4,19 @@ import net.minecraft.server.v1_16_R3.Chunk; import net.minecraft.server.v1_16_R3.ChunkSection; import net.minecraft.server.v1_16_R3.PacketPlayOutMapChunk; +import org.bukkit.craftbukkit.v1_16_R3.CraftChunk; import org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer; import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; public class Chunk_1_16_R3 implements NMSChunkDef { private final @NotNull ChunkProvider_1_16_R3 provider; + private final @NotNull org.bukkit.Chunk bukkitChunk; private final @NotNull Chunk chunk; - public Chunk_1_16_R3(@NotNull ChunkProvider_1_16_R3 provider, @NotNull Chunk chunk) { + public Chunk_1_16_R3(@NotNull ChunkProvider_1_16_R3 provider, @NotNull org.bukkit.Chunk bukkitChunk) { this.provider = provider; - this.chunk = chunk; + this.bukkitChunk = bukkitChunk; + this.chunk = ((CraftChunk) bukkitChunk).getHandle(); } @Override @@ -21,6 +24,11 @@ public Chunk_1_16_R3(@NotNull ChunkProvider_1_16_R3 provider, @NotNull Chunk chu return this.provider; } + @Override + public @NotNull org.bukkit.Chunk getBukkitChunk() { + return bukkitChunk; + } + @Override public @NotNull Object getHandle() { return this.chunk; diff --git a/spigot-nms/v1_16_R3/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_16_R3.java b/spigot-nms/v1_16_R3/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_16_R3.java index bd50be17..422b5f53 100644 --- a/spigot-nms/v1_16_R3/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_16_R3.java +++ b/spigot-nms/v1_16_R3/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_16_R3.java @@ -1,5 +1,7 @@ package com.kamikazejam.kamicommon.nms.wrappers.world; +import com.kamikazejam.kamicommon.nms.abstraction.block.AbstractBlockUtil; +import com.kamikazejam.kamicommon.nms.provider.Provider; import com.kamikazejam.kamicommon.nms.wrappers.chunk.ChunkProvider_1_16_R3; import com.kamikazejam.kamicommon.nms.wrappers.chunk.NMSChunkProvider; import lombok.Getter; @@ -20,10 +22,12 @@ public class NMSWorld_1_16_R3 implements NMSWorld { private final @NotNull World bukkitWorld; private final @NotNull WorldServer worldServer; private final @NotNull CraftWorld craftWorld; - public NMSWorld_1_16_R3(@NotNull World world) { + private final @NotNull Provider provider; + public NMSWorld_1_16_R3(@NotNull World world, @NotNull Provider provider) { this.bukkitWorld = world; this.craftWorld = (CraftWorld) world; this.worldServer = this.craftWorld.getHandle(); + this.provider = provider; } @Override @@ -31,6 +35,11 @@ public NMSWorld_1_16_R3(@NotNull World world) { return this.worldServer; } + @Override + public @NotNull AbstractBlockUtil getBlockUtil() { + return this.provider.get(); + } + @Override public int getMinHeight() { return this.bukkitWorld.getMinHeight(); diff --git a/spigot-nms/v1_17_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_17_R1.java b/spigot-nms/v1_17_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_17_R1.java index 04cd6723..a969cfcf 100644 --- a/spigot-nms/v1_17_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_17_R1.java +++ b/spigot-nms/v1_17_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_17_R1.java @@ -3,11 +3,8 @@ import com.kamikazejam.kamicommon.nms.wrappers.world.NMSWorld; import com.kamikazejam.kamicommon.nms.wrappers.world.NMSWorld_1_17_R1; import net.minecraft.server.level.ServerChunkCache; -import org.bukkit.craftbukkit.v1_17_R1.CraftChunk; import org.jetbrains.annotations.NotNull; -import java.util.Objects; - public class ChunkProvider_1_17_R1 implements NMSChunkProvider { private final @NotNull NMSWorld_1_17_R1 world; private final @NotNull ServerChunkCache handle; @@ -26,17 +23,12 @@ public ChunkProvider_1_17_R1(@NotNull NMSWorld_1_17_R1 world, @NotNull ServerChu return this.handle; } - @Override - public @NotNull NMSChunk getOrCreateChunk(int x, int z) { - return new Chunk_1_17_R1(this, Objects.requireNonNull(this.handle.getChunkAtMainThread(x, z))); - } - @Override public void saveChunk(@NotNull NMSChunk chunk) { } @Override public @NotNull NMSChunk wrap(org.bukkit.@NotNull Chunk chunk) { - return new Chunk_1_17_R1(this, ((CraftChunk) chunk).getHandle()); + return new Chunk_1_17_R1(this, chunk); } } diff --git a/spigot-nms/v1_17_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_17_R1.java b/spigot-nms/v1_17_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_17_R1.java index 57055970..9a3504ee 100644 --- a/spigot-nms/v1_17_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_17_R1.java +++ b/spigot-nms/v1_17_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_17_R1.java @@ -4,16 +4,20 @@ import net.minecraft.network.protocol.game.ClientboundLevelChunkPacket; import net.minecraft.world.level.chunk.LevelChunk; import net.minecraft.world.level.chunk.LevelChunkSection; +import org.bukkit.Chunk; +import org.bukkit.craftbukkit.v1_17_R1.CraftChunk; import org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer; import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; public class Chunk_1_17_R1 implements NMSChunkDef { private final @NotNull ChunkProvider_1_17_R1 provider; + private final @NotNull Chunk bukkitChunk; private final @NotNull LevelChunk chunk; - public Chunk_1_17_R1(@NotNull ChunkProvider_1_17_R1 provider, @NotNull LevelChunk chunk) { + public Chunk_1_17_R1(@NotNull ChunkProvider_1_17_R1 provider, @NotNull Chunk bukkitChunk) { this.provider = provider; - this.chunk = chunk; + this.bukkitChunk = bukkitChunk; + this.chunk = ((CraftChunk) bukkitChunk).getHandle(); } @Override @@ -21,6 +25,11 @@ public Chunk_1_17_R1(@NotNull ChunkProvider_1_17_R1 provider, @NotNull LevelChun return this.provider; } + @Override + public @NotNull org.bukkit.Chunk getBukkitChunk() { + return bukkitChunk; + } + @Override public @NotNull Object getHandle() { return this.chunk; diff --git a/spigot-nms/v1_17_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_17_R1.java b/spigot-nms/v1_17_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_17_R1.java index 2248016f..5b1abcdb 100644 --- a/spigot-nms/v1_17_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_17_R1.java +++ b/spigot-nms/v1_17_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_17_R1.java @@ -1,5 +1,7 @@ package com.kamikazejam.kamicommon.nms.wrappers.world; +import com.kamikazejam.kamicommon.nms.abstraction.block.AbstractBlockUtil; +import com.kamikazejam.kamicommon.nms.provider.Provider; import com.kamikazejam.kamicommon.nms.wrappers.chunk.ChunkProvider_1_17_R1; import com.kamikazejam.kamicommon.nms.wrappers.chunk.NMSChunkProvider; import lombok.Getter; @@ -20,10 +22,12 @@ public class NMSWorld_1_17_R1 implements NMSWorld { private final @NotNull World bukkitWorld; private final @NotNull ServerLevel serverLevel; private final @NotNull CraftWorld craftWorld; - public NMSWorld_1_17_R1(@NotNull World world) { + private final @NotNull Provider provider; + public NMSWorld_1_17_R1(@NotNull World world, @NotNull Provider provider) { this.bukkitWorld = world; this.craftWorld = (CraftWorld) world; this.serverLevel = this.craftWorld.getHandle(); + this.provider = provider; } @Override @@ -31,6 +35,11 @@ public NMSWorld_1_17_R1(@NotNull World world) { return this.serverLevel; } + @Override + public @NotNull AbstractBlockUtil getBlockUtil() { + return this.provider.get(); + } + @Override public int getMinHeight() { return this.bukkitWorld.getMinHeight(); diff --git a/spigot-nms/v1_18_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_18_R1.java b/spigot-nms/v1_18_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_18_R1.java index f8f890ab..7ac950a7 100644 --- a/spigot-nms/v1_18_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_18_R1.java +++ b/spigot-nms/v1_18_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_18_R1.java @@ -3,11 +3,8 @@ import com.kamikazejam.kamicommon.nms.wrappers.world.NMSWorld; import com.kamikazejam.kamicommon.nms.wrappers.world.NMSWorld_1_18_R1; import net.minecraft.server.level.ServerChunkCache; -import org.bukkit.craftbukkit.v1_18_R1.CraftChunk; import org.jetbrains.annotations.NotNull; -import java.util.Objects; - public class ChunkProvider_1_18_R1 implements NMSChunkProvider { private final @NotNull NMSWorld_1_18_R1 world; private final @NotNull ServerChunkCache handle; @@ -26,17 +23,12 @@ public ChunkProvider_1_18_R1(@NotNull NMSWorld_1_18_R1 world, @NotNull ServerChu return this.handle; } - @Override - public @NotNull NMSChunk getOrCreateChunk(int x, int z) { - return new Chunk_1_18_R1(this, Objects.requireNonNull(this.handle.getChunkAtMainThread(x, z))); - } - @Override public void saveChunk(@NotNull NMSChunk chunk) { } @Override public @NotNull NMSChunk wrap(org.bukkit.@NotNull Chunk chunk) { - return new Chunk_1_18_R1(this, ((CraftChunk) chunk).getHandle()); + return new Chunk_1_18_R1(this, chunk); } } diff --git a/spigot-nms/v1_18_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_18_R1.java b/spigot-nms/v1_18_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_18_R1.java index 7722c5b8..88f7a914 100644 --- a/spigot-nms/v1_18_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_18_R1.java +++ b/spigot-nms/v1_18_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_18_R1.java @@ -4,16 +4,20 @@ import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket; import net.minecraft.world.level.chunk.LevelChunk; +import org.bukkit.Chunk; +import org.bukkit.craftbukkit.v1_18_R1.CraftChunk; import org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer; import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; public class Chunk_1_18_R1 implements NMSChunkDef { private final @NotNull ChunkProvider_1_18_R1 provider; + private final @NotNull Chunk bukkitChunk; private final @NotNull LevelChunk chunk; - public Chunk_1_18_R1(@NotNull ChunkProvider_1_18_R1 provider, @NotNull LevelChunk chunk) { + public Chunk_1_18_R1(@NotNull ChunkProvider_1_18_R1 provider, @NotNull Chunk bukkitChunk) { this.provider = provider; - this.chunk = chunk; + this.bukkitChunk = bukkitChunk; + this.chunk = ((CraftChunk) bukkitChunk).getHandle(); } @Override @@ -21,6 +25,11 @@ public Chunk_1_18_R1(@NotNull ChunkProvider_1_18_R1 provider, @NotNull LevelChun return this.provider; } + @Override + public @NotNull org.bukkit.Chunk getBukkitChunk() { + return bukkitChunk; + } + @Override public @NotNull Object getHandle() { return this.chunk; diff --git a/spigot-nms/v1_18_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_18_R1.java b/spigot-nms/v1_18_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_18_R1.java index df98d435..aeef4549 100644 --- a/spigot-nms/v1_18_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_18_R1.java +++ b/spigot-nms/v1_18_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_18_R1.java @@ -1,5 +1,7 @@ package com.kamikazejam.kamicommon.nms.wrappers.world; +import com.kamikazejam.kamicommon.nms.abstraction.block.AbstractBlockUtil; +import com.kamikazejam.kamicommon.nms.provider.Provider; import com.kamikazejam.kamicommon.nms.wrappers.chunk.ChunkProvider_1_18_R1; import com.kamikazejam.kamicommon.nms.wrappers.chunk.NMSChunkProvider; import lombok.Getter; @@ -20,10 +22,12 @@ public class NMSWorld_1_18_R1 implements NMSWorld { private final @NotNull World bukkitWorld; private final @NotNull ServerLevel serverLevel; private final @NotNull CraftWorld craftWorld; - public NMSWorld_1_18_R1(@NotNull World world) { + private final @NotNull Provider provider; + public NMSWorld_1_18_R1(@NotNull World world, @NotNull Provider provider) { this.bukkitWorld = world; this.craftWorld = (CraftWorld) world; this.serverLevel = this.craftWorld.getHandle(); + this.provider = provider; } @Override @@ -31,6 +35,11 @@ public NMSWorld_1_18_R1(@NotNull World world) { return this.serverLevel; } + @Override + public @NotNull AbstractBlockUtil getBlockUtil() { + return this.provider.get(); + } + @Override public int getMinHeight() { return this.bukkitWorld.getMinHeight(); diff --git a/spigot-nms/v1_18_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_18_R2.java b/spigot-nms/v1_18_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_18_R2.java index 281162ad..e3f5a4dc 100644 --- a/spigot-nms/v1_18_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_18_R2.java +++ b/spigot-nms/v1_18_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_18_R2.java @@ -3,11 +3,8 @@ import com.kamikazejam.kamicommon.nms.wrappers.world.NMSWorld; import com.kamikazejam.kamicommon.nms.wrappers.world.NMSWorld_1_18_R2; import net.minecraft.server.level.ServerChunkCache; -import org.bukkit.craftbukkit.v1_18_R2.CraftChunk; import org.jetbrains.annotations.NotNull; -import java.util.Objects; - public class ChunkProvider_1_18_R2 implements NMSChunkProvider { private final @NotNull NMSWorld_1_18_R2 world; private final @NotNull ServerChunkCache handle; @@ -26,17 +23,12 @@ public ChunkProvider_1_18_R2(@NotNull NMSWorld_1_18_R2 world, @NotNull ServerChu return this.handle; } - @Override - public @NotNull NMSChunk getOrCreateChunk(int x, int z) { - return new Chunk_1_18_R2(this, Objects.requireNonNull(this.handle.getChunkAtMainThread(x, z))); - } - @Override public void saveChunk(@NotNull NMSChunk chunk) { } @Override public @NotNull NMSChunk wrap(org.bukkit.@NotNull Chunk chunk) { - return new Chunk_1_18_R2(this, ((CraftChunk) chunk).getHandle()); + return new Chunk_1_18_R2(this, chunk); } } diff --git a/spigot-nms/v1_18_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_18_R2.java b/spigot-nms/v1_18_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_18_R2.java index cbdcd362..a72cea84 100644 --- a/spigot-nms/v1_18_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_18_R2.java +++ b/spigot-nms/v1_18_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_18_R2.java @@ -4,16 +4,20 @@ import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket; import net.minecraft.world.level.chunk.LevelChunk; +import org.bukkit.Chunk; +import org.bukkit.craftbukkit.v1_18_R2.CraftChunk; import org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer; import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; public class Chunk_1_18_R2 implements NMSChunkDef { private final @NotNull ChunkProvider_1_18_R2 provider; + private final @NotNull Chunk bukkitChunk; private final @NotNull LevelChunk chunk; - public Chunk_1_18_R2(@NotNull ChunkProvider_1_18_R2 provider, @NotNull LevelChunk chunk) { + public Chunk_1_18_R2(@NotNull ChunkProvider_1_18_R2 provider, @NotNull Chunk bukkitChunk) { this.provider = provider; - this.chunk = chunk; + this.bukkitChunk = bukkitChunk; + this.chunk = ((CraftChunk) bukkitChunk).getHandle(); } @Override @@ -21,6 +25,11 @@ public Chunk_1_18_R2(@NotNull ChunkProvider_1_18_R2 provider, @NotNull LevelChun return this.provider; } + @Override + public @NotNull org.bukkit.Chunk getBukkitChunk() { + return bukkitChunk; + } + @Override public @NotNull Object getHandle() { return this.chunk; diff --git a/spigot-nms/v1_18_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_18_R2.java b/spigot-nms/v1_18_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_18_R2.java index 20c4ab8f..9232f949 100644 --- a/spigot-nms/v1_18_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_18_R2.java +++ b/spigot-nms/v1_18_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_18_R2.java @@ -1,5 +1,7 @@ package com.kamikazejam.kamicommon.nms.wrappers.world; +import com.kamikazejam.kamicommon.nms.abstraction.block.AbstractBlockUtil; +import com.kamikazejam.kamicommon.nms.provider.Provider; import com.kamikazejam.kamicommon.nms.wrappers.chunk.ChunkProvider_1_18_R2; import com.kamikazejam.kamicommon.nms.wrappers.chunk.NMSChunkProvider; import lombok.Getter; @@ -20,10 +22,12 @@ public class NMSWorld_1_18_R2 implements NMSWorld { private final @NotNull World bukkitWorld; private final @NotNull ServerLevel serverLevel; private final @NotNull CraftWorld craftWorld; - public NMSWorld_1_18_R2(@NotNull World world) { + private final @NotNull Provider provider; + public NMSWorld_1_18_R2(@NotNull World world, @NotNull Provider provider) { this.bukkitWorld = world; this.craftWorld = (CraftWorld) world; this.serverLevel = this.craftWorld.getHandle(); + this.provider = provider; } @Override @@ -31,6 +35,11 @@ public NMSWorld_1_18_R2(@NotNull World world) { return this.serverLevel; } + @Override + public @NotNull AbstractBlockUtil getBlockUtil() { + return this.provider.get(); + } + @Override public int getMinHeight() { return this.bukkitWorld.getMinHeight(); diff --git a/spigot-nms/v1_19_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_19_R1.java b/spigot-nms/v1_19_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_19_R1.java index 6f63688e..fe6882a7 100644 --- a/spigot-nms/v1_19_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_19_R1.java +++ b/spigot-nms/v1_19_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_19_R1.java @@ -3,11 +3,8 @@ import com.kamikazejam.kamicommon.nms.wrappers.world.NMSWorld; import com.kamikazejam.kamicommon.nms.wrappers.world.NMSWorld_1_19_R1; import net.minecraft.server.level.ServerChunkCache; -import org.bukkit.craftbukkit.v1_19_R1.CraftChunk; import org.jetbrains.annotations.NotNull; -import java.util.Objects; - public class ChunkProvider_1_19_R1 implements NMSChunkProvider { private final @NotNull NMSWorld_1_19_R1 world; private final @NotNull ServerChunkCache handle; @@ -26,17 +23,12 @@ public ChunkProvider_1_19_R1(@NotNull NMSWorld_1_19_R1 world, @NotNull ServerChu return this.handle; } - @Override - public @NotNull NMSChunk getOrCreateChunk(int x, int z) { - return new Chunk_1_19_R1(this, Objects.requireNonNull(this.handle.getChunkAtMainThread(x, z))); - } - @Override public void saveChunk(@NotNull NMSChunk chunk) { } @Override public @NotNull NMSChunk wrap(org.bukkit.@NotNull Chunk chunk) { - return new Chunk_1_19_R1(this, ((CraftChunk) chunk).getHandle()); + return new Chunk_1_19_R1(this, chunk); } } diff --git a/spigot-nms/v1_19_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_19_R1.java b/spigot-nms/v1_19_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_19_R1.java index 203f9919..678ae08a 100644 --- a/spigot-nms/v1_19_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_19_R1.java +++ b/spigot-nms/v1_19_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_19_R1.java @@ -4,16 +4,20 @@ import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket; import net.minecraft.world.level.chunk.LevelChunk; +import org.bukkit.Chunk; +import org.bukkit.craftbukkit.v1_19_R1.CraftChunk; import org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer; import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; public class Chunk_1_19_R1 implements NMSChunkDef { private final @NotNull ChunkProvider_1_19_R1 provider; + private final @NotNull Chunk bukkitChunk; private final @NotNull LevelChunk chunk; - public Chunk_1_19_R1(@NotNull ChunkProvider_1_19_R1 provider, @NotNull LevelChunk chunk) { + public Chunk_1_19_R1(@NotNull ChunkProvider_1_19_R1 provider, @NotNull Chunk bukkitChunk) { this.provider = provider; - this.chunk = chunk; + this.bukkitChunk = bukkitChunk; + this.chunk = ((CraftChunk) bukkitChunk).getHandle(); } @Override @@ -21,6 +25,11 @@ public Chunk_1_19_R1(@NotNull ChunkProvider_1_19_R1 provider, @NotNull LevelChun return this.provider; } + @Override + public @NotNull org.bukkit.Chunk getBukkitChunk() { + return bukkitChunk; + } + @Override public @NotNull Object getHandle() { return this.chunk; diff --git a/spigot-nms/v1_19_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_19_R1.java b/spigot-nms/v1_19_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_19_R1.java index 5b1cb5c0..f9cac5fa 100644 --- a/spigot-nms/v1_19_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_19_R1.java +++ b/spigot-nms/v1_19_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_19_R1.java @@ -1,5 +1,7 @@ package com.kamikazejam.kamicommon.nms.wrappers.world; +import com.kamikazejam.kamicommon.nms.abstraction.block.AbstractBlockUtil; +import com.kamikazejam.kamicommon.nms.provider.Provider; import com.kamikazejam.kamicommon.nms.wrappers.chunk.ChunkProvider_1_19_R1; import com.kamikazejam.kamicommon.nms.wrappers.chunk.NMSChunkProvider; import lombok.Getter; @@ -20,10 +22,12 @@ public class NMSWorld_1_19_R1 implements NMSWorld { private final @NotNull World bukkitWorld; private final @NotNull ServerLevel serverLevel; private final @NotNull CraftWorld craftWorld; - public NMSWorld_1_19_R1(@NotNull World world) { + private final @NotNull Provider provider; + public NMSWorld_1_19_R1(@NotNull World world, @NotNull Provider provider) { this.bukkitWorld = world; this.craftWorld = (CraftWorld) world; this.serverLevel = ((CraftWorld) world).getHandle(); + this.provider = provider; } @Override @@ -31,6 +35,11 @@ public NMSWorld_1_19_R1(@NotNull World world) { return this.serverLevel; } + @Override + public @NotNull AbstractBlockUtil getBlockUtil() { + return this.provider.get(); + } + @Override public int getMinHeight() { return this.bukkitWorld.getMinHeight(); diff --git a/spigot-nms/v1_19_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_19_R2.java b/spigot-nms/v1_19_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_19_R2.java index f6a1ec2f..2cb1e45a 100644 --- a/spigot-nms/v1_19_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_19_R2.java +++ b/spigot-nms/v1_19_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_19_R2.java @@ -3,11 +3,8 @@ import com.kamikazejam.kamicommon.nms.wrappers.world.NMSWorld; import com.kamikazejam.kamicommon.nms.wrappers.world.NMSWorld_1_19_R2; import net.minecraft.server.level.ServerChunkCache; -import org.bukkit.craftbukkit.v1_19_R2.CraftChunk; import org.jetbrains.annotations.NotNull; -import java.util.Objects; - public class ChunkProvider_1_19_R2 implements NMSChunkProvider { private final @NotNull NMSWorld_1_19_R2 world; private final @NotNull ServerChunkCache handle; @@ -26,17 +23,12 @@ public ChunkProvider_1_19_R2(@NotNull NMSWorld_1_19_R2 world, @NotNull ServerChu return this.handle; } - @Override - public @NotNull NMSChunk getOrCreateChunk(int x, int z) { - return new Chunk_1_19_R2(this, Objects.requireNonNull(this.handle.getChunkAtMainThread(x, z))); - } - @Override public void saveChunk(@NotNull NMSChunk chunk) { } @Override public @NotNull NMSChunk wrap(org.bukkit.@NotNull Chunk chunk) { - return new Chunk_1_19_R2(this, ((CraftChunk) chunk).getHandle()); + return new Chunk_1_19_R2(this, chunk); } } diff --git a/spigot-nms/v1_19_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_19_R2.java b/spigot-nms/v1_19_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_19_R2.java index 956ebed5..10a478df 100644 --- a/spigot-nms/v1_19_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_19_R2.java +++ b/spigot-nms/v1_19_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_19_R2.java @@ -4,16 +4,20 @@ import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket; import net.minecraft.world.level.chunk.LevelChunk; +import org.bukkit.Chunk; +import org.bukkit.craftbukkit.v1_19_R2.CraftChunk; import org.bukkit.craftbukkit.v1_19_R2.entity.CraftPlayer; import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; public class Chunk_1_19_R2 implements NMSChunkDef { private final @NotNull ChunkProvider_1_19_R2 provider; + private final @NotNull Chunk bukkitChunk; private final @NotNull LevelChunk chunk; - public Chunk_1_19_R2(@NotNull ChunkProvider_1_19_R2 provider, @NotNull LevelChunk chunk) { + public Chunk_1_19_R2(@NotNull ChunkProvider_1_19_R2 provider, @NotNull Chunk bukkitChunk) { this.provider = provider; - this.chunk = chunk; + this.bukkitChunk = bukkitChunk; + this.chunk = ((CraftChunk) bukkitChunk).getHandle(); } @Override @@ -21,6 +25,11 @@ public Chunk_1_19_R2(@NotNull ChunkProvider_1_19_R2 provider, @NotNull LevelChun return this.provider; } + @Override + public @NotNull org.bukkit.Chunk getBukkitChunk() { + return bukkitChunk; + } + @Override public @NotNull Object getHandle() { return this.chunk; diff --git a/spigot-nms/v1_19_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_19_R2.java b/spigot-nms/v1_19_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_19_R2.java index 990e54d3..56a0a2fb 100644 --- a/spigot-nms/v1_19_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_19_R2.java +++ b/spigot-nms/v1_19_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_19_R2.java @@ -1,5 +1,7 @@ package com.kamikazejam.kamicommon.nms.wrappers.world; +import com.kamikazejam.kamicommon.nms.abstraction.block.AbstractBlockUtil; +import com.kamikazejam.kamicommon.nms.provider.Provider; import com.kamikazejam.kamicommon.nms.wrappers.chunk.ChunkProvider_1_19_R2; import com.kamikazejam.kamicommon.nms.wrappers.chunk.NMSChunkProvider; import lombok.Getter; @@ -20,10 +22,12 @@ public class NMSWorld_1_19_R2 implements NMSWorld { private final @NotNull World bukkitWorld; private final @NotNull ServerLevel serverLevel; private final @NotNull CraftWorld craftWorld; - public NMSWorld_1_19_R2(@NotNull World world) { + private final @NotNull Provider provider; + public NMSWorld_1_19_R2(@NotNull World world, @NotNull Provider provider) { this.bukkitWorld = world; this.craftWorld = (CraftWorld) world; this.serverLevel = this.craftWorld.getHandle(); + this.provider = provider; } @Override @@ -31,6 +35,11 @@ public NMSWorld_1_19_R2(@NotNull World world) { return this.serverLevel; } + @Override + public @NotNull AbstractBlockUtil getBlockUtil() { + return this.provider.get(); + } + @Override public int getMinHeight() { return this.bukkitWorld.getMinHeight(); diff --git a/spigot-nms/v1_19_R3/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_19_R3.java b/spigot-nms/v1_19_R3/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_19_R3.java index f2457a2c..fc38387e 100644 --- a/spigot-nms/v1_19_R3/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_19_R3.java +++ b/spigot-nms/v1_19_R3/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_19_R3.java @@ -3,12 +3,8 @@ import com.kamikazejam.kamicommon.nms.wrappers.world.NMSWorld; import com.kamikazejam.kamicommon.nms.wrappers.world.NMSWorld_1_19_R3; import net.minecraft.server.level.ServerChunkCache; -import net.minecraft.world.level.chunk.ChunkStatus; -import org.bukkit.craftbukkit.v1_19_R3.CraftChunk; import org.jetbrains.annotations.NotNull; -import java.util.Objects; - public class ChunkProvider_1_19_R3 implements NMSChunkProvider { private final @NotNull NMSWorld_1_19_R3 world; private final @NotNull ServerChunkCache handle; @@ -27,17 +23,12 @@ public ChunkProvider_1_19_R3(@NotNull NMSWorld_1_19_R3 world, @NotNull ServerChu return this.handle; } - @Override - public @NotNull NMSChunk getOrCreateChunk(int x, int z) { - return new Chunk_1_19_R3(this, Objects.requireNonNull(this.handle.getChunkAtMainThread(x, z))); - } - @Override public void saveChunk(@NotNull NMSChunk chunk) { } @Override public @NotNull NMSChunk wrap(org.bukkit.@NotNull Chunk chunk) { - return new Chunk_1_19_R3(this, ((CraftChunk) chunk).getHandle(ChunkStatus.FULL)); + return new Chunk_1_19_R3(this, chunk); } } diff --git a/spigot-nms/v1_19_R3/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_19_R3.java b/spigot-nms/v1_19_R3/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_19_R3.java index dc642bb5..9d515387 100644 --- a/spigot-nms/v1_19_R3/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_19_R3.java +++ b/spigot-nms/v1_19_R3/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_19_R3.java @@ -4,17 +4,22 @@ import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket; import net.minecraft.world.level.chunk.ChunkAccess; +import net.minecraft.world.level.chunk.ChunkStatus; import net.minecraft.world.level.chunk.LevelChunk; +import org.bukkit.Chunk; +import org.bukkit.craftbukkit.v1_19_R3.CraftChunk; import org.bukkit.craftbukkit.v1_19_R3.entity.CraftPlayer; import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; public class Chunk_1_19_R3 implements NMSChunkDef { private final @NotNull ChunkProvider_1_19_R3 provider; + private final @NotNull Chunk bukkitChunk; private final @NotNull ChunkAccess chunk; - public Chunk_1_19_R3(@NotNull ChunkProvider_1_19_R3 provider, @NotNull ChunkAccess chunk) { + public Chunk_1_19_R3(@NotNull ChunkProvider_1_19_R3 provider, @NotNull Chunk bukkitChunk) { this.provider = provider; - this.chunk = chunk; + this.bukkitChunk = bukkitChunk; + this.chunk = ((CraftChunk) bukkitChunk).getHandle(ChunkStatus.FULL); } @Override @@ -22,6 +27,11 @@ public Chunk_1_19_R3(@NotNull ChunkProvider_1_19_R3 provider, @NotNull ChunkAcce return this.provider; } + @Override + public @NotNull org.bukkit.Chunk getBukkitChunk() { + return bukkitChunk; + } + @Override public @NotNull Object getHandle() { return this.chunk; diff --git a/spigot-nms/v1_19_R3/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_19_R3.java b/spigot-nms/v1_19_R3/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_19_R3.java index edfe1e7e..1b3a3436 100644 --- a/spigot-nms/v1_19_R3/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_19_R3.java +++ b/spigot-nms/v1_19_R3/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_19_R3.java @@ -1,5 +1,7 @@ package com.kamikazejam.kamicommon.nms.wrappers.world; +import com.kamikazejam.kamicommon.nms.abstraction.block.AbstractBlockUtil; +import com.kamikazejam.kamicommon.nms.provider.Provider; import com.kamikazejam.kamicommon.nms.wrappers.chunk.ChunkProvider_1_19_R3; import com.kamikazejam.kamicommon.nms.wrappers.chunk.NMSChunkProvider; import lombok.Getter; @@ -20,10 +22,12 @@ public class NMSWorld_1_19_R3 implements NMSWorld { private final @NotNull World bukkitWorld; private final @NotNull ServerLevel serverLevel; private final @NotNull CraftWorld craftWorld; - public NMSWorld_1_19_R3(@NotNull World world) { + private final @NotNull Provider provider; + public NMSWorld_1_19_R3(@NotNull World world, @NotNull Provider provider) { this.bukkitWorld = world; this.craftWorld = (CraftWorld) world; this.serverLevel = this.craftWorld.getHandle(); + this.provider = provider; } @Override @@ -31,6 +35,11 @@ public NMSWorld_1_19_R3(@NotNull World world) { return this.serverLevel; } + @Override + public @NotNull AbstractBlockUtil getBlockUtil() { + return this.provider.get(); + } + @Override public int getMinHeight() { return this.bukkitWorld.getMinHeight(); diff --git a/spigot-nms/v1_20_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_20_R1.java b/spigot-nms/v1_20_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_20_R1.java index 81d2ecef..03399538 100644 --- a/spigot-nms/v1_20_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_20_R1.java +++ b/spigot-nms/v1_20_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_20_R1.java @@ -3,12 +3,8 @@ import com.kamikazejam.kamicommon.nms.wrappers.world.NMSWorld; import com.kamikazejam.kamicommon.nms.wrappers.world.NMSWorld_1_20_R1; import net.minecraft.server.level.ServerChunkCache; -import net.minecraft.world.level.chunk.ChunkStatus; -import org.bukkit.craftbukkit.v1_20_R1.CraftChunk; import org.jetbrains.annotations.NotNull; -import java.util.Objects; - public class ChunkProvider_1_20_R1 implements NMSChunkProvider { private final @NotNull NMSWorld_1_20_R1 world; private final @NotNull ServerChunkCache handle; @@ -27,17 +23,12 @@ public ChunkProvider_1_20_R1(@NotNull NMSWorld_1_20_R1 world, @NotNull ServerChu return this.handle; } - @Override - public @NotNull NMSChunk getOrCreateChunk(int x, int z) { - return new Chunk_1_20_R1(this, Objects.requireNonNull(this.handle.getChunkAtMainThread(x, z))); - } - @Override public void saveChunk(@NotNull NMSChunk chunk) { } @Override public @NotNull NMSChunk wrap(org.bukkit.@NotNull Chunk chunk) { - return new Chunk_1_20_R1(this, ((CraftChunk) chunk).getHandle(ChunkStatus.FULL)); + return new Chunk_1_20_R1(this, chunk); } } diff --git a/spigot-nms/v1_20_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_20_R1.java b/spigot-nms/v1_20_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_20_R1.java index ba00240a..5ce93448 100644 --- a/spigot-nms/v1_20_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_20_R1.java +++ b/spigot-nms/v1_20_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_20_R1.java @@ -4,17 +4,22 @@ import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket; import net.minecraft.world.level.chunk.ChunkAccess; +import net.minecraft.world.level.chunk.ChunkStatus; import net.minecraft.world.level.chunk.LevelChunk; +import org.bukkit.Chunk; +import org.bukkit.craftbukkit.v1_20_R1.CraftChunk; import org.bukkit.craftbukkit.v1_20_R1.entity.CraftPlayer; import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; public class Chunk_1_20_R1 implements NMSChunkDef { private final @NotNull ChunkProvider_1_20_R1 provider; + private final @NotNull Chunk bukkitChunk; private final @NotNull ChunkAccess chunk; - public Chunk_1_20_R1(@NotNull ChunkProvider_1_20_R1 provider, @NotNull ChunkAccess chunk) { + public Chunk_1_20_R1(@NotNull ChunkProvider_1_20_R1 provider, @NotNull Chunk bukkitChunk) { this.provider = provider; - this.chunk = chunk; + this.bukkitChunk = bukkitChunk; + this.chunk = ((CraftChunk) bukkitChunk).getHandle(ChunkStatus.FULL); } @Override @@ -22,6 +27,11 @@ public Chunk_1_20_R1(@NotNull ChunkProvider_1_20_R1 provider, @NotNull ChunkAcce return this.provider; } + @Override + public @NotNull org.bukkit.Chunk getBukkitChunk() { + return bukkitChunk; + } + @Override public @NotNull Object getHandle() { return this.chunk; diff --git a/spigot-nms/v1_20_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_20_R1.java b/spigot-nms/v1_20_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_20_R1.java index a8d17e5b..9c94d0f0 100644 --- a/spigot-nms/v1_20_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_20_R1.java +++ b/spigot-nms/v1_20_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_20_R1.java @@ -1,5 +1,7 @@ package com.kamikazejam.kamicommon.nms.wrappers.world; +import com.kamikazejam.kamicommon.nms.abstraction.block.AbstractBlockUtil; +import com.kamikazejam.kamicommon.nms.provider.Provider; import com.kamikazejam.kamicommon.nms.wrappers.chunk.ChunkProvider_1_20_R1; import com.kamikazejam.kamicommon.nms.wrappers.chunk.NMSChunkProvider; import lombok.Getter; @@ -20,10 +22,12 @@ public class NMSWorld_1_20_R1 implements NMSWorld { private final @NotNull World bukkitWorld; private final @NotNull ServerLevel serverLevel; private final @NotNull CraftWorld craftWorld; - public NMSWorld_1_20_R1(@NotNull World world) { + private final @NotNull Provider provider; + public NMSWorld_1_20_R1(@NotNull World world, @NotNull Provider provider) { this.bukkitWorld = world; this.craftWorld = (CraftWorld) world; this.serverLevel = this.craftWorld.getHandle(); + this.provider = provider; } @Override @@ -31,6 +35,11 @@ public NMSWorld_1_20_R1(@NotNull World world) { return this.serverLevel; } + @Override + public @NotNull AbstractBlockUtil getBlockUtil() { + return this.provider.get(); + } + @Override public int getMinHeight() { return this.bukkitWorld.getMinHeight(); diff --git a/spigot-nms/v1_20_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_20_R2.java b/spigot-nms/v1_20_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_20_R2.java index 2e097544..0d2ef4dc 100644 --- a/spigot-nms/v1_20_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_20_R2.java +++ b/spigot-nms/v1_20_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_20_R2.java @@ -3,12 +3,8 @@ import com.kamikazejam.kamicommon.nms.wrappers.world.NMSWorld; import com.kamikazejam.kamicommon.nms.wrappers.world.NMSWorld_1_20_R2; import net.minecraft.server.level.ServerChunkCache; -import net.minecraft.world.level.chunk.ChunkStatus; -import org.bukkit.craftbukkit.v1_20_R2.CraftChunk; import org.jetbrains.annotations.NotNull; -import java.util.Objects; - public class ChunkProvider_1_20_R2 implements NMSChunkProvider { private final @NotNull NMSWorld_1_20_R2 world; private final @NotNull ServerChunkCache handle; @@ -27,17 +23,12 @@ public ChunkProvider_1_20_R2(@NotNull NMSWorld_1_20_R2 world, @NotNull ServerChu return this.handle; } - @Override - public @NotNull NMSChunk getOrCreateChunk(int x, int z) { - return new Chunk_1_20_R2(this, Objects.requireNonNull(this.handle.getChunkAtMainThread(x, z))); - } - @Override public void saveChunk(@NotNull NMSChunk chunk) { } @Override public @NotNull NMSChunk wrap(org.bukkit.@NotNull Chunk chunk) { - return new Chunk_1_20_R2(this, ((CraftChunk) chunk).getHandle(ChunkStatus.FULL)); + return new Chunk_1_20_R2(this, chunk); } } diff --git a/spigot-nms/v1_20_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_20_R2.java b/spigot-nms/v1_20_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_20_R2.java index 1c858399..a58b5a37 100644 --- a/spigot-nms/v1_20_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_20_R2.java +++ b/spigot-nms/v1_20_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_20_R2.java @@ -4,17 +4,22 @@ import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket; import net.minecraft.world.level.chunk.ChunkAccess; +import net.minecraft.world.level.chunk.ChunkStatus; import net.minecraft.world.level.chunk.LevelChunk; +import org.bukkit.Chunk; +import org.bukkit.craftbukkit.v1_20_R2.CraftChunk; import org.bukkit.craftbukkit.v1_20_R2.entity.CraftPlayer; import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; public class Chunk_1_20_R2 implements NMSChunkDef { private final @NotNull ChunkProvider_1_20_R2 provider; + private final @NotNull Chunk bukkitChunk; private final @NotNull ChunkAccess chunk; - public Chunk_1_20_R2(@NotNull ChunkProvider_1_20_R2 provider, @NotNull ChunkAccess chunk) { + public Chunk_1_20_R2(@NotNull ChunkProvider_1_20_R2 provider, @NotNull Chunk bukkitChunk) { this.provider = provider; - this.chunk = chunk; + this.bukkitChunk = bukkitChunk; + this.chunk = ((CraftChunk) bukkitChunk).getHandle(ChunkStatus.FULL); } @Override @@ -22,6 +27,11 @@ public Chunk_1_20_R2(@NotNull ChunkProvider_1_20_R2 provider, @NotNull ChunkAcce return this.provider; } + @Override + public @NotNull org.bukkit.Chunk getBukkitChunk() { + return bukkitChunk; + } + @Override public @NotNull Object getHandle() { return this.chunk; diff --git a/spigot-nms/v1_20_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_20_R2.java b/spigot-nms/v1_20_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_20_R2.java index ea928c37..8fe41bdd 100644 --- a/spigot-nms/v1_20_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_20_R2.java +++ b/spigot-nms/v1_20_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_20_R2.java @@ -1,5 +1,7 @@ package com.kamikazejam.kamicommon.nms.wrappers.world; +import com.kamikazejam.kamicommon.nms.abstraction.block.AbstractBlockUtil; +import com.kamikazejam.kamicommon.nms.provider.Provider; import com.kamikazejam.kamicommon.nms.wrappers.chunk.ChunkProvider_1_20_R2; import com.kamikazejam.kamicommon.nms.wrappers.chunk.NMSChunkProvider; import lombok.Getter; @@ -20,10 +22,12 @@ public class NMSWorld_1_20_R2 implements NMSWorld { private final @NotNull World bukkitWorld; private final @NotNull ServerLevel serverLevel; private final @NotNull CraftWorld craftWorld; - public NMSWorld_1_20_R2(@NotNull World world) { + private final @NotNull Provider provider; + public NMSWorld_1_20_R2(@NotNull World world, @NotNull Provider provider) { this.bukkitWorld = world; this.craftWorld = (CraftWorld) world; this.serverLevel = this.craftWorld.getHandle(); + this.provider = provider; } @Override @@ -31,6 +35,11 @@ public NMSWorld_1_20_R2(@NotNull World world) { return this.serverLevel; } + @Override + public @NotNull AbstractBlockUtil getBlockUtil() { + return this.provider.get(); + } + @Override public int getMinHeight() { return this.bukkitWorld.getMinHeight(); diff --git a/spigot-nms/v1_20_R3/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_20_R3.java b/spigot-nms/v1_20_R3/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_20_R3.java index b7d3d76c..711410db 100644 --- a/spigot-nms/v1_20_R3/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_20_R3.java +++ b/spigot-nms/v1_20_R3/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_20_R3.java @@ -3,12 +3,8 @@ import com.kamikazejam.kamicommon.nms.wrappers.world.NMSWorld; import com.kamikazejam.kamicommon.nms.wrappers.world.NMSWorld_1_20_R3; import net.minecraft.server.level.ServerChunkCache; -import net.minecraft.world.level.chunk.ChunkStatus; -import org.bukkit.craftbukkit.v1_20_R3.CraftChunk; import org.jetbrains.annotations.NotNull; -import java.util.Objects; - public class ChunkProvider_1_20_R3 implements NMSChunkProvider { private final @NotNull NMSWorld_1_20_R3 world; private final @NotNull ServerChunkCache handle; @@ -27,17 +23,12 @@ public ChunkProvider_1_20_R3(@NotNull NMSWorld_1_20_R3 world, @NotNull ServerChu return this.handle; } - @Override - public @NotNull NMSChunk getOrCreateChunk(int x, int z) { - return new Chunk_1_20_R3(this, Objects.requireNonNull(this.handle.getChunk(x, z, true))); - } - @Override public void saveChunk(@NotNull NMSChunk chunk) { } @Override public @NotNull NMSChunk wrap(org.bukkit.@NotNull Chunk chunk) { - return new Chunk_1_20_R3(this, ((CraftChunk) chunk).getHandle(ChunkStatus.FULL)); + return new Chunk_1_20_R3(this, chunk); } } diff --git a/spigot-nms/v1_20_R3/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_20_R3.java b/spigot-nms/v1_20_R3/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_20_R3.java index 1b3bfcd1..490923e9 100644 --- a/spigot-nms/v1_20_R3/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_20_R3.java +++ b/spigot-nms/v1_20_R3/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_20_R3.java @@ -4,17 +4,22 @@ import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket; import net.minecraft.world.level.chunk.ChunkAccess; +import net.minecraft.world.level.chunk.ChunkStatus; import net.minecraft.world.level.chunk.LevelChunk; +import org.bukkit.Chunk; +import org.bukkit.craftbukkit.v1_20_R3.CraftChunk; import org.bukkit.craftbukkit.v1_20_R3.entity.CraftPlayer; import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; public class Chunk_1_20_R3 implements NMSChunkDef { private final @NotNull ChunkProvider_1_20_R3 provider; + private final @NotNull Chunk bukkitChunk; private final @NotNull ChunkAccess chunk; - public Chunk_1_20_R3(@NotNull ChunkProvider_1_20_R3 provider, @NotNull ChunkAccess chunk) { + public Chunk_1_20_R3(@NotNull ChunkProvider_1_20_R3 provider, @NotNull Chunk bukkitChunk) { this.provider = provider; - this.chunk = chunk; + this.bukkitChunk = bukkitChunk; + this.chunk = ((CraftChunk) bukkitChunk).getHandle(ChunkStatus.FULL); } @Override @@ -22,6 +27,11 @@ public Chunk_1_20_R3(@NotNull ChunkProvider_1_20_R3 provider, @NotNull ChunkAcce return this.provider; } + @Override + public @NotNull org.bukkit.Chunk getBukkitChunk() { + return bukkitChunk; + } + @Override public @NotNull Object getHandle() { return this.chunk; diff --git a/spigot-nms/v1_20_R3/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_20_R3.java b/spigot-nms/v1_20_R3/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_20_R3.java index 874a5f44..1c6286c1 100644 --- a/spigot-nms/v1_20_R3/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_20_R3.java +++ b/spigot-nms/v1_20_R3/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_20_R3.java @@ -1,5 +1,7 @@ package com.kamikazejam.kamicommon.nms.wrappers.world; +import com.kamikazejam.kamicommon.nms.abstraction.block.AbstractBlockUtil; +import com.kamikazejam.kamicommon.nms.provider.Provider; import com.kamikazejam.kamicommon.nms.wrappers.chunk.ChunkProvider_1_20_R3; import com.kamikazejam.kamicommon.nms.wrappers.chunk.NMSChunkProvider; import lombok.Getter; @@ -20,10 +22,12 @@ public class NMSWorld_1_20_R3 implements NMSWorld { private final @NotNull World bukkitWorld; private final @NotNull ServerLevel serverLevel; private final @NotNull CraftWorld craftWorld; - public NMSWorld_1_20_R3(@NotNull World world) { + private final @NotNull Provider provider; + public NMSWorld_1_20_R3(@NotNull World world, @NotNull Provider provider) { this.bukkitWorld = world; this.craftWorld = (CraftWorld) world; this.serverLevel = this.craftWorld.getHandle(); + this.provider = provider; } @Override @@ -31,6 +35,11 @@ public NMSWorld_1_20_R3(@NotNull World world) { return this.serverLevel; } + @Override + public @NotNull AbstractBlockUtil getBlockUtil() { + return this.provider.get(); + } + @Override public int getMinHeight() { return this.bukkitWorld.getMinHeight(); diff --git a/spigot-nms/v1_21_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_21_CB.java b/spigot-nms/v1_21_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_21_CB.java index 2bac9f2d..aebedd83 100644 --- a/spigot-nms/v1_21_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_21_CB.java +++ b/spigot-nms/v1_21_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_21_CB.java @@ -3,12 +3,8 @@ import com.kamikazejam.kamicommon.nms.wrappers.world.NMSWorld; import com.kamikazejam.kamicommon.nms.wrappers.world.NMSWorld_1_21_CB; import net.minecraft.server.level.ServerChunkCache; -import net.minecraft.world.level.chunk.status.ChunkStatus; -import org.bukkit.craftbukkit.CraftChunk; import org.jetbrains.annotations.NotNull; -import java.util.Objects; - public class ChunkProvider_1_21_CB implements NMSChunkProvider { private final @NotNull NMSWorld_1_21_CB world; private final @NotNull ServerChunkCache handle; @@ -27,17 +23,12 @@ public ChunkProvider_1_21_CB(@NotNull NMSWorld_1_21_CB world, @NotNull ServerChu return this.handle; } - @Override - public @NotNull NMSChunk getOrCreateChunk(int x, int z) { - return new Chunk_1_21_CB(this, Objects.requireNonNull(this.handle.getChunk(x, z, true))); - } - @Override public void saveChunk(@NotNull NMSChunk chunk) { } @Override public @NotNull NMSChunk wrap(org.bukkit.@NotNull Chunk chunk) { - return new Chunk_1_21_CB(this, ((CraftChunk) chunk).getHandle(ChunkStatus.FULL)); + return new Chunk_1_21_CB(this, chunk); } } diff --git a/spigot-nms/v1_21_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_21_CB.java b/spigot-nms/v1_21_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_21_CB.java index f608c5cb..d7db53e1 100644 --- a/spigot-nms/v1_21_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_21_CB.java +++ b/spigot-nms/v1_21_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_21_CB.java @@ -5,16 +5,21 @@ import net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket; import net.minecraft.world.level.chunk.ChunkAccess; import net.minecraft.world.level.chunk.LevelChunk; +import net.minecraft.world.level.chunk.status.ChunkStatus; +import org.bukkit.Chunk; +import org.bukkit.craftbukkit.CraftChunk; import org.bukkit.craftbukkit.entity.CraftPlayer; import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; public class Chunk_1_21_CB implements NMSChunkDef { private final @NotNull ChunkProvider_1_21_CB provider; + private final @NotNull Chunk bukkitChunk; private final @NotNull ChunkAccess chunk; - public Chunk_1_21_CB(@NotNull ChunkProvider_1_21_CB provider, @NotNull ChunkAccess chunk) { + public Chunk_1_21_CB(@NotNull ChunkProvider_1_21_CB provider, @NotNull Chunk bukkitChunk) { this.provider = provider; - this.chunk = chunk; + this.bukkitChunk = bukkitChunk; + this.chunk = ((CraftChunk) bukkitChunk).getHandle(ChunkStatus.FULL); } @Override @@ -22,6 +27,11 @@ public Chunk_1_21_CB(@NotNull ChunkProvider_1_21_CB provider, @NotNull ChunkAcce return this.provider; } + @Override + public @NotNull org.bukkit.Chunk getBukkitChunk() { + return bukkitChunk; + } + @Override public @NotNull Object getHandle() { return this.chunk; diff --git a/spigot-nms/v1_21_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_21_CB.java b/spigot-nms/v1_21_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_21_CB.java index 66ebc107..dc477a16 100644 --- a/spigot-nms/v1_21_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_21_CB.java +++ b/spigot-nms/v1_21_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_21_CB.java @@ -1,5 +1,7 @@ package com.kamikazejam.kamicommon.nms.wrappers.world; +import com.kamikazejam.kamicommon.nms.abstraction.block.AbstractBlockUtil; +import com.kamikazejam.kamicommon.nms.provider.Provider; import com.kamikazejam.kamicommon.nms.wrappers.chunk.ChunkProvider_1_21_CB; import com.kamikazejam.kamicommon.nms.wrappers.chunk.NMSChunkProvider; import lombok.Getter; @@ -20,10 +22,12 @@ public class NMSWorld_1_21_CB implements NMSWorld { private final @NotNull World bukkitWorld; private final @NotNull ServerLevel serverLevel; private final @NotNull CraftWorld craftWorld; - public NMSWorld_1_21_CB(@NotNull World world) { + private final @NotNull Provider provider; + public NMSWorld_1_21_CB(@NotNull World world, @NotNull Provider provider) { this.bukkitWorld = world; this.craftWorld = (CraftWorld) world; this.serverLevel = this.craftWorld.getHandle(); + this.provider = provider; } @Override @@ -31,6 +35,11 @@ public NMSWorld_1_21_CB(@NotNull World world) { return this.serverLevel; } + @Override + public @NotNull AbstractBlockUtil getBlockUtil() { + return this.provider.get(); + } + @Override public int getMinHeight() { return this.bukkitWorld.getMinHeight(); diff --git a/spigot-nms/v1_8_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_8_R1.java b/spigot-nms/v1_8_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_8_R1.java index 783c4ff6..7f9bf152 100644 --- a/spigot-nms/v1_8_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_8_R1.java +++ b/spigot-nms/v1_8_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_8_R1.java @@ -4,7 +4,6 @@ import com.kamikazejam.kamicommon.nms.wrappers.world.NMSWorld_1_8_R1; import net.minecraft.server.v1_8_R1.Chunk; import net.minecraft.server.v1_8_R1.ChunkProviderServer; -import org.bukkit.craftbukkit.v1_8_R1.CraftChunk; import org.jetbrains.annotations.NotNull; public class ChunkProvider_1_8_R1 implements NMSChunkProvider { @@ -35,11 +34,6 @@ public void setForceChunkLoad(boolean value) { this.handle.forceChunkLoad = value; } - @Override - public @NotNull NMSChunk getOrCreateChunk(int x, int z) { - return new Chunk_1_8_R1(this, this.handle.getOrCreateChunk(x, z)); - } - @Override public void saveChunk(NMSChunk chunk) { this.handle.saveChunk((Chunk) chunk.getHandle()); @@ -47,6 +41,6 @@ public void saveChunk(NMSChunk chunk) { @Override public @NotNull NMSChunk wrap(org.bukkit.@NotNull Chunk chunk) { - return new Chunk_1_8_R1(this, ((CraftChunk) chunk).getHandle()); + return new Chunk_1_8_R1(this, chunk); } } diff --git a/spigot-nms/v1_8_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_8_R1.java b/spigot-nms/v1_8_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_8_R1.java index ff287f0d..962737ed 100644 --- a/spigot-nms/v1_8_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_8_R1.java +++ b/spigot-nms/v1_8_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_8_R1.java @@ -5,6 +5,7 @@ import net.minecraft.server.v1_8_R1.ChunkSection; import net.minecraft.server.v1_8_R1.PacketPlayOutMapChunk; import org.bukkit.World; +import org.bukkit.craftbukkit.v1_8_R1.CraftChunk; import org.bukkit.craftbukkit.v1_8_R1.CraftWorld; import org.bukkit.craftbukkit.v1_8_R1.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_8_R1.util.LongHash; @@ -13,10 +14,12 @@ public class Chunk_1_8_R1 implements NMSChunkDef { private final @NotNull ChunkProvider_1_8_R1 provider; + private final @NotNull org.bukkit.Chunk bukkitChunk; private final @NotNull Chunk chunk; - public Chunk_1_8_R1(@NotNull ChunkProvider_1_8_R1 provider, @NotNull Chunk chunk) { + public Chunk_1_8_R1(@NotNull ChunkProvider_1_8_R1 provider, @NotNull org.bukkit.Chunk bukkitChunk) { this.provider = provider; - this.chunk = chunk; + this.bukkitChunk = bukkitChunk; + this.chunk = ((CraftChunk) bukkitChunk).getHandle(); } @Override @@ -24,6 +27,11 @@ public Chunk_1_8_R1(@NotNull ChunkProvider_1_8_R1 provider, @NotNull Chunk chunk return this.provider; } + @Override + public @NotNull org.bukkit.Chunk getBukkitChunk() { + return bukkitChunk; + } + @Override public @NotNull Object getHandle() { return this.chunk; diff --git a/spigot-nms/v1_8_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_8_R1.java b/spigot-nms/v1_8_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_8_R1.java index f04d4607..d40ec9c3 100644 --- a/spigot-nms/v1_8_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_8_R1.java +++ b/spigot-nms/v1_8_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_8_R1.java @@ -1,5 +1,7 @@ package com.kamikazejam.kamicommon.nms.wrappers.world; +import com.kamikazejam.kamicommon.nms.abstraction.block.AbstractBlockUtil; +import com.kamikazejam.kamicommon.nms.provider.Provider; import com.kamikazejam.kamicommon.nms.wrappers.chunk.ChunkProvider_1_8_R1; import com.kamikazejam.kamicommon.nms.wrappers.chunk.NMSChunkProvider; import lombok.Getter; @@ -20,10 +22,12 @@ public class NMSWorld_1_8_R1 implements NMSWorld { private final @NotNull World bukkitWorld; private final @NotNull WorldServer worldServer; private final @NotNull CraftWorld craftWorld; - public NMSWorld_1_8_R1(@NotNull World world) { + private final @NotNull Provider provider; + public NMSWorld_1_8_R1(@NotNull World world, @NotNull Provider provider) { this.bukkitWorld = world; this.craftWorld = (CraftWorld) world; this.worldServer = this.craftWorld.getHandle(); + this.provider = provider; } @Override @@ -31,6 +35,11 @@ public NMSWorld_1_8_R1(@NotNull World world) { return this.worldServer; } + @Override + public @NotNull AbstractBlockUtil getBlockUtil() { + return provider.get(); + } + @Override public int getMinHeight() { return 0; diff --git a/spigot-nms/v1_8_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_8_R2.java b/spigot-nms/v1_8_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_8_R2.java index 6713f631..9a61f76e 100644 --- a/spigot-nms/v1_8_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_8_R2.java +++ b/spigot-nms/v1_8_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_8_R2.java @@ -4,7 +4,6 @@ import com.kamikazejam.kamicommon.nms.wrappers.world.NMSWorld_1_8_R2; import net.minecraft.server.v1_8_R2.Chunk; import net.minecraft.server.v1_8_R2.ChunkProviderServer; -import org.bukkit.craftbukkit.v1_8_R2.CraftChunk; import org.jetbrains.annotations.NotNull; public class ChunkProvider_1_8_R2 implements NMSChunkProvider { @@ -35,11 +34,6 @@ public void setForceChunkLoad(boolean value) { this.handle.forceChunkLoad = value; } - @Override - public @NotNull NMSChunk getOrCreateChunk(int x, int z) { - return new Chunk_1_8_R2(this, this.handle.getOrCreateChunk(x, z)); - } - @Override public void saveChunk(NMSChunk chunk) { this.handle.saveChunk((Chunk) chunk.getHandle()); @@ -47,6 +41,6 @@ public void saveChunk(NMSChunk chunk) { @Override public @NotNull NMSChunk wrap(org.bukkit.@NotNull Chunk chunk) { - return new Chunk_1_8_R2(this, ((CraftChunk) chunk).getHandle()); + return new Chunk_1_8_R2(this, chunk); } } diff --git a/spigot-nms/v1_8_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_8_R2.java b/spigot-nms/v1_8_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_8_R2.java index 2af6bd9f..d6201189 100644 --- a/spigot-nms/v1_8_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_8_R2.java +++ b/spigot-nms/v1_8_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_8_R2.java @@ -5,6 +5,7 @@ import net.minecraft.server.v1_8_R2.ChunkSection; import net.minecraft.server.v1_8_R2.PacketPlayOutMapChunk; import org.bukkit.World; +import org.bukkit.craftbukkit.v1_8_R2.CraftChunk; import org.bukkit.craftbukkit.v1_8_R2.CraftWorld; import org.bukkit.craftbukkit.v1_8_R2.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_8_R2.util.LongHash; @@ -13,10 +14,12 @@ public class Chunk_1_8_R2 implements NMSChunkDef { private final @NotNull ChunkProvider_1_8_R2 provider; + private final @NotNull org.bukkit.Chunk bukkitChunk; private final @NotNull Chunk chunk; - public Chunk_1_8_R2(@NotNull ChunkProvider_1_8_R2 provider, @NotNull Chunk chunk) { + public Chunk_1_8_R2(@NotNull ChunkProvider_1_8_R2 provider, @NotNull org.bukkit.Chunk bukkitChunk) { this.provider = provider; - this.chunk = chunk; + this.bukkitChunk = bukkitChunk; + this.chunk = ((CraftChunk) bukkitChunk).getHandle(); } @Override @@ -24,6 +27,11 @@ public Chunk_1_8_R2(@NotNull ChunkProvider_1_8_R2 provider, @NotNull Chunk chunk return this.provider; } + @Override + public @NotNull org.bukkit.Chunk getBukkitChunk() { + return bukkitChunk; + } + @Override public @NotNull Object getHandle() { return this.chunk; diff --git a/spigot-nms/v1_8_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_8_R2.java b/spigot-nms/v1_8_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_8_R2.java index 85ade6d8..f8eb6867 100644 --- a/spigot-nms/v1_8_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_8_R2.java +++ b/spigot-nms/v1_8_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_8_R2.java @@ -1,5 +1,7 @@ package com.kamikazejam.kamicommon.nms.wrappers.world; +import com.kamikazejam.kamicommon.nms.abstraction.block.AbstractBlockUtil; +import com.kamikazejam.kamicommon.nms.provider.Provider; import com.kamikazejam.kamicommon.nms.wrappers.chunk.ChunkProvider_1_8_R2; import com.kamikazejam.kamicommon.nms.wrappers.chunk.NMSChunkProvider; import lombok.Getter; @@ -20,10 +22,12 @@ public class NMSWorld_1_8_R2 implements NMSWorld { private final @NotNull World bukkitWorld; private final @NotNull WorldServer worldServer; private final @NotNull CraftWorld craftWorld; - public NMSWorld_1_8_R2(@NotNull World world) { + private final @NotNull Provider provider; + public NMSWorld_1_8_R2(@NotNull World world, @NotNull Provider provider) { this.bukkitWorld = world; this.craftWorld = (CraftWorld) world; this.worldServer = this.craftWorld.getHandle(); + this.provider = provider; } @Override @@ -31,6 +35,11 @@ public NMSWorld_1_8_R2(@NotNull World world) { return this.worldServer; } + @Override + public @NotNull AbstractBlockUtil getBlockUtil() { + return this.provider.get(); + } + @Override public int getMinHeight() { return 0; diff --git a/spigot-nms/v1_8_R3/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_8_R3.java b/spigot-nms/v1_8_R3/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_8_R3.java index 2ed856ed..1e1d584d 100644 --- a/spigot-nms/v1_8_R3/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_8_R3.java +++ b/spigot-nms/v1_8_R3/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_8_R3.java @@ -4,7 +4,6 @@ import com.kamikazejam.kamicommon.nms.wrappers.world.NMSWorld_1_8_R3; import net.minecraft.server.v1_8_R3.Chunk; import net.minecraft.server.v1_8_R3.ChunkProviderServer; -import org.bukkit.craftbukkit.v1_8_R3.CraftChunk; import org.jetbrains.annotations.NotNull; public class ChunkProvider_1_8_R3 implements NMSChunkProvider { @@ -35,11 +34,6 @@ public void setForceChunkLoad(boolean value) { this.handle.forceChunkLoad = value; } - @Override - public @NotNull NMSChunk getOrCreateChunk(int x, int z) { - return new Chunk_1_8_R3(this, this.handle.getOrCreateChunk(x, z)); - } - @Override public void saveChunk(NMSChunk chunk) { this.handle.saveChunk((Chunk) chunk.getHandle()); @@ -47,6 +41,6 @@ public void saveChunk(NMSChunk chunk) { @Override public @NotNull NMSChunk wrap(org.bukkit.@NotNull Chunk chunk) { - return new Chunk_1_8_R3(this, ((CraftChunk) chunk).getHandle()); + return new Chunk_1_8_R3(this, chunk); } } diff --git a/spigot-nms/v1_8_R3/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_8_R3.java b/spigot-nms/v1_8_R3/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_8_R3.java index f2249cf1..27f4a34d 100644 --- a/spigot-nms/v1_8_R3/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_8_R3.java +++ b/spigot-nms/v1_8_R3/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_8_R3.java @@ -6,6 +6,7 @@ import net.minecraft.server.v1_8_R3.ChunkSection; import net.minecraft.server.v1_8_R3.PacketPlayOutMapChunk; import org.bukkit.World; +import org.bukkit.craftbukkit.v1_8_R3.CraftChunk; import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_8_R3.util.LongHash; @@ -17,11 +18,13 @@ public class Chunk_1_8_R3 implements NMSChunkDef { private final @NotNull ChunkProvider_1_8_R3 provider; + private final @NotNull org.bukkit.Chunk bukkitChunk; private final @NotNull Chunk chunk; private @Nullable Constructor constructor; // Alternate ChunkSection constructor - public Chunk_1_8_R3(@NotNull ChunkProvider_1_8_R3 provider, @NotNull Chunk chunk) { + public Chunk_1_8_R3(@NotNull ChunkProvider_1_8_R3 provider, @NotNull org.bukkit.Chunk bukkitChunk) { this.provider = provider; - this.chunk = chunk; + this.bukkitChunk = bukkitChunk; + this.chunk = ((CraftChunk) bukkitChunk).getHandle(); try { this.constructor = ChunkSection.class.getConstructor(int.class, boolean.class, int.class, int.class); }catch (NoSuchMethodException | SecurityException e) { @@ -34,6 +37,11 @@ public Chunk_1_8_R3(@NotNull ChunkProvider_1_8_R3 provider, @NotNull Chunk chunk return this.provider; } + @Override + public @NotNull org.bukkit.Chunk getBukkitChunk() { + return bukkitChunk; + } + @Override public @NotNull Object getHandle() { return this.chunk; diff --git a/spigot-nms/v1_8_R3/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_8_R3.java b/spigot-nms/v1_8_R3/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_8_R3.java index a983f7bd..12270f5f 100644 --- a/spigot-nms/v1_8_R3/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_8_R3.java +++ b/spigot-nms/v1_8_R3/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_8_R3.java @@ -1,5 +1,7 @@ package com.kamikazejam.kamicommon.nms.wrappers.world; +import com.kamikazejam.kamicommon.nms.abstraction.block.AbstractBlockUtil; +import com.kamikazejam.kamicommon.nms.provider.Provider; import com.kamikazejam.kamicommon.nms.wrappers.chunk.ChunkProvider_1_8_R3; import com.kamikazejam.kamicommon.nms.wrappers.chunk.NMSChunkProvider; import lombok.Getter; @@ -20,10 +22,12 @@ public class NMSWorld_1_8_R3 implements NMSWorld { private final @NotNull World bukkitWorld; private final @NotNull WorldServer worldServer; private final @NotNull CraftWorld craftWorld; - public NMSWorld_1_8_R3(@NotNull World world) { + private final @NotNull Provider provider; + public NMSWorld_1_8_R3(@NotNull World world, @NotNull Provider provider) { this.bukkitWorld = world; this.craftWorld = (CraftWorld) world; this.worldServer = this.craftWorld.getHandle(); + this.provider = provider; } @Override @@ -31,6 +35,11 @@ public NMSWorld_1_8_R3(@NotNull World world) { return this.worldServer; } + @Override + public @NotNull AbstractBlockUtil getBlockUtil() { + return this.provider.get(); + } + @Override public int getMinHeight() { return 0; diff --git a/spigot-nms/v1_9_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_9_R1.java b/spigot-nms/v1_9_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_9_R1.java index 4debe916..2a9c593f 100644 --- a/spigot-nms/v1_9_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_9_R1.java +++ b/spigot-nms/v1_9_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_9_R1.java @@ -4,7 +4,6 @@ import com.kamikazejam.kamicommon.nms.wrappers.world.NMSWorld_1_9_R1; import net.minecraft.server.v1_9_R1.Chunk; import net.minecraft.server.v1_9_R1.ChunkProviderServer; -import org.bukkit.craftbukkit.v1_9_R1.CraftChunk; import org.jetbrains.annotations.NotNull; public class ChunkProvider_1_9_R1 implements NMSChunkProvider { @@ -25,11 +24,6 @@ public ChunkProvider_1_9_R1(@NotNull NMSWorld_1_9_R1 world, @NotNull ChunkProvid return this.handle; } - @Override - public @NotNull NMSChunk getOrCreateChunk(int x, int z) { - return new Chunk_1_9_R1(this, this.handle.getChunkAt(x, z)); - } - @Override public void saveChunk(NMSChunk chunk) { this.handle.saveChunk((Chunk) chunk.getHandle()); @@ -37,6 +31,6 @@ public void saveChunk(NMSChunk chunk) { @Override public @NotNull NMSChunk wrap(org.bukkit.@NotNull Chunk chunk) { - return new Chunk_1_9_R1(this, ((CraftChunk) chunk).getHandle()); + return new Chunk_1_9_R1(this, chunk); } } diff --git a/spigot-nms/v1_9_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_9_R1.java b/spigot-nms/v1_9_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_9_R1.java index 25fceb81..bbb3a905 100644 --- a/spigot-nms/v1_9_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_9_R1.java +++ b/spigot-nms/v1_9_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_9_R1.java @@ -4,16 +4,19 @@ import net.minecraft.server.v1_9_R1.Chunk; import net.minecraft.server.v1_9_R1.ChunkSection; import net.minecraft.server.v1_9_R1.PacketPlayOutMapChunk; +import org.bukkit.craftbukkit.v1_9_R1.CraftChunk; import org.bukkit.craftbukkit.v1_9_R1.entity.CraftPlayer; import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; public class Chunk_1_9_R1 implements NMSChunkDef { private final @NotNull ChunkProvider_1_9_R1 provider; + private final @NotNull org.bukkit.Chunk bukkitChunk; private final @NotNull Chunk chunk; - public Chunk_1_9_R1(@NotNull ChunkProvider_1_9_R1 provider, @NotNull Chunk chunk) { + public Chunk_1_9_R1(@NotNull ChunkProvider_1_9_R1 provider, @NotNull org.bukkit.Chunk bukkitChunk) { this.provider = provider; - this.chunk = chunk; + this.bukkitChunk = bukkitChunk; + this.chunk = ((CraftChunk) bukkitChunk).getHandle(); } @Override @@ -21,6 +24,11 @@ public Chunk_1_9_R1(@NotNull ChunkProvider_1_9_R1 provider, @NotNull Chunk chunk return this.provider; } + @Override + public @NotNull org.bukkit.Chunk getBukkitChunk() { + return bukkitChunk; + } + @Override public @NotNull Object getHandle() { return this.chunk; diff --git a/spigot-nms/v1_9_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_9_R1.java b/spigot-nms/v1_9_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_9_R1.java index 3a62554f..fa1ab96f 100644 --- a/spigot-nms/v1_9_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_9_R1.java +++ b/spigot-nms/v1_9_R1/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_9_R1.java @@ -1,5 +1,7 @@ package com.kamikazejam.kamicommon.nms.wrappers.world; +import com.kamikazejam.kamicommon.nms.abstraction.block.AbstractBlockUtil; +import com.kamikazejam.kamicommon.nms.provider.Provider; import com.kamikazejam.kamicommon.nms.wrappers.chunk.ChunkProvider_1_9_R1; import com.kamikazejam.kamicommon.nms.wrappers.chunk.NMSChunkProvider; import lombok.Getter; @@ -20,10 +22,12 @@ public class NMSWorld_1_9_R1 implements NMSWorld { private final @NotNull World bukkitWorld; private final @NotNull WorldServer worldServer; private final @NotNull CraftWorld craftWorld; - public NMSWorld_1_9_R1(@NotNull World world) { + private final @NotNull Provider provider; + public NMSWorld_1_9_R1(@NotNull World world, @NotNull Provider provider) { this.bukkitWorld = world; this.craftWorld = (CraftWorld) world; this.worldServer = this.craftWorld.getHandle(); + this.provider = provider; } @Override @@ -31,6 +35,11 @@ public NMSWorld_1_9_R1(@NotNull World world) { return this.worldServer; } + @Override + public @NotNull AbstractBlockUtil getBlockUtil() { + return this.provider.get(); + } + @Override public int getMinHeight() { return 0; diff --git a/spigot-nms/v1_9_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_9_R2.java b/spigot-nms/v1_9_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_9_R2.java index ae9d8b15..edad3ce5 100644 --- a/spigot-nms/v1_9_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_9_R2.java +++ b/spigot-nms/v1_9_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/ChunkProvider_1_9_R2.java @@ -4,7 +4,6 @@ import com.kamikazejam.kamicommon.nms.wrappers.world.NMSWorld_1_9_R2; import net.minecraft.server.v1_9_R2.Chunk; import net.minecraft.server.v1_9_R2.ChunkProviderServer; -import org.bukkit.craftbukkit.v1_9_R2.CraftChunk; import org.jetbrains.annotations.NotNull; public class ChunkProvider_1_9_R2 implements NMSChunkProvider { @@ -25,11 +24,6 @@ public ChunkProvider_1_9_R2(@NotNull NMSWorld_1_9_R2 world, @NotNull ChunkProvid return this.handle; } - @Override - public @NotNull NMSChunk getOrCreateChunk(int x, int z) { - return new Chunk_1_9_R2(this, this.handle.getChunkAt(x, z)); - } - @Override public void saveChunk(NMSChunk chunk) { this.handle.saveChunk((Chunk) chunk.getHandle()); @@ -37,6 +31,6 @@ public void saveChunk(NMSChunk chunk) { @Override public @NotNull NMSChunk wrap(org.bukkit.@NotNull Chunk chunk) { - return new Chunk_1_9_R2(this, ((CraftChunk) chunk).getHandle()); + return new Chunk_1_9_R2(this, chunk); } } diff --git a/spigot-nms/v1_9_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_9_R2.java b/spigot-nms/v1_9_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_9_R2.java index 967e28a1..18edc121 100644 --- a/spigot-nms/v1_9_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_9_R2.java +++ b/spigot-nms/v1_9_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/chunk/Chunk_1_9_R2.java @@ -4,16 +4,19 @@ import net.minecraft.server.v1_9_R2.Chunk; import net.minecraft.server.v1_9_R2.ChunkSection; import net.minecraft.server.v1_9_R2.PacketPlayOutMapChunk; +import org.bukkit.craftbukkit.v1_9_R2.CraftChunk; import org.bukkit.craftbukkit.v1_9_R2.entity.CraftPlayer; import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; public class Chunk_1_9_R2 implements NMSChunkDef { private final @NotNull ChunkProvider_1_9_R2 provider; + private final @NotNull org.bukkit.Chunk bukkitChunk; private final @NotNull Chunk chunk; - public Chunk_1_9_R2(@NotNull ChunkProvider_1_9_R2 provider, @NotNull Chunk chunk) { + public Chunk_1_9_R2(@NotNull ChunkProvider_1_9_R2 provider, @NotNull org.bukkit.Chunk bukkitChunk) { this.provider = provider; - this.chunk = chunk; + this.bukkitChunk = bukkitChunk; + this.chunk = ((CraftChunk) bukkitChunk).getHandle(); } @Override @@ -21,6 +24,11 @@ public Chunk_1_9_R2(@NotNull ChunkProvider_1_9_R2 provider, @NotNull Chunk chunk return this.provider; } + @Override + public @NotNull org.bukkit.Chunk getBukkitChunk() { + return bukkitChunk; + } + @Override public @NotNull Object getHandle() { return this.chunk; diff --git a/spigot-nms/v1_9_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_9_R2.java b/spigot-nms/v1_9_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_9_R2.java index 0364dbb9..7c18c337 100644 --- a/spigot-nms/v1_9_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_9_R2.java +++ b/spigot-nms/v1_9_R2/src/main/java/com/kamikazejam/kamicommon/nms/wrappers/world/NMSWorld_1_9_R2.java @@ -1,5 +1,7 @@ package com.kamikazejam.kamicommon.nms.wrappers.world; +import com.kamikazejam.kamicommon.nms.abstraction.block.AbstractBlockUtil; +import com.kamikazejam.kamicommon.nms.provider.Provider; import com.kamikazejam.kamicommon.nms.wrappers.chunk.ChunkProvider_1_9_R2; import com.kamikazejam.kamicommon.nms.wrappers.chunk.NMSChunkProvider; import lombok.Getter; @@ -20,10 +22,12 @@ public class NMSWorld_1_9_R2 implements NMSWorld { private final @NotNull World bukkitWorld; private final @NotNull WorldServer worldServer; private final @NotNull CraftWorld craftWorld; - public NMSWorld_1_9_R2(@NotNull World world) { + private final @NotNull Provider provider; + public NMSWorld_1_9_R2(@NotNull World world, @NotNull Provider provider) { this.bukkitWorld = world; this.craftWorld = (CraftWorld) world; this.worldServer = this.craftWorld.getHandle(); + this.provider = provider; } @Override @@ -31,6 +35,11 @@ public NMSWorld_1_9_R2(@NotNull World world) { return this.worldServer; } + @Override + public @NotNull AbstractBlockUtil getBlockUtil() { + return this.provider.get(); + } + @Override public int getMinHeight() { return 0;