From 14b705c7a9c94673a0af7270ed74152bfaed7c30 Mon Sep 17 00:00:00 2001 From: Aleksey-Terzi Date: Sat, 29 Apr 2017 11:27:46 +0300 Subject: [PATCH] Issue #146: Obfuscate signs based on whether the sign has text or not. --- .../lishid/orebfuscator/nms/INmsManager.java | 2 + Plugin/pom.xml | 2 +- .../orebfuscator/chunkmap/ChunkData.java | 5 ++ .../orebfuscator/config/ConfigManager.java | 1 + .../orebfuscator/config/WorldConfig.java | 16 ++++- .../orebfuscator/config/WorldReader.java | 2 + .../orebfuscator/hook/ProtocolLibHook.java | 27 ++++++++ .../obfuscation/Calculations.java | 61 ++++++++++++++++++- README.md | 1 + pom.xml | 4 ++ .../orebfuscator/nms/v1_10_R1/NmsManager.java | 16 +++++ .../orebfuscator/nms/v1_11_R1/NmsManager.java | 16 +++++ .../orebfuscator/nms/v1_9_R1/NmsManager.java | 7 +++ .../orebfuscator/nms/v1_9_R2/NmsManager.java | 7 +++ 14 files changed, 164 insertions(+), 3 deletions(-) diff --git a/API/src/main/java/com/lishid/orebfuscator/nms/INmsManager.java b/API/src/main/java/com/lishid/orebfuscator/nms/INmsManager.java index 359e512..d75bb3d 100644 --- a/API/src/main/java/com/lishid/orebfuscator/nms/INmsManager.java +++ b/API/src/main/java/com/lishid/orebfuscator/nms/INmsManager.java @@ -31,4 +31,6 @@ public interface INmsManager { BlockState getBlockState(World world, int x, int y, int z); int getBlockId(World world, int x, int y, int z); + + String getTextFromChatComponent(String json); } diff --git a/Plugin/pom.xml b/Plugin/pom.xml index c905e57..8f51601 100644 --- a/Plugin/pom.xml +++ b/Plugin/pom.xml @@ -4,7 +4,7 @@ com.lishid orebfuscator - 4.2.1-SNAPSHOT + 4.2.2-SNAPSHOT jar Orebfuscator4 diff --git a/Plugin/src/main/java/com/lishid/orebfuscator/chunkmap/ChunkData.java b/Plugin/src/main/java/com/lishid/orebfuscator/chunkmap/ChunkData.java index 74ca849..70604b4 100644 --- a/Plugin/src/main/java/com/lishid/orebfuscator/chunkmap/ChunkData.java +++ b/Plugin/src/main/java/com/lishid/orebfuscator/chunkmap/ChunkData.java @@ -5,6 +5,10 @@ package com.lishid.orebfuscator.chunkmap; +import java.util.List; + +import com.comphenix.protocol.wrappers.nbt.NbtCompound; + public class ChunkData { public int chunkX; public int chunkZ; @@ -13,4 +17,5 @@ public class ChunkData { public byte[] data; public boolean isOverworld; public boolean useCache; + public List blockEntities; } diff --git a/Plugin/src/main/java/com/lishid/orebfuscator/config/ConfigManager.java b/Plugin/src/main/java/com/lishid/orebfuscator/config/ConfigManager.java index 5f11874..abdd2c7 100644 --- a/Plugin/src/main/java/com/lishid/orebfuscator/config/ConfigManager.java +++ b/Plugin/src/main/java/com/lishid/orebfuscator/config/ConfigManager.java @@ -54,6 +54,7 @@ public class ConfigManager { break; default: baseCfg = this.orebfuscatorConfig.getNormalWorld(); + break; } WorldConfig cfg = this.orebfuscatorConfig.getWorlds().get(world.getName().toLowerCase()); diff --git a/Plugin/src/main/java/com/lishid/orebfuscator/config/WorldConfig.java b/Plugin/src/main/java/com/lishid/orebfuscator/config/WorldConfig.java index b8b84b3..2a0b912 100644 --- a/Plugin/src/main/java/com/lishid/orebfuscator/config/WorldConfig.java +++ b/Plugin/src/main/java/com/lishid/orebfuscator/config/WorldConfig.java @@ -15,7 +15,8 @@ public class WorldConfig { private Boolean enabled; private Boolean darknessHideBlocks; private Boolean antiTexturePackAndFreecam; - private Integer airGeneratorMaxChance; + private Boolean bypassObfuscationForSignsWithText; + private Integer airGeneratorMaxChance; private boolean[] obfuscateBlocks; private boolean[] obfuscateAndProximityBlocks; private boolean[] darknessBlocks; @@ -34,6 +35,7 @@ public class WorldConfig { this.enabled = true; this.darknessHideBlocks = false; this.antiTexturePackAndFreecam = true; + this.bypassObfuscationForSignsWithText = false; this.airGeneratorMaxChance = 43; this.obfuscateBlocks = new boolean[256]; @@ -68,6 +70,10 @@ public class WorldConfig { this.antiTexturePackAndFreecam = baseWorld.antiTexturePackAndFreecam; } + if(this.bypassObfuscationForSignsWithText == null) { + this.bypassObfuscationForSignsWithText = baseWorld.bypassObfuscationForSignsWithText; + } + if(this.airGeneratorMaxChance == null) { this.airGeneratorMaxChance = baseWorld.airGeneratorMaxChance; } @@ -126,6 +132,14 @@ public class WorldConfig { this.antiTexturePackAndFreecam = value; } + public Boolean isBypassObfuscationForSignsWithText() { + return this.bypassObfuscationForSignsWithText; + } + + public void setBypassObfuscationForSignsWithText(Boolean value) { + this.bypassObfuscationForSignsWithText = value; + } + public Integer getAirGeneratorMaxChance() { return this.airGeneratorMaxChance; } diff --git a/Plugin/src/main/java/com/lishid/orebfuscator/config/WorldReader.java b/Plugin/src/main/java/com/lishid/orebfuscator/config/WorldReader.java index 77ef2a6..c9f90ae 100644 --- a/Plugin/src/main/java/com/lishid/orebfuscator/config/WorldReader.java +++ b/Plugin/src/main/java/com/lishid/orebfuscator/config/WorldReader.java @@ -181,6 +181,7 @@ public class WorldReader { Boolean antiTexturePackAndFreecam = getBoolean(worldPath + ".AntiTexturePackAndFreecam", cfg.isAntiTexturePackAndFreecam(), withSave); Integer airGeneratorMaxChance = getInt(worldPath + ".AirGeneratorMaxChance", cfg.getAirGeneratorMaxChance(), 40, 100, withSave); Boolean darknessHideBlocks = getBoolean(worldPath + ".DarknessHideBlocks", cfg.isDarknessHideBlocks(), withSave); + Boolean bypassObfuscationForSignsWithText = getBoolean(worldPath + ".BypassObfuscationForSignsWithText", cfg.isBypassObfuscationForSignsWithText(), withSave); boolean[] darknessBlocks = readBlockMatrix(cfg.getDarknessBlocks(), cfg.getDarknessBlockIds(), worldPath + ".DarknessBlocks", withSave); Integer mode1Block = this.materialReader.getMaterialIdByPath(worldPath + ".Mode1Block", cfg.getMode1BlockId(), withSave); Integer[] randomBlocks = this.materialReader.getMaterialIdsByPath(worldPath + ".RandomBlocks", cfg.getRandomBlocks(), withSave); @@ -204,6 +205,7 @@ public class WorldReader { cfg.setEnabled(enabled); cfg.setAntiTexturePackAndFreecam(antiTexturePackAndFreecam); + cfg.setBypassObfuscationForSignsWithText(bypassObfuscationForSignsWithText); cfg.setAirGeneratorMaxChance(airGeneratorMaxChance); cfg.setDarknessHideBlocks(darknessHideBlocks); cfg.setDarknessBlocks(darknessBlocks); diff --git a/Plugin/src/main/java/com/lishid/orebfuscator/hook/ProtocolLibHook.java b/Plugin/src/main/java/com/lishid/orebfuscator/hook/ProtocolLibHook.java index 6c3dae6..c0bafe2 100644 --- a/Plugin/src/main/java/com/lishid/orebfuscator/hook/ProtocolLibHook.java +++ b/Plugin/src/main/java/com/lishid/orebfuscator/hook/ProtocolLibHook.java @@ -16,7 +16,11 @@ package com.lishid.orebfuscator.hook; +import java.util.ArrayList; +import java.util.List; + import org.bukkit.World; +import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; import com.comphenix.protocol.PacketType; @@ -27,7 +31,11 @@ import com.comphenix.protocol.events.PacketContainer; import com.comphenix.protocol.events.PacketEvent; import com.comphenix.protocol.reflect.StructureModifier; import com.comphenix.protocol.wrappers.EnumWrappers; +import com.comphenix.protocol.wrappers.nbt.NbtCompound; +import com.comphenix.protocol.wrappers.nbt.NbtFactory; +import com.lishid.orebfuscator.Orebfuscator; import com.lishid.orebfuscator.chunkmap.ChunkData; +import com.lishid.orebfuscator.config.WorldConfig; import com.lishid.orebfuscator.hithack.BlockHitManager; import com.lishid.orebfuscator.obfuscation.Calculations; @@ -53,6 +61,7 @@ public class ProtocolLibHook { chunkData.primaryBitMask = ints.read(2); chunkData.data = byteArray.read(0); chunkData.isOverworld = event.getPlayer().getWorld().getEnvironment() == World.Environment.NORMAL; + chunkData.blockEntities = getBlockEntities(packet, event.getPlayer()); try { byte[] newData = Calculations.obfuscateOrUseCache(chunkData, event.getPlayer()); @@ -79,6 +88,24 @@ public class ProtocolLibHook { }); } + @SuppressWarnings("rawtypes") + private static List getBlockEntities(PacketContainer packet, Player player) { + WorldConfig worldConfig = Orebfuscator.configManager.getWorld(player.getWorld()); + + if(!worldConfig.isBypassObfuscationForSignsWithText()) { + return null; + } + + List list = packet.getSpecificModifier(List.class).read(0); + List result = new ArrayList(); + + for(Object tag : list) { + result.add(NbtFactory.fromNMSCompound(tag)); + } + + return result; + } + /* private static boolean _isSaved; private void saveTestData(ChunkData chunkData) { diff --git a/Plugin/src/main/java/com/lishid/orebfuscator/obfuscation/Calculations.java b/Plugin/src/main/java/com/lishid/orebfuscator/obfuscation/Calculations.java index 195973f..f139ec4 100644 --- a/Plugin/src/main/java/com/lishid/orebfuscator/obfuscation/Calculations.java +++ b/Plugin/src/main/java/com/lishid/orebfuscator/obfuscation/Calculations.java @@ -21,9 +21,14 @@ import java.io.IOException; import java.util.ArrayList; import java.util.Random; +import org.bukkit.Material; import org.bukkit.World; import org.bukkit.entity.Player; +import com.comphenix.protocol.wrappers.nbt.NbtBase; +import com.comphenix.protocol.wrappers.nbt.NbtCompound; +import com.comphenix.protocol.wrappers.nbt.NbtType; +import com.lishid.orebfuscator.DeprecatedMethods; import com.lishid.orebfuscator.Orebfuscator; import com.lishid.orebfuscator.cache.ObfuscatedCachedChunk; import com.lishid.orebfuscator.cache.ObfuscatedDataCache; @@ -173,7 +178,7 @@ public class Calculations { } // Check if the block is obfuscated - if (obfuscate) { + if (obfuscate && canObfuscate(chunkData, x, y, z, blockState)) { if (specialObfuscate) { // Proximity hider blockState.id = proximityHider.getSpecialBlockID(); @@ -247,6 +252,60 @@ public class Calculations { return output; } + private static boolean canObfuscate(ChunkData chunkData, int x, int y, int z, BlockState blockState) { + if(chunkData.blockEntities == null + || ( + blockState.id != DeprecatedMethods.getMaterialId(Material.WALL_SIGN) + && blockState.id != DeprecatedMethods.getMaterialId(Material.SIGN_POST) + ) + ) + { + return true; + } + + NbtCompound tag = getNbtTag(chunkData, x, y, z); + + return tag == null || + isSignTextEmpty(tag, "Text1") + && isSignTextEmpty(tag, "Text2") + && isSignTextEmpty(tag, "Text3") + && isSignTextEmpty(tag, "Text4"); + } + + private static boolean isSignTextEmpty(NbtCompound compound, String key) { + NbtBase tag = compound.getValue(key); + + if(tag == null || tag.getType() != NbtType.TAG_STRING) { + return true; + } + + String json = (String)tag.getValue(); + + if(json == null || json.isEmpty()) { + return true; + } + + String text = Orebfuscator.nms.getTextFromChatComponent(json); + + return text == null || text.isEmpty(); + } + + private static NbtCompound getNbtTag(ChunkData chunkData, int x, int y, int z) { + for(NbtCompound tag : chunkData.blockEntities) { + if(tag != null) { + if(x == tag.getInteger("x") + && y == tag.getInteger("y") + && z == tag.getInteger("z") + ) + { + return tag; + } + } + } + + return null; + } + private static void addBlocksToPalette(ChunkMapManager manager, WorldConfig worldConfig) { if(!manager.inputHasNonAirBlock()) { return; diff --git a/README.md b/README.md index 0357e4b..8f6cfe0 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ The definitive Anti X-Ray plugin for CraftBukkit ###Changelog: +- Updated to support 1.11 - 1.11.2 - Updated to support 1.10 (Thanks Asgorioth) - Updated to support 1.9.4 - Updated to support 1.9-1.9.2 (https://www.devotedmc.com) diff --git a/pom.xml b/pom.xml index 9b2c875..a3ec8ca 100644 --- a/pom.xml +++ b/pom.xml @@ -23,6 +23,10 @@ spigot-repo https://hub.spigotmc.org/nexus/content/repositories/snapshots/ + + techcable-repo + https://repo.techcable.net/content/groups/public/ + diff --git a/v1_10_R1/src/main/java/com/lishid/orebfuscator/nms/v1_10_R1/NmsManager.java b/v1_10_R1/src/main/java/com/lishid/orebfuscator/nms/v1_10_R1/NmsManager.java index 42b80c6..dd4e750 100644 --- a/v1_10_R1/src/main/java/com/lishid/orebfuscator/nms/v1_10_R1/NmsManager.java +++ b/v1_10_R1/src/main/java/com/lishid/orebfuscator/nms/v1_10_R1/NmsManager.java @@ -11,6 +11,7 @@ import net.minecraft.server.v1_10_R1.BlockPosition; import net.minecraft.server.v1_10_R1.Chunk; import net.minecraft.server.v1_10_R1.ChunkProviderServer; import net.minecraft.server.v1_10_R1.IBlockData; +import net.minecraft.server.v1_10_R1.IChatBaseComponent; import net.minecraft.server.v1_10_R1.Packet; import net.minecraft.server.v1_10_R1.PlayerChunkMap; import net.minecraft.server.v1_10_R1.TileEntity; @@ -19,6 +20,7 @@ import net.minecraft.server.v1_10_R1.WorldServer; import org.bukkit.World; import org.bukkit.craftbukkit.v1_10_R1.CraftWorld; import org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer; +import org.bukkit.craftbukkit.v1_10_R1.util.CraftChatMessage; import org.bukkit.entity.Player; import com.lishid.orebfuscator.nms.IBlockInfo; @@ -40,10 +42,12 @@ public class NmsManager implements INmsManager { return new NBT(); } + @Override public IChunkCache createChunkCache() { return new ChunkCache(this.maxLoadedCacheFiles); } + @Override public IChunkManager getChunkManager(World world) { WorldServer worldServer = ((CraftWorld)world).getHandle(); PlayerChunkMap chunkMap = worldServer.getPlayerChunkMap(); @@ -51,6 +55,7 @@ public class NmsManager implements INmsManager { return new ChunkManager(chunkMap); } + @Override public void updateBlockTileEntity(BlockCoord blockCoord, Player player) { CraftWorld world = (CraftWorld)player.getWorld(); TileEntity tileEntity = world.getTileEntityAt(blockCoord.x, blockCoord.y, blockCoord.z); @@ -67,6 +72,7 @@ public class NmsManager implements INmsManager { } } + @Override public void notifyBlockChange(World world, IBlockInfo blockInfo) { BlockPosition blockPosition = new BlockPosition(blockInfo.getX(), blockInfo.getY(), blockInfo.getZ()); IBlockData blockData = ((BlockInfo)blockInfo).getBlockData(); @@ -74,10 +80,12 @@ public class NmsManager implements INmsManager { ((CraftWorld)world).getHandle().notify(blockPosition, blockData, blockData, 0); } + @Override public int getBlockLightLevel(World world, int x, int y, int z) { return ((CraftWorld)world).getHandle().getLightLevel(new BlockPosition(x, y, z)); } + @Override public IBlockInfo getBlockInfo(World world, int x, int y, int z) { IBlockData blockData = getBlockData(world, x, y, z); @@ -86,6 +94,7 @@ public class NmsManager implements INmsManager { : null; } + @Override public BlockState getBlockState(World world, int x, int y, int z) { IBlockData blockData = getBlockData(world, x, y, z); @@ -100,12 +109,19 @@ public class NmsManager implements INmsManager { return blockState; } + @Override public int getBlockId(World world, int x, int y, int z) { IBlockData blockData = getBlockData(world, x, y, z); return blockData != null ? Block.getId(blockData.getBlock()): -1; } + @Override + public String getTextFromChatComponent(String json) { + IChatBaseComponent component = IChatBaseComponent.ChatSerializer.a(json); + return CraftChatMessage.fromComponent(component); + } + private static IBlockData getBlockData(World world, int x, int y, int z) { int chunkX = x >> 4; int chunkZ = z >> 4; diff --git a/v1_11_R1/src/main/java/com/lishid/orebfuscator/nms/v1_11_R1/NmsManager.java b/v1_11_R1/src/main/java/com/lishid/orebfuscator/nms/v1_11_R1/NmsManager.java index 20d07ec..0cb9270 100644 --- a/v1_11_R1/src/main/java/com/lishid/orebfuscator/nms/v1_11_R1/NmsManager.java +++ b/v1_11_R1/src/main/java/com/lishid/orebfuscator/nms/v1_11_R1/NmsManager.java @@ -11,6 +11,7 @@ import net.minecraft.server.v1_11_R1.BlockPosition; import net.minecraft.server.v1_11_R1.Chunk; import net.minecraft.server.v1_11_R1.ChunkProviderServer; import net.minecraft.server.v1_11_R1.IBlockData; +import net.minecraft.server.v1_11_R1.IChatBaseComponent; import net.minecraft.server.v1_11_R1.Packet; import net.minecraft.server.v1_11_R1.PlayerChunkMap; import net.minecraft.server.v1_11_R1.TileEntity; @@ -19,6 +20,7 @@ import net.minecraft.server.v1_11_R1.WorldServer; import org.bukkit.World; import org.bukkit.craftbukkit.v1_11_R1.CraftWorld; import org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer; +import org.bukkit.craftbukkit.v1_11_R1.util.CraftChatMessage; import org.bukkit.entity.Player; import com.lishid.orebfuscator.nms.IBlockInfo; @@ -40,10 +42,12 @@ public class NmsManager implements INmsManager { return new NBT(); } + @Override public IChunkCache createChunkCache() { return new ChunkCache(this.maxLoadedCacheFiles); } + @Override public IChunkManager getChunkManager(World world) { WorldServer worldServer = ((CraftWorld)world).getHandle(); PlayerChunkMap chunkMap = worldServer.getPlayerChunkMap(); @@ -51,6 +55,7 @@ public class NmsManager implements INmsManager { return new ChunkManager(chunkMap); } + @Override public void updateBlockTileEntity(BlockCoord blockCoord, Player player) { CraftWorld world = (CraftWorld)player.getWorld(); TileEntity tileEntity = world.getTileEntityAt(blockCoord.x, blockCoord.y, blockCoord.z); @@ -67,6 +72,7 @@ public class NmsManager implements INmsManager { } } + @Override public void notifyBlockChange(World world, IBlockInfo blockInfo) { BlockPosition blockPosition = new BlockPosition(blockInfo.getX(), blockInfo.getY(), blockInfo.getZ()); IBlockData blockData = ((BlockInfo)blockInfo).getBlockData(); @@ -74,10 +80,12 @@ public class NmsManager implements INmsManager { ((CraftWorld)world).getHandle().notify(blockPosition, blockData, blockData, 0); } + @Override public int getBlockLightLevel(World world, int x, int y, int z) { return ((CraftWorld)world).getHandle().getLightLevel(new BlockPosition(x, y, z)); } + @Override public IBlockInfo getBlockInfo(World world, int x, int y, int z) { IBlockData blockData = getBlockData(world, x, y, z); @@ -86,6 +94,7 @@ public class NmsManager implements INmsManager { : null; } + @Override public BlockState getBlockState(World world, int x, int y, int z) { IBlockData blockData = getBlockData(world, x, y, z); @@ -100,12 +109,19 @@ public class NmsManager implements INmsManager { return blockState; } + @Override public int getBlockId(World world, int x, int y, int z) { IBlockData blockData = getBlockData(world, x, y, z); return blockData != null ? Block.getId(blockData.getBlock()): -1; } + @Override + public String getTextFromChatComponent(String json) { + IChatBaseComponent component = IChatBaseComponent.ChatSerializer.a(json); + return CraftChatMessage.fromComponent(component); + } + private static IBlockData getBlockData(World world, int x, int y, int z) { int chunkX = x >> 4; int chunkZ = z >> 4; diff --git a/v1_9_R1/src/main/java/com/lishid/orebfuscator/nms/v1_9_R1/NmsManager.java b/v1_9_R1/src/main/java/com/lishid/orebfuscator/nms/v1_9_R1/NmsManager.java index ffc4ecd..18ac530 100644 --- a/v1_9_R1/src/main/java/com/lishid/orebfuscator/nms/v1_9_R1/NmsManager.java +++ b/v1_9_R1/src/main/java/com/lishid/orebfuscator/nms/v1_9_R1/NmsManager.java @@ -11,6 +11,7 @@ import net.minecraft.server.v1_9_R1.BlockPosition; import net.minecraft.server.v1_9_R1.Chunk; import net.minecraft.server.v1_9_R1.ChunkProviderServer; import net.minecraft.server.v1_9_R1.IBlockData; +import net.minecraft.server.v1_9_R1.IChatBaseComponent; import net.minecraft.server.v1_9_R1.Packet; import net.minecraft.server.v1_9_R1.PlayerChunkMap; import net.minecraft.server.v1_9_R1.TileEntity; @@ -19,6 +20,7 @@ import net.minecraft.server.v1_9_R1.WorldServer; import org.bukkit.World; import org.bukkit.craftbukkit.v1_9_R1.CraftWorld; import org.bukkit.craftbukkit.v1_9_R1.entity.CraftPlayer; +import org.bukkit.craftbukkit.v1_9_R1.util.CraftChatMessage; import org.bukkit.entity.Player; import com.lishid.orebfuscator.nms.IBlockInfo; @@ -106,6 +108,11 @@ public class NmsManager implements INmsManager { return blockData != null ? Block.getId(blockData.getBlock()): -1; } + public String getTextFromChatComponent(String json) { + IChatBaseComponent component = IChatBaseComponent.ChatSerializer.a(json); + return CraftChatMessage.fromComponent(component); + } + private static IBlockData getBlockData(World world, int x, int y, int z) { int chunkX = x >> 4; int chunkZ = z >> 4; diff --git a/v1_9_R2/src/main/java/com/lishid/orebfuscator/nms/v1_9_R2/NmsManager.java b/v1_9_R2/src/main/java/com/lishid/orebfuscator/nms/v1_9_R2/NmsManager.java index 8e99d58..06fa1d2 100644 --- a/v1_9_R2/src/main/java/com/lishid/orebfuscator/nms/v1_9_R2/NmsManager.java +++ b/v1_9_R2/src/main/java/com/lishid/orebfuscator/nms/v1_9_R2/NmsManager.java @@ -11,6 +11,7 @@ import net.minecraft.server.v1_9_R2.BlockPosition; import net.minecraft.server.v1_9_R2.Chunk; import net.minecraft.server.v1_9_R2.ChunkProviderServer; import net.minecraft.server.v1_9_R2.IBlockData; +import net.minecraft.server.v1_9_R2.IChatBaseComponent; import net.minecraft.server.v1_9_R2.Packet; import net.minecraft.server.v1_9_R2.PlayerChunkMap; import net.minecraft.server.v1_9_R2.TileEntity; @@ -19,6 +20,7 @@ import net.minecraft.server.v1_9_R2.WorldServer; 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.CraftChatMessage; import org.bukkit.entity.Player; import com.lishid.orebfuscator.nms.IBlockInfo; @@ -106,6 +108,11 @@ public class NmsManager implements INmsManager { return blockData != null ? Block.getId(blockData.getBlock()): -1; } + public String getTextFromChatComponent(String json) { + IChatBaseComponent component = IChatBaseComponent.ChatSerializer.a(json); + return CraftChatMessage.fromComponent(component); + } + private static IBlockData getBlockData(World world, int x, int y, int z) { int chunkX = x >> 4; int chunkZ = z >> 4;