diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1ce9c07a..b7a0489a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,6 +6,7 @@ on: jobs: build: + if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository runs-on: ubuntu-latest steps: diff --git a/.github/workflows/buildtools.sh b/.github/workflows/buildtools.sh index 102091c7..2344e6cb 100644 --- a/.github/workflows/buildtools.sh +++ b/.github/workflows/buildtools.sh @@ -24,14 +24,6 @@ checkVersion () { fi } -checkVersion "1.9.4" "8" -checkVersion "1.10.2" "8" -checkVersion "1.11.2" "8" -checkVersion "1.12.2" "8" -checkVersion "1.13" "8" -checkVersion "1.13.2" "8" -checkVersion "1.14.4" "8" -checkVersion "1.15.2" "8" checkVersion "1.16.1" "8" checkVersion "1.16.3" "8" checkVersion "1.16.5" "8" @@ -45,3 +37,4 @@ checkVersion "1.20.1" "17" checkVersion "1.20.2" "17" checkVersion "1.20.4" "17" checkVersion "1.20.6" "21" +checkVersion "1.21" "21" diff --git a/README.md b/README.md index a6de4ade..0d733017 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ - # Orebfuscator - Anti X-Ray [![Release Status](https://github.com/Imprex-Development/Orebfuscator/workflows/Releases/badge.svg)](https://github.com/Imprex-Development/Orebfuscator/releases/latest) [![Build Status](https://github.com/Imprex-Development/Orebfuscator/workflows/Build/badge.svg)](https://github.com/Imprex-Development/Orebfuscator/actions?query=workflow%3ABuild) + Orebfuscator empowers server owners to protect their server from X-Ray Clients and Texture Packs, all while offering a high degree of configurability. This is achieved through modifying network packets without altering your game world, guaranteeing a secure and reliable experience for users. With Orebfuscator, you can tailor the settings to suit your server's needs, ensuring precise control over the visibility of specific blocks. This means that not only does Orebfuscator safeguard your world's integrity, but it also empowers you to fine-tune your Anti-X-Ray measures for the best gameplay experience. @@ -14,9 +14,9 @@ Orebfuscator empowers server owners to protect their server from X-Ray Clients a * Dynamic Block Visibility: Adjust block visibility based on player proximity and distance. ### Requirements -* Java 11 or higher -* Spigot, Paper, Folia or compatible forks (1.9.4 or newer) -* [ProtocolLib](https://www.spigotmc.org/resources/protocollib.1997) 5.0.0 or later +* Java 17 or higher +* Spigot, Paper, Folia or compatible forks (1.16 or newer) +* [ProtocolLib](https://www.spigotmc.org/resources/protocollib.1997) 5.2.0 or later ### Installation 1. Download [ProtocolLib](https://github.com/dmulloy2/ProtocolLib/releases) @@ -26,6 +26,9 @@ Orebfuscator empowers server owners to protect their server from X-Ray Clients a Still having trouble getting Orebfuscator to run check out our [common issues](https://github.com/Imprex-Development/Orebfuscator/wiki/Common-Issues). +### Legacy support +For compatibility with Java 11 or Minecraft 1.9.4 and later, you can use any legacy release prior to version 5.5.0. Please note that these legacy releases will no longer receive regular support or updates. However, they may receive critical security and vulnerability patches if necessary. + ### Maven To include the API in your Maven project, add the following configuration to your `pom.xml`: @@ -52,7 +55,7 @@ To include the API in your Maven project, add the following configuration to you ## License: Completely rewritten by Imprex-Development to support v1.14 and higher Minecraft version's; these portions as permissible: -Copyright (C) 2020-2023 by Imprex-Development. All rights reserved. +Copyright (C) 2020-2024 by Imprex-Development. All rights reserved. Released under the same license as original. diff --git a/orebfuscator-common/src/main/java/net/imprex/orebfuscator/config/AdvancedConfig.java b/orebfuscator-common/src/main/java/net/imprex/orebfuscator/config/AdvancedConfig.java index 129468a4..e891fd37 100644 --- a/orebfuscator-common/src/main/java/net/imprex/orebfuscator/config/AdvancedConfig.java +++ b/orebfuscator-common/src/main/java/net/imprex/orebfuscator/config/AdvancedConfig.java @@ -2,12 +2,8 @@ public interface AdvancedConfig { - boolean useAsyncPacketListener(); - int maxMillisecondsPerTick(); - int protocolLibThreads(); - int obfuscationWorkerThreads(); boolean hasObfuscationTimeout(); diff --git a/orebfuscator-common/src/main/java/net/imprex/orebfuscator/util/BlockProperties.java b/orebfuscator-common/src/main/java/net/imprex/orebfuscator/util/BlockProperties.java index a1c32905..a445d9fd 100644 --- a/orebfuscator-common/src/main/java/net/imprex/orebfuscator/util/BlockProperties.java +++ b/orebfuscator-common/src/main/java/net/imprex/orebfuscator/util/BlockProperties.java @@ -69,13 +69,7 @@ private Builder(NamespacedKey key) { } public Builder withBlockState(BlockStateProperties blockState) { - return this.withBlockState(blockState, false); - } - - /** dumb version for dumb id systems (pre 1.13.2) */ - @Deprecated - public Builder withBlockState(BlockStateProperties blockState, boolean ignoreDuplicates) { - if (!blockStates.add(blockState) && !ignoreDuplicates) { + if (!blockStates.add(blockState)) { throw new IllegalStateException(String.format("duplicate block state id (%s) for block: %s", blockState.getId(), key)); } diff --git a/orebfuscator-common/src/main/java/net/imprex/orebfuscator/util/MinecraftVersion.java b/orebfuscator-common/src/main/java/net/imprex/orebfuscator/util/MinecraftVersion.java index 74944552..1d7cc37c 100644 --- a/orebfuscator-common/src/main/java/net/imprex/orebfuscator/util/MinecraftVersion.java +++ b/orebfuscator-common/src/main/java/net/imprex/orebfuscator/util/MinecraftVersion.java @@ -15,6 +15,7 @@ private static final class NmsMapping { private static final List MAPPINGS = new ArrayList<>(); static { + MAPPINGS.add(new NmsMapping("1.21", "v1_21_R1")); MAPPINGS.add(new NmsMapping("1.20.5", "v1_20_R4")); } diff --git a/orebfuscator-nms/orebfuscator-nms-v1_10_R1/pom.xml b/orebfuscator-nms/orebfuscator-nms-v1_10_R1/pom.xml deleted file mode 100644 index 1b9b8dbd..00000000 --- a/orebfuscator-nms/orebfuscator-nms-v1_10_R1/pom.xml +++ /dev/null @@ -1,33 +0,0 @@ - - 4.0.0 - - - net.imprex - orebfuscator-nms - ${revision} - - - orebfuscator-nms-v1_10_R1 - jar - - - - net.imprex - orebfuscator-nms-api - ${revision} - provided - - - com.comphenix.protocol - ProtocolLib - ${dependency.protocollib.version} - provided - - - org.spigotmc - spigot - 1.10.2-R0.1-SNAPSHOT - provided - - - \ No newline at end of file diff --git a/orebfuscator-nms/orebfuscator-nms-v1_10_R1/src/main/java/net/imprex/orebfuscator/nms/v1_10_R1/NmsManager.java b/orebfuscator-nms/orebfuscator-nms-v1_10_R1/src/main/java/net/imprex/orebfuscator/nms/v1_10_R1/NmsManager.java deleted file mode 100644 index b87046f1..00000000 --- a/orebfuscator-nms/orebfuscator-nms-v1_10_R1/src/main/java/net/imprex/orebfuscator/nms/v1_10_R1/NmsManager.java +++ /dev/null @@ -1,198 +0,0 @@ -package net.imprex.orebfuscator.nms.v1_10_R1; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -import org.bukkit.World; -import org.bukkit.craftbukkit.v1_10_R1.CraftWorld; -import org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer; -import org.bukkit.entity.Player; - -import com.comphenix.protocol.PacketType; -import com.comphenix.protocol.events.PacketContainer; -import com.comphenix.protocol.wrappers.ChunkCoordIntPair; -import com.comphenix.protocol.wrappers.MultiBlockChangeInfo; -import com.comphenix.protocol.wrappers.WrappedBlockData; -import com.google.common.collect.ImmutableList; - -import net.imprex.orebfuscator.config.Config; -import net.imprex.orebfuscator.nms.AbstractNmsManager; -import net.imprex.orebfuscator.nms.ReadOnlyChunk; -import net.imprex.orebfuscator.util.BlockPos; -import net.imprex.orebfuscator.util.BlockProperties; -import net.imprex.orebfuscator.util.BlockStateProperties; -import net.imprex.orebfuscator.util.NamespacedKey; -import net.minecraft.server.v1_10_R1.Block; -import net.minecraft.server.v1_10_R1.BlockAir; -import net.minecraft.server.v1_10_R1.BlockPosition; -import net.minecraft.server.v1_10_R1.Blocks; -import net.minecraft.server.v1_10_R1.Chunk; -import net.minecraft.server.v1_10_R1.ChunkProviderServer; -import net.minecraft.server.v1_10_R1.ChunkSection; -import net.minecraft.server.v1_10_R1.EntityPlayer; -import net.minecraft.server.v1_10_R1.IBlockData; -import net.minecraft.server.v1_10_R1.MinecraftKey; -import net.minecraft.server.v1_10_R1.Packet; -import net.minecraft.server.v1_10_R1.PacketListenerPlayOut; -import net.minecraft.server.v1_10_R1.TileEntity; -import net.minecraft.server.v1_10_R1.WorldServer; - -public class NmsManager extends AbstractNmsManager { - - private static final int BLOCK_ID_AIR = getBlockId(Blocks.AIR.getBlockData()); - - static int getBlockState(Chunk chunk, int x, int y, int z) { - ChunkSection[] sections = chunk.getSections(); - - int sectionIndex = y >> 4; - if (sectionIndex >= 0 && sectionIndex < sections.length) { - ChunkSection section = sections[sectionIndex]; - if (section != null && section != Chunk.a) { - return getBlockId(section.getType(x & 0xF, y & 0xF, z & 0xF)); - } - } - - return BLOCK_ID_AIR; - } - - private static WorldServer level(World world) { - return ((CraftWorld) world).getHandle(); - } - - private static EntityPlayer player(Player player) { - return ((CraftPlayer) player).getHandle(); - } - - private static int getBlockId(IBlockData blockData) { - if (blockData == null) { - return 0; - } else { - int id = Block.REGISTRY_ID.getId(blockData); - return id == -1 ? 0 : id; - } - } - - public NmsManager(Config config) { - super(Block.REGISTRY_ID.a(), new RegionFileCache(config.cache())); - - for (MinecraftKey key : Block.REGISTRY.keySet()) { - NamespacedKey namespacedKey = NamespacedKey.fromString(key.toString()); - Block block = Block.REGISTRY.get(key); - - ImmutableList possibleBlockStates = block.t().a(); - BlockProperties.Builder builder = BlockProperties.builder(namespacedKey); - - for (IBlockData blockState : possibleBlockStates) { - - BlockStateProperties properties = BlockStateProperties.builder(getBlockId(blockState)) - .withIsAir(block instanceof BlockAir) - /** - * p -> for barrier/slime_block/spawner - * j -> for every other block - */ - .withIsOccluding(blockState.p() && block.j()/*canOcclude*/) - .withIsBlockEntity(block.isTileEntity()) - .withIsDefaultState(Objects.equals(block.getBlockData(), blockState)) - .build(); - - builder.withBlockState(properties, true); - } - - this.registerBlockProperties(builder.build()); - } - } - - @Override - public ReadOnlyChunk getReadOnlyChunk(World world, int chunkX, int chunkZ) { - ChunkProviderServer chunkProviderServer = level(world).getChunkProviderServer(); - Chunk chunk = chunkProviderServer.getChunkAt(chunkX, chunkZ); - return new ReadOnlyChunkWrapper(chunk); - } - - @Override - public int getBlockState(World world, int x, int y, int z) { - ChunkProviderServer serverChunkCache = level(world).getChunkProviderServer(); - if (!serverChunkCache.isLoaded(x >> 4, z >> 4)) { - return BLOCK_ID_AIR; - } - - Chunk chunk = serverChunkCache.getChunkAt(x >> 4, z >> 4); - if (chunk == null) { - return BLOCK_ID_AIR; - } - - return getBlockState(chunk, x, y, z); - } - - @Override - public void sendBlockUpdates(World world, Iterable iterable) { - WorldServer level = level(world); - BlockPosition.MutableBlockPosition position = new BlockPosition.MutableBlockPosition(); - - for (net.imprex.orebfuscator.util.BlockPos pos : iterable) { - position.c(pos.x, pos.y, pos.z); - - IBlockData blockState = level.getType(position); - level.notify(position, blockState, blockState, 0); - } - } - - @Override - public void sendBlockUpdates(Player player, Iterable iterable) { - EntityPlayer serverPlayer = player(player); - WorldServer level = serverPlayer.x(); - ChunkProviderServer serverChunkCache = level.getChunkProviderServer(); - - BlockPosition.MutableBlockPosition position = new BlockPosition.MutableBlockPosition(); - Map> sectionPackets = new HashMap<>(); - List> blockEntityPackets = new ArrayList<>(); - - for (net.imprex.orebfuscator.util.BlockPos pos : iterable) { - if (!serverChunkCache.isLoaded(pos.x >> 4, pos.z >> 4)) { - continue; - } - - position.c(pos.x, pos.y, pos.z); - IBlockData blockState = level.getType(position); - - ChunkCoordIntPair chunkCoord = new ChunkCoordIntPair(pos.x >> 4, pos.z >> 4); - short location = (short) ((pos.x & 0xF) << 12 | (pos.z & 0xF) << 8 | pos.y); - - sectionPackets.computeIfAbsent(chunkCoord, key -> new ArrayList<>()) - .add(new MultiBlockChangeInfo(location, WrappedBlockData.fromHandle(blockState), chunkCoord)); - - if (blockState.getBlock().isTileEntity()) { - TileEntity blockEntity = level.getTileEntity(position); - if (blockEntity != null) { - blockEntityPackets.add(blockEntity.getUpdatePacket()); - } - } - } - - for (Map.Entry> entry : sectionPackets.entrySet()) { - List blockStates = entry.getValue(); - if (blockStates.size() == 1) { - MultiBlockChangeInfo blockEntry = blockStates.get(0); - var blockPosition = new com.comphenix.protocol.wrappers.BlockPosition( - blockEntry.getAbsoluteX(), blockEntry.getY(), blockEntry.getAbsoluteZ()); - - PacketContainer packet = new PacketContainer(PacketType.Play.Server.BLOCK_CHANGE); - packet.getBlockPositionModifier().write(0, blockPosition); - packet.getBlockData().write(0, blockEntry.getData()); - serverPlayer.playerConnection.sendPacket((Packet) packet.getHandle()); - } else { - PacketContainer packet = new PacketContainer(PacketType.Play.Server.MULTI_BLOCK_CHANGE); - packet.getChunkCoordIntPairs().write(0, entry.getKey()); - packet.getMultiBlockChangeInfoArrays().write(0, blockStates.toArray(MultiBlockChangeInfo[]::new)); - serverPlayer.playerConnection.sendPacket((Packet) packet.getHandle()); - } - } - - for (Packet packet : blockEntityPackets) { - serverPlayer.playerConnection.sendPacket(packet); - } - } -} diff --git a/orebfuscator-nms/orebfuscator-nms-v1_10_R1/src/main/java/net/imprex/orebfuscator/nms/v1_10_R1/ReadOnlyChunkWrapper.java b/orebfuscator-nms/orebfuscator-nms-v1_10_R1/src/main/java/net/imprex/orebfuscator/nms/v1_10_R1/ReadOnlyChunkWrapper.java deleted file mode 100644 index 346cf3c4..00000000 --- a/orebfuscator-nms/orebfuscator-nms-v1_10_R1/src/main/java/net/imprex/orebfuscator/nms/v1_10_R1/ReadOnlyChunkWrapper.java +++ /dev/null @@ -1,18 +0,0 @@ -package net.imprex.orebfuscator.nms.v1_10_R1; - -import net.imprex.orebfuscator.nms.ReadOnlyChunk; -import net.minecraft.server.v1_10_R1.Chunk; - -public class ReadOnlyChunkWrapper implements ReadOnlyChunk { - - private final Chunk chunk; - - ReadOnlyChunkWrapper(Chunk chunk) { - this.chunk = chunk; - } - - @Override - public int getBlockState(int x, int y, int z) { - return NmsManager.getBlockState(chunk, x, y, z); - } -} diff --git a/orebfuscator-nms/orebfuscator-nms-v1_10_R1/src/main/java/net/imprex/orebfuscator/nms/v1_10_R1/RegionFileCache.java b/orebfuscator-nms/orebfuscator-nms-v1_10_R1/src/main/java/net/imprex/orebfuscator/nms/v1_10_R1/RegionFileCache.java deleted file mode 100644 index 90481ad0..00000000 --- a/orebfuscator-nms/orebfuscator-nms-v1_10_R1/src/main/java/net/imprex/orebfuscator/nms/v1_10_R1/RegionFileCache.java +++ /dev/null @@ -1,38 +0,0 @@ -package net.imprex.orebfuscator.nms.v1_10_R1; - -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; -import java.nio.file.Path; - -import net.imprex.orebfuscator.config.CacheConfig; -import net.imprex.orebfuscator.nms.AbstractRegionFileCache; -import net.imprex.orebfuscator.util.ChunkPosition; -import net.minecraft.server.v1_10_R1.RegionFile; - -public class RegionFileCache extends AbstractRegionFileCache { - - RegionFileCache(CacheConfig cacheConfig) { - super(cacheConfig); - } - - @Override - protected RegionFile createRegionFile(Path path) throws IOException { - return new RegionFile(path.toFile()); - } - - @Override - protected void closeRegionFile(RegionFile t) throws IOException { - t.c(); - } - - @Override - protected DataInputStream createInputStream(RegionFile t, ChunkPosition key) throws IOException { - return t.a(key.x & 0x1F, key.z & 0x1F); - } - - @Override - protected DataOutputStream createOutputStream(RegionFile t, ChunkPosition key) throws IOException { - return t.b(key.x & 0x1F, key.z & 0x1F); - } -} diff --git a/orebfuscator-nms/orebfuscator-nms-v1_11_R1/pom.xml b/orebfuscator-nms/orebfuscator-nms-v1_11_R1/pom.xml deleted file mode 100644 index 47fb2a77..00000000 --- a/orebfuscator-nms/orebfuscator-nms-v1_11_R1/pom.xml +++ /dev/null @@ -1,33 +0,0 @@ - - 4.0.0 - - - net.imprex - orebfuscator-nms - ${revision} - - - orebfuscator-nms-v1_11_R1 - jar - - - - net.imprex - orebfuscator-nms-api - ${revision} - provided - - - com.comphenix.protocol - ProtocolLib - ${dependency.protocollib.version} - provided - - - org.spigotmc - spigot - 1.11.2-R0.1-SNAPSHOT - provided - - - \ No newline at end of file diff --git a/orebfuscator-nms/orebfuscator-nms-v1_11_R1/src/main/java/net/imprex/orebfuscator/nms/v1_11_R1/NmsManager.java b/orebfuscator-nms/orebfuscator-nms-v1_11_R1/src/main/java/net/imprex/orebfuscator/nms/v1_11_R1/NmsManager.java deleted file mode 100644 index 800c1bb1..00000000 --- a/orebfuscator-nms/orebfuscator-nms-v1_11_R1/src/main/java/net/imprex/orebfuscator/nms/v1_11_R1/NmsManager.java +++ /dev/null @@ -1,198 +0,0 @@ -package net.imprex.orebfuscator.nms.v1_11_R1; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -import org.bukkit.World; -import org.bukkit.craftbukkit.v1_11_R1.CraftWorld; -import org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer; -import org.bukkit.entity.Player; - -import com.comphenix.protocol.PacketType; -import com.comphenix.protocol.events.PacketContainer; -import com.comphenix.protocol.wrappers.ChunkCoordIntPair; -import com.comphenix.protocol.wrappers.MultiBlockChangeInfo; -import com.comphenix.protocol.wrappers.WrappedBlockData; -import com.google.common.collect.ImmutableList; - -import net.imprex.orebfuscator.config.Config; -import net.imprex.orebfuscator.nms.AbstractNmsManager; -import net.imprex.orebfuscator.nms.ReadOnlyChunk; -import net.imprex.orebfuscator.util.BlockPos; -import net.imprex.orebfuscator.util.BlockProperties; -import net.imprex.orebfuscator.util.BlockStateProperties; -import net.imprex.orebfuscator.util.NamespacedKey; -import net.minecraft.server.v1_11_R1.Block; -import net.minecraft.server.v1_11_R1.BlockAir; -import net.minecraft.server.v1_11_R1.BlockPosition; -import net.minecraft.server.v1_11_R1.Blocks; -import net.minecraft.server.v1_11_R1.Chunk; -import net.minecraft.server.v1_11_R1.ChunkProviderServer; -import net.minecraft.server.v1_11_R1.ChunkSection; -import net.minecraft.server.v1_11_R1.EntityPlayer; -import net.minecraft.server.v1_11_R1.IBlockData; -import net.minecraft.server.v1_11_R1.MinecraftKey; -import net.minecraft.server.v1_11_R1.Packet; -import net.minecraft.server.v1_11_R1.PacketListenerPlayOut; -import net.minecraft.server.v1_11_R1.TileEntity; -import net.minecraft.server.v1_11_R1.WorldServer; - -public class NmsManager extends AbstractNmsManager { - - private static final int BLOCK_ID_AIR = getBlockId(Blocks.AIR.getBlockData()); - - static int getBlockState(Chunk chunk, int x, int y, int z) { - ChunkSection[] sections = chunk.getSections(); - - int sectionIndex = y >> 4; - if (sectionIndex >= 0 && sectionIndex < sections.length) { - ChunkSection section = sections[sectionIndex]; - if (section != null && section != Chunk.a) { - return getBlockId(section.getType(x & 0xF, y & 0xF, z & 0xF)); - } - } - - return BLOCK_ID_AIR; - } - - private static WorldServer level(World world) { - return ((CraftWorld) world).getHandle(); - } - - private static EntityPlayer player(Player player) { - return ((CraftPlayer) player).getHandle(); - } - - private static int getBlockId(IBlockData blockData) { - if (blockData == null) { - return 0; - } else { - int id = Block.REGISTRY_ID.getId(blockData); - return id == -1 ? 0 : id; - } - } - - public NmsManager(Config config) { - super(Block.REGISTRY_ID.a(), new RegionFileCache(config.cache())); - - for (MinecraftKey key : Block.REGISTRY.keySet()) { - NamespacedKey namespacedKey = NamespacedKey.fromString(key.toString()); - Block block = Block.REGISTRY.get(key); - - ImmutableList possibleBlockStates = block.s().a(); - BlockProperties.Builder builder = BlockProperties.builder(namespacedKey); - - for (IBlockData blockState : possibleBlockStates) { - - BlockStateProperties properties = BlockStateProperties.builder(getBlockId(blockState)) - .withIsAir(block instanceof BlockAir) - /** - * q -> for barrier/slime_block/spawner - * s -> for every other block - */ - .withIsOccluding(blockState.q() && blockState.s()/*canOcclude*/) - .withIsBlockEntity(block.isTileEntity()) - .withIsDefaultState(Objects.equals(block.getBlockData(), blockState)) - .build(); - - builder.withBlockState(properties, true); - } - - this.registerBlockProperties(builder.build()); - } - } - - @Override - public ReadOnlyChunk getReadOnlyChunk(World world, int chunkX, int chunkZ) { - ChunkProviderServer chunkProviderServer = level(world).getChunkProviderServer(); - Chunk chunk = chunkProviderServer.getChunkAt(chunkX, chunkZ); - return new ReadOnlyChunkWrapper(chunk); - } - - @Override - public int getBlockState(World world, int x, int y, int z) { - ChunkProviderServer serverChunkCache = level(world).getChunkProviderServer(); - if (!serverChunkCache.isLoaded(x >> 4, z >> 4)) { - return BLOCK_ID_AIR; - } - - Chunk chunk = serverChunkCache.getChunkAt(x >> 4, z >> 4); - if (chunk == null) { - return BLOCK_ID_AIR; - } - - return getBlockState(chunk, x, y, z); - } - - @Override - public void sendBlockUpdates(World world, Iterable iterable) { - WorldServer level = level(world); - BlockPosition.MutableBlockPosition position = new BlockPosition.MutableBlockPosition(); - - for (net.imprex.orebfuscator.util.BlockPos pos : iterable) { - position.c(pos.x, pos.y, pos.z); - - IBlockData blockState = level.getType(position); - level.notify(position, blockState, blockState, 0); - } - } - - @Override - public void sendBlockUpdates(Player player, Iterable iterable) { - EntityPlayer serverPlayer = player(player); - WorldServer level = serverPlayer.x(); - ChunkProviderServer serverChunkCache = level.getChunkProviderServer(); - - BlockPosition.MutableBlockPosition position = new BlockPosition.MutableBlockPosition(); - Map> sectionPackets = new HashMap<>(); - List> blockEntityPackets = new ArrayList<>(); - - for (net.imprex.orebfuscator.util.BlockPos pos : iterable) { - if (!serverChunkCache.isLoaded(pos.x >> 4, pos.z >> 4)) { - continue; - } - - position.c(pos.x, pos.y, pos.z); - IBlockData blockState = level.getType(position); - - ChunkCoordIntPair chunkCoord = new ChunkCoordIntPair(pos.x >> 4, pos.z >> 4); - short location = (short) ((pos.x & 0xF) << 12 | (pos.z & 0xF) << 8 | pos.y); - - sectionPackets.computeIfAbsent(chunkCoord, key -> new ArrayList<>()) - .add(new MultiBlockChangeInfo(location, WrappedBlockData.fromHandle(blockState), chunkCoord)); - - if (blockState.getBlock().isTileEntity()) { - TileEntity blockEntity = level.getTileEntity(position); - if (blockEntity != null) { - blockEntityPackets.add(blockEntity.getUpdatePacket()); - } - } - } - - for (Map.Entry> entry : sectionPackets.entrySet()) { - List blockStates = entry.getValue(); - if (blockStates.size() == 1) { - MultiBlockChangeInfo blockEntry = blockStates.get(0); - var blockPosition = new com.comphenix.protocol.wrappers.BlockPosition( - blockEntry.getAbsoluteX(), blockEntry.getY(), blockEntry.getAbsoluteZ()); - - PacketContainer packet = new PacketContainer(PacketType.Play.Server.BLOCK_CHANGE); - packet.getBlockPositionModifier().write(0, blockPosition); - packet.getBlockData().write(0, blockEntry.getData()); - serverPlayer.playerConnection.sendPacket((Packet) packet.getHandle()); - } else { - PacketContainer packet = new PacketContainer(PacketType.Play.Server.MULTI_BLOCK_CHANGE); - packet.getChunkCoordIntPairs().write(0, entry.getKey()); - packet.getMultiBlockChangeInfoArrays().write(0, blockStates.toArray(MultiBlockChangeInfo[]::new)); - serverPlayer.playerConnection.sendPacket((Packet) packet.getHandle()); - } - } - - for (Packet packet : blockEntityPackets) { - serverPlayer.playerConnection.sendPacket(packet); - } - } -} diff --git a/orebfuscator-nms/orebfuscator-nms-v1_11_R1/src/main/java/net/imprex/orebfuscator/nms/v1_11_R1/RegionFileCache.java b/orebfuscator-nms/orebfuscator-nms-v1_11_R1/src/main/java/net/imprex/orebfuscator/nms/v1_11_R1/RegionFileCache.java deleted file mode 100644 index 94384db2..00000000 --- a/orebfuscator-nms/orebfuscator-nms-v1_11_R1/src/main/java/net/imprex/orebfuscator/nms/v1_11_R1/RegionFileCache.java +++ /dev/null @@ -1,38 +0,0 @@ -package net.imprex.orebfuscator.nms.v1_11_R1; - -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; -import java.nio.file.Path; - -import net.imprex.orebfuscator.config.CacheConfig; -import net.imprex.orebfuscator.nms.AbstractRegionFileCache; -import net.imprex.orebfuscator.util.ChunkPosition; -import net.minecraft.server.v1_11_R1.RegionFile; - -public class RegionFileCache extends AbstractRegionFileCache { - - RegionFileCache(CacheConfig cacheConfig) { - super(cacheConfig); - } - - @Override - protected RegionFile createRegionFile(Path path) throws IOException { - return new RegionFile(path.toFile()); - } - - @Override - protected void closeRegionFile(RegionFile t) throws IOException { - t.c(); - } - - @Override - protected DataInputStream createInputStream(RegionFile t, ChunkPosition key) throws IOException { - return t.a(key.x & 0x1F, key.z & 0x1F); - } - - @Override - protected DataOutputStream createOutputStream(RegionFile t, ChunkPosition key) throws IOException { - return t.b(key.x & 0x1F, key.z & 0x1F); - } -} diff --git a/orebfuscator-nms/orebfuscator-nms-v1_12_R1/pom.xml b/orebfuscator-nms/orebfuscator-nms-v1_12_R1/pom.xml deleted file mode 100644 index f0beea37..00000000 --- a/orebfuscator-nms/orebfuscator-nms-v1_12_R1/pom.xml +++ /dev/null @@ -1,33 +0,0 @@ - - 4.0.0 - - - net.imprex - orebfuscator-nms - ${revision} - - - orebfuscator-nms-v1_12_R1 - jar - - - - net.imprex - orebfuscator-nms-api - ${revision} - provided - - - com.comphenix.protocol - ProtocolLib - ${dependency.protocollib.version} - provided - - - org.spigotmc - spigot - 1.12.2-R0.1-SNAPSHOT - provided - - - \ No newline at end of file diff --git a/orebfuscator-nms/orebfuscator-nms-v1_12_R1/src/main/java/net/imprex/orebfuscator/nms/v1_12_R1/NmsManager.java b/orebfuscator-nms/orebfuscator-nms-v1_12_R1/src/main/java/net/imprex/orebfuscator/nms/v1_12_R1/NmsManager.java deleted file mode 100644 index 92adcbaa..00000000 --- a/orebfuscator-nms/orebfuscator-nms-v1_12_R1/src/main/java/net/imprex/orebfuscator/nms/v1_12_R1/NmsManager.java +++ /dev/null @@ -1,198 +0,0 @@ -package net.imprex.orebfuscator.nms.v1_12_R1; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -import org.bukkit.World; -import org.bukkit.craftbukkit.v1_12_R1.CraftWorld; -import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer; -import org.bukkit.entity.Player; - -import com.comphenix.protocol.PacketType; -import com.comphenix.protocol.events.PacketContainer; -import com.comphenix.protocol.wrappers.ChunkCoordIntPair; -import com.comphenix.protocol.wrappers.MultiBlockChangeInfo; -import com.comphenix.protocol.wrappers.WrappedBlockData; -import com.google.common.collect.ImmutableList; - -import net.imprex.orebfuscator.config.Config; -import net.imprex.orebfuscator.nms.AbstractNmsManager; -import net.imprex.orebfuscator.nms.ReadOnlyChunk; -import net.imprex.orebfuscator.util.BlockPos; -import net.imprex.orebfuscator.util.BlockProperties; -import net.imprex.orebfuscator.util.BlockStateProperties; -import net.imprex.orebfuscator.util.NamespacedKey; -import net.minecraft.server.v1_12_R1.Block; -import net.minecraft.server.v1_12_R1.BlockAir; -import net.minecraft.server.v1_12_R1.BlockPosition; -import net.minecraft.server.v1_12_R1.Blocks; -import net.minecraft.server.v1_12_R1.Chunk; -import net.minecraft.server.v1_12_R1.ChunkProviderServer; -import net.minecraft.server.v1_12_R1.ChunkSection; -import net.minecraft.server.v1_12_R1.EntityPlayer; -import net.minecraft.server.v1_12_R1.IBlockData; -import net.minecraft.server.v1_12_R1.MinecraftKey; -import net.minecraft.server.v1_12_R1.Packet; -import net.minecraft.server.v1_12_R1.PacketListenerPlayOut; -import net.minecraft.server.v1_12_R1.TileEntity; -import net.minecraft.server.v1_12_R1.WorldServer; - -public class NmsManager extends AbstractNmsManager { - - private static final int BLOCK_ID_AIR = getBlockId(Blocks.AIR.getBlockData()); - - static int getBlockState(Chunk chunk, int x, int y, int z) { - ChunkSection[] sections = chunk.getSections(); - - int sectionIndex = y >> 4; - if (sectionIndex >= 0 && sectionIndex < sections.length) { - ChunkSection section = sections[sectionIndex]; - if (section != null && section != Chunk.a) { - return getBlockId(section.getType(x & 0xF, y & 0xF, z & 0xF)); - } - } - - return BLOCK_ID_AIR; - } - - private static WorldServer level(World world) { - return ((CraftWorld) world).getHandle(); - } - - private static EntityPlayer player(Player player) { - return ((CraftPlayer) player).getHandle(); - } - - private static int getBlockId(IBlockData blockData) { - if (blockData == null) { - return 0; - } else { - int id = Block.REGISTRY_ID.getId(blockData); - return id == -1 ? 0 : id; - } - } - - public NmsManager(Config config) { - super(Block.REGISTRY_ID.a(), new RegionFileCache(config.cache())); - - for (MinecraftKey key : Block.REGISTRY.keySet()) { - NamespacedKey namespacedKey = NamespacedKey.fromString(key.toString()); - Block block = Block.REGISTRY.get(key); - - ImmutableList possibleBlockStates = block.s().a(); - BlockProperties.Builder builder = BlockProperties.builder(namespacedKey); - - for (IBlockData blockState : possibleBlockStates) { - - BlockStateProperties properties = BlockStateProperties.builder(getBlockId(blockState)) - .withIsAir(block instanceof BlockAir) - /** - * p -> for barrier/slime_block/spawner - * r -> for every other block - */ - .withIsOccluding(blockState.p() && blockState.r()/*canOcclude*/) - .withIsBlockEntity(block.isTileEntity()) - .withIsDefaultState(Objects.equals(block.getBlockData(), blockState)) - .build(); - - builder.withBlockState(properties, true); - } - - this.registerBlockProperties(builder.build()); - } - } - - @Override - public ReadOnlyChunk getReadOnlyChunk(World world, int chunkX, int chunkZ) { - ChunkProviderServer chunkProviderServer = level(world).getChunkProviderServer(); - Chunk chunk = chunkProviderServer.getChunkAt(chunkX, chunkZ); - return new ReadOnlyChunkWrapper(chunk); - } - - @Override - public int getBlockState(World world, int x, int y, int z) { - ChunkProviderServer serverChunkCache = level(world).getChunkProviderServer(); - if (!serverChunkCache.isLoaded(x >> 4, z >> 4)) { - return BLOCK_ID_AIR; - } - - Chunk chunk = serverChunkCache.getChunkAt(x >> 4, z >> 4); - if (chunk == null) { - return BLOCK_ID_AIR; - } - - return getBlockState(chunk, x, y, z); - } - - @Override - public void sendBlockUpdates(World world, Iterable iterable) { - WorldServer level = level(world); - BlockPosition.MutableBlockPosition position = new BlockPosition.MutableBlockPosition(); - - for (net.imprex.orebfuscator.util.BlockPos pos : iterable) { - position.c(pos.x, pos.y, pos.z); - - IBlockData blockState = level.getType(position); - level.notify(position, blockState, blockState, 0); - } - } - - @Override - public void sendBlockUpdates(Player player, Iterable iterable) { - EntityPlayer serverPlayer = player(player); - WorldServer level = serverPlayer.x(); - ChunkProviderServer serverChunkCache = level.getChunkProviderServer(); - - BlockPosition.MutableBlockPosition position = new BlockPosition.MutableBlockPosition(); - Map> sectionPackets = new HashMap<>(); - List> blockEntityPackets = new ArrayList<>(); - - for (net.imprex.orebfuscator.util.BlockPos pos : iterable) { - if (!serverChunkCache.isLoaded(pos.x >> 4, pos.z >> 4)) { - continue; - } - - position.c(pos.x, pos.y, pos.z); - IBlockData blockState = level.getType(position); - - ChunkCoordIntPair chunkCoord = new ChunkCoordIntPair(pos.x >> 4, pos.z >> 4); - short location = (short) ((pos.x & 0xF) << 12 | (pos.z & 0xF) << 8 | pos.y); - - sectionPackets.computeIfAbsent(chunkCoord, key -> new ArrayList<>()) - .add(new MultiBlockChangeInfo(location, WrappedBlockData.fromHandle(blockState), chunkCoord)); - - if (blockState.getBlock().isTileEntity()) { - TileEntity blockEntity = level.getTileEntity(position); - if (blockEntity != null) { - blockEntityPackets.add(blockEntity.getUpdatePacket()); - } - } - } - - for (Map.Entry> entry : sectionPackets.entrySet()) { - List blockStates = entry.getValue(); - if (blockStates.size() == 1) { - MultiBlockChangeInfo blockEntry = blockStates.get(0); - var blockPosition = new com.comphenix.protocol.wrappers.BlockPosition( - blockEntry.getAbsoluteX(), blockEntry.getY(), blockEntry.getAbsoluteZ()); - - PacketContainer packet = new PacketContainer(PacketType.Play.Server.BLOCK_CHANGE); - packet.getBlockPositionModifier().write(0, blockPosition); - packet.getBlockData().write(0, blockEntry.getData()); - serverPlayer.playerConnection.sendPacket((Packet) packet.getHandle()); - } else { - PacketContainer packet = new PacketContainer(PacketType.Play.Server.MULTI_BLOCK_CHANGE); - packet.getChunkCoordIntPairs().write(0, entry.getKey()); - packet.getMultiBlockChangeInfoArrays().write(0, blockStates.toArray(MultiBlockChangeInfo[]::new)); - serverPlayer.playerConnection.sendPacket((Packet) packet.getHandle()); - } - } - - for (Packet packet : blockEntityPackets) { - serverPlayer.playerConnection.sendPacket(packet); - } - } -} diff --git a/orebfuscator-nms/orebfuscator-nms-v1_12_R1/src/main/java/net/imprex/orebfuscator/nms/v1_12_R1/ReadOnlyChunkWrapper.java b/orebfuscator-nms/orebfuscator-nms-v1_12_R1/src/main/java/net/imprex/orebfuscator/nms/v1_12_R1/ReadOnlyChunkWrapper.java deleted file mode 100644 index 6b7227ca..00000000 --- a/orebfuscator-nms/orebfuscator-nms-v1_12_R1/src/main/java/net/imprex/orebfuscator/nms/v1_12_R1/ReadOnlyChunkWrapper.java +++ /dev/null @@ -1,18 +0,0 @@ -package net.imprex.orebfuscator.nms.v1_12_R1; - -import net.imprex.orebfuscator.nms.ReadOnlyChunk; -import net.minecraft.server.v1_12_R1.Chunk; - -public class ReadOnlyChunkWrapper implements ReadOnlyChunk { - - private final Chunk chunk; - - ReadOnlyChunkWrapper(Chunk chunk) { - this.chunk = chunk; - } - - @Override - public int getBlockState(int x, int y, int z) { - return NmsManager.getBlockState(chunk, x, y, z); - } -} diff --git a/orebfuscator-nms/orebfuscator-nms-v1_12_R1/src/main/java/net/imprex/orebfuscator/nms/v1_12_R1/RegionFileCache.java b/orebfuscator-nms/orebfuscator-nms-v1_12_R1/src/main/java/net/imprex/orebfuscator/nms/v1_12_R1/RegionFileCache.java deleted file mode 100644 index 72bb7f4e..00000000 --- a/orebfuscator-nms/orebfuscator-nms-v1_12_R1/src/main/java/net/imprex/orebfuscator/nms/v1_12_R1/RegionFileCache.java +++ /dev/null @@ -1,38 +0,0 @@ -package net.imprex.orebfuscator.nms.v1_12_R1; - -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; -import java.nio.file.Path; - -import net.imprex.orebfuscator.config.CacheConfig; -import net.imprex.orebfuscator.nms.AbstractRegionFileCache; -import net.imprex.orebfuscator.util.ChunkPosition; -import net.minecraft.server.v1_12_R1.RegionFile; - -public class RegionFileCache extends AbstractRegionFileCache { - - RegionFileCache(CacheConfig cacheConfig) { - super(cacheConfig); - } - - @Override - protected RegionFile createRegionFile(Path path) throws IOException { - return new RegionFile(path.toFile()); - } - - @Override - protected void closeRegionFile(RegionFile t) throws IOException { - t.c(); - } - - @Override - protected DataInputStream createInputStream(RegionFile t, ChunkPosition key) throws IOException { - return t.a(key.x & 0x1F, key.z & 0x1F); - } - - @Override - protected DataOutputStream createOutputStream(RegionFile t, ChunkPosition key) throws IOException { - return t.b(key.x & 0x1F, key.z & 0x1F); - } -} diff --git a/orebfuscator-nms/orebfuscator-nms-v1_13_R1/pom.xml b/orebfuscator-nms/orebfuscator-nms-v1_13_R1/pom.xml deleted file mode 100644 index 05e92c76..00000000 --- a/orebfuscator-nms/orebfuscator-nms-v1_13_R1/pom.xml +++ /dev/null @@ -1,33 +0,0 @@ - - 4.0.0 - - - net.imprex - orebfuscator-nms - ${revision} - - - orebfuscator-nms-v1_13_R1 - jar - - - - net.imprex - orebfuscator-nms-api - ${revision} - provided - - - com.comphenix.protocol - ProtocolLib - ${dependency.protocollib.version} - provided - - - org.spigotmc - spigot - 1.13-R0.1-SNAPSHOT - provided - - - \ No newline at end of file diff --git a/orebfuscator-nms/orebfuscator-nms-v1_13_R1/src/main/java/net/imprex/orebfuscator/nms/v1_13_R1/NmsManager.java b/orebfuscator-nms/orebfuscator-nms-v1_13_R1/src/main/java/net/imprex/orebfuscator/nms/v1_13_R1/NmsManager.java deleted file mode 100644 index f2f69629..00000000 --- a/orebfuscator-nms/orebfuscator-nms-v1_13_R1/src/main/java/net/imprex/orebfuscator/nms/v1_13_R1/NmsManager.java +++ /dev/null @@ -1,187 +0,0 @@ -package net.imprex.orebfuscator.nms.v1_13_R1; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -import org.bukkit.World; -import org.bukkit.craftbukkit.v1_13_R1.CraftWorld; -import org.bukkit.craftbukkit.v1_13_R1.entity.CraftPlayer; -import org.bukkit.entity.Player; - -import com.comphenix.protocol.PacketType; -import com.comphenix.protocol.events.PacketContainer; -import com.comphenix.protocol.wrappers.ChunkCoordIntPair; -import com.comphenix.protocol.wrappers.MultiBlockChangeInfo; -import com.comphenix.protocol.wrappers.WrappedBlockData; -import com.google.common.collect.ImmutableList; - -import net.imprex.orebfuscator.config.Config; -import net.imprex.orebfuscator.nms.AbstractNmsManager; -import net.imprex.orebfuscator.nms.ReadOnlyChunk; -import net.imprex.orebfuscator.util.BlockPos; -import net.imprex.orebfuscator.util.BlockProperties; -import net.imprex.orebfuscator.util.BlockStateProperties; -import net.imprex.orebfuscator.util.NamespacedKey; -import net.minecraft.server.v1_13_R1.Block; -import net.minecraft.server.v1_13_R1.BlockPosition; -import net.minecraft.server.v1_13_R1.Blocks; -import net.minecraft.server.v1_13_R1.Chunk; -import net.minecraft.server.v1_13_R1.ChunkProviderServer; -import net.minecraft.server.v1_13_R1.ChunkSection; -import net.minecraft.server.v1_13_R1.EntityPlayer; -import net.minecraft.server.v1_13_R1.IBlockData; -import net.minecraft.server.v1_13_R1.MinecraftKey; -import net.minecraft.server.v1_13_R1.Packet; -import net.minecraft.server.v1_13_R1.PacketListenerPlayOut; -import net.minecraft.server.v1_13_R1.TileEntity; -import net.minecraft.server.v1_13_R1.WorldServer; - -public class NmsManager extends AbstractNmsManager { - - private static final int BLOCK_ID_AIR = Block.getCombinedId(Blocks.AIR.getBlockData()); - - static int getBlockState(Chunk chunk, int x, int y, int z) { - ChunkSection[] sections = chunk.getSections(); - - int sectionIndex = y >> 4; - if (sectionIndex >= 0 && sectionIndex < sections.length) { - ChunkSection section = sections[sectionIndex]; - if (section != null && section != Chunk.a) { - return Block.getCombinedId(section.getType(x & 0xF, y & 0xF, z & 0xF)); - } - } - - return BLOCK_ID_AIR; - } - - private static WorldServer level(World world) { - return ((CraftWorld) world).getHandle(); - } - - private static EntityPlayer player(Player player) { - return ((CraftPlayer) player).getHandle(); - } - - public NmsManager(Config config) { - super(Block.REGISTRY_ID.a(), new RegionFileCache(config.cache())); - - for (MinecraftKey key : Block.REGISTRY.keySet()) { - NamespacedKey namespacedKey = NamespacedKey.fromString(key.toString()); - Block block = Block.REGISTRY.get(key); - - ImmutableList possibleBlockStates = block.getStates().a(); - BlockProperties.Builder builder = BlockProperties.builder(namespacedKey); - - for (IBlockData blockState : possibleBlockStates) { - BlockStateProperties properties = BlockStateProperties.builder(Block.getCombinedId(blockState)) - .withIsAir(blockState.isAir()) - /** - * p -> for barrier/slime_block/spawner - * r -> for every other block - */ - .withIsOccluding(blockState.p() && blockState.r()/*canOcclude*/) - .withIsBlockEntity(block.isTileEntity()) - .withIsDefaultState(Objects.equals(block.getBlockData(), blockState)) - .build(); - - builder.withBlockState(properties, false); - } - - this.registerBlockProperties(builder.build()); - } - } - - @Override - public ReadOnlyChunk getReadOnlyChunk(World world, int chunkX, int chunkZ) { - ChunkProviderServer chunkProviderServer = level(world).getChunkProviderServer(); - Chunk chunk = chunkProviderServer.getChunkAt(chunkX, chunkZ); - return new ReadOnlyChunkWrapper(chunk); - } - - @Override - public int getBlockState(World world, int x, int y, int z) { - ChunkProviderServer serverChunkCache = level(world).getChunkProviderServer(); - if (!serverChunkCache.isLoaded(x >> 4, z >> 4)) { - return BLOCK_ID_AIR; - } - - Chunk chunk = serverChunkCache.getChunkAt(x >> 4, z >> 4); - if (chunk == null) { - return BLOCK_ID_AIR; - } - - return getBlockState(chunk, x, y, z); - } - - @Override - public void sendBlockUpdates(World world, Iterable iterable) { - WorldServer level = level(world); - BlockPosition.MutableBlockPosition position = new BlockPosition.MutableBlockPosition(); - - for (net.imprex.orebfuscator.util.BlockPos pos : iterable) { - position.c(pos.x, pos.y, pos.z); - - IBlockData blockState = level.getType(position); - level.notify(position, blockState, blockState, 0); - } - } - - @Override - public void sendBlockUpdates(Player player, Iterable iterable) { - EntityPlayer serverPlayer = player(player); - WorldServer level = serverPlayer.getWorldServer(); - ChunkProviderServer serverChunkCache = level.getChunkProviderServer(); - - BlockPosition.MutableBlockPosition position = new BlockPosition.MutableBlockPosition(); - Map> sectionPackets = new HashMap<>(); - List> blockEntityPackets = new ArrayList<>(); - - for (net.imprex.orebfuscator.util.BlockPos pos : iterable) { - if (!serverChunkCache.isLoaded(pos.x >> 4, pos.z >> 4)) { - continue; - } - - position.c(pos.x, pos.y, pos.z); - IBlockData blockState = level.getType(position); - - ChunkCoordIntPair chunkCoord = new ChunkCoordIntPair(pos.x >> 4, pos.z >> 4); - short location = (short) ((pos.x & 0xF) << 12 | (pos.z & 0xF) << 8 | pos.y); - - sectionPackets.computeIfAbsent(chunkCoord, key -> new ArrayList<>()) - .add(new MultiBlockChangeInfo(location, WrappedBlockData.fromHandle(blockState), chunkCoord)); - - if (blockState.getBlock().isTileEntity()) { - TileEntity blockEntity = level.getTileEntity(position); - if (blockEntity != null) { - blockEntityPackets.add(blockEntity.getUpdatePacket()); - } - } - } - - for (Map.Entry> entry : sectionPackets.entrySet()) { - List blockStates = entry.getValue(); - if (blockStates.size() == 1) { - MultiBlockChangeInfo blockEntry = blockStates.get(0); - var blockPosition = new com.comphenix.protocol.wrappers.BlockPosition( - blockEntry.getAbsoluteX(), blockEntry.getY(), blockEntry.getAbsoluteZ()); - - PacketContainer packet = new PacketContainer(PacketType.Play.Server.BLOCK_CHANGE); - packet.getBlockPositionModifier().write(0, blockPosition); - packet.getBlockData().write(0, blockEntry.getData()); - serverPlayer.playerConnection.sendPacket((Packet) packet.getHandle()); - } else { - PacketContainer packet = new PacketContainer(PacketType.Play.Server.MULTI_BLOCK_CHANGE); - packet.getChunkCoordIntPairs().write(0, entry.getKey()); - packet.getMultiBlockChangeInfoArrays().write(0, blockStates.toArray(MultiBlockChangeInfo[]::new)); - serverPlayer.playerConnection.sendPacket((Packet) packet.getHandle()); - } - } - - for (Packet packet : blockEntityPackets) { - serverPlayer.playerConnection.sendPacket(packet); - } - } -} diff --git a/orebfuscator-nms/orebfuscator-nms-v1_13_R1/src/main/java/net/imprex/orebfuscator/nms/v1_13_R1/ReadOnlyChunkWrapper.java b/orebfuscator-nms/orebfuscator-nms-v1_13_R1/src/main/java/net/imprex/orebfuscator/nms/v1_13_R1/ReadOnlyChunkWrapper.java deleted file mode 100644 index b91eb669..00000000 --- a/orebfuscator-nms/orebfuscator-nms-v1_13_R1/src/main/java/net/imprex/orebfuscator/nms/v1_13_R1/ReadOnlyChunkWrapper.java +++ /dev/null @@ -1,18 +0,0 @@ -package net.imprex.orebfuscator.nms.v1_13_R1; - -import net.imprex.orebfuscator.nms.ReadOnlyChunk; -import net.minecraft.server.v1_13_R1.Chunk; - -public class ReadOnlyChunkWrapper implements ReadOnlyChunk { - - private final Chunk chunk; - - ReadOnlyChunkWrapper(Chunk chunk) { - this.chunk = chunk; - } - - @Override - public int getBlockState(int x, int y, int z) { - return NmsManager.getBlockState(chunk, x, y, z); - } -} diff --git a/orebfuscator-nms/orebfuscator-nms-v1_13_R1/src/main/java/net/imprex/orebfuscator/nms/v1_13_R1/RegionFileCache.java b/orebfuscator-nms/orebfuscator-nms-v1_13_R1/src/main/java/net/imprex/orebfuscator/nms/v1_13_R1/RegionFileCache.java deleted file mode 100644 index f1115bcf..00000000 --- a/orebfuscator-nms/orebfuscator-nms-v1_13_R1/src/main/java/net/imprex/orebfuscator/nms/v1_13_R1/RegionFileCache.java +++ /dev/null @@ -1,38 +0,0 @@ -package net.imprex.orebfuscator.nms.v1_13_R1; - -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; -import java.nio.file.Path; - -import net.imprex.orebfuscator.config.CacheConfig; -import net.imprex.orebfuscator.nms.AbstractRegionFileCache; -import net.imprex.orebfuscator.util.ChunkPosition; -import net.minecraft.server.v1_13_R1.RegionFile; - -public class RegionFileCache extends AbstractRegionFileCache { - - RegionFileCache(CacheConfig cacheConfig) { - super(cacheConfig); - } - - @Override - protected RegionFile createRegionFile(Path path) throws IOException { - return new RegionFile(path.toFile()); - } - - @Override - protected void closeRegionFile(RegionFile t) throws IOException { - t.c(); - } - - @Override - protected DataInputStream createInputStream(RegionFile t, ChunkPosition key) throws IOException { - return t.a(key.x & 0x1F, key.z & 0x1F); - } - - @Override - protected DataOutputStream createOutputStream(RegionFile t, ChunkPosition key) throws IOException { - return t.c(key.x & 0x1F, key.z & 0x1F); - } -} diff --git a/orebfuscator-nms/orebfuscator-nms-v1_13_R2/pom.xml b/orebfuscator-nms/orebfuscator-nms-v1_13_R2/pom.xml deleted file mode 100644 index 6ea49cc5..00000000 --- a/orebfuscator-nms/orebfuscator-nms-v1_13_R2/pom.xml +++ /dev/null @@ -1,33 +0,0 @@ - - 4.0.0 - - - net.imprex - orebfuscator-nms - ${revision} - - - orebfuscator-nms-v1_13_R2 - jar - - - - net.imprex - orebfuscator-nms-api - ${revision} - provided - - - com.comphenix.protocol - ProtocolLib - ${dependency.protocollib.version} - provided - - - org.spigotmc - spigot - 1.13.2-R0.1-SNAPSHOT - provided - - - \ No newline at end of file diff --git a/orebfuscator-nms/orebfuscator-nms-v1_13_R2/src/main/java/net/imprex/orebfuscator/nms/v1_13_R2/NmsManager.java b/orebfuscator-nms/orebfuscator-nms-v1_13_R2/src/main/java/net/imprex/orebfuscator/nms/v1_13_R2/NmsManager.java deleted file mode 100644 index c4505e6e..00000000 --- a/orebfuscator-nms/orebfuscator-nms-v1_13_R2/src/main/java/net/imprex/orebfuscator/nms/v1_13_R2/NmsManager.java +++ /dev/null @@ -1,188 +0,0 @@ -package net.imprex.orebfuscator.nms.v1_13_R2; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -import org.bukkit.World; -import org.bukkit.craftbukkit.v1_13_R2.CraftWorld; -import org.bukkit.craftbukkit.v1_13_R2.entity.CraftPlayer; -import org.bukkit.entity.Player; - -import com.comphenix.protocol.PacketType; -import com.comphenix.protocol.events.PacketContainer; -import com.comphenix.protocol.wrappers.ChunkCoordIntPair; -import com.comphenix.protocol.wrappers.MultiBlockChangeInfo; -import com.comphenix.protocol.wrappers.WrappedBlockData; -import com.google.common.collect.ImmutableList; - -import net.imprex.orebfuscator.config.Config; -import net.imprex.orebfuscator.nms.AbstractNmsManager; -import net.imprex.orebfuscator.nms.ReadOnlyChunk; -import net.imprex.orebfuscator.util.BlockPos; -import net.imprex.orebfuscator.util.BlockProperties; -import net.imprex.orebfuscator.util.BlockStateProperties; -import net.imprex.orebfuscator.util.NamespacedKey; -import net.minecraft.server.v1_13_R2.Block; -import net.minecraft.server.v1_13_R2.BlockPosition; -import net.minecraft.server.v1_13_R2.Blocks; -import net.minecraft.server.v1_13_R2.Chunk; -import net.minecraft.server.v1_13_R2.ChunkProviderServer; -import net.minecraft.server.v1_13_R2.ChunkSection; -import net.minecraft.server.v1_13_R2.EntityPlayer; -import net.minecraft.server.v1_13_R2.IBlockData; -import net.minecraft.server.v1_13_R2.IRegistry; -import net.minecraft.server.v1_13_R2.MinecraftKey; -import net.minecraft.server.v1_13_R2.Packet; -import net.minecraft.server.v1_13_R2.PacketListenerPlayOut; -import net.minecraft.server.v1_13_R2.TileEntity; -import net.minecraft.server.v1_13_R2.WorldServer; - -public class NmsManager extends AbstractNmsManager { - - private static final int BLOCK_ID_AIR = Block.getCombinedId(Blocks.AIR.getBlockData()); - - static int getBlockState(Chunk chunk, int x, int y, int z) { - ChunkSection[] sections = chunk.getSections(); - - int sectionIndex = y >> 4; - if (sectionIndex >= 0 && sectionIndex < sections.length) { - ChunkSection section = sections[sectionIndex]; - if (section != null && section != Chunk.a) { - return Block.getCombinedId(section.getType(x & 0xF, y & 0xF, z & 0xF)); - } - } - - return BLOCK_ID_AIR; - } - - private static WorldServer level(World world) { - return ((CraftWorld) world).getHandle(); - } - - private static EntityPlayer player(Player player) { - return ((CraftPlayer) player).getHandle(); - } - - public NmsManager(Config config) { - super(Block.REGISTRY_ID.a(), new RegionFileCache(config.cache())); - - for (MinecraftKey key : IRegistry.BLOCK.keySet()) { - NamespacedKey namespacedKey = NamespacedKey.fromString(key.toString()); - Block block = IRegistry.BLOCK.get(key); - - ImmutableList possibleBlockStates = block.getStates().a(); - BlockProperties.Builder builder = BlockProperties.builder(namespacedKey); - - for (IBlockData blockState : possibleBlockStates) { - BlockStateProperties properties = BlockStateProperties.builder(Block.getCombinedId(blockState)) - .withIsAir(blockState.isAir()) - /** - * p -> for barrier/slime_block/spawner - * r -> for every other block - */ - .withIsOccluding(blockState.p() && blockState.r()/*canOcclude*/) - .withIsBlockEntity(block.isTileEntity()) - .withIsDefaultState(Objects.equals(block.getBlockData(), blockState)) - .build(); - - builder.withBlockState(properties); - } - - this.registerBlockProperties(builder.build()); - } - } - - @Override - public ReadOnlyChunk getReadOnlyChunk(World world, int chunkX, int chunkZ) { - ChunkProviderServer chunkProviderServer = level(world).getChunkProvider(); - Chunk chunk = chunkProviderServer.getChunkAt(chunkX, chunkZ, true, true); - return new ReadOnlyChunkWrapper(chunk); - } - - @Override - public int getBlockState(World world, int x, int y, int z) { - ChunkProviderServer serverChunkCache = level(world).getChunkProvider(); - if (!serverChunkCache.isLoaded(x >> 4, z >> 4)) { - return BLOCK_ID_AIR; - } - - Chunk chunk = serverChunkCache.getChunkAt(x >> 4, z >> 4, true, true); - if (chunk == null) { - return BLOCK_ID_AIR; - } - - return getBlockState(chunk, x, y, z); - } - - @Override - public void sendBlockUpdates(World world, Iterable iterable) { - WorldServer level = level(world); - BlockPosition.MutableBlockPosition position = new BlockPosition.MutableBlockPosition(); - - for (net.imprex.orebfuscator.util.BlockPos pos : iterable) { - position.c(pos.x, pos.y, pos.z); - - IBlockData blockState = level.getType(position); - level.notify(position, blockState, blockState, 0); - } - } - - @Override - public void sendBlockUpdates(Player player, Iterable iterable) { - EntityPlayer serverPlayer = player(player); - WorldServer level = serverPlayer.getWorldServer(); - ChunkProviderServer serverChunkCache = level.getChunkProvider(); - - BlockPosition.MutableBlockPosition position = new BlockPosition.MutableBlockPosition(); - Map> sectionPackets = new HashMap<>(); - List> blockEntityPackets = new ArrayList<>(); - - for (net.imprex.orebfuscator.util.BlockPos pos : iterable) { - if (!serverChunkCache.isLoaded(pos.x >> 4, pos.z >> 4)) { - continue; - } - - position.c(pos.x, pos.y, pos.z); - IBlockData blockState = level.getType(position); - - ChunkCoordIntPair chunkCoord = new ChunkCoordIntPair(pos.x >> 4, pos.z >> 4); - short location = (short) ((pos.x & 0xF) << 12 | (pos.z & 0xF) << 8 | pos.y); - - sectionPackets.computeIfAbsent(chunkCoord, key -> new ArrayList<>()) - .add(new MultiBlockChangeInfo(location, WrappedBlockData.fromHandle(blockState), chunkCoord)); - - if (blockState.getBlock().isTileEntity()) { - TileEntity blockEntity = level.getTileEntity(position); - if (blockEntity != null) { - blockEntityPackets.add(blockEntity.getUpdatePacket()); - } - } - } - - for (Map.Entry> entry : sectionPackets.entrySet()) { - List blockStates = entry.getValue(); - if (blockStates.size() == 1) { - MultiBlockChangeInfo blockEntry = blockStates.get(0); - var blockPosition = new com.comphenix.protocol.wrappers.BlockPosition( - blockEntry.getAbsoluteX(), blockEntry.getY(), blockEntry.getAbsoluteZ()); - - PacketContainer packet = new PacketContainer(PacketType.Play.Server.BLOCK_CHANGE); - packet.getBlockPositionModifier().write(0, blockPosition); - packet.getBlockData().write(0, blockEntry.getData()); - serverPlayer.playerConnection.sendPacket((Packet) packet.getHandle()); - } else { - PacketContainer packet = new PacketContainer(PacketType.Play.Server.MULTI_BLOCK_CHANGE); - packet.getChunkCoordIntPairs().write(0, entry.getKey()); - packet.getMultiBlockChangeInfoArrays().write(0, blockStates.toArray(MultiBlockChangeInfo[]::new)); - serverPlayer.playerConnection.sendPacket((Packet) packet.getHandle()); - } - } - - for (Packet packet : blockEntityPackets) { - serverPlayer.playerConnection.sendPacket(packet); - } - } -} diff --git a/orebfuscator-nms/orebfuscator-nms-v1_13_R2/src/main/java/net/imprex/orebfuscator/nms/v1_13_R2/ReadOnlyChunkWrapper.java b/orebfuscator-nms/orebfuscator-nms-v1_13_R2/src/main/java/net/imprex/orebfuscator/nms/v1_13_R2/ReadOnlyChunkWrapper.java deleted file mode 100644 index 517a47be..00000000 --- a/orebfuscator-nms/orebfuscator-nms-v1_13_R2/src/main/java/net/imprex/orebfuscator/nms/v1_13_R2/ReadOnlyChunkWrapper.java +++ /dev/null @@ -1,18 +0,0 @@ -package net.imprex.orebfuscator.nms.v1_13_R2; - -import net.imprex.orebfuscator.nms.ReadOnlyChunk; -import net.minecraft.server.v1_13_R2.Chunk; - -public class ReadOnlyChunkWrapper implements ReadOnlyChunk { - - private final Chunk chunk; - - ReadOnlyChunkWrapper(Chunk chunk) { - this.chunk = chunk; - } - - @Override - public int getBlockState(int x, int y, int z) { - return NmsManager.getBlockState(chunk, x, y, z); - } -} diff --git a/orebfuscator-nms/orebfuscator-nms-v1_13_R2/src/main/java/net/imprex/orebfuscator/nms/v1_13_R2/RegionFileCache.java b/orebfuscator-nms/orebfuscator-nms-v1_13_R2/src/main/java/net/imprex/orebfuscator/nms/v1_13_R2/RegionFileCache.java deleted file mode 100644 index b106729f..00000000 --- a/orebfuscator-nms/orebfuscator-nms-v1_13_R2/src/main/java/net/imprex/orebfuscator/nms/v1_13_R2/RegionFileCache.java +++ /dev/null @@ -1,38 +0,0 @@ -package net.imprex.orebfuscator.nms.v1_13_R2; - -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; -import java.nio.file.Path; - -import net.imprex.orebfuscator.config.CacheConfig; -import net.imprex.orebfuscator.nms.AbstractRegionFileCache; -import net.imprex.orebfuscator.util.ChunkPosition; -import net.minecraft.server.v1_13_R2.RegionFile; - -public class RegionFileCache extends AbstractRegionFileCache { - - RegionFileCache(CacheConfig cacheConfig) { - super(cacheConfig); - } - - @Override - protected RegionFile createRegionFile(Path path) throws IOException { - return new RegionFile(path.toFile()); - } - - @Override - protected void closeRegionFile(RegionFile t) throws IOException { - t.close(); - } - - @Override - protected DataInputStream createInputStream(RegionFile t, ChunkPosition key) throws IOException { - return t.a(key.x & 0x1F, key.z & 0x1F); - } - - @Override - protected DataOutputStream createOutputStream(RegionFile t, ChunkPosition key) throws IOException { - return t.c(key.x & 0x1F, key.z & 0x1F); - } -} diff --git a/orebfuscator-nms/orebfuscator-nms-v1_14_R1/pom.xml b/orebfuscator-nms/orebfuscator-nms-v1_14_R1/pom.xml deleted file mode 100644 index 8dcc24b9..00000000 --- a/orebfuscator-nms/orebfuscator-nms-v1_14_R1/pom.xml +++ /dev/null @@ -1,33 +0,0 @@ - - 4.0.0 - - - net.imprex - orebfuscator-nms - ${revision} - - - orebfuscator-nms-v1_14_R1 - jar - - - - net.imprex - orebfuscator-nms-api - ${revision} - provided - - - com.comphenix.protocol - ProtocolLib - ${dependency.protocollib.version} - provided - - - org.spigotmc - spigot - 1.14.4-R0.1-SNAPSHOT - provided - - - \ No newline at end of file diff --git a/orebfuscator-nms/orebfuscator-nms-v1_14_R1/src/main/java/net/imprex/orebfuscator/nms/v1_14_R1/NmsManager.java b/orebfuscator-nms/orebfuscator-nms-v1_14_R1/src/main/java/net/imprex/orebfuscator/nms/v1_14_R1/NmsManager.java deleted file mode 100644 index 480093bc..00000000 --- a/orebfuscator-nms/orebfuscator-nms-v1_14_R1/src/main/java/net/imprex/orebfuscator/nms/v1_14_R1/NmsManager.java +++ /dev/null @@ -1,190 +0,0 @@ -package net.imprex.orebfuscator.nms.v1_14_R1; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -import org.bukkit.Material; -import org.bukkit.World; -import org.bukkit.craftbukkit.v1_14_R1.CraftWorld; -import org.bukkit.craftbukkit.v1_14_R1.block.data.CraftBlockData; -import org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer; -import org.bukkit.entity.Player; - -import com.comphenix.protocol.PacketType; -import com.comphenix.protocol.events.PacketContainer; -import com.comphenix.protocol.wrappers.ChunkCoordIntPair; -import com.comphenix.protocol.wrappers.MultiBlockChangeInfo; -import com.comphenix.protocol.wrappers.WrappedBlockData; -import com.google.common.collect.ImmutableList; - -import net.imprex.orebfuscator.config.Config; -import net.imprex.orebfuscator.nms.AbstractNmsManager; -import net.imprex.orebfuscator.nms.ReadOnlyChunk; -import net.imprex.orebfuscator.util.BlockPos; -import net.imprex.orebfuscator.util.BlockProperties; -import net.imprex.orebfuscator.util.BlockStateProperties; -import net.imprex.orebfuscator.util.NamespacedKey; -import net.minecraft.server.v1_14_R1.Block; -import net.minecraft.server.v1_14_R1.BlockPosition; -import net.minecraft.server.v1_14_R1.Blocks; -import net.minecraft.server.v1_14_R1.Chunk; -import net.minecraft.server.v1_14_R1.ChunkProviderServer; -import net.minecraft.server.v1_14_R1.ChunkSection; -import net.minecraft.server.v1_14_R1.EntityPlayer; -import net.minecraft.server.v1_14_R1.IBlockData; -import net.minecraft.server.v1_14_R1.IRegistry; -import net.minecraft.server.v1_14_R1.MinecraftKey; -import net.minecraft.server.v1_14_R1.Packet; -import net.minecraft.server.v1_14_R1.PacketListenerPlayOut; -import net.minecraft.server.v1_14_R1.TileEntity; -import net.minecraft.server.v1_14_R1.WorldServer; - -public class NmsManager extends AbstractNmsManager { - - private static final int BLOCK_ID_AIR = Block.getCombinedId(Blocks.AIR.getBlockData()); - - static int getBlockState(Chunk chunk, int x, int y, int z) { - ChunkSection[] sections = chunk.getSections(); - - int sectionIndex = y >> 4; - if (sectionIndex >= 0 && sectionIndex < sections.length) { - ChunkSection section = sections[sectionIndex]; - if (section != null && !ChunkSection.a(section)) { - return Block.getCombinedId(section.getType(x & 0xF, y & 0xF, z & 0xF)); - } - } - - return BLOCK_ID_AIR; - } - - private static WorldServer level(World world) { - return ((CraftWorld) world).getHandle(); - } - - private static EntityPlayer player(Player player) { - return ((CraftPlayer) player).getHandle(); - } - - public NmsManager(Config config) { - super(Block.REGISTRY_ID.a(), new RegionFileCache(config.cache())); - - for (MinecraftKey key : IRegistry.BLOCK.keySet()) { - NamespacedKey namespacedKey = NamespacedKey.fromString(key.toString()); - Block block = IRegistry.BLOCK.get(key); - - ImmutableList possibleBlockStates = block.getStates().a(); - BlockProperties.Builder builder = BlockProperties.builder(namespacedKey); - - for (IBlockData blockState : possibleBlockStates) { - Material material = CraftBlockData.fromData(blockState).getMaterial(); - - BlockStateProperties properties = BlockStateProperties.builder(Block.getCombinedId(blockState)) - .withIsAir(blockState.isAir()) - /** - * o -> for barrier/slime_block/spawner/leaves - * isOccluding -> for every other block - */ - .withIsOccluding(material.isOccluding() && blockState.o()/*canOcclude*/) - .withIsBlockEntity(block.isTileEntity()) - .withIsDefaultState(Objects.equals(block.getBlockData(), blockState)) - .build(); - - builder.withBlockState(properties); - } - - this.registerBlockProperties(builder.build()); - } - } - - @Override - public ReadOnlyChunk getReadOnlyChunk(World world, int chunkX, int chunkZ) { - ChunkProviderServer chunkProviderServer = level(world).getChunkProvider(); - Chunk chunk = chunkProviderServer.getChunkAt(chunkX, chunkZ, true); - return new ReadOnlyChunkWrapper(chunk); - } - - @Override - public int getBlockState(World world, int x, int y, int z) { - ChunkProviderServer serverChunkCache = level(world).getChunkProvider(); - if (!serverChunkCache.b(x >> 4, z >> 4)) { - return BLOCK_ID_AIR; - } - - Chunk chunk = serverChunkCache.getChunkAt(x >> 4, z >> 4, true); - if (chunk == null) { - return BLOCK_ID_AIR; - } - - return getBlockState(chunk, x, y, z); - } - - @Override - public void sendBlockUpdates(World world, Iterable iterable) { - ChunkProviderServer serverChunkCache = level(world).getChunkProvider(); - BlockPosition.MutableBlockPosition position = new BlockPosition.MutableBlockPosition(); - - for (net.imprex.orebfuscator.util.BlockPos pos : iterable) { - position.c(pos.x, pos.y, pos.z); - serverChunkCache.flagDirty(position); - } - } - - @Override - public void sendBlockUpdates(Player player, Iterable iterable) { - EntityPlayer serverPlayer = player(player); - WorldServer level = serverPlayer.getWorldServer(); - ChunkProviderServer serverChunkCache = level.getChunkProvider(); - - BlockPosition.MutableBlockPosition position = new BlockPosition.MutableBlockPosition(); - Map> sectionPackets = new HashMap<>(); - List> blockEntityPackets = new ArrayList<>(); - - for (net.imprex.orebfuscator.util.BlockPos pos : iterable) { - if (!serverChunkCache.b(pos.x >> 4, pos.z >> 4)) { - continue; - } - - position.c(pos.x, pos.y, pos.z); - IBlockData blockState = level.getType(position); - - ChunkCoordIntPair chunkCoord = new ChunkCoordIntPair(pos.x >> 4, pos.z >> 4); - short location = (short) ((pos.x & 0xF) << 12 | (pos.z & 0xF) << 8 | pos.y); - - sectionPackets.computeIfAbsent(chunkCoord, key -> new ArrayList<>()) - .add(new MultiBlockChangeInfo(location, WrappedBlockData.fromHandle(blockState), chunkCoord)); - - if (blockState.getBlock().isTileEntity()) { - TileEntity blockEntity = level.getTileEntity(position); - if (blockEntity != null) { - blockEntityPackets.add(blockEntity.getUpdatePacket()); - } - } - } - - for (Map.Entry> entry : sectionPackets.entrySet()) { - List blockStates = entry.getValue(); - if (blockStates.size() == 1) { - MultiBlockChangeInfo blockEntry = blockStates.get(0); - var blockPosition = new com.comphenix.protocol.wrappers.BlockPosition( - blockEntry.getAbsoluteX(), blockEntry.getY(), blockEntry.getAbsoluteZ()); - - PacketContainer packet = new PacketContainer(PacketType.Play.Server.BLOCK_CHANGE); - packet.getBlockPositionModifier().write(0, blockPosition); - packet.getBlockData().write(0, blockEntry.getData()); - serverPlayer.playerConnection.sendPacket((Packet) packet.getHandle()); - } else { - PacketContainer packet = new PacketContainer(PacketType.Play.Server.MULTI_BLOCK_CHANGE); - packet.getChunkCoordIntPairs().write(0, entry.getKey()); - packet.getMultiBlockChangeInfoArrays().write(0, blockStates.toArray(MultiBlockChangeInfo[]::new)); - serverPlayer.playerConnection.sendPacket((Packet) packet.getHandle()); - } - } - - for (Packet packet : blockEntityPackets) { - serverPlayer.playerConnection.sendPacket(packet); - } - } -} diff --git a/orebfuscator-nms/orebfuscator-nms-v1_14_R1/src/main/java/net/imprex/orebfuscator/nms/v1_14_R1/ReadOnlyChunkWrapper.java b/orebfuscator-nms/orebfuscator-nms-v1_14_R1/src/main/java/net/imprex/orebfuscator/nms/v1_14_R1/ReadOnlyChunkWrapper.java deleted file mode 100644 index cff903ee..00000000 --- a/orebfuscator-nms/orebfuscator-nms-v1_14_R1/src/main/java/net/imprex/orebfuscator/nms/v1_14_R1/ReadOnlyChunkWrapper.java +++ /dev/null @@ -1,18 +0,0 @@ -package net.imprex.orebfuscator.nms.v1_14_R1; - -import net.imprex.orebfuscator.nms.ReadOnlyChunk; -import net.minecraft.server.v1_14_R1.Chunk; - -public class ReadOnlyChunkWrapper implements ReadOnlyChunk { - - private final Chunk chunk; - - ReadOnlyChunkWrapper(Chunk chunk) { - this.chunk = chunk; - } - - @Override - public int getBlockState(int x, int y, int z) { - return NmsManager.getBlockState(chunk, x, y, z); - } -} diff --git a/orebfuscator-nms/orebfuscator-nms-v1_14_R1/src/main/java/net/imprex/orebfuscator/nms/v1_14_R1/RegionFileCache.java b/orebfuscator-nms/orebfuscator-nms-v1_14_R1/src/main/java/net/imprex/orebfuscator/nms/v1_14_R1/RegionFileCache.java deleted file mode 100644 index d8f4ea37..00000000 --- a/orebfuscator-nms/orebfuscator-nms-v1_14_R1/src/main/java/net/imprex/orebfuscator/nms/v1_14_R1/RegionFileCache.java +++ /dev/null @@ -1,39 +0,0 @@ -package net.imprex.orebfuscator.nms.v1_14_R1; - -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; -import java.nio.file.Path; - -import net.imprex.orebfuscator.config.CacheConfig; -import net.imprex.orebfuscator.nms.AbstractRegionFileCache; -import net.imprex.orebfuscator.util.ChunkPosition; -import net.minecraft.server.v1_14_R1.ChunkCoordIntPair; -import net.minecraft.server.v1_14_R1.RegionFile; - -public class RegionFileCache extends AbstractRegionFileCache { - - RegionFileCache(CacheConfig cacheConfig) { - super(cacheConfig); - } - - @Override - protected RegionFile createRegionFile(Path path) throws IOException { - return new RegionFile(path.toFile()); - } - - @Override - protected void closeRegionFile(RegionFile t) throws IOException { - t.close(); - } - - @Override - protected DataInputStream createInputStream(RegionFile t, ChunkPosition key) throws IOException { - return t.a(new ChunkCoordIntPair(key.x, key.z)); - } - - @Override - protected DataOutputStream createOutputStream(RegionFile t, ChunkPosition key) throws IOException { - return t.c(new ChunkCoordIntPair(key.x, key.z)); - } -} diff --git a/orebfuscator-nms/orebfuscator-nms-v1_15_R1/pom.xml b/orebfuscator-nms/orebfuscator-nms-v1_15_R1/pom.xml deleted file mode 100644 index a423e883..00000000 --- a/orebfuscator-nms/orebfuscator-nms-v1_15_R1/pom.xml +++ /dev/null @@ -1,35 +0,0 @@ - - 4.0.0 - - - net.imprex - orebfuscator-nms - ${revision} - - - orebfuscator-nms-v1_15_R1 - jar - - - - net.imprex - orebfuscator-nms-api - ${revision} - provided - - - com.comphenix.protocol - ProtocolLib - ${dependency.protocollib.version} - provided - - - org.spigotmc - spigot - 1.15.2-R0.1-SNAPSHOT - provided - - - \ No newline at end of file diff --git a/orebfuscator-nms/orebfuscator-nms-v1_15_R1/src/main/java/net/imprex/orebfuscator/nms/v1_15_R1/NmsManager.java b/orebfuscator-nms/orebfuscator-nms-v1_15_R1/src/main/java/net/imprex/orebfuscator/nms/v1_15_R1/NmsManager.java deleted file mode 100644 index 1811000f..00000000 --- a/orebfuscator-nms/orebfuscator-nms-v1_15_R1/src/main/java/net/imprex/orebfuscator/nms/v1_15_R1/NmsManager.java +++ /dev/null @@ -1,190 +0,0 @@ -package net.imprex.orebfuscator.nms.v1_15_R1; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -import org.bukkit.Material; -import org.bukkit.World; -import org.bukkit.craftbukkit.v1_15_R1.CraftWorld; -import org.bukkit.craftbukkit.v1_15_R1.block.data.CraftBlockData; -import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer; -import org.bukkit.entity.Player; - -import com.comphenix.protocol.PacketType; -import com.comphenix.protocol.events.PacketContainer; -import com.comphenix.protocol.wrappers.ChunkCoordIntPair; -import com.comphenix.protocol.wrappers.MultiBlockChangeInfo; -import com.comphenix.protocol.wrappers.WrappedBlockData; -import com.google.common.collect.ImmutableList; - -import net.imprex.orebfuscator.config.Config; -import net.imprex.orebfuscator.nms.AbstractNmsManager; -import net.imprex.orebfuscator.nms.ReadOnlyChunk; -import net.imprex.orebfuscator.util.BlockPos; -import net.imprex.orebfuscator.util.BlockProperties; -import net.imprex.orebfuscator.util.BlockStateProperties; -import net.imprex.orebfuscator.util.NamespacedKey; -import net.minecraft.server.v1_15_R1.Block; -import net.minecraft.server.v1_15_R1.BlockPosition; -import net.minecraft.server.v1_15_R1.Blocks; -import net.minecraft.server.v1_15_R1.Chunk; -import net.minecraft.server.v1_15_R1.ChunkProviderServer; -import net.minecraft.server.v1_15_R1.ChunkSection; -import net.minecraft.server.v1_15_R1.EntityPlayer; -import net.minecraft.server.v1_15_R1.IBlockData; -import net.minecraft.server.v1_15_R1.IRegistry; -import net.minecraft.server.v1_15_R1.MinecraftKey; -import net.minecraft.server.v1_15_R1.Packet; -import net.minecraft.server.v1_15_R1.PacketListenerPlayOut; -import net.minecraft.server.v1_15_R1.TileEntity; -import net.minecraft.server.v1_15_R1.WorldServer; - -public class NmsManager extends AbstractNmsManager { - - private static final int BLOCK_ID_AIR = Block.getCombinedId(Blocks.AIR.getBlockData()); - - static int getBlockState(Chunk chunk, int x, int y, int z) { - ChunkSection[] sections = chunk.getSections(); - - int sectionIndex = y >> 4; - if (sectionIndex >= 0 && sectionIndex < sections.length) { - ChunkSection section = sections[sectionIndex]; - if (section != null && !ChunkSection.a(section)) { - return Block.getCombinedId(section.getType(x & 0xF, y & 0xF, z & 0xF)); - } - } - - return BLOCK_ID_AIR; - } - - private static WorldServer level(World world) { - return ((CraftWorld) world).getHandle(); - } - - private static EntityPlayer player(Player player) { - return ((CraftPlayer) player).getHandle(); - } - - public NmsManager(Config config) { - super(Block.REGISTRY_ID.a(), new RegionFileCache(config.cache())); - - for (MinecraftKey key : IRegistry.BLOCK.keySet()) { - NamespacedKey namespacedKey = NamespacedKey.fromString(key.toString()); - Block block = IRegistry.BLOCK.get(key); - - ImmutableList possibleBlockStates = block.getStates().a(); - BlockProperties.Builder builder = BlockProperties.builder(namespacedKey); - - for (IBlockData blockState : possibleBlockStates) { - Material material = CraftBlockData.fromData(blockState).getMaterial(); - - BlockStateProperties properties = BlockStateProperties.builder(Block.getCombinedId(blockState)) - .withIsAir(blockState.isAir()) - /** - * o -> for barrier/slime_block/spawner/leaves - * isOccluding -> for every other block - */ - .withIsOccluding(material.isOccluding() && blockState.o()/*canOcclude*/) - .withIsBlockEntity(block.isTileEntity()) - .withIsDefaultState(Objects.equals(block.getBlockData(), blockState)) - .build(); - - builder.withBlockState(properties); - } - - this.registerBlockProperties(builder.build()); - } - } - - @Override - public ReadOnlyChunk getReadOnlyChunk(World world, int chunkX, int chunkZ) { - ChunkProviderServer chunkProviderServer = level(world).getChunkProvider(); - Chunk chunk = chunkProviderServer.getChunkAt(chunkX, chunkZ, true); - return new ReadOnlyChunkWrapper(chunk); - } - - @Override - public int getBlockState(World world, int x, int y, int z) { - ChunkProviderServer serverChunkCache = level(world).getChunkProvider(); - if (!serverChunkCache.b(x >> 4, z >> 4)) { - return BLOCK_ID_AIR; - } - - Chunk chunk = serverChunkCache.getChunkAt(x >> 4, z >> 4, true); - if (chunk == null) { - return BLOCK_ID_AIR; - } - - return getBlockState(chunk, x, y, z); - } - - @Override - public void sendBlockUpdates(World world, Iterable iterable) { - ChunkProviderServer serverChunkCache = level(world).getChunkProvider(); - BlockPosition.MutableBlockPosition position = new BlockPosition.MutableBlockPosition(); - - for (net.imprex.orebfuscator.util.BlockPos pos : iterable) { - position.c(pos.x, pos.y, pos.z); - serverChunkCache.flagDirty(position); - } - } - - @Override - public void sendBlockUpdates(Player player, Iterable iterable) { - EntityPlayer serverPlayer = player(player); - WorldServer level = serverPlayer.getWorldServer(); - ChunkProviderServer serverChunkCache = level.getChunkProvider(); - - BlockPosition.MutableBlockPosition position = new BlockPosition.MutableBlockPosition(); - Map> sectionPackets = new HashMap<>(); - List> blockEntityPackets = new ArrayList<>(); - - for (net.imprex.orebfuscator.util.BlockPos pos : iterable) { - if (!serverChunkCache.b(pos.x >> 4, pos.z >> 4)) { - continue; - } - - position.c(pos.x, pos.y, pos.z); - IBlockData blockState = level.getType(position); - - ChunkCoordIntPair chunkCoord = new ChunkCoordIntPair(pos.x >> 4, pos.z >> 4); - short location = (short) ((pos.x & 0xF) << 12 | (pos.z & 0xF) << 8 | pos.y); - - sectionPackets.computeIfAbsent(chunkCoord, key -> new ArrayList<>()) - .add(new MultiBlockChangeInfo(location, WrappedBlockData.fromHandle(blockState), chunkCoord)); - - if (blockState.getBlock().isTileEntity()) { - TileEntity blockEntity = level.getTileEntity(position); - if (blockEntity != null) { - blockEntityPackets.add(blockEntity.getUpdatePacket()); - } - } - } - - for (Map.Entry> entry : sectionPackets.entrySet()) { - List blockStates = entry.getValue(); - if (blockStates.size() == 1) { - MultiBlockChangeInfo blockEntry = blockStates.get(0); - var blockPosition = new com.comphenix.protocol.wrappers.BlockPosition( - blockEntry.getAbsoluteX(), blockEntry.getY(), blockEntry.getAbsoluteZ()); - - PacketContainer packet = new PacketContainer(PacketType.Play.Server.BLOCK_CHANGE); - packet.getBlockPositionModifier().write(0, blockPosition); - packet.getBlockData().write(0, blockEntry.getData()); - serverPlayer.playerConnection.sendPacket((Packet) packet.getHandle()); - } else { - PacketContainer packet = new PacketContainer(PacketType.Play.Server.MULTI_BLOCK_CHANGE); - packet.getChunkCoordIntPairs().write(0, entry.getKey()); - packet.getMultiBlockChangeInfoArrays().write(0, blockStates.toArray(MultiBlockChangeInfo[]::new)); - serverPlayer.playerConnection.sendPacket((Packet) packet.getHandle()); - } - } - - for (Packet packet : blockEntityPackets) { - serverPlayer.playerConnection.sendPacket(packet); - } - } -} diff --git a/orebfuscator-nms/orebfuscator-nms-v1_15_R1/src/main/java/net/imprex/orebfuscator/nms/v1_15_R1/ReadOnlyChunkWrapper.java b/orebfuscator-nms/orebfuscator-nms-v1_15_R1/src/main/java/net/imprex/orebfuscator/nms/v1_15_R1/ReadOnlyChunkWrapper.java deleted file mode 100644 index cc9cf965..00000000 --- a/orebfuscator-nms/orebfuscator-nms-v1_15_R1/src/main/java/net/imprex/orebfuscator/nms/v1_15_R1/ReadOnlyChunkWrapper.java +++ /dev/null @@ -1,18 +0,0 @@ -package net.imprex.orebfuscator.nms.v1_15_R1; - -import net.imprex.orebfuscator.nms.ReadOnlyChunk; -import net.minecraft.server.v1_15_R1.Chunk; - -public class ReadOnlyChunkWrapper implements ReadOnlyChunk { - - private final Chunk chunk; - - ReadOnlyChunkWrapper(Chunk chunk) { - this.chunk = chunk; - } - - @Override - public int getBlockState(int x, int y, int z) { - return NmsManager.getBlockState(chunk, x, y, z); - } -} diff --git a/orebfuscator-nms/orebfuscator-nms-v1_21_R1/pom.xml b/orebfuscator-nms/orebfuscator-nms-v1_21_R1/pom.xml new file mode 100644 index 00000000..3a8bf7fe --- /dev/null +++ b/orebfuscator-nms/orebfuscator-nms-v1_21_R1/pom.xml @@ -0,0 +1,81 @@ + + 4.0.0 + + + net.imprex + orebfuscator-nms + ${revision} + + + orebfuscator-nms-v1_21_R1 + jar + + + + net.imprex + orebfuscator-nms-api + ${revision} + provided + + + org.spigotmc + spigot + 1.21-R0.1-SNAPSHOT + remapped-mojang + provided + + + + + + + org.apache.maven.plugins + maven-shade-plugin + + true + mojang-mapped + + + net.imprex.orebfuscator.nms.v1_21_R1 + net.imprex.orebfuscator.nms.v1_21_R1_mojang + + + + + + net.md-5 + specialsource-maven-plugin + ${plugin.specialsource.version} + + + package + + remap + + remap-obf + + org.spigotmc:minecraft-server:1.21-R0.1-SNAPSHOT:txt:maps-mojang + true + org.spigotmc:spigot:1.21-R0.1-SNAPSHOT:jar:remapped-mojang + true + remapped-obf + + + + package + + remap + + remap-spigot + + ${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar + org.spigotmc:minecraft-server:1.21-R0.1-SNAPSHOT:csrg:maps-spigot + org.spigotmc:spigot:1.21-R0.1-SNAPSHOT:jar:remapped-obf + + + + + + + + \ No newline at end of file diff --git a/orebfuscator-nms/orebfuscator-nms-v1_21_R1/src/main/java/net/imprex/orebfuscator/nms/v1_21_R1/NmsManager.java b/orebfuscator-nms/orebfuscator-nms-v1_21_R1/src/main/java/net/imprex/orebfuscator/nms/v1_21_R1/NmsManager.java new file mode 100644 index 00000000..27493057 --- /dev/null +++ b/orebfuscator-nms/orebfuscator-nms-v1_21_R1/src/main/java/net/imprex/orebfuscator/nms/v1_21_R1/NmsManager.java @@ -0,0 +1,176 @@ +package net.imprex.orebfuscator.nms.v1_21_R1; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +import org.bukkit.Material; +import org.bukkit.World; +import org.bukkit.craftbukkit.v1_21_R1.CraftWorld; +import org.bukkit.craftbukkit.v1_21_R1.block.data.CraftBlockData; +import org.bukkit.craftbukkit.v1_21_R1.entity.CraftPlayer; +import org.bukkit.entity.Player; + +import com.google.common.collect.ImmutableList; + +import it.unimi.dsi.fastutil.shorts.Short2ObjectLinkedOpenHashMap; +import it.unimi.dsi.fastutil.shorts.Short2ObjectMap; +import net.imprex.orebfuscator.config.Config; +import net.imprex.orebfuscator.nms.AbstractNmsManager; +import net.imprex.orebfuscator.nms.ReadOnlyChunk; +import net.imprex.orebfuscator.util.BlockProperties; +import net.imprex.orebfuscator.util.BlockStateProperties; +import net.imprex.orebfuscator.util.NamespacedKey; +import net.minecraft.core.BlockPos; +import net.minecraft.core.SectionPos; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.network.protocol.Packet; +import net.minecraft.network.protocol.game.ClientGamePacketListener; +import net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket; +import net.minecraft.network.protocol.game.ClientboundSectionBlocksUpdatePacket; +import net.minecraft.resources.ResourceKey; +import net.minecraft.server.level.ServerChunkCache; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.chunk.LevelChunk; +import net.minecraft.world.level.chunk.LevelChunkSection; + +public class NmsManager extends AbstractNmsManager { + + private static final int BLOCK_ID_AIR = Block.getId(Blocks.AIR.defaultBlockState()); + + static int getBlockState(LevelChunk chunk, int x, int y, int z) { + LevelChunkSection[] sections = chunk.getSections(); + + int sectionIndex = chunk.getSectionIndex(y); + if (sectionIndex >= 0 && sectionIndex < sections.length) { + LevelChunkSection section = sections[sectionIndex]; + if (section != null && !section.hasOnlyAir()) { + return Block.getId(section.getBlockState(x & 0xF, y & 0xF, z & 0xF)); + } + } + + return BLOCK_ID_AIR; + } + + private static ServerLevel level(World world) { + return ((CraftWorld) world).getHandle(); + } + + private static ServerPlayer player(Player player) { + return ((CraftPlayer) player).getHandle(); + } + + public NmsManager(Config config) { + super(Block.BLOCK_STATE_REGISTRY.size(), new RegionFileCache(config.cache())); + + for (Map.Entry, Block> entry : BuiltInRegistries.BLOCK.entrySet()) { + NamespacedKey namespacedKey = NamespacedKey.fromString(entry.getKey().location().toString()); + Block block = entry.getValue(); + + ImmutableList possibleBlockStates = block.getStateDefinition().getPossibleStates(); + BlockProperties.Builder builder = BlockProperties.builder(namespacedKey); + + for (BlockState blockState : possibleBlockStates) { + Material material = CraftBlockData.fromData(blockState).getMaterial(); + + BlockStateProperties properties = BlockStateProperties.builder(Block.getId(blockState)) + .withIsAir(blockState.isAir()) + // check if material is occluding and use blockData check for rare edge cases like barrier, spawner, slime_block, ... + .withIsOccluding(material.isOccluding() && blockState.canOcclude()) + .withIsBlockEntity(blockState.hasBlockEntity()) + .withIsDefaultState(Objects.equals(block.defaultBlockState(), blockState)) + .build(); + + builder.withBlockState(properties); + } + + this.registerBlockProperties(builder.build()); + } + } + + @Override + public ReadOnlyChunk getReadOnlyChunk(World world, int chunkX, int chunkZ) { + ServerChunkCache serverChunkCache = level(world).getChunkSource(); + LevelChunk chunk = serverChunkCache.getChunk(chunkX, chunkZ, true); + return new ReadOnlyChunkWrapper(chunk); + } + + @Override + public int getBlockState(World world, int x, int y, int z) { + ServerChunkCache serverChunkCache = level(world).getChunkSource(); + if (!serverChunkCache.isChunkLoaded(x >> 4, z >> 4)) { + return BLOCK_ID_AIR; + } + + LevelChunk chunk = serverChunkCache.getChunk(x >> 4, z >> 4, true); + if (chunk == null) { + return BLOCK_ID_AIR; + } + + return getBlockState(chunk, x, y, z); + } + + @Override + public void sendBlockUpdates(World world, Iterable iterable) { + ServerChunkCache serverChunkCache = level(world).getChunkSource(); + BlockPos.MutableBlockPos position = new BlockPos.MutableBlockPos(); + + for (net.imprex.orebfuscator.util.BlockPos pos : iterable) { + position.set(pos.x, pos.y, pos.z); + serverChunkCache.blockChanged(position); + } + } + + @Override + public void sendBlockUpdates(Player player, Iterable iterable) { + ServerPlayer serverPlayer = player(player); + ServerLevel level = serverPlayer.serverLevel(); + ServerChunkCache serverChunkCache = level.getChunkSource(); + + BlockPos.MutableBlockPos position = new BlockPos.MutableBlockPos(); + Map> sectionPackets = new HashMap<>(); + List> blockEntityPackets = new ArrayList<>(); + + for (net.imprex.orebfuscator.util.BlockPos pos : iterable) { + if (!serverChunkCache.isChunkLoaded(pos.x >> 4, pos.z >> 4)) { + continue; + } + + position.set(pos.x, pos.y, pos.z); + BlockState blockState = level.getBlockState(position); + + sectionPackets.computeIfAbsent(SectionPos.of(position), key -> new Short2ObjectLinkedOpenHashMap<>()) + .put(SectionPos.sectionRelativePos(position), blockState); + + if (blockState.hasBlockEntity()) { + BlockEntity blockEntity = level.getBlockEntity(position); + if (blockEntity != null) { + blockEntityPackets.add(blockEntity.getUpdatePacket()); + } + } + } + + for (Map.Entry> entry : sectionPackets.entrySet()) { + Short2ObjectMap blockStates = entry.getValue(); + if (blockStates.size() == 1) { + Short2ObjectMap.Entry blockEntry = blockStates.short2ObjectEntrySet().iterator().next(); + BlockPos blockPosition = entry.getKey().relativeToBlockPos(blockEntry.getShortKey()); + serverPlayer.connection.send(new ClientboundBlockUpdatePacket(blockPosition, blockEntry.getValue())); + } else { + serverPlayer.connection.send(new ClientboundSectionBlocksUpdatePacket(entry.getKey(), + blockStates.keySet(), blockStates.values().toArray(BlockState[]::new))); + } + } + + for (Packet packet : blockEntityPackets) { + serverPlayer.connection.send(packet); + } + } +} diff --git a/orebfuscator-nms/orebfuscator-nms-v1_11_R1/src/main/java/net/imprex/orebfuscator/nms/v1_11_R1/ReadOnlyChunkWrapper.java b/orebfuscator-nms/orebfuscator-nms-v1_21_R1/src/main/java/net/imprex/orebfuscator/nms/v1_21_R1/ReadOnlyChunkWrapper.java similarity index 59% rename from orebfuscator-nms/orebfuscator-nms-v1_11_R1/src/main/java/net/imprex/orebfuscator/nms/v1_11_R1/ReadOnlyChunkWrapper.java rename to orebfuscator-nms/orebfuscator-nms-v1_21_R1/src/main/java/net/imprex/orebfuscator/nms/v1_21_R1/ReadOnlyChunkWrapper.java index 91210c55..0dd5f392 100644 --- a/orebfuscator-nms/orebfuscator-nms-v1_11_R1/src/main/java/net/imprex/orebfuscator/nms/v1_11_R1/ReadOnlyChunkWrapper.java +++ b/orebfuscator-nms/orebfuscator-nms-v1_21_R1/src/main/java/net/imprex/orebfuscator/nms/v1_21_R1/ReadOnlyChunkWrapper.java @@ -1,13 +1,13 @@ -package net.imprex.orebfuscator.nms.v1_11_R1; +package net.imprex.orebfuscator.nms.v1_21_R1; import net.imprex.orebfuscator.nms.ReadOnlyChunk; -import net.minecraft.server.v1_11_R1.Chunk; +import net.minecraft.world.level.chunk.LevelChunk; public class ReadOnlyChunkWrapper implements ReadOnlyChunk { - private final Chunk chunk; + private final LevelChunk chunk; - ReadOnlyChunkWrapper(Chunk chunk) { + ReadOnlyChunkWrapper(LevelChunk chunk) { this.chunk = chunk; } diff --git a/orebfuscator-nms/orebfuscator-nms-v1_15_R1/src/main/java/net/imprex/orebfuscator/nms/v1_15_R1/RegionFileCache.java b/orebfuscator-nms/orebfuscator-nms-v1_21_R1/src/main/java/net/imprex/orebfuscator/nms/v1_21_R1/RegionFileCache.java similarity index 57% rename from orebfuscator-nms/orebfuscator-nms-v1_15_R1/src/main/java/net/imprex/orebfuscator/nms/v1_15_R1/RegionFileCache.java rename to orebfuscator-nms/orebfuscator-nms-v1_21_R1/src/main/java/net/imprex/orebfuscator/nms/v1_21_R1/RegionFileCache.java index a38b35af..061875fd 100644 --- a/orebfuscator-nms/orebfuscator-nms-v1_15_R1/src/main/java/net/imprex/orebfuscator/nms/v1_15_R1/RegionFileCache.java +++ b/orebfuscator-nms/orebfuscator-nms-v1_21_R1/src/main/java/net/imprex/orebfuscator/nms/v1_21_R1/RegionFileCache.java @@ -1,16 +1,19 @@ -package net.imprex.orebfuscator.nms.v1_15_R1; +package net.imprex.orebfuscator.nms.v1_21_R1; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.nio.file.Path; +import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.v1_21_R1.CraftServer; + import net.imprex.orebfuscator.config.CacheConfig; import net.imprex.orebfuscator.nms.AbstractRegionFileCache; import net.imprex.orebfuscator.util.ChunkPosition; -import net.minecraft.server.v1_15_R1.ChunkCoordIntPair; -import net.minecraft.server.v1_15_R1.RegionFile; -import net.minecraft.server.v1_15_R1.RegionFileCompression; +import net.minecraft.world.level.ChunkPos; +import net.minecraft.world.level.chunk.storage.RegionFile; +import net.minecraft.world.level.chunk.storage.RegionFileVersion; public class RegionFileCache extends AbstractRegionFileCache { @@ -20,7 +23,8 @@ public class RegionFileCache extends AbstractRegionFileCache { @Override protected RegionFile createRegionFile(Path path) throws IOException { - return new RegionFile(path, path.getParent(), RegionFileCompression.b); + boolean isSyncChunkWrites = ((CraftServer) Bukkit.getServer()).getServer().forceSynchronousWrites(); + return new RegionFile(null, path, path.getParent(), RegionFileVersion.VERSION_DEFLATE, isSyncChunkWrites); } @Override @@ -30,11 +34,11 @@ protected void closeRegionFile(RegionFile t) throws IOException { @Override protected DataInputStream createInputStream(RegionFile t, ChunkPosition key) throws IOException { - return t.a(new ChunkCoordIntPair(key.x, key.z)); + return t.getChunkDataInputStream(new ChunkPos(key.x, key.z)); } @Override protected DataOutputStream createOutputStream(RegionFile t, ChunkPosition key) throws IOException { - return t.c(new ChunkCoordIntPair(key.x, key.z)); + return t.getChunkDataOutputStream(new ChunkPos(key.x, key.z)); } } \ No newline at end of file diff --git a/orebfuscator-nms/orebfuscator-nms-v1_9_R2/pom.xml b/orebfuscator-nms/orebfuscator-nms-v1_9_R2/pom.xml deleted file mode 100644 index 937dd96f..00000000 --- a/orebfuscator-nms/orebfuscator-nms-v1_9_R2/pom.xml +++ /dev/null @@ -1,33 +0,0 @@ - - 4.0.0 - - - net.imprex - orebfuscator-nms - ${revision} - - - orebfuscator-nms-v1_9_R2 - jar - - - - org.spigotmc - spigot - 1.9.4-R0.1-SNAPSHOT - provided - - - com.comphenix.protocol - ProtocolLib - ${dependency.protocollib.version} - provided - - - net.imprex - orebfuscator-nms-api - ${revision} - provided - - - \ No newline at end of file diff --git a/orebfuscator-nms/orebfuscator-nms-v1_9_R2/src/main/java/net/imprex/orebfuscator/nms/v1_9_R2/NmsManager.java b/orebfuscator-nms/orebfuscator-nms-v1_9_R2/src/main/java/net/imprex/orebfuscator/nms/v1_9_R2/NmsManager.java deleted file mode 100644 index 10141ea1..00000000 --- a/orebfuscator-nms/orebfuscator-nms-v1_9_R2/src/main/java/net/imprex/orebfuscator/nms/v1_9_R2/NmsManager.java +++ /dev/null @@ -1,197 +0,0 @@ -package net.imprex.orebfuscator.nms.v1_9_R2; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -import org.bukkit.Material; -import org.bukkit.World; -import org.bukkit.craftbukkit.v1_9_R2.CraftWorld; -import org.bukkit.craftbukkit.v1_9_R2.entity.CraftPlayer; -import org.bukkit.craftbukkit.v1_9_R2.util.CraftMagicNumbers; -import org.bukkit.entity.Player; - -import com.comphenix.protocol.PacketType; -import com.comphenix.protocol.events.PacketContainer; -import com.comphenix.protocol.wrappers.ChunkCoordIntPair; -import com.comphenix.protocol.wrappers.MultiBlockChangeInfo; -import com.comphenix.protocol.wrappers.WrappedBlockData; -import com.google.common.collect.ImmutableList; - -import net.imprex.orebfuscator.config.Config; -import net.imprex.orebfuscator.nms.AbstractNmsManager; -import net.imprex.orebfuscator.nms.ReadOnlyChunk; -import net.imprex.orebfuscator.util.BlockPos; -import net.imprex.orebfuscator.util.BlockProperties; -import net.imprex.orebfuscator.util.BlockStateProperties; -import net.imprex.orebfuscator.util.NamespacedKey; -import net.minecraft.server.v1_9_R2.Block; -import net.minecraft.server.v1_9_R2.BlockAir; -import net.minecraft.server.v1_9_R2.BlockPosition; -import net.minecraft.server.v1_9_R2.Blocks; -import net.minecraft.server.v1_9_R2.Chunk; -import net.minecraft.server.v1_9_R2.ChunkProviderServer; -import net.minecraft.server.v1_9_R2.ChunkSection; -import net.minecraft.server.v1_9_R2.EntityPlayer; -import net.minecraft.server.v1_9_R2.IBlockData; -import net.minecraft.server.v1_9_R2.MinecraftKey; -import net.minecraft.server.v1_9_R2.Packet; -import net.minecraft.server.v1_9_R2.PacketListenerPlayOut; -import net.minecraft.server.v1_9_R2.TileEntity; -import net.minecraft.server.v1_9_R2.WorldServer; - -public class NmsManager extends AbstractNmsManager { - - private static final int BLOCK_ID_AIR = getBlockId(Blocks.AIR.getBlockData()); - - static int getBlockState(Chunk chunk, int x, int y, int z) { - ChunkSection[] sections = chunk.getSections(); - - int sectionIndex = y >> 4; - if (sectionIndex >= 0 && sectionIndex < sections.length) { - ChunkSection section = sections[sectionIndex]; - if (section != null && section != Chunk.a) { - return getBlockId(section.getType(x & 0xF, y & 0xF, z & 0xF)); - } - } - - return BLOCK_ID_AIR; - } - - private static WorldServer level(World world) { - return ((CraftWorld) world).getHandle(); - } - - private static EntityPlayer player(Player player) { - return ((CraftPlayer) player).getHandle(); - } - - private static int getBlockId(IBlockData blockData) { - if (blockData == null) { - return 0; - } else { - int id = Block.REGISTRY_ID.getId(blockData); - return id == -1 ? 0 : id; - } - } - - public NmsManager(Config config) { - super(Block.REGISTRY_ID.a(), new RegionFileCache(config.cache())); - - for (MinecraftKey key : Block.REGISTRY.keySet()) { - NamespacedKey namespacedKey = NamespacedKey.fromString(key.toString()); - - Block block = Block.REGISTRY.get(key); - Material material = CraftMagicNumbers.getMaterial(block); - - ImmutableList possibleBlockStates = block.t().a(); - BlockProperties.Builder builder = BlockProperties.builder(namespacedKey); - - for (IBlockData blockState : possibleBlockStates) { - BlockStateProperties properties = BlockStateProperties.builder(getBlockId(blockState)) - .withIsAir(block instanceof BlockAir) - .withIsOccluding(material.isOccluding()) - .withIsBlockEntity(block.isTileEntity()) - .withIsDefaultState(Objects.equals(block.getBlockData(), blockState)) - .build(); - - builder.withBlockState(properties, true); - } - - this.registerBlockProperties(builder.build()); - } - } - - @Override - public ReadOnlyChunk getReadOnlyChunk(World world, int chunkX, int chunkZ) { - ChunkProviderServer chunkProviderServer = level(world).getChunkProviderServer(); - Chunk chunk = chunkProviderServer.getChunkAt(chunkX, chunkZ); - return new ReadOnlyChunkWrapper(chunk); - } - - @Override - public int getBlockState(World world, int x, int y, int z) { - ChunkProviderServer serverChunkCache = level(world).getChunkProviderServer(); - if (!serverChunkCache.isLoaded(x >> 4, z >> 4)) { - return BLOCK_ID_AIR; - } - - Chunk chunk = serverChunkCache.getChunkAt(x >> 4, z >> 4); - if (chunk == null) { - return BLOCK_ID_AIR; - } - - return getBlockState(chunk, x, y, z); - } - - @Override - public void sendBlockUpdates(World world, Iterable iterable) { - WorldServer level = level(world); - BlockPosition.MutableBlockPosition position = new BlockPosition.MutableBlockPosition(); - - for (net.imprex.orebfuscator.util.BlockPos pos : iterable) { - position.c(pos.x, pos.y, pos.z); - - IBlockData blockState = level.getType(position); - level.notify(position, blockState, blockState, 0); - } - } - - @Override - public void sendBlockUpdates(Player player, Iterable iterable) { - EntityPlayer serverPlayer = player(player); - WorldServer level = serverPlayer.x(); - ChunkProviderServer serverChunkCache = level.getChunkProviderServer(); - - BlockPosition.MutableBlockPosition position = new BlockPosition.MutableBlockPosition(); - Map> sectionPackets = new HashMap<>(); - List> blockEntityPackets = new ArrayList<>(); - - for (net.imprex.orebfuscator.util.BlockPos pos : iterable) { - if (!serverChunkCache.isLoaded(pos.x >> 4, pos.z >> 4)) { - continue; - } - - position.c(pos.x, pos.y, pos.z); - IBlockData blockState = level.getType(position); - - ChunkCoordIntPair chunkCoord = new ChunkCoordIntPair(pos.x >> 4, pos.z >> 4); - short location = (short) ((pos.x & 0xF) << 12 | (pos.z & 0xF) << 8 | pos.y); - - sectionPackets.computeIfAbsent(chunkCoord, key -> new ArrayList<>()) - .add(new MultiBlockChangeInfo(location, WrappedBlockData.fromHandle(blockState), chunkCoord)); - - if (blockState.getBlock().isTileEntity()) { - TileEntity blockEntity = level.getTileEntity(position); - if (blockEntity != null) { - blockEntityPackets.add(blockEntity.getUpdatePacket()); - } - } - } - - for (Map.Entry> entry : sectionPackets.entrySet()) { - List blockStates = entry.getValue(); - if (blockStates.size() == 1) { - MultiBlockChangeInfo blockEntry = blockStates.get(0); - var blockPosition = new com.comphenix.protocol.wrappers.BlockPosition( - blockEntry.getAbsoluteX(), blockEntry.getY(), blockEntry.getAbsoluteZ()); - - PacketContainer packet = new PacketContainer(PacketType.Play.Server.BLOCK_CHANGE); - packet.getBlockPositionModifier().write(0, blockPosition); - packet.getBlockData().write(0, blockEntry.getData()); - serverPlayer.playerConnection.sendPacket((Packet) packet.getHandle()); - } else { - PacketContainer packet = new PacketContainer(PacketType.Play.Server.MULTI_BLOCK_CHANGE); - packet.getChunkCoordIntPairs().write(0, entry.getKey()); - packet.getMultiBlockChangeInfoArrays().write(0, blockStates.toArray(MultiBlockChangeInfo[]::new)); - serverPlayer.playerConnection.sendPacket((Packet) packet.getHandle()); - } - } - - for (Packet packet : blockEntityPackets) { - serverPlayer.playerConnection.sendPacket(packet); - } - } -} diff --git a/orebfuscator-nms/orebfuscator-nms-v1_9_R2/src/main/java/net/imprex/orebfuscator/nms/v1_9_R2/ReadOnlyChunkWrapper.java b/orebfuscator-nms/orebfuscator-nms-v1_9_R2/src/main/java/net/imprex/orebfuscator/nms/v1_9_R2/ReadOnlyChunkWrapper.java deleted file mode 100644 index 5a5008a9..00000000 --- a/orebfuscator-nms/orebfuscator-nms-v1_9_R2/src/main/java/net/imprex/orebfuscator/nms/v1_9_R2/ReadOnlyChunkWrapper.java +++ /dev/null @@ -1,18 +0,0 @@ -package net.imprex.orebfuscator.nms.v1_9_R2; - -import net.imprex.orebfuscator.nms.ReadOnlyChunk; -import net.minecraft.server.v1_9_R2.Chunk; - -public class ReadOnlyChunkWrapper implements ReadOnlyChunk { - - private final Chunk chunk; - - ReadOnlyChunkWrapper(Chunk chunk) { - this.chunk = chunk; - } - - @Override - public int getBlockState(int x, int y, int z) { - return NmsManager.getBlockState(chunk, x, y, z); - } -} diff --git a/orebfuscator-nms/orebfuscator-nms-v1_9_R2/src/main/java/net/imprex/orebfuscator/nms/v1_9_R2/RegionFileCache.java b/orebfuscator-nms/orebfuscator-nms-v1_9_R2/src/main/java/net/imprex/orebfuscator/nms/v1_9_R2/RegionFileCache.java deleted file mode 100644 index 572e0f8d..00000000 --- a/orebfuscator-nms/orebfuscator-nms-v1_9_R2/src/main/java/net/imprex/orebfuscator/nms/v1_9_R2/RegionFileCache.java +++ /dev/null @@ -1,38 +0,0 @@ -package net.imprex.orebfuscator.nms.v1_9_R2; - -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; -import java.nio.file.Path; - -import net.imprex.orebfuscator.config.CacheConfig; -import net.imprex.orebfuscator.nms.AbstractRegionFileCache; -import net.imprex.orebfuscator.util.ChunkPosition; -import net.minecraft.server.v1_9_R2.RegionFile; - -public class RegionFileCache extends AbstractRegionFileCache { - - RegionFileCache(CacheConfig cacheConfig) { - super(cacheConfig); - } - - @Override - protected RegionFile createRegionFile(Path path) throws IOException { - return new RegionFile(path.toFile()); - } - - @Override - protected void closeRegionFile(RegionFile t) throws IOException { - t.c(); - } - - @Override - protected DataInputStream createInputStream(RegionFile t, ChunkPosition key) throws IOException { - return t.a(key.x & 0x1F, key.z & 0x1F); - } - - @Override - protected DataOutputStream createOutputStream(RegionFile t, ChunkPosition key) throws IOException { - return t.b(key.x & 0x1F, key.z & 0x1F); - } -} \ No newline at end of file diff --git a/orebfuscator-nms/pom.xml b/orebfuscator-nms/pom.xml index 23fe8399..9cc79fc5 100644 --- a/orebfuscator-nms/pom.xml +++ b/orebfuscator-nms/pom.xml @@ -14,14 +14,6 @@ orebfuscator-nms-api - orebfuscator-nms-v1_9_R2 - orebfuscator-nms-v1_10_R1 - orebfuscator-nms-v1_11_R1 - orebfuscator-nms-v1_12_R1 - orebfuscator-nms-v1_13_R1 - orebfuscator-nms-v1_13_R2 - orebfuscator-nms-v1_14_R1 - orebfuscator-nms-v1_15_R1 orebfuscator-nms-v1_16_R1 orebfuscator-nms-v1_16_R2 orebfuscator-nms-v1_16_R3 @@ -35,5 +27,6 @@ orebfuscator-nms-v1_20_R2 orebfuscator-nms-v1_20_R3 orebfuscator-nms-v1_20_R4 + orebfuscator-nms-v1_21_R1 \ No newline at end of file diff --git a/orebfuscator-plugin/pom.xml b/orebfuscator-plugin/pom.xml index ed7b4fe1..a5ddaefe 100644 --- a/orebfuscator-plugin/pom.xml +++ b/orebfuscator-plugin/pom.xml @@ -133,54 +133,6 @@ ${revision} compile - - net.imprex - orebfuscator-nms-v1_9_R2 - ${revision} - compile - - - net.imprex - orebfuscator-nms-v1_10_R1 - ${revision} - compile - - - net.imprex - orebfuscator-nms-v1_11_R1 - ${revision} - compile - - - net.imprex - orebfuscator-nms-v1_12_R1 - ${revision} - compile - - - net.imprex - orebfuscator-nms-v1_13_R1 - ${revision} - compile - - - net.imprex - orebfuscator-nms-v1_13_R2 - ${revision} - compile - - - net.imprex - orebfuscator-nms-v1_14_R1 - ${revision} - compile - - - net.imprex - orebfuscator-nms-v1_15_R1 - ${revision} - compile - net.imprex orebfuscator-nms-v1_16_R1 @@ -221,52 +173,52 @@ net.imprex orebfuscator-nms-v1_19_R1 ${revision} + mojang-mapped compile net.imprex orebfuscator-nms-v1_19_R1 ${revision} - mojang-mapped compile net.imprex orebfuscator-nms-v1_19_R2 ${revision} + mojang-mapped compile net.imprex orebfuscator-nms-v1_19_R2 ${revision} - mojang-mapped compile net.imprex orebfuscator-nms-v1_19_R3 ${revision} + mojang-mapped compile net.imprex orebfuscator-nms-v1_19_R3 ${revision} - mojang-mapped compile net.imprex orebfuscator-nms-v1_20_R1 ${revision} + mojang-mapped compile net.imprex orebfuscator-nms-v1_20_R1 ${revision} - mojang-mapped compile @@ -308,5 +260,18 @@ ${revision} compile + + net.imprex + orebfuscator-nms-v1_21_R1 + ${revision} + mojang-mapped + compile + + + net.imprex + orebfuscator-nms-v1_21_R1 + ${revision} + compile + \ No newline at end of file diff --git a/orebfuscator-plugin/src/main/java/net/imprex/orebfuscator/MetricsSystem.java b/orebfuscator-plugin/src/main/java/net/imprex/orebfuscator/MetricsSystem.java index b4cfb0e0..3989b7dd 100644 --- a/orebfuscator-plugin/src/main/java/net/imprex/orebfuscator/MetricsSystem.java +++ b/orebfuscator-plugin/src/main/java/net/imprex/orebfuscator/MetricsSystem.java @@ -77,9 +77,6 @@ public void addUsageCharts(OrebfuscatorConfig config) { this.metrics.addCustomChart(new SimplePie("ignore_spectator", () -> { return Boolean.toString(config.general().ignoreSpectator()); })); - this.metrics.addCustomChart(new SimplePie("async_packet_listener", () -> { - return Boolean.toString(config.advanced().useAsyncPacketListener()); - })); this.metrics.addCustomChart(new SimplePie("cache", () -> { return Boolean.toString(config.cache().enabled()); })); @@ -93,7 +90,7 @@ public void addUsageCharts(OrebfuscatorConfig config) { return Boolean.toString(config.usesFrustumCulling()); })); this.metrics.addCustomChart(new SimplePie("ray_cast", () -> { - return Boolean.toString(config.usesRayCastCheck()); + return config.usesRayCastCheck(); })); } } diff --git a/orebfuscator-plugin/src/main/java/net/imprex/orebfuscator/Orebfuscator.java b/orebfuscator-plugin/src/main/java/net/imprex/orebfuscator/Orebfuscator.java index 2ba8b68a..b5c27863 100644 --- a/orebfuscator-plugin/src/main/java/net/imprex/orebfuscator/Orebfuscator.java +++ b/orebfuscator-plugin/src/main/java/net/imprex/orebfuscator/Orebfuscator.java @@ -1,7 +1,5 @@ package net.imprex.orebfuscator; -import java.util.logging.Level; - import org.bukkit.Bukkit; import org.bukkit.event.Event; import org.bukkit.event.EventPriority; @@ -19,8 +17,8 @@ import net.imprex.orebfuscator.player.OrebfuscatorPlayerMap; import net.imprex.orebfuscator.proximity.ProximityDirectorThread; import net.imprex.orebfuscator.proximity.ProximityPacketListener; -import net.imprex.orebfuscator.util.ConsoleUtil; import net.imprex.orebfuscator.util.HeightAccessor; +import net.imprex.orebfuscator.util.MinecraftVersion; import net.imprex.orebfuscator.util.OFCLogger; public class Orebfuscator extends JavaPlugin implements Listener { @@ -45,12 +43,11 @@ public void onLoad() { @Override public void onEnable() { try { - ConsoleUtil.printBox(Level.SEVERE, - "WARNING", - "REMOVAL OF SUPPORT FOR JAVA VERSIONS BEFORE 17 AND MINECRAFT VERSIONS BEFORE 1.16", - "", - "https://github.com/Imprex-Development/orebfuscator/discussions/367"); - + // Check for valid minecraft version + if (MinecraftVersion.isBelow("1.16")) { + throw new RuntimeException("Orebfuscator only supports minecraft 1.16 and above"); + } + // Check if protocolLib is enabled Plugin protocolLib = getServer().getPluginManager().getPlugin("ProtocolLib"); if (protocolLib == null || !protocolLib.isEnabled()) { @@ -60,8 +57,6 @@ public void onEnable() { // Load configurations this.config = new OrebfuscatorConfig(this); - new SyncPacketListenerDeprecationNotifier(this); - this.playerMap = new OrebfuscatorPlayerMap(this); // register cleanup listener diff --git a/orebfuscator-plugin/src/main/java/net/imprex/orebfuscator/SyncPacketListenerDeprecationNotifier.java b/orebfuscator-plugin/src/main/java/net/imprex/orebfuscator/SyncPacketListenerDeprecationNotifier.java deleted file mode 100644 index df8b3a67..00000000 --- a/orebfuscator-plugin/src/main/java/net/imprex/orebfuscator/SyncPacketListenerDeprecationNotifier.java +++ /dev/null @@ -1,43 +0,0 @@ -package net.imprex.orebfuscator; - -import java.util.logging.Level; - -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerJoinEvent; - -import net.imprex.orebfuscator.util.ConsoleUtil; -import net.imprex.orebfuscator.util.JavaVersion; -import net.imprex.orebfuscator.util.PermissionUtil; -import net.md_5.bungee.api.chat.TextComponent; - -public class SyncPacketListenerDeprecationNotifier implements Listener { - - private final boolean isUsingSyncListener; - - public SyncPacketListenerDeprecationNotifier(Orebfuscator orebfuscator) { - this.isUsingSyncListener = !orebfuscator.getOrebfuscatorConfig().advanced().useAsyncPacketListener(); - - Bukkit.getPluginManager().registerEvents(this, orebfuscator); - - if (isUsingSyncListener) { - ConsoleUtil.printBox(Level.SEVERE, - "WARNING", - "SUPPORT FOR SYNC PACKET LISTENER WILL BE DROPPED IN THE NEAR FUTURE", - "", - "Future releases of Orebfuscator will only support async packet listeners"); - } - } - - @EventHandler - public void onJoin(PlayerJoinEvent event) { - Player player = event.getPlayer(); - if (PermissionUtil.canAccessAdminTools(player) && isUsingSyncListener) { - player.spigot().sendMessage(new TextComponent(String.format( - "[§bOrebfuscator§f]§c§l You are using sync packet listeners which Orebfuscator will no longer support in the near future! Please make sure everything works fine with async packet listeners enabled.", - JavaVersion.get()))); - } - } -} diff --git a/orebfuscator-plugin/src/main/java/net/imprex/orebfuscator/cache/ChunkSerializer.java b/orebfuscator-plugin/src/main/java/net/imprex/orebfuscator/cache/ChunkSerializer.java index cca88cf6..246d26e7 100644 --- a/orebfuscator-plugin/src/main/java/net/imprex/orebfuscator/cache/ChunkSerializer.java +++ b/orebfuscator-plugin/src/main/java/net/imprex/orebfuscator/cache/ChunkSerializer.java @@ -56,7 +56,6 @@ public static ObfuscationResult read(ChunkPosition key) throws IOException { return null; } - // TODO consider size limit for cache since RegionFile before 1.14 have a hard limit of 256 * 4kb public static void write(ChunkPosition key, ObfuscationResult value) throws IOException { try (DataOutputStream dataOutputStream = createOutputStream(key)) { dataOutputStream.writeInt(CACHE_VERSION); diff --git a/orebfuscator-plugin/src/main/java/net/imprex/orebfuscator/chunk/Chunk.java b/orebfuscator-plugin/src/main/java/net/imprex/orebfuscator/chunk/Chunk.java index ec6e5155..d9a8030a 100644 --- a/orebfuscator-plugin/src/main/java/net/imprex/orebfuscator/chunk/Chunk.java +++ b/orebfuscator-plugin/src/main/java/net/imprex/orebfuscator/chunk/Chunk.java @@ -10,7 +10,7 @@ public class Chunk implements AutoCloseable { public static Chunk fromChunkStruct(ChunkStruct chunkStruct) { - return new Chunk(chunkStruct, ChunkCapabilities.getExtraBytes(chunkStruct)); + return new Chunk(chunkStruct); } private final int chunkX; @@ -22,7 +22,7 @@ public static Chunk fromChunkStruct(ChunkStruct chunkStruct) { private final ByteBuf inputBuffer; private final ByteBuf outputBuffer; - private Chunk(ChunkStruct chunkStruct, int extraBytes) { + private Chunk(ChunkStruct chunkStruct) { this.chunkX = chunkStruct.chunkX; this.chunkZ = chunkStruct.chunkZ; @@ -34,7 +34,7 @@ private Chunk(ChunkStruct chunkStruct, int extraBytes) { for (int sectionIndex = 0; sectionIndex < this.sections.length; sectionIndex++) { if (chunkStruct.sectionMask.get(sectionIndex)) { - this.sections[sectionIndex] = new ChunkSectionHolder(extraBytes); + this.sections[sectionIndex] = new ChunkSectionHolder(); } } } @@ -109,28 +109,27 @@ private class ChunkSectionHolder { public ChunkSection chunkSection; public final int[] data; - public final int offset; + public final int extraOffset; private int extraBytes; - public ChunkSectionHolder(int extraBytes) { + public ChunkSectionHolder() { this.chunkSection = new ChunkSection(); this.data = this.chunkSection.read(inputBuffer); - this.offset = inputBuffer.readerIndex(); + this.extraOffset = inputBuffer.readerIndex(); if (ChunkCapabilities.hasBiomePalettedContainer()) { skipBiomePalettedContainer(); - this.extraBytes = inputBuffer.readerIndex() - this.offset; - } else { - this.extraBytes = extraBytes; - inputBuffer.skipBytes(extraBytes); + this.extraBytes = inputBuffer.readerIndex() - this.extraOffset; } } public void write() { this.chunkSection.write(outputBuffer); - outputBuffer.writeBytes(inputBuffer, this.offset, extraBytes); + if (this.extraBytes > 0) { + outputBuffer.writeBytes(inputBuffer, this.extraOffset, extraBytes); + } } } } diff --git a/orebfuscator-plugin/src/main/java/net/imprex/orebfuscator/chunk/ChunkCapabilities.java b/orebfuscator-plugin/src/main/java/net/imprex/orebfuscator/chunk/ChunkCapabilities.java index 0a123d86..68c4e6a1 100644 --- a/orebfuscator-plugin/src/main/java/net/imprex/orebfuscator/chunk/ChunkCapabilities.java +++ b/orebfuscator-plugin/src/main/java/net/imprex/orebfuscator/chunk/ChunkCapabilities.java @@ -8,23 +8,15 @@ public final class ChunkCapabilities { // hasClientboundLevelChunkPacketData >= 1.18; // hasBiomePalettedContainer >= 1.18 // hasSingleValuePalette >= 1.18 - // hasHeightBitMask <= 1.17 + // hasHeightBitMask < 1.18 // hasDynamicHeight >= 1.17 - // hasSimpleVarBitBuffer >= 1.16 - // hasBlockCount >= 1.14 - // hasDirectPaletteZeroLength < 1.13 - // hasLight < 1.14 private static final boolean hasChunkPosFieldUnloadPacket = MinecraftVersion.isAtOrAbove("1.20.2"); private static final boolean hasClientboundLevelChunkPacketData = MinecraftVersion.isAtOrAbove("1.18"); private static final boolean hasBiomePalettedContainer = MinecraftVersion.isAtOrAbove("1.18"); private static final boolean hasSingleValuePalette = MinecraftVersion.isAtOrAbove("1.18"); - private static final boolean hasHeightBitMask = MinecraftVersion.isAtOrBelow("1.17"); + private static final boolean hasHeightBitMask = MinecraftVersion.isBelow("1.18"); private static final boolean hasDynamicHeight = MinecraftVersion.isAtOrAbove("1.17"); - private static final boolean hasSimpleVarBitBuffer = MinecraftVersion.isAtOrAbove("1.16"); - private static final boolean hasBlockCount = MinecraftVersion.isAtOrAbove("1.14"); - private static final boolean hasDirectPaletteZeroLength = MinecraftVersion.isBelow("1.13"); - private static final boolean hasLightArray = MinecraftVersion.isBelow("1.14"); private ChunkCapabilities() { } @@ -52,35 +44,4 @@ public static boolean hasHeightBitMask() { public static boolean hasDynamicHeight() { return hasDynamicHeight; } - - public static boolean hasSimpleVarBitBuffer() { - return hasSimpleVarBitBuffer; - } - - public static boolean hasBlockCount() { - return hasBlockCount; - } - - public static boolean hasDirectPaletteZeroLength() { - return hasDirectPaletteZeroLength; - } - - public static boolean hasLightArray() { - return hasLightArray; - } - - public static int getExtraBytes(ChunkStruct chunkStruct) { - int extraBytes = ChunkCapabilities.hasLightArray() ? 2048 : 0; - if (chunkStruct.isOverworld) { - extraBytes *= 2; - } - return extraBytes; - } - - public static VarBitBuffer createVarBitBuffer(int bitsPerEntry, int size) { - if (hasSimpleVarBitBuffer) { - return new SimpleVarBitBuffer(bitsPerEntry, size); - } - return new CompactVarBitBuffer(bitsPerEntry, size); - } } diff --git a/orebfuscator-plugin/src/main/java/net/imprex/orebfuscator/chunk/ChunkSection.java b/orebfuscator-plugin/src/main/java/net/imprex/orebfuscator/chunk/ChunkSection.java index e25558f5..f6b2873b 100644 --- a/orebfuscator-plugin/src/main/java/net/imprex/orebfuscator/chunk/ChunkSection.java +++ b/orebfuscator-plugin/src/main/java/net/imprex/orebfuscator/chunk/ChunkSection.java @@ -36,7 +36,7 @@ private void setBitsPerBlock(int bitsPerBlock, boolean grow) { if (this.bitsPerBlock == 0) { this.data = new ZeroVarBitBuffer(4096); } else { - this.data = ChunkCapabilities.createVarBitBuffer(this.bitsPerBlock, 4096); + this.data = new SimpleVarBitBuffer(this.bitsPerBlock, 4096); } } } @@ -87,13 +87,11 @@ public int getBlockState(int index) { } public boolean isEmpty() { - return ChunkCapabilities.hasBlockCount() && this.blockCount == 0; + return this.blockCount == 0; } public void write(ByteBuf buffer) { - if (ChunkCapabilities.hasBlockCount()) { - buffer.writeShort(this.blockCount); - } + buffer.writeShort(this.blockCount); buffer.writeByte(this.bitsPerBlock); this.palette.write(buffer); @@ -106,9 +104,7 @@ public void write(ByteBuf buffer) { } public int[] read(ByteBuf buffer) { - if (ChunkCapabilities.hasBlockCount()) { - this.blockCount = buffer.readShort(); - } + this.blockCount = buffer.readShort(); this.setBitsPerBlock(buffer.readUnsignedByte(), false); diff --git a/orebfuscator-plugin/src/main/java/net/imprex/orebfuscator/chunk/ChunkStruct.java b/orebfuscator-plugin/src/main/java/net/imprex/orebfuscator/chunk/ChunkStruct.java index 4ce8fb0c..3d8debb6 100644 --- a/orebfuscator-plugin/src/main/java/net/imprex/orebfuscator/chunk/ChunkStruct.java +++ b/orebfuscator-plugin/src/main/java/net/imprex/orebfuscator/chunk/ChunkStruct.java @@ -18,7 +18,6 @@ public class ChunkStruct { public final World world; - public final boolean isOverworld; public final int chunkX; public final int chunkZ; @@ -34,7 +33,6 @@ public ChunkStruct(PacketContainer packet, World world) { StructureModifier packetInteger = packet.getIntegers(); this.world = world; - this.isOverworld = world.getEnvironment() == World.Environment.NORMAL; this.chunkX = packetInteger.read(0); this.chunkZ = packetInteger.read(1); diff --git a/orebfuscator-plugin/src/main/java/net/imprex/orebfuscator/chunk/CompactVarBitBuffer.java b/orebfuscator-plugin/src/main/java/net/imprex/orebfuscator/chunk/CompactVarBitBuffer.java deleted file mode 100644 index a53253c7..00000000 --- a/orebfuscator-plugin/src/main/java/net/imprex/orebfuscator/chunk/CompactVarBitBuffer.java +++ /dev/null @@ -1,53 +0,0 @@ -package net.imprex.orebfuscator.chunk; - -public class CompactVarBitBuffer implements VarBitBuffer { - - private final int bitsPerEntry; - private final long adjustmentMask; - - private final int size; - private final long[] buffer; - - public CompactVarBitBuffer(int bitsPerEntry, int size) { - this.bitsPerEntry = bitsPerEntry; - this.adjustmentMask = (1L << bitsPerEntry) - 1L; - - this.size = size; - this.buffer = new long[(int) Math.ceil(bitsPerEntry * size / 64f)]; - } - - public int get(int index) { - int position = index * this.bitsPerEntry; - int startIndex = position >> 6; - int endIndex = (position + this.bitsPerEntry - 1) >> 6; - int bitOffset = position % 64; - - long value = this.buffer[startIndex] >>> bitOffset; - if (startIndex != endIndex) { - value |= this.buffer[endIndex] << (64 - bitOffset); - } - return (int) (value & this.adjustmentMask); - } - - public void set(int index, int value) { - int position = index * this.bitsPerEntry; - int startIndex = position >> 6; - int endIndex = (position + this.bitsPerEntry - 1) >> 6; - int bitOffset = position % 64; - - this.buffer[startIndex] = this.buffer[startIndex] & ~(this.adjustmentMask << bitOffset) | (value & this.adjustmentMask) << bitOffset; - - if (startIndex != endIndex) { - int endBitOffset = 64 - bitOffset; - this.buffer[endIndex] = this.buffer[endIndex] & ~(this.adjustmentMask >> endBitOffset) | (value & this.adjustmentMask) >> endBitOffset; - } - } - - public long[] toArray() { - return this.buffer; - } - - public int size() { - return this.size; - } -} diff --git a/orebfuscator-plugin/src/main/java/net/imprex/orebfuscator/chunk/DirectPalette.java b/orebfuscator-plugin/src/main/java/net/imprex/orebfuscator/chunk/DirectPalette.java index c5453d75..75bc0bd0 100644 --- a/orebfuscator-plugin/src/main/java/net/imprex/orebfuscator/chunk/DirectPalette.java +++ b/orebfuscator-plugin/src/main/java/net/imprex/orebfuscator/chunk/DirectPalette.java @@ -16,15 +16,9 @@ public int valueFor(int id) { @Override public void read(ByteBuf buffer) { - if (ChunkCapabilities.hasDirectPaletteZeroLength()) { - ByteBufUtil.readVarInt(buffer); - } } @Override public void write(ByteBuf buffer) { - if (ChunkCapabilities.hasDirectPaletteZeroLength()) { - ByteBufUtil.writeVarInt(buffer, 0); - } } } diff --git a/orebfuscator-plugin/src/main/java/net/imprex/orebfuscator/config/OrebfuscatorAdvancedConfig.java b/orebfuscator-plugin/src/main/java/net/imprex/orebfuscator/config/OrebfuscatorAdvancedConfig.java index 2be16eaa..89f9f1b1 100644 --- a/orebfuscator-plugin/src/main/java/net/imprex/orebfuscator/config/OrebfuscatorAdvancedConfig.java +++ b/orebfuscator-plugin/src/main/java/net/imprex/orebfuscator/config/OrebfuscatorAdvancedConfig.java @@ -7,9 +7,7 @@ public class OrebfuscatorAdvancedConfig implements AdvancedConfig { private boolean verbose = false; - private boolean useAsyncPacketListener = true; private int maxMillisecondsPerTick = 10; - private int protocolLibThreads = -1; private int obfuscationWorkerThreads = -1; private int obfuscationTimeout = 10_000; @@ -19,7 +17,6 @@ public class OrebfuscatorAdvancedConfig implements AdvancedConfig { private int proximityThreadCheckInterval = 50; private int proximityPlayerCheckInterval = 5000; - private boolean protocolLibThreadsSet = false; private boolean obfuscationWorkerThreadsSet = false; private boolean hasObfuscationTimeout = false; private boolean proximityHiderThreadsSet = false; @@ -27,7 +24,6 @@ public class OrebfuscatorAdvancedConfig implements AdvancedConfig { public void deserialize(ConfigurationSection section) { this.verbose = section.getBoolean("verbose", false); - this.useAsyncPacketListener = section.getBoolean("useAsyncPacketListener", true); this.maxMillisecondsPerTick = section.getInt("maxMillisecondsPerTick", 10); if (this.maxMillisecondsPerTick <= 0 || this.maxMillisecondsPerTick >= 50) { @@ -35,9 +31,6 @@ public void deserialize(ConfigurationSection section) { "maxMillisecondsPerTick has to be between 0 and 50, value: " + this.maxMillisecondsPerTick); } - this.protocolLibThreads = section.getInt("protocolLibThreads", -1); - this.protocolLibThreadsSet = (this.protocolLibThreads > 0); - this.obfuscationWorkerThreads = section.getInt("obfuscationWorkerThreads", -1); this.obfuscationWorkerThreadsSet = (this.obfuscationWorkerThreads > 0); @@ -65,21 +58,17 @@ public void deserialize(ConfigurationSection section) { public void initialize() { int availableThreads = Runtime.getRuntime().availableProcessors(); - this.protocolLibThreads = (int) (protocolLibThreadsSet ? protocolLibThreads : Math.ceil(availableThreads / 2f)); this.obfuscationWorkerThreads = (int) (obfuscationWorkerThreadsSet ? obfuscationWorkerThreads : availableThreads); this.proximityHiderThreads = (int) (proximityHiderThreadsSet ? proximityHiderThreads : Math.ceil(availableThreads / 2f)); OFCLogger.setVerboseLogging(this.verbose); - OFCLogger.debug("advanced.protocolLibThreads = " + this.protocolLibThreads); OFCLogger.debug("advanced.obfuscationWorkerThreads = " + this.obfuscationWorkerThreads); OFCLogger.debug("advanced.proximityHiderThreads = " + this.proximityHiderThreads); } public void serialize(ConfigurationSection section) { section.set("verbose", this.verbose); - section.set("useAsyncPacketListener", this.useAsyncPacketListener); section.set("maxMillisecondsPerTick", this.maxMillisecondsPerTick); - section.set("protocolLibThreads", this.protocolLibThreadsSet ? this.protocolLibThreads : -1); section.set("obfuscationWorkerThreads", this.obfuscationWorkerThreadsSet ? this.obfuscationWorkerThreads : -1); section.set("obfuscationTimeout", this.hasObfuscationTimeout ? this.obfuscationTimeout : -1); @@ -90,21 +79,11 @@ public void serialize(ConfigurationSection section) { section.set("proximityPlayerCheckInterval", this.hasProximityPlayerCheckInterval ? this.proximityPlayerCheckInterval : -1); } - @Override - public boolean useAsyncPacketListener() { - return this.useAsyncPacketListener; - } - @Override public int maxMillisecondsPerTick() { return this.maxMillisecondsPerTick; } - @Override - public int protocolLibThreads() { - return this.protocolLibThreads; - } - @Override public int obfuscationWorkerThreads() { return this.obfuscationWorkerThreads; diff --git a/orebfuscator-plugin/src/main/java/net/imprex/orebfuscator/config/OrebfuscatorConfig.java b/orebfuscator-plugin/src/main/java/net/imprex/orebfuscator/config/OrebfuscatorConfig.java index 755c569a..94b7fb14 100644 --- a/orebfuscator-plugin/src/main/java/net/imprex/orebfuscator/config/OrebfuscatorConfig.java +++ b/orebfuscator-plugin/src/main/java/net/imprex/orebfuscator/config/OrebfuscatorConfig.java @@ -230,13 +230,13 @@ public boolean usesFrustumCulling() { return false; } - public boolean usesRayCastCheck() { + public String usesRayCastCheck() { for (ProximityConfig config : this.proximityConfigs) { if (config.rayCastCheckEnabled()) { - return true; + return config.rayCastCheckOnlyCheckCenter() ? "center" : "true"; } } - return false; + return "false"; } private OrebfuscatorWorldConfigBundle getWorldConfigBundle(World world) { diff --git a/orebfuscator-plugin/src/main/java/net/imprex/orebfuscator/config/OrebfuscatorProximityConfig.java b/orebfuscator-plugin/src/main/java/net/imprex/orebfuscator/config/OrebfuscatorProximityConfig.java index 2326078e..d849e72a 100644 --- a/orebfuscator-plugin/src/main/java/net/imprex/orebfuscator/config/OrebfuscatorProximityConfig.java +++ b/orebfuscator-plugin/src/main/java/net/imprex/orebfuscator/config/OrebfuscatorProximityConfig.java @@ -18,7 +18,7 @@ public class OrebfuscatorProximityConfig extends AbstractWorldConfig implements private int distance = 24; - private boolean frustumCullingEnabled = false; + private boolean frustumCullingEnabled = true; private float frustumCullingMinDistance = 3; private float frustumCullingFov = 80f; diff --git a/orebfuscator-plugin/src/main/java/net/imprex/orebfuscator/obfuscation/ObfuscationListener.java b/orebfuscator-plugin/src/main/java/net/imprex/orebfuscator/obfuscation/ObfuscationListener.java index e0108328..10e4df55 100644 --- a/orebfuscator-plugin/src/main/java/net/imprex/orebfuscator/obfuscation/ObfuscationListener.java +++ b/orebfuscator-plugin/src/main/java/net/imprex/orebfuscator/obfuscation/ObfuscationListener.java @@ -11,12 +11,16 @@ import org.bukkit.entity.Player; +import com.comphenix.protocol.AsynchronousManager; import com.comphenix.protocol.PacketType; import com.comphenix.protocol.PacketTypeEnum; +import com.comphenix.protocol.ProtocolLibrary; +import com.comphenix.protocol.async.AsyncListenerHandler; import com.comphenix.protocol.events.PacketAdapter; import com.comphenix.protocol.events.PacketEvent; import net.imprex.orebfuscator.Orebfuscator; +import net.imprex.orebfuscator.OrebfuscatorCompatibility; import net.imprex.orebfuscator.chunk.ChunkStruct; import net.imprex.orebfuscator.config.AdvancedConfig; import net.imprex.orebfuscator.config.OrebfuscatorConfig; @@ -25,8 +29,9 @@ import net.imprex.orebfuscator.util.BlockPos; import net.imprex.orebfuscator.util.OFCLogger; import net.imprex.orebfuscator.util.PermissionUtil; +import net.imprex.orebfuscator.util.ServerVersion; -public abstract class ObfuscationListener extends PacketAdapter { +public class ObfuscationListener extends PacketAdapter { private static final List PACKET_TYPES = Arrays.asList( PacketType.Play.Server.MAP_CHUNK, @@ -47,6 +52,9 @@ private static PacketType tryGetPacketType(PacketTypeEnum packetTypeEnum, String private final OrebfuscatorPlayerMap playerMap; private final ObfuscationSystem obfuscationSystem; + private final AsynchronousManager asynchronousManager; + private final AsyncListenerHandler asyncListenerHandler; + public ObfuscationListener(Orebfuscator orebfuscator) { super(orebfuscator, PACKET_TYPES.stream() .filter(Objects::nonNull) @@ -56,13 +64,20 @@ public ObfuscationListener(Orebfuscator orebfuscator) { this.config = orebfuscator.getOrebfuscatorConfig(); this.playerMap = orebfuscator.getPlayerMap(); this.obfuscationSystem = orebfuscator.getObfuscationSystem(); - } - protected abstract void preChunkProcessing(PacketEvent event); + this.asynchronousManager = ProtocolLibrary.getProtocolManager().getAsynchronousManager(); + this.asyncListenerHandler = this.asynchronousManager.registerAsyncHandler(this); - protected abstract void postChunkProcessing(PacketEvent event); + if (ServerVersion.isFolia()) { + OrebfuscatorCompatibility.runAsyncNow(this.asyncListenerHandler.getListenerLoop()); + } else { + this.asyncListenerHandler.start(); + } + } - public abstract void unregister(); + public void unregister() { + this.asynchronousManager.unregisterAsyncHandler(this.asyncListenerHandler); + } @Override public void onPacketReceiving(PacketEvent event) { @@ -85,7 +100,8 @@ public void onPacketSending(PacketEvent event) { return; } - this.preChunkProcessing(event); + // delay packet + event.getAsyncMarker().incrementProcessingDelay(); CompletableFuture future = this.obfuscationSystem.obfuscate(struct); @@ -102,7 +118,7 @@ public void onPacketSending(PacketEvent event) { } else { OFCLogger.warn(String.format("skipping chunk[world=%s, x=%d, z=%d] because obfuscation result is missing", struct.world.getName(), struct.chunkX, struct.chunkZ)); - this.postChunkProcessing(event); + this.asynchronousManager.signalPacketTransmission(event); } }); } @@ -120,7 +136,7 @@ private void completeExceptionally(PacketEvent event, ChunkStruct struct, Throwa struct.world.getName(), struct.chunkX, struct.chunkZ), throwable); } - this.postChunkProcessing(event); + this.asynchronousManager.signalPacketTransmission(event); } private void complete(PacketEvent event, ChunkStruct struct, ObfuscationResult chunk) { @@ -136,6 +152,6 @@ private void complete(PacketEvent event, ChunkStruct struct, ObfuscationResult c player.addChunk(struct.chunkX, struct.chunkZ, chunk.getProximityBlocks()); } - this.postChunkProcessing(event); + this.asynchronousManager.signalPacketTransmission(event); } } diff --git a/orebfuscator-plugin/src/main/java/net/imprex/orebfuscator/obfuscation/ObfuscationListenerAsync.java b/orebfuscator-plugin/src/main/java/net/imprex/orebfuscator/obfuscation/ObfuscationListenerAsync.java deleted file mode 100644 index f8f74b9f..00000000 --- a/orebfuscator-plugin/src/main/java/net/imprex/orebfuscator/obfuscation/ObfuscationListenerAsync.java +++ /dev/null @@ -1,44 +0,0 @@ -package net.imprex.orebfuscator.obfuscation; - -import com.comphenix.protocol.AsynchronousManager; -import com.comphenix.protocol.ProtocolLibrary; -import com.comphenix.protocol.async.AsyncListenerHandler; -import com.comphenix.protocol.events.PacketEvent; - -import net.imprex.orebfuscator.Orebfuscator; -import net.imprex.orebfuscator.OrebfuscatorCompatibility; -import net.imprex.orebfuscator.util.ServerVersion; - -public class ObfuscationListenerAsync extends ObfuscationListener { - - private final AsynchronousManager asynchronousManager; - private final AsyncListenerHandler asyncListenerHandler; - - public ObfuscationListenerAsync(Orebfuscator orebfuscator) { - super(orebfuscator); - - this.asynchronousManager = ProtocolLibrary.getProtocolManager().getAsynchronousManager(); - this.asyncListenerHandler = this.asynchronousManager.registerAsyncHandler(this); - - if (ServerVersion.isFolia()) { - OrebfuscatorCompatibility.runAsyncNow(this.asyncListenerHandler.getListenerLoop()); - } else { - this.asyncListenerHandler.start(); - } - } - - @Override - protected void preChunkProcessing(PacketEvent event) { - event.getAsyncMarker().incrementProcessingDelay(); - } - - @Override - protected void postChunkProcessing(PacketEvent event) { - this.asynchronousManager.signalPacketTransmission(event); - } - - @Override - public void unregister() { - this.asynchronousManager.unregisterAsyncHandler(this.asyncListenerHandler); - } -} diff --git a/orebfuscator-plugin/src/main/java/net/imprex/orebfuscator/obfuscation/ObfuscationListenerSync.java b/orebfuscator-plugin/src/main/java/net/imprex/orebfuscator/obfuscation/ObfuscationListenerSync.java deleted file mode 100644 index 368fdc1e..00000000 --- a/orebfuscator-plugin/src/main/java/net/imprex/orebfuscator/obfuscation/ObfuscationListenerSync.java +++ /dev/null @@ -1,34 +0,0 @@ -package net.imprex.orebfuscator.obfuscation; - -import com.comphenix.protocol.ProtocolLibrary; -import com.comphenix.protocol.ProtocolManager; -import com.comphenix.protocol.events.PacketEvent; - -import net.imprex.orebfuscator.Orebfuscator; - -public class ObfuscationListenerSync extends ObfuscationListener { - - private final ProtocolManager protocolManager; - - public ObfuscationListenerSync(Orebfuscator orebfuscator) { - super(orebfuscator); - - this.protocolManager = ProtocolLibrary.getProtocolManager(); - this.protocolManager.addPacketListener(this); - } - - @Override - protected void preChunkProcessing(PacketEvent event) { - event.setCancelled(true); - } - - @Override - protected void postChunkProcessing(PacketEvent event) { - this.protocolManager.sendServerPacket(event.getPlayer(), event.getPacket(), false); - } - - @Override - public void unregister() { - this.protocolManager.removePacketListener(this); - } -} diff --git a/orebfuscator-plugin/src/main/java/net/imprex/orebfuscator/obfuscation/ObfuscationSystem.java b/orebfuscator-plugin/src/main/java/net/imprex/orebfuscator/obfuscation/ObfuscationSystem.java index 7270a096..7238a468 100644 --- a/orebfuscator-plugin/src/main/java/net/imprex/orebfuscator/obfuscation/ObfuscationSystem.java +++ b/orebfuscator-plugin/src/main/java/net/imprex/orebfuscator/obfuscation/ObfuscationSystem.java @@ -35,11 +35,7 @@ public ObfuscationSystem(Orebfuscator orebfuscator) { } public void registerChunkListener() { - if (this.config.advanced().useAsyncPacketListener()) { - this.listener = new ObfuscationListenerAsync(orebfuscator); - } else { - this.listener = new ObfuscationListenerSync(orebfuscator); - } + this.listener = new ObfuscationListener(orebfuscator); } public CompletableFuture obfuscate(ChunkStruct chunkStruct) { diff --git a/orebfuscator-plugin/src/main/resources/config/config-1.10.yml b/orebfuscator-plugin/src/main/resources/config/config-1.10.yml deleted file mode 100644 index d70c8519..00000000 --- a/orebfuscator-plugin/src/main/resources/config/config-1.10.yml +++ /dev/null @@ -1,226 +0,0 @@ -version: 3 -general: - checkForUpdates: true - updateOnBlockDamage: true - bypassNotification: true - ignoreSpectator: false - updateRadius: 2 -advanced: - verbose: false - useAsyncPacketListener: true - maxMillisecondsPerTick: 10 - protocolLibThreads: -1 - obfuscationWorkerThreads: -1 - obfuscationTimeout: 10000 - proximityHiderThreads: -1 - proximityDefaultBucketSize: 50 - proximityThreadCheckInterval: 50 - proximityPlayerCheckInterval: 5000 -cache: - enabled: true - baseDirectory: orebfuscator_cache - maximumOpenRegionFiles: 256 - deleteRegionFilesAfterAccess: 172800000 - enableDiskCache: true - maximumSize: 16384 - expireAfterAccess: 60000 - maximumTaskQueueSize: 32768 -obfuscation: - obfuscation-overworld: - enabled: true - minY: -2032 - maxY: 2031 - worlds: - - world - layerObfuscation: false - hiddenBlocks: - - minecraft:chest - - minecraft:ender_chest - - minecraft:trapped_chest - - minecraft:mob_spawner - - minecraft:emerald_ore - - minecraft:diamond_ore - - minecraft:gold_ore - - minecraft:iron_ore - - minecraft:coal_ore - - minecraft:lapis_ore - - minecraft:redstone_ore - - minecraft:stone - - minecraft:clay - - minecraft:bedrock - randomBlocks: - section-global: - minY: -2032 - maxY: 2032 - blocks: - minecraft:air: 5 - minecraft:cobblestone: 1 - minecraft:mossy_cobblestone: 1 - minecraft:obsidian: 1 - minecraft:stone: 15 - minecraft:diamond_ore: 10 - minecraft:emerald_ore: 5 - minecraft:gold_ore: 5 - minecraft:iron_ore: 5 - minecraft:coal_ore: 5 - minecraft:lapis_ore: 5 - minecraft:redstone_ore: 5 - section-bedrock: - minY: 0 - maxY: 5 - blocks: - minecraft:bedrock: 20 - obfuscation-nether: - enabled: true - minY: -2032 - maxY: 2031 - worlds: - - world_nether - layerObfuscation: false - hiddenBlocks: - - minecraft:chest - - minecraft:ender_chest - - minecraft:trapped_chest - - minecraft:mob_spawner - - minecraft:netherrack - - minecraft:quartz_ore - - minecraft:bedrock - randomBlocks: - section-global: - minY: -2032 - maxY: 2032 - blocks: - minecraft:netherrack: 1 - minecraft:quartz_ore: 1 - section-bedrock-top: - minY: 123 - maxY: 127 - blocks: - minecraft:bedrock: 20 - section-bedrock-bottom: - minY: 0 - maxY: 4 - blocks: - minecraft:bedrock: 20 - obfuscation-end: - enabled: true - minY: -2032 - maxY: 2031 - worlds: - - world_the_end - layerObfuscation: false - hiddenBlocks: - - minecraft:chest - - minecraft:ender_chest - - minecraft:trapped_chest - - minecraft:mob_spawner - randomBlocks: - section-global: - minY: -2032 - maxY: 2032 - blocks: - minecraft:end_stone: 1 - minecraft:end_bricks: 1 - minecraft:bedrock: 1 - minecraft:obsidian: 1 - minecraft:purpur_block: 1 -proximity: - proximity-overworld: - enabled: true - minY: 0 - maxY: 2031 - worlds: - - world - distance: 24 - frustumCulling: - enabled: true - minDistance: 3 - fov: 80 - rayCastCheck: - enabled: false - onlyCheckCenter: false - useBlockBelow: true - hiddenBlocks: - minecraft:mossy_cobblestone: {} - minecraft:diamond_ore: {} - minecraft:emerald_ore: {} - minecraft:chest: {} - minecraft:ender_chest: {} - minecraft:trapped_chest: {} - minecraft:anvil: {} - minecraft:crafting_table: {} - minecraft:dispenser: {} - minecraft:enchanting_table: {} - minecraft:furnace: {} - minecraft:hopper: {} - minecraft:mob_spawner: {} - randomBlocks: - section-global: - minY: -2032 - maxY: 2032 - blocks: - minecraft:stone: 1 - proximity-nether: - enabled: true - minY: 0 - maxY: 2031 - worlds: - - world_nether - distance: 24 - frustumCulling: - enabled: true - minDistance: 3 - fov: 80 - rayCastCheck: - enabled: false - onlyCheckCenter: false - useBlockBelow: true - hiddenBlocks: - minecraft:chest: {} - minecraft:ender_chest: {} - minecraft:trapped_chest: {} - minecraft:anvil: {} - minecraft:crafting_table: {} - minecraft:dispenser: {} - minecraft:enchanting_table: {} - minecraft:furnace: {} - minecraft:hopper: {} - minecraft:mob_spawner: {} - randomBlocks: - section-global: - minY: -2032 - maxY: 2032 - blocks: - minecraft:netherrack: 1 - proximity-end: - enabled: true - minY: 0 - maxY: 2031 - worlds: - - world_the_end - distance: 24 - frustumCulling: - enabled: true - minDistance: 3 - fov: 80 - rayCastCheck: - enabled: false - onlyCheckCenter: false - useBlockBelow: true - hiddenBlocks: - minecraft:chest: {} - minecraft:ender_chest: {} - minecraft:trapped_chest: {} - minecraft:anvil: {} - minecraft:crafting_table: {} - minecraft:dispenser: {} - minecraft:enchanting_table: {} - minecraft:furnace: {} - minecraft:hopper: {} - minecraft:mob_spawner: {} - randomBlocks: - section-global: - minY: -2032 - maxY: 2032 - blocks: - minecraft:end_stone: 1 diff --git a/orebfuscator-plugin/src/main/resources/config/config-1.11.yml b/orebfuscator-plugin/src/main/resources/config/config-1.11.yml deleted file mode 100644 index c45808b2..00000000 --- a/orebfuscator-plugin/src/main/resources/config/config-1.11.yml +++ /dev/null @@ -1,322 +0,0 @@ -version: 3 -general: - checkForUpdates: true - updateOnBlockDamage: true - bypassNotification: true - ignoreSpectator: false - updateRadius: 2 -advanced: - verbose: false - useAsyncPacketListener: true - maxMillisecondsPerTick: 10 - protocolLibThreads: -1 - obfuscationWorkerThreads: -1 - obfuscationTimeout: 10000 - proximityHiderThreads: -1 - proximityDefaultBucketSize: 50 - proximityThreadCheckInterval: 50 - proximityPlayerCheckInterval: 5000 -cache: - enabled: true - baseDirectory: orebfuscator_cache - maximumOpenRegionFiles: 256 - deleteRegionFilesAfterAccess: 172800000 - enableDiskCache: true - maximumSize: 16384 - expireAfterAccess: 60000 - maximumTaskQueueSize: 32768 -obfuscation: - obfuscation-overworld: - enabled: true - minY: -2032 - maxY: 2031 - worlds: - - world - layerObfuscation: false - hiddenBlocks: - - minecraft:chest - - minecraft:ender_chest - - minecraft:trapped_chest - - minecraft:mob_spawner - - minecraft:emerald_ore - - minecraft:diamond_ore - - minecraft:gold_ore - - minecraft:iron_ore - - minecraft:coal_ore - - minecraft:lapis_ore - - minecraft:redstone_ore - - minecraft:stone - - minecraft:clay - - minecraft:white_shulker_box - - minecraft:orange_shulker_box - - minecraft:magenta_shulker_box - - minecraft:light_blue_shulker_box - - minecraft:yellow_shulker_box - - minecraft:lime_shulker_box - - minecraft:pink_shulker_box - - minecraft:gray_shulker_box - - minecraft:silver_shulker_box - - minecraft:cyan_shulker_box - - minecraft:purple_shulker_box - - minecraft:blue_shulker_box - - minecraft:brown_shulker_box - - minecraft:green_shulker_box - - minecraft:red_shulker_box - - minecraft:black_shulker_box - - minecraft:bedrock - randomBlocks: - section-global: - minY: -2032 - maxY: 2032 - blocks: - minecraft:air: 5 - minecraft:cobblestone: 1 - minecraft:mossy_cobblestone: 1 - minecraft:obsidian: 1 - minecraft:stone: 15 - minecraft:diamond_ore: 10 - minecraft:emerald_ore: 5 - minecraft:gold_ore: 5 - minecraft:iron_ore: 5 - minecraft:coal_ore: 5 - minecraft:lapis_ore: 5 - minecraft:redstone_ore: 5 - section-bedrock: - minY: 0 - maxY: 5 - blocks: - minecraft:bedrock: 20 - obfuscation-nether: - enabled: true - minY: -2032 - maxY: 2031 - worlds: - - world_nether - layerObfuscation: false - hiddenBlocks: - - minecraft:chest - - minecraft:ender_chest - - minecraft:trapped_chest - - minecraft:mob_spawner - - minecraft:netherrack - - minecraft:quartz_ore - - minecraft:white_shulker_box - - minecraft:orange_shulker_box - - minecraft:magenta_shulker_box - - minecraft:light_blue_shulker_box - - minecraft:yellow_shulker_box - - minecraft:lime_shulker_box - - minecraft:pink_shulker_box - - minecraft:gray_shulker_box - - minecraft:silver_shulker_box - - minecraft:cyan_shulker_box - - minecraft:purple_shulker_box - - minecraft:blue_shulker_box - - minecraft:brown_shulker_box - - minecraft:green_shulker_box - - minecraft:red_shulker_box - - minecraft:black_shulker_box - - minecraft:bedrock - randomBlocks: - section-global: - minY: -2032 - maxY: 2032 - blocks: - minecraft:netherrack: 1 - minecraft:quartz_ore: 1 - section-bedrock-top: - minY: 123 - maxY: 127 - blocks: - minecraft:bedrock: 20 - section-bedrock-bottom: - minY: 0 - maxY: 4 - blocks: - minecraft:bedrock: 20 - obfuscation-end: - enabled: true - minY: -2032 - maxY: 2031 - worlds: - - world_the_end - layerObfuscation: false - hiddenBlocks: - - minecraft:chest - - minecraft:ender_chest - - minecraft:trapped_chest - - minecraft:mob_spawner - - minecraft:white_shulker_box - - minecraft:orange_shulker_box - - minecraft:magenta_shulker_box - - minecraft:light_blue_shulker_box - - minecraft:yellow_shulker_box - - minecraft:lime_shulker_box - - minecraft:pink_shulker_box - - minecraft:gray_shulker_box - - minecraft:silver_shulker_box - - minecraft:cyan_shulker_box - - minecraft:purple_shulker_box - - minecraft:blue_shulker_box - - minecraft:brown_shulker_box - - minecraft:green_shulker_box - - minecraft:red_shulker_box - - minecraft:black_shulker_box - randomBlocks: - section-global: - minY: -2032 - maxY: 2032 - blocks: - minecraft:end_stone: 1 - minecraft:end_bricks: 1 - minecraft:bedrock: 1 - minecraft:obsidian: 1 - minecraft:purpur_block: 1 -proximity: - proximity-overworld: - enabled: true - minY: 0 - maxY: 2031 - worlds: - - world - distance: 24 - frustumCulling: - enabled: true - minDistance: 3 - fov: 80 - rayCastCheck: - enabled: false - onlyCheckCenter: false - useBlockBelow: true - hiddenBlocks: - minecraft:mossy_cobblestone: {} - minecraft:diamond_ore: {} - minecraft:emerald_ore: {} - minecraft:chest: {} - minecraft:ender_chest: {} - minecraft:trapped_chest: {} - minecraft:anvil: {} - minecraft:crafting_table: {} - minecraft:dispenser: {} - minecraft:enchanting_table: {} - minecraft:furnace: {} - minecraft:hopper: {} - minecraft:mob_spawner: {} - minecraft:white_shulker_box: {} - minecraft:orange_shulker_box: {} - minecraft:magenta_shulker_box: {} - minecraft:light_blue_shulker_box: {} - minecraft:yellow_shulker_box: {} - minecraft:lime_shulker_box: {} - minecraft:pink_shulker_box: {} - minecraft:gray_shulker_box: {} - minecraft:silver_shulker_box: {} - minecraft:cyan_shulker_box: {} - minecraft:purple_shulker_box: {} - minecraft:blue_shulker_box: {} - minecraft:brown_shulker_box: {} - minecraft:green_shulker_box: {} - minecraft:red_shulker_box: {} - minecraft:black_shulker_box: {} - randomBlocks: - section-global: - minY: -2032 - maxY: 2032 - blocks: - minecraft:stone: 1 - proximity-nether: - enabled: true - minY: 0 - maxY: 2031 - worlds: - - world_nether - distance: 24 - frustumCulling: - enabled: true - minDistance: 3 - fov: 80 - rayCastCheck: - enabled: false - onlyCheckCenter: false - useBlockBelow: true - hiddenBlocks: - minecraft:chest: {} - minecraft:ender_chest: {} - minecraft:trapped_chest: {} - minecraft:anvil: {} - minecraft:crafting_table: {} - minecraft:dispenser: {} - minecraft:enchanting_table: {} - minecraft:furnace: {} - minecraft:hopper: {} - minecraft:mob_spawner: {} - minecraft:white_shulker_box: {} - minecraft:orange_shulker_box: {} - minecraft:magenta_shulker_box: {} - minecraft:light_blue_shulker_box: {} - minecraft:yellow_shulker_box: {} - minecraft:lime_shulker_box: {} - minecraft:pink_shulker_box: {} - minecraft:gray_shulker_box: {} - minecraft:silver_shulker_box: {} - minecraft:cyan_shulker_box: {} - minecraft:purple_shulker_box: {} - minecraft:blue_shulker_box: {} - minecraft:brown_shulker_box: {} - minecraft:green_shulker_box: {} - minecraft:red_shulker_box: {} - minecraft:black_shulker_box: {} - randomBlocks: - section-global: - minY: -2032 - maxY: 2032 - blocks: - minecraft:netherrack: 1 - proximity-end: - enabled: true - minY: 0 - maxY: 2031 - worlds: - - world_the_end - distance: 24 - frustumCulling: - enabled: true - minDistance: 3 - fov: 80 - rayCastCheck: - enabled: false - onlyCheckCenter: false - useBlockBelow: true - hiddenBlocks: - minecraft:chest: {} - minecraft:ender_chest: {} - minecraft:trapped_chest: {} - minecraft:anvil: {} - minecraft:crafting_table: {} - minecraft:dispenser: {} - minecraft:enchanting_table: {} - minecraft:furnace: {} - minecraft:hopper: {} - minecraft:mob_spawner: {} - minecraft:white_shulker_box: {} - minecraft:orange_shulker_box: {} - minecraft:magenta_shulker_box: {} - minecraft:light_blue_shulker_box: {} - minecraft:yellow_shulker_box: {} - minecraft:lime_shulker_box: {} - minecraft:pink_shulker_box: {} - minecraft:gray_shulker_box: {} - minecraft:silver_shulker_box: {} - minecraft:cyan_shulker_box: {} - minecraft:purple_shulker_box: {} - minecraft:blue_shulker_box: {} - minecraft:brown_shulker_box: {} - minecraft:green_shulker_box: {} - minecraft:red_shulker_box: {} - minecraft:black_shulker_box: {} - randomBlocks: - section-global: - minY: -2032 - maxY: 2032 - blocks: - minecraft:end_stone: 1 diff --git a/orebfuscator-plugin/src/main/resources/config/config-1.12.yml b/orebfuscator-plugin/src/main/resources/config/config-1.12.yml deleted file mode 100644 index c45808b2..00000000 --- a/orebfuscator-plugin/src/main/resources/config/config-1.12.yml +++ /dev/null @@ -1,322 +0,0 @@ -version: 3 -general: - checkForUpdates: true - updateOnBlockDamage: true - bypassNotification: true - ignoreSpectator: false - updateRadius: 2 -advanced: - verbose: false - useAsyncPacketListener: true - maxMillisecondsPerTick: 10 - protocolLibThreads: -1 - obfuscationWorkerThreads: -1 - obfuscationTimeout: 10000 - proximityHiderThreads: -1 - proximityDefaultBucketSize: 50 - proximityThreadCheckInterval: 50 - proximityPlayerCheckInterval: 5000 -cache: - enabled: true - baseDirectory: orebfuscator_cache - maximumOpenRegionFiles: 256 - deleteRegionFilesAfterAccess: 172800000 - enableDiskCache: true - maximumSize: 16384 - expireAfterAccess: 60000 - maximumTaskQueueSize: 32768 -obfuscation: - obfuscation-overworld: - enabled: true - minY: -2032 - maxY: 2031 - worlds: - - world - layerObfuscation: false - hiddenBlocks: - - minecraft:chest - - minecraft:ender_chest - - minecraft:trapped_chest - - minecraft:mob_spawner - - minecraft:emerald_ore - - minecraft:diamond_ore - - minecraft:gold_ore - - minecraft:iron_ore - - minecraft:coal_ore - - minecraft:lapis_ore - - minecraft:redstone_ore - - minecraft:stone - - minecraft:clay - - minecraft:white_shulker_box - - minecraft:orange_shulker_box - - minecraft:magenta_shulker_box - - minecraft:light_blue_shulker_box - - minecraft:yellow_shulker_box - - minecraft:lime_shulker_box - - minecraft:pink_shulker_box - - minecraft:gray_shulker_box - - minecraft:silver_shulker_box - - minecraft:cyan_shulker_box - - minecraft:purple_shulker_box - - minecraft:blue_shulker_box - - minecraft:brown_shulker_box - - minecraft:green_shulker_box - - minecraft:red_shulker_box - - minecraft:black_shulker_box - - minecraft:bedrock - randomBlocks: - section-global: - minY: -2032 - maxY: 2032 - blocks: - minecraft:air: 5 - minecraft:cobblestone: 1 - minecraft:mossy_cobblestone: 1 - minecraft:obsidian: 1 - minecraft:stone: 15 - minecraft:diamond_ore: 10 - minecraft:emerald_ore: 5 - minecraft:gold_ore: 5 - minecraft:iron_ore: 5 - minecraft:coal_ore: 5 - minecraft:lapis_ore: 5 - minecraft:redstone_ore: 5 - section-bedrock: - minY: 0 - maxY: 5 - blocks: - minecraft:bedrock: 20 - obfuscation-nether: - enabled: true - minY: -2032 - maxY: 2031 - worlds: - - world_nether - layerObfuscation: false - hiddenBlocks: - - minecraft:chest - - minecraft:ender_chest - - minecraft:trapped_chest - - minecraft:mob_spawner - - minecraft:netherrack - - minecraft:quartz_ore - - minecraft:white_shulker_box - - minecraft:orange_shulker_box - - minecraft:magenta_shulker_box - - minecraft:light_blue_shulker_box - - minecraft:yellow_shulker_box - - minecraft:lime_shulker_box - - minecraft:pink_shulker_box - - minecraft:gray_shulker_box - - minecraft:silver_shulker_box - - minecraft:cyan_shulker_box - - minecraft:purple_shulker_box - - minecraft:blue_shulker_box - - minecraft:brown_shulker_box - - minecraft:green_shulker_box - - minecraft:red_shulker_box - - minecraft:black_shulker_box - - minecraft:bedrock - randomBlocks: - section-global: - minY: -2032 - maxY: 2032 - blocks: - minecraft:netherrack: 1 - minecraft:quartz_ore: 1 - section-bedrock-top: - minY: 123 - maxY: 127 - blocks: - minecraft:bedrock: 20 - section-bedrock-bottom: - minY: 0 - maxY: 4 - blocks: - minecraft:bedrock: 20 - obfuscation-end: - enabled: true - minY: -2032 - maxY: 2031 - worlds: - - world_the_end - layerObfuscation: false - hiddenBlocks: - - minecraft:chest - - minecraft:ender_chest - - minecraft:trapped_chest - - minecraft:mob_spawner - - minecraft:white_shulker_box - - minecraft:orange_shulker_box - - minecraft:magenta_shulker_box - - minecraft:light_blue_shulker_box - - minecraft:yellow_shulker_box - - minecraft:lime_shulker_box - - minecraft:pink_shulker_box - - minecraft:gray_shulker_box - - minecraft:silver_shulker_box - - minecraft:cyan_shulker_box - - minecraft:purple_shulker_box - - minecraft:blue_shulker_box - - minecraft:brown_shulker_box - - minecraft:green_shulker_box - - minecraft:red_shulker_box - - minecraft:black_shulker_box - randomBlocks: - section-global: - minY: -2032 - maxY: 2032 - blocks: - minecraft:end_stone: 1 - minecraft:end_bricks: 1 - minecraft:bedrock: 1 - minecraft:obsidian: 1 - minecraft:purpur_block: 1 -proximity: - proximity-overworld: - enabled: true - minY: 0 - maxY: 2031 - worlds: - - world - distance: 24 - frustumCulling: - enabled: true - minDistance: 3 - fov: 80 - rayCastCheck: - enabled: false - onlyCheckCenter: false - useBlockBelow: true - hiddenBlocks: - minecraft:mossy_cobblestone: {} - minecraft:diamond_ore: {} - minecraft:emerald_ore: {} - minecraft:chest: {} - minecraft:ender_chest: {} - minecraft:trapped_chest: {} - minecraft:anvil: {} - minecraft:crafting_table: {} - minecraft:dispenser: {} - minecraft:enchanting_table: {} - minecraft:furnace: {} - minecraft:hopper: {} - minecraft:mob_spawner: {} - minecraft:white_shulker_box: {} - minecraft:orange_shulker_box: {} - minecraft:magenta_shulker_box: {} - minecraft:light_blue_shulker_box: {} - minecraft:yellow_shulker_box: {} - minecraft:lime_shulker_box: {} - minecraft:pink_shulker_box: {} - minecraft:gray_shulker_box: {} - minecraft:silver_shulker_box: {} - minecraft:cyan_shulker_box: {} - minecraft:purple_shulker_box: {} - minecraft:blue_shulker_box: {} - minecraft:brown_shulker_box: {} - minecraft:green_shulker_box: {} - minecraft:red_shulker_box: {} - minecraft:black_shulker_box: {} - randomBlocks: - section-global: - minY: -2032 - maxY: 2032 - blocks: - minecraft:stone: 1 - proximity-nether: - enabled: true - minY: 0 - maxY: 2031 - worlds: - - world_nether - distance: 24 - frustumCulling: - enabled: true - minDistance: 3 - fov: 80 - rayCastCheck: - enabled: false - onlyCheckCenter: false - useBlockBelow: true - hiddenBlocks: - minecraft:chest: {} - minecraft:ender_chest: {} - minecraft:trapped_chest: {} - minecraft:anvil: {} - minecraft:crafting_table: {} - minecraft:dispenser: {} - minecraft:enchanting_table: {} - minecraft:furnace: {} - minecraft:hopper: {} - minecraft:mob_spawner: {} - minecraft:white_shulker_box: {} - minecraft:orange_shulker_box: {} - minecraft:magenta_shulker_box: {} - minecraft:light_blue_shulker_box: {} - minecraft:yellow_shulker_box: {} - minecraft:lime_shulker_box: {} - minecraft:pink_shulker_box: {} - minecraft:gray_shulker_box: {} - minecraft:silver_shulker_box: {} - minecraft:cyan_shulker_box: {} - minecraft:purple_shulker_box: {} - minecraft:blue_shulker_box: {} - minecraft:brown_shulker_box: {} - minecraft:green_shulker_box: {} - minecraft:red_shulker_box: {} - minecraft:black_shulker_box: {} - randomBlocks: - section-global: - minY: -2032 - maxY: 2032 - blocks: - minecraft:netherrack: 1 - proximity-end: - enabled: true - minY: 0 - maxY: 2031 - worlds: - - world_the_end - distance: 24 - frustumCulling: - enabled: true - minDistance: 3 - fov: 80 - rayCastCheck: - enabled: false - onlyCheckCenter: false - useBlockBelow: true - hiddenBlocks: - minecraft:chest: {} - minecraft:ender_chest: {} - minecraft:trapped_chest: {} - minecraft:anvil: {} - minecraft:crafting_table: {} - minecraft:dispenser: {} - minecraft:enchanting_table: {} - minecraft:furnace: {} - minecraft:hopper: {} - minecraft:mob_spawner: {} - minecraft:white_shulker_box: {} - minecraft:orange_shulker_box: {} - minecraft:magenta_shulker_box: {} - minecraft:light_blue_shulker_box: {} - minecraft:yellow_shulker_box: {} - minecraft:lime_shulker_box: {} - minecraft:pink_shulker_box: {} - minecraft:gray_shulker_box: {} - minecraft:silver_shulker_box: {} - minecraft:cyan_shulker_box: {} - minecraft:purple_shulker_box: {} - minecraft:blue_shulker_box: {} - minecraft:brown_shulker_box: {} - minecraft:green_shulker_box: {} - minecraft:red_shulker_box: {} - minecraft:black_shulker_box: {} - randomBlocks: - section-global: - minY: -2032 - maxY: 2032 - blocks: - minecraft:end_stone: 1 diff --git a/orebfuscator-plugin/src/main/resources/config/config-1.13.yml b/orebfuscator-plugin/src/main/resources/config/config-1.13.yml deleted file mode 100644 index faba48db..00000000 --- a/orebfuscator-plugin/src/main/resources/config/config-1.13.yml +++ /dev/null @@ -1,326 +0,0 @@ -version: 3 -general: - checkForUpdates: true - updateOnBlockDamage: true - bypassNotification: true - ignoreSpectator: false - updateRadius: 2 -advanced: - verbose: false - useAsyncPacketListener: true - maxMillisecondsPerTick: 10 - protocolLibThreads: -1 - obfuscationWorkerThreads: -1 - obfuscationTimeout: 10000 - proximityHiderThreads: -1 - proximityDefaultBucketSize: 50 - proximityThreadCheckInterval: 50 - proximityPlayerCheckInterval: 5000 -cache: - enabled: true - baseDirectory: orebfuscator_cache - maximumOpenRegionFiles: 256 - deleteRegionFilesAfterAccess: 172800000 - enableDiskCache: true - maximumSize: 16384 - expireAfterAccess: 60000 - maximumTaskQueueSize: 32768 -obfuscation: - obfuscation-overworld: - enabled: true - minY: -2032 - maxY: 2031 - worlds: - - world - layerObfuscation: false - hiddenBlocks: - - minecraft:chest - - minecraft:ender_chest - - minecraft:trapped_chest - - minecraft:spawner - - minecraft:emerald_ore - - minecraft:diamond_ore - - minecraft:gold_ore - - minecraft:iron_ore - - minecraft:coal_ore - - minecraft:lapis_ore - - minecraft:redstone_ore - - minecraft:stone - - minecraft:clay - - minecraft:shulker_box - - minecraft:white_shulker_box - - minecraft:orange_shulker_box - - minecraft:magenta_shulker_box - - minecraft:light_blue_shulker_box - - minecraft:yellow_shulker_box - - minecraft:lime_shulker_box - - minecraft:pink_shulker_box - - minecraft:gray_shulker_box - - minecraft:light_gray_shulker_box - - minecraft:cyan_shulker_box - - minecraft:purple_shulker_box - - minecraft:blue_shulker_box - - minecraft:brown_shulker_box - - minecraft:green_shulker_box - - minecraft:red_shulker_box - - minecraft:black_shulker_box - - minecraft:bedrock - randomBlocks: - section-global: - minY: -2032 - maxY: 2032 - blocks: - minecraft:cave_air: 5 - minecraft:cobblestone: 1 - minecraft:mossy_cobblestone: 1 - minecraft:obsidian: 1 - minecraft:stone: 15 - minecraft:diamond_ore: 10 - minecraft:emerald_ore: 5 - minecraft:gold_ore: 5 - minecraft:iron_ore: 5 - minecraft:coal_ore: 5 - minecraft:lapis_ore: 5 - minecraft:redstone_ore: 5 - section-bedrock: - minY: 0 - maxY: 5 - blocks: - minecraft:bedrock: 20 - obfuscation-nether: - enabled: true - minY: -2032 - maxY: 2031 - worlds: - - world_nether - layerObfuscation: false - hiddenBlocks: - - minecraft:chest - - minecraft:ender_chest - - minecraft:trapped_chest - - minecraft:spawner - - minecraft:netherrack - - minecraft:nether_quartz_ore - - minecraft:shulker_box - - minecraft:white_shulker_box - - minecraft:orange_shulker_box - - minecraft:magenta_shulker_box - - minecraft:light_blue_shulker_box - - minecraft:yellow_shulker_box - - minecraft:lime_shulker_box - - minecraft:pink_shulker_box - - minecraft:gray_shulker_box - - minecraft:light_gray_shulker_box - - minecraft:cyan_shulker_box - - minecraft:purple_shulker_box - - minecraft:blue_shulker_box - - minecraft:brown_shulker_box - - minecraft:green_shulker_box - - minecraft:red_shulker_box - - minecraft:black_shulker_box - - minecraft:bedrock - randomBlocks: - section-global: - minY: -2032 - maxY: 2032 - blocks: - minecraft:netherrack: 1 - minecraft:nether_quartz_ore: 1 - section-bedrock-top: - minY: 123 - maxY: 127 - blocks: - minecraft:bedrock: 20 - section-bedrock-bottom: - minY: 0 - maxY: 4 - blocks: - minecraft:bedrock: 20 - obfuscation-end: - enabled: true - minY: -2032 - maxY: 2031 - worlds: - - world_the_end - layerObfuscation: false - hiddenBlocks: - - minecraft:chest - - minecraft:ender_chest - - minecraft:trapped_chest - - minecraft:spawner - - minecraft:shulker_box - - minecraft:white_shulker_box - - minecraft:orange_shulker_box - - minecraft:magenta_shulker_box - - minecraft:light_blue_shulker_box - - minecraft:yellow_shulker_box - - minecraft:lime_shulker_box - - minecraft:pink_shulker_box - - minecraft:gray_shulker_box - - minecraft:light_gray_shulker_box - - minecraft:cyan_shulker_box - - minecraft:purple_shulker_box - - minecraft:blue_shulker_box - - minecraft:brown_shulker_box - - minecraft:green_shulker_box - - minecraft:red_shulker_box - - minecraft:black_shulker_box - randomBlocks: - section-global: - minY: -2032 - maxY: 2032 - blocks: - minecraft:end_stone: 1 - minecraft:end_stone_bricks: 1 - minecraft:bedrock: 1 - minecraft:obsidian: 1 - minecraft:purpur_block: 1 -proximity: - proximity-overworld: - enabled: true - minY: 0 - maxY: 2031 - worlds: - - world - distance: 24 - frustumCulling: - enabled: true - minDistance: 3 - fov: 80 - rayCastCheck: - enabled: false - useBlockBelow: true - hiddenBlocks: - minecraft:mossy_cobblestone: {} - minecraft:diamond_ore: {} - minecraft:emerald_ore: {} - minecraft:chest: {} - minecraft:ender_chest: {} - minecraft:trapped_chest: {} - minecraft:anvil: {} - minecraft:crafting_table: {} - minecraft:dispenser: {} - minecraft:enchanting_table: {} - minecraft:furnace: {} - minecraft:hopper: {} - minecraft:spawner: {} - minecraft:shulker_box: {} - minecraft:white_shulker_box: {} - minecraft:orange_shulker_box: {} - minecraft:magenta_shulker_box: {} - minecraft:light_blue_shulker_box: {} - minecraft:yellow_shulker_box: {} - minecraft:lime_shulker_box: {} - minecraft:pink_shulker_box: {} - minecraft:gray_shulker_box: {} - minecraft:light_gray_shulker_box: {} - minecraft:cyan_shulker_box: {} - minecraft:purple_shulker_box: {} - minecraft:blue_shulker_box: {} - minecraft:brown_shulker_box: {} - minecraft:green_shulker_box: {} - minecraft:red_shulker_box: {} - minecraft:black_shulker_box: {} - randomBlocks: - section-global: - minY: -2032 - maxY: 2032 - blocks: - minecraft:stone: 1 - proximity-nether: - enabled: true - minY: 0 - maxY: 2031 - worlds: - - world_nether - distance: 24 - frustumCulling: - enabled: true - minDistance: 3 - fov: 80 - rayCastCheck: - enabled: false - useBlockBelow: true - hiddenBlocks: - minecraft:chest: {} - minecraft:ender_chest: {} - minecraft:trapped_chest: {} - minecraft:anvil: {} - minecraft:crafting_table: {} - minecraft:dispenser: {} - minecraft:enchanting_table: {} - minecraft:furnace: {} - minecraft:hopper: {} - minecraft:spawner: {} - minecraft:shulker_box: {} - minecraft:white_shulker_box: {} - minecraft:orange_shulker_box: {} - minecraft:magenta_shulker_box: {} - minecraft:light_blue_shulker_box: {} - minecraft:yellow_shulker_box: {} - minecraft:lime_shulker_box: {} - minecraft:pink_shulker_box: {} - minecraft:gray_shulker_box: {} - minecraft:light_gray_shulker_box: {} - minecraft:cyan_shulker_box: {} - minecraft:purple_shulker_box: {} - minecraft:blue_shulker_box: {} - minecraft:brown_shulker_box: {} - minecraft:green_shulker_box: {} - minecraft:red_shulker_box: {} - minecraft:black_shulker_box: {} - randomBlocks: - section-global: - minY: -2032 - maxY: 2032 - blocks: - minecraft:netherrack: 1 - proximity-end: - enabled: true - minY: 0 - maxY: 2031 - worlds: - - world_the_end - distance: 24 - frustumCulling: - enabled: true - minDistance: 3 - fov: 80 - rayCastCheck: - enabled: false - onlyCheckCenter: false - useBlockBelow: true - hiddenBlocks: - minecraft:chest: {} - minecraft:ender_chest: {} - minecraft:trapped_chest: {} - minecraft:anvil: {} - minecraft:crafting_table: {} - minecraft:dispenser: {} - minecraft:enchanting_table: {} - minecraft:furnace: {} - minecraft:hopper: {} - minecraft:spawner: {} - minecraft:shulker_box: {} - minecraft:white_shulker_box: {} - minecraft:orange_shulker_box: {} - minecraft:magenta_shulker_box: {} - minecraft:light_blue_shulker_box: {} - minecraft:yellow_shulker_box: {} - minecraft:lime_shulker_box: {} - minecraft:pink_shulker_box: {} - minecraft:gray_shulker_box: {} - minecraft:light_gray_shulker_box: {} - minecraft:cyan_shulker_box: {} - minecraft:purple_shulker_box: {} - minecraft:blue_shulker_box: {} - minecraft:brown_shulker_box: {} - minecraft:green_shulker_box: {} - minecraft:red_shulker_box: {} - minecraft:black_shulker_box: {} - randomBlocks: - section-global: - minY: -2032 - maxY: 2032 - blocks: - minecraft:end_stone: 1 diff --git a/orebfuscator-plugin/src/main/resources/config/config-1.14.yml b/orebfuscator-plugin/src/main/resources/config/config-1.14.yml deleted file mode 100644 index 681c17cc..00000000 --- a/orebfuscator-plugin/src/main/resources/config/config-1.14.yml +++ /dev/null @@ -1,358 +0,0 @@ -version: 3 -general: - checkForUpdates: true - updateOnBlockDamage: true - bypassNotification: true - ignoreSpectator: false - updateRadius: 2 -advanced: - verbose: false - useAsyncPacketListener: true - maxMillisecondsPerTick: 10 - protocolLibThreads: -1 - obfuscationWorkerThreads: -1 - obfuscationTimeout: 10000 - proximityHiderThreads: -1 - proximityDefaultBucketSize: 50 - proximityThreadCheckInterval: 50 - proximityPlayerCheckInterval: 5000 -cache: - enabled: true - baseDirectory: orebfuscator_cache - maximumOpenRegionFiles: 256 - deleteRegionFilesAfterAccess: 172800000 - enableDiskCache: true - maximumSize: 16384 - expireAfterAccess: 60000 - maximumTaskQueueSize: 32768 -obfuscation: - obfuscation-overworld: - enabled: true - minY: -2032 - maxY: 2031 - worlds: - - world - layerObfuscation: false - hiddenBlocks: - - minecraft:chest - - minecraft:ender_chest - - minecraft:trapped_chest - - minecraft:spawner - - minecraft:emerald_ore - - minecraft:diamond_ore - - minecraft:gold_ore - - minecraft:iron_ore - - minecraft:coal_ore - - minecraft:lapis_ore - - minecraft:redstone_ore - - minecraft:stone - - minecraft:clay - - minecraft:shulker_box - - minecraft:white_shulker_box - - minecraft:orange_shulker_box - - minecraft:magenta_shulker_box - - minecraft:light_blue_shulker_box - - minecraft:yellow_shulker_box - - minecraft:lime_shulker_box - - minecraft:pink_shulker_box - - minecraft:gray_shulker_box - - minecraft:light_gray_shulker_box - - minecraft:cyan_shulker_box - - minecraft:purple_shulker_box - - minecraft:blue_shulker_box - - minecraft:brown_shulker_box - - minecraft:green_shulker_box - - minecraft:red_shulker_box - - minecraft:black_shulker_box - - minecraft:bedrock - randomBlocks: - section-global: - minY: -2032 - maxY: 2032 - blocks: - minecraft:cave_air: 5 - minecraft:cobblestone: 1 - minecraft:mossy_cobblestone: 1 - minecraft:obsidian: 1 - minecraft:stone: 15 - minecraft:diamond_ore: 10 - minecraft:emerald_ore: 5 - minecraft:gold_ore: 5 - minecraft:iron_ore: 5 - minecraft:coal_ore: 5 - minecraft:lapis_ore: 5 - minecraft:redstone_ore: 5 - section-bedrock: - minY: 0 - maxY: 5 - blocks: - minecraft:bedrock: 20 - obfuscation-nether: - enabled: true - minY: -2032 - maxY: 2031 - worlds: - - world_nether - layerObfuscation: false - hiddenBlocks: - - minecraft:chest - - minecraft:ender_chest - - minecraft:trapped_chest - - minecraft:spawner - - minecraft:netherrack - - minecraft:nether_quartz_ore - - minecraft:shulker_box - - minecraft:white_shulker_box - - minecraft:orange_shulker_box - - minecraft:magenta_shulker_box - - minecraft:light_blue_shulker_box - - minecraft:yellow_shulker_box - - minecraft:lime_shulker_box - - minecraft:pink_shulker_box - - minecraft:gray_shulker_box - - minecraft:light_gray_shulker_box - - minecraft:cyan_shulker_box - - minecraft:purple_shulker_box - - minecraft:blue_shulker_box - - minecraft:brown_shulker_box - - minecraft:green_shulker_box - - minecraft:red_shulker_box - - minecraft:black_shulker_box - - minecraft:bedrock - randomBlocks: - section-global: - minY: -2032 - maxY: 2032 - blocks: - minecraft:netherrack: 1 - minecraft:nether_quartz_ore: 1 - section-bedrock-top: - minY: 123 - maxY: 127 - blocks: - minecraft:bedrock: 20 - section-bedrock-bottom: - minY: 0 - maxY: 4 - blocks: - minecraft:bedrock: 20 - obfuscation-end: - enabled: true - minY: -2032 - maxY: 2031 - worlds: - - world_the_end - layerObfuscation: false - hiddenBlocks: - - minecraft:chest - - minecraft:ender_chest - - minecraft:trapped_chest - - minecraft:spawner - - minecraft:shulker_box - - minecraft:white_shulker_box - - minecraft:orange_shulker_box - - minecraft:magenta_shulker_box - - minecraft:light_blue_shulker_box - - minecraft:yellow_shulker_box - - minecraft:lime_shulker_box - - minecraft:pink_shulker_box - - minecraft:gray_shulker_box - - minecraft:light_gray_shulker_box - - minecraft:cyan_shulker_box - - minecraft:purple_shulker_box - - minecraft:blue_shulker_box - - minecraft:brown_shulker_box - - minecraft:green_shulker_box - - minecraft:red_shulker_box - - minecraft:black_shulker_box - randomBlocks: - section-global: - minY: -2032 - maxY: 2032 - blocks: - minecraft:end_stone: 1 - minecraft:end_stone_bricks: 1 - minecraft:bedrock: 1 - minecraft:obsidian: 1 - minecraft:purpur_block: 1 -proximity: - proximity-overworld: - enabled: true - minY: 0 - maxY: 2031 - worlds: - - world - distance: 24 - frustumCulling: - enabled: true - minDistance: 3 - fov: 80 - rayCastCheck: - enabled: false - onlyCheckCenter: false - useBlockBelow: true - hiddenBlocks: - minecraft:mossy_cobblestone: {} - minecraft:diamond_ore: {} - minecraft:emerald_ore: {} - minecraft:chest: {} - minecraft:ender_chest: {} - minecraft:trapped_chest: {} - minecraft:anvil: {} - minecraft:crafting_table: {} - minecraft:dispenser: {} - minecraft:enchanting_table: {} - minecraft:furnace: {} - minecraft:blast_furnace: {} - minecraft:cartography_table: {} - minecraft:fletching_table: {} - minecraft:grindstone: {} - minecraft:composter: {} - minecraft:lectern: {} - minecraft:loom: {} - minecraft:smithing_table: {} - minecraft:smoker: {} - minecraft:stonecutter: {} - minecraft:hopper: {} - minecraft:spawner: {} - minecraft:shulker_box: {} - minecraft:white_shulker_box: {} - minecraft:orange_shulker_box: {} - minecraft:magenta_shulker_box: {} - minecraft:light_blue_shulker_box: {} - minecraft:yellow_shulker_box: {} - minecraft:lime_shulker_box: {} - minecraft:pink_shulker_box: {} - minecraft:gray_shulker_box: {} - minecraft:light_gray_shulker_box: {} - minecraft:cyan_shulker_box: {} - minecraft:purple_shulker_box: {} - minecraft:blue_shulker_box: {} - minecraft:brown_shulker_box: {} - minecraft:green_shulker_box: {} - minecraft:red_shulker_box: {} - minecraft:black_shulker_box: {} - randomBlocks: - section-global: - minY: -2032 - maxY: 2032 - blocks: - minecraft:stone: 1 - proximity-nether: - enabled: true - minY: 0 - maxY: 2031 - worlds: - - world_nether - distance: 24 - frustumCulling: - enabled: true - minDistance: 3 - fov: 80 - rayCastCheck: - enabled: false - onlyCheckCenter: false - useBlockBelow: true - hiddenBlocks: - minecraft:chest: {} - minecraft:ender_chest: {} - minecraft:trapped_chest: {} - minecraft:anvil: {} - minecraft:crafting_table: {} - minecraft:dispenser: {} - minecraft:enchanting_table: {} - minecraft:furnace: {} - minecraft:blast_furnace: {} - minecraft:cartography_table: {} - minecraft:fletching_table: {} - minecraft:grindstone: {} - minecraft:composter: {} - minecraft:lectern: {} - minecraft:loom: {} - minecraft:smithing_table: {} - minecraft:smoker: {} - minecraft:stonecutter: {} - minecraft:hopper: {} - minecraft:spawner: {} - minecraft:shulker_box: {} - minecraft:white_shulker_box: {} - minecraft:orange_shulker_box: {} - minecraft:magenta_shulker_box: {} - minecraft:light_blue_shulker_box: {} - minecraft:yellow_shulker_box: {} - minecraft:lime_shulker_box: {} - minecraft:pink_shulker_box: {} - minecraft:gray_shulker_box: {} - minecraft:light_gray_shulker_box: {} - minecraft:cyan_shulker_box: {} - minecraft:purple_shulker_box: {} - minecraft:blue_shulker_box: {} - minecraft:brown_shulker_box: {} - minecraft:green_shulker_box: {} - minecraft:red_shulker_box: {} - minecraft:black_shulker_box: {} - randomBlocks: - section-global: - minY: -2032 - maxY: 2032 - blocks: - minecraft:netherrack: 1 - proximity-end: - enabled: true - minY: 0 - maxY: 2031 - worlds: - - world_the_end - distance: 24 - frustumCulling: - enabled: true - minDistance: 3 - fov: 80 - rayCastCheck: - enabled: false - onlyCheckCenter: false - useBlockBelow: true - hiddenBlocks: - minecraft:chest: {} - minecraft:ender_chest: {} - minecraft:trapped_chest: {} - minecraft:anvil: {} - minecraft:crafting_table: {} - minecraft:dispenser: {} - minecraft:enchanting_table: {} - minecraft:furnace: {} - minecraft:blast_furnace: {} - minecraft:cartography_table: {} - minecraft:fletching_table: {} - minecraft:grindstone: {} - minecraft:composter: {} - minecraft:lectern: {} - minecraft:loom: {} - minecraft:smithing_table: {} - minecraft:smoker: {} - minecraft:stonecutter: {} - minecraft:hopper: {} - minecraft:spawner: {} - minecraft:shulker_box: {} - minecraft:white_shulker_box: {} - minecraft:orange_shulker_box: {} - minecraft:magenta_shulker_box: {} - minecraft:light_blue_shulker_box: {} - minecraft:yellow_shulker_box: {} - minecraft:lime_shulker_box: {} - minecraft:pink_shulker_box: {} - minecraft:gray_shulker_box: {} - minecraft:light_gray_shulker_box: {} - minecraft:cyan_shulker_box: {} - minecraft:purple_shulker_box: {} - minecraft:blue_shulker_box: {} - minecraft:brown_shulker_box: {} - minecraft:green_shulker_box: {} - minecraft:red_shulker_box: {} - minecraft:black_shulker_box: {} - randomBlocks: - section-global: - minY: -2032 - maxY: 2032 - blocks: - minecraft:end_stone: 1 diff --git a/orebfuscator-plugin/src/main/resources/config/config-1.16.yml b/orebfuscator-plugin/src/main/resources/config/config-1.16.yml index 3ea7a324..6c66ba69 100644 --- a/orebfuscator-plugin/src/main/resources/config/config-1.16.yml +++ b/orebfuscator-plugin/src/main/resources/config/config-1.16.yml @@ -7,9 +7,7 @@ general: updateRadius: 2 advanced: verbose: false - useAsyncPacketListener: true maxMillisecondsPerTick: 10 - protocolLibThreads: -1 obfuscationWorkerThreads: -1 obfuscationTimeout: 10000 proximityHiderThreads: -1 diff --git a/orebfuscator-plugin/src/main/resources/config/config-1.17.yml b/orebfuscator-plugin/src/main/resources/config/config-1.17.yml index dc1d4e03..9cb377fe 100644 --- a/orebfuscator-plugin/src/main/resources/config/config-1.17.yml +++ b/orebfuscator-plugin/src/main/resources/config/config-1.17.yml @@ -7,9 +7,7 @@ general: updateRadius: 2 advanced: verbose: false - useAsyncPacketListener: true maxMillisecondsPerTick: 10 - protocolLibThreads: -1 obfuscationWorkerThreads: -1 obfuscationTimeout: 10000 proximityHiderThreads: -1 diff --git a/orebfuscator-plugin/src/main/resources/config/config-1.18.yml b/orebfuscator-plugin/src/main/resources/config/config-1.18.yml index c49c6cb0..8087a3e5 100644 --- a/orebfuscator-plugin/src/main/resources/config/config-1.18.yml +++ b/orebfuscator-plugin/src/main/resources/config/config-1.18.yml @@ -7,9 +7,7 @@ general: updateRadius: 2 advanced: verbose: false - useAsyncPacketListener: true maxMillisecondsPerTick: 10 - protocolLibThreads: -1 obfuscationWorkerThreads: -1 obfuscationTimeout: 10000 proximityHiderThreads: -1 diff --git a/orebfuscator-plugin/src/main/resources/config/config-1.19.yml b/orebfuscator-plugin/src/main/resources/config/config-1.19.yml index c49c6cb0..8087a3e5 100644 --- a/orebfuscator-plugin/src/main/resources/config/config-1.19.yml +++ b/orebfuscator-plugin/src/main/resources/config/config-1.19.yml @@ -7,9 +7,7 @@ general: updateRadius: 2 advanced: verbose: false - useAsyncPacketListener: true maxMillisecondsPerTick: 10 - protocolLibThreads: -1 obfuscationWorkerThreads: -1 obfuscationTimeout: 10000 proximityHiderThreads: -1 diff --git a/orebfuscator-plugin/src/main/resources/config/config-1.20.yml b/orebfuscator-plugin/src/main/resources/config/config-1.20.yml index c49c6cb0..8087a3e5 100644 --- a/orebfuscator-plugin/src/main/resources/config/config-1.20.yml +++ b/orebfuscator-plugin/src/main/resources/config/config-1.20.yml @@ -7,9 +7,7 @@ general: updateRadius: 2 advanced: verbose: false - useAsyncPacketListener: true maxMillisecondsPerTick: 10 - protocolLibThreads: -1 obfuscationWorkerThreads: -1 obfuscationTimeout: 10000 proximityHiderThreads: -1 diff --git a/orebfuscator-plugin/src/main/resources/config/config-1.15.yml b/orebfuscator-plugin/src/main/resources/config/config-1.21.yml similarity index 84% rename from orebfuscator-plugin/src/main/resources/config/config-1.15.yml rename to orebfuscator-plugin/src/main/resources/config/config-1.21.yml index c27c2a86..8f7318d6 100644 --- a/orebfuscator-plugin/src/main/resources/config/config-1.15.yml +++ b/orebfuscator-plugin/src/main/resources/config/config-1.21.yml @@ -7,9 +7,7 @@ general: updateRadius: 2 advanced: verbose: false - useAsyncPacketListener: true maxMillisecondsPerTick: 10 - protocolLibThreads: -1 obfuscationWorkerThreads: -1 obfuscationTimeout: 10000 proximityHiderThreads: -1 @@ -34,19 +32,30 @@ obfuscation: - world layerObfuscation: false hiddenBlocks: - - minecraft:chest - - minecraft:ender_chest - - minecraft:trapped_chest - - minecraft:spawner - minecraft:emerald_ore + - minecraft:deepslate_emerald_ore - minecraft:diamond_ore + - minecraft:deepslate_diamond_ore - minecraft:gold_ore + - minecraft:deepslate_gold_ore + - minecraft:raw_gold_block - minecraft:iron_ore + - minecraft:deepslate_iron_ore + - minecraft:raw_iron_block - minecraft:coal_ore + - minecraft:deepslate_coal_ore - minecraft:lapis_ore + - minecraft:deepslate_lapis_ore - minecraft:redstone_ore + - minecraft:deepslate_redstone_ore + - minecraft:copper_ore + - minecraft:raw_copper_block + - minecraft:deepslate_copper_ore - minecraft:stone - - minecraft:clay + - minecraft:deepslate + - minecraft:chest + - minecraft:ender_chest + - minecraft:trapped_chest - minecraft:shulker_box - minecraft:white_shulker_box - minecraft:orange_shulker_box @@ -68,23 +77,41 @@ obfuscation: randomBlocks: section-global: minY: -2032 - maxY: 2032 + maxY: 2031 blocks: minecraft:cave_air: 5 minecraft:cobblestone: 1 minecraft:mossy_cobblestone: 1 minecraft:obsidian: 1 + section-stone: + minY: -5 + maxY: 2031 + blocks: minecraft:stone: 15 minecraft:diamond_ore: 10 minecraft:emerald_ore: 5 minecraft:gold_ore: 5 minecraft:iron_ore: 5 + minecraft:copper_ore: 5 minecraft:coal_ore: 5 minecraft:lapis_ore: 5 minecraft:redstone_ore: 5 - section-bedrock: - minY: 0 + section-deepslate: + minY: -2032 maxY: 5 + blocks: + minecraft:deepslate: 15 + minecraft:deepslate_diamond_ore: 10 + minecraft:deepslate_emerald_ore: 5 + minecraft:deepslate_gold_ore: 5 + minecraft:deepslate_iron_ore: 5 + minecraft:deepslate_copper_ore: 5 + minecraft:deepslate_coal_ore: 5 + minecraft:deepslate_lapis_ore: 5 + minecraft:deepslate_redstone_ore: 5 + section-bedrock: + minY: -64 + maxY: -60 blocks: minecraft:bedrock: 20 obfuscation-nether: @@ -95,12 +122,11 @@ obfuscation: - world_nether layerObfuscation: false hiddenBlocks: + - minecraft:netherrack + - minecraft:nether_quartz_ore - minecraft:chest - minecraft:ender_chest - minecraft:trapped_chest - - minecraft:spawner - - minecraft:netherrack - - minecraft:nether_quartz_ore - minecraft:shulker_box - minecraft:white_shulker_box - minecraft:orange_shulker_box @@ -118,14 +144,21 @@ obfuscation: - minecraft:green_shulker_box - minecraft:red_shulker_box - minecraft:black_shulker_box + - minecraft:ancient_debris + - minecraft:nether_gold_ore + - minecraft:basalt + - minecraft:soul_sand + - minecraft:soul_soil - minecraft:bedrock randomBlocks: section-global: minY: -2032 maxY: 2032 blocks: - minecraft:netherrack: 1 + minecraft:netherrack: 4 minecraft:nether_quartz_ore: 1 + minecraft:nether_gold_ore: 1 + minecraft:ancient_debris: 1 section-bedrock-top: minY: 123 maxY: 127 @@ -147,7 +180,6 @@ obfuscation: - minecraft:chest - minecraft:ender_chest - minecraft:trapped_chest - - minecraft:spawner - minecraft:shulker_box - minecraft:white_shulker_box - minecraft:orange_shulker_box @@ -178,7 +210,7 @@ obfuscation: proximity: proximity-overworld: enabled: true - minY: 0 + minY: -2032 maxY: 2031 worlds: - world @@ -194,11 +226,14 @@ proximity: hiddenBlocks: minecraft:mossy_cobblestone: {} minecraft:diamond_ore: {} + minecraft:deepslate_diamond_ore: {} minecraft:emerald_ore: {} + minecraft:deepslate_emerald_ore: {} minecraft:chest: {} minecraft:ender_chest: {} minecraft:trapped_chest: {} minecraft:anvil: {} + minecraft:crafter: {} minecraft:crafting_table: {} minecraft:dispenser: {} minecraft:enchanting_table: {} @@ -235,14 +270,19 @@ proximity: minecraft:bee_nest: {} minecraft:beehive: {} randomBlocks: - section-global: - minY: -2032 - maxY: 2032 + section-stone: + minY: -5 + maxY: 2031 blocks: minecraft:stone: 1 + section-deepslate: + minY: -2032 + maxY: 5 + blocks: + minecraft:deepslate: 1 proximity-nether: enabled: true - minY: 0 + minY: -2032 maxY: 2031 worlds: - world_nether @@ -260,6 +300,7 @@ proximity: minecraft:ender_chest: {} minecraft:trapped_chest: {} minecraft:anvil: {} + minecraft:crafter: {} minecraft:crafting_table: {} minecraft:dispenser: {} minecraft:enchanting_table: {} @@ -295,6 +336,9 @@ proximity: minecraft:black_shulker_box: {} minecraft:bee_nest: {} minecraft:beehive: {} + minecraft:ancient_debris: {} + minecraft:nether_gold_ore: {} + minecraft:respawn_anchor: {} randomBlocks: section-global: minY: -2032 @@ -303,7 +347,7 @@ proximity: minecraft:netherrack: 1 proximity-end: enabled: true - minY: 0 + minY: -2032 maxY: 2031 worlds: - world_the_end @@ -321,6 +365,7 @@ proximity: minecraft:ender_chest: {} minecraft:trapped_chest: {} minecraft:anvil: {} + minecraft:crafter: {} minecraft:crafting_table: {} minecraft:dispenser: {} minecraft:enchanting_table: {} diff --git a/orebfuscator-plugin/src/main/resources/config/config-1.9.yml b/orebfuscator-plugin/src/main/resources/config/config-1.9.yml deleted file mode 100644 index d70c8519..00000000 --- a/orebfuscator-plugin/src/main/resources/config/config-1.9.yml +++ /dev/null @@ -1,226 +0,0 @@ -version: 3 -general: - checkForUpdates: true - updateOnBlockDamage: true - bypassNotification: true - ignoreSpectator: false - updateRadius: 2 -advanced: - verbose: false - useAsyncPacketListener: true - maxMillisecondsPerTick: 10 - protocolLibThreads: -1 - obfuscationWorkerThreads: -1 - obfuscationTimeout: 10000 - proximityHiderThreads: -1 - proximityDefaultBucketSize: 50 - proximityThreadCheckInterval: 50 - proximityPlayerCheckInterval: 5000 -cache: - enabled: true - baseDirectory: orebfuscator_cache - maximumOpenRegionFiles: 256 - deleteRegionFilesAfterAccess: 172800000 - enableDiskCache: true - maximumSize: 16384 - expireAfterAccess: 60000 - maximumTaskQueueSize: 32768 -obfuscation: - obfuscation-overworld: - enabled: true - minY: -2032 - maxY: 2031 - worlds: - - world - layerObfuscation: false - hiddenBlocks: - - minecraft:chest - - minecraft:ender_chest - - minecraft:trapped_chest - - minecraft:mob_spawner - - minecraft:emerald_ore - - minecraft:diamond_ore - - minecraft:gold_ore - - minecraft:iron_ore - - minecraft:coal_ore - - minecraft:lapis_ore - - minecraft:redstone_ore - - minecraft:stone - - minecraft:clay - - minecraft:bedrock - randomBlocks: - section-global: - minY: -2032 - maxY: 2032 - blocks: - minecraft:air: 5 - minecraft:cobblestone: 1 - minecraft:mossy_cobblestone: 1 - minecraft:obsidian: 1 - minecraft:stone: 15 - minecraft:diamond_ore: 10 - minecraft:emerald_ore: 5 - minecraft:gold_ore: 5 - minecraft:iron_ore: 5 - minecraft:coal_ore: 5 - minecraft:lapis_ore: 5 - minecraft:redstone_ore: 5 - section-bedrock: - minY: 0 - maxY: 5 - blocks: - minecraft:bedrock: 20 - obfuscation-nether: - enabled: true - minY: -2032 - maxY: 2031 - worlds: - - world_nether - layerObfuscation: false - hiddenBlocks: - - minecraft:chest - - minecraft:ender_chest - - minecraft:trapped_chest - - minecraft:mob_spawner - - minecraft:netherrack - - minecraft:quartz_ore - - minecraft:bedrock - randomBlocks: - section-global: - minY: -2032 - maxY: 2032 - blocks: - minecraft:netherrack: 1 - minecraft:quartz_ore: 1 - section-bedrock-top: - minY: 123 - maxY: 127 - blocks: - minecraft:bedrock: 20 - section-bedrock-bottom: - minY: 0 - maxY: 4 - blocks: - minecraft:bedrock: 20 - obfuscation-end: - enabled: true - minY: -2032 - maxY: 2031 - worlds: - - world_the_end - layerObfuscation: false - hiddenBlocks: - - minecraft:chest - - minecraft:ender_chest - - minecraft:trapped_chest - - minecraft:mob_spawner - randomBlocks: - section-global: - minY: -2032 - maxY: 2032 - blocks: - minecraft:end_stone: 1 - minecraft:end_bricks: 1 - minecraft:bedrock: 1 - minecraft:obsidian: 1 - minecraft:purpur_block: 1 -proximity: - proximity-overworld: - enabled: true - minY: 0 - maxY: 2031 - worlds: - - world - distance: 24 - frustumCulling: - enabled: true - minDistance: 3 - fov: 80 - rayCastCheck: - enabled: false - onlyCheckCenter: false - useBlockBelow: true - hiddenBlocks: - minecraft:mossy_cobblestone: {} - minecraft:diamond_ore: {} - minecraft:emerald_ore: {} - minecraft:chest: {} - minecraft:ender_chest: {} - minecraft:trapped_chest: {} - minecraft:anvil: {} - minecraft:crafting_table: {} - minecraft:dispenser: {} - minecraft:enchanting_table: {} - minecraft:furnace: {} - minecraft:hopper: {} - minecraft:mob_spawner: {} - randomBlocks: - section-global: - minY: -2032 - maxY: 2032 - blocks: - minecraft:stone: 1 - proximity-nether: - enabled: true - minY: 0 - maxY: 2031 - worlds: - - world_nether - distance: 24 - frustumCulling: - enabled: true - minDistance: 3 - fov: 80 - rayCastCheck: - enabled: false - onlyCheckCenter: false - useBlockBelow: true - hiddenBlocks: - minecraft:chest: {} - minecraft:ender_chest: {} - minecraft:trapped_chest: {} - minecraft:anvil: {} - minecraft:crafting_table: {} - minecraft:dispenser: {} - minecraft:enchanting_table: {} - minecraft:furnace: {} - minecraft:hopper: {} - minecraft:mob_spawner: {} - randomBlocks: - section-global: - minY: -2032 - maxY: 2032 - blocks: - minecraft:netherrack: 1 - proximity-end: - enabled: true - minY: 0 - maxY: 2031 - worlds: - - world_the_end - distance: 24 - frustumCulling: - enabled: true - minDistance: 3 - fov: 80 - rayCastCheck: - enabled: false - onlyCheckCenter: false - useBlockBelow: true - hiddenBlocks: - minecraft:chest: {} - minecraft:ender_chest: {} - minecraft:trapped_chest: {} - minecraft:anvil: {} - minecraft:crafting_table: {} - minecraft:dispenser: {} - minecraft:enchanting_table: {} - minecraft:furnace: {} - minecraft:hopper: {} - minecraft:mob_spawner: {} - randomBlocks: - section-global: - minY: -2032 - maxY: 2032 - blocks: - minecraft:end_stone: 1 diff --git a/orebfuscator-plugin/src/main/resources/plugin.yml b/orebfuscator-plugin/src/main/resources/plugin.yml index d3bf69b1..8d21b340 100644 --- a/orebfuscator-plugin/src/main/resources/plugin.yml +++ b/orebfuscator-plugin/src/main/resources/plugin.yml @@ -1,4 +1,4 @@ -api-version: 1.13 +api-version: 1.16 folia-supported: true name: ${project.parent.name} diff --git a/pom.xml b/pom.xml index c41acc1b..1f4e8e98 100644 --- a/pom.xml +++ b/pom.xml @@ -130,7 +130,7 @@ maven-compiler-plugin ${plugin.compile.version} - 11 + 17