commit
aef51cbdfb
|
@ -4,7 +4,7 @@
|
|||
|
||||
<groupId>com.lishid</groupId>
|
||||
<artifactId>orebfuscator</artifactId>
|
||||
<version>4.1.4-SNAPSHOT</version>
|
||||
<version>4.1.8-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>Orebfuscator4</name>
|
||||
|
|
|
@ -57,6 +57,8 @@ public class OrebfuscatorConfig {
|
|||
public static int InitialRadius = 1;
|
||||
public static int UpdateRadius = 2;
|
||||
public static boolean UseWorldsAsBlacklist = true;
|
||||
public static boolean NoObfuscationForMetadata = true;
|
||||
public static String NoObfuscationForMetadataTagName = "NPC";
|
||||
|
||||
// Darkness
|
||||
public static boolean DarknessHideBlocks = false;
|
||||
|
@ -447,6 +449,8 @@ public class OrebfuscatorConfig {
|
|||
AntiTexturePackAndFreecam = getBoolean("Booleans.AntiTexturePackAndFreecam", AntiTexturePackAndFreecam);
|
||||
UseWorldsAsBlacklist = getBoolean("Booleans.UseWorldsAsBlacklist", UseWorldsAsBlacklist);
|
||||
Enabled = getBoolean("Booleans.Enabled", Enabled);
|
||||
NoObfuscationForMetadata = getBoolean("Booleans.NoObfuscationForMetadata", NoObfuscationForMetadata);
|
||||
NoObfuscationForMetadataTagName = getString("Strings.NoObfuscationForMetadataTagName", NoObfuscationForMetadataTagName);
|
||||
|
||||
generateTransparentBlocks();
|
||||
|
||||
|
@ -641,7 +645,7 @@ public class OrebfuscatorConfig {
|
|||
}
|
||||
|
||||
public static boolean obfuscateForPlayer(Player player) {
|
||||
return !(playerBypassOp(player) || playerBypassPerms(player));
|
||||
return !(playerBypassOp(player) || playerBypassPerms(player) || playerBypassMetadata(player));
|
||||
}
|
||||
|
||||
public static boolean playerBypassOp(Player player) {
|
||||
|
@ -666,6 +670,19 @@ public class OrebfuscatorConfig {
|
|||
return ret;
|
||||
}
|
||||
|
||||
public static boolean playerBypassMetadata(Player player) {
|
||||
boolean ret = false;
|
||||
try {
|
||||
ret = OrebfuscatorConfig.NoObfuscationForMetadata
|
||||
&& player.hasMetadata(OrebfuscatorConfig.NoObfuscationForMetadataTagName)
|
||||
&& player.getMetadata(OrebfuscatorConfig.NoObfuscationForMetadataTagName).get(0).asBoolean();
|
||||
} catch (Exception e) {
|
||||
Orebfuscator.log("Error while obtaining metadata for player" + player.getName() + ": " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
private static FileConfiguration getConfig() {
|
||||
return Orebfuscator.instance.getConfig();
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
package com.lishid.orebfuscator.hook;
|
||||
|
||||
import com.comphenix.protocol.wrappers.EnumWrappers;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
|
@ -27,6 +26,7 @@ import com.comphenix.protocol.events.PacketAdapter;
|
|||
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.lishid.orebfuscator.chunkmap.ChunkData;
|
||||
import com.lishid.orebfuscator.hithack.BlockHitManager;
|
||||
import com.lishid.orebfuscator.obfuscation.Calculations;
|
||||
|
@ -78,4 +78,33 @@ public class ProtocolLibHook {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
private static boolean _isSaved;
|
||||
private void saveTestData(ChunkData chunkData) {
|
||||
if(_isSaved) return;
|
||||
|
||||
_isSaved = true;
|
||||
|
||||
FileOutputStream fos;
|
||||
try {
|
||||
fos = new FileOutputStream("D:\\Temp\\chunk.dat");
|
||||
fos.write(chunkData.chunkX & 0xff);
|
||||
fos.write((chunkData.chunkX >> 8) & 0xff);
|
||||
fos.write(chunkData.chunkZ & 0xff);
|
||||
fos.write((chunkData.chunkZ >> 8) & 0xff);
|
||||
fos.write(chunkData.primaryBitMask & 0xff);
|
||||
fos.write((chunkData.primaryBitMask >> 8) & 0xff);
|
||||
fos.write(chunkData.data.length & 0xff);
|
||||
fos.write((chunkData.data.length >> 8) & 0xff);
|
||||
fos.write((chunkData.data.length >> 16) & 0xff);
|
||||
fos.write(chunkData.data);
|
||||
fos.close();
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
|
|
@ -33,19 +33,15 @@ import com.lishid.orebfuscator.obfuscation.BlockUpdate;
|
|||
|
||||
public class OrebfuscatorBlockListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onBlockBreak(BlockBreakEvent event) {
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
BlockUpdate.update(event.getBlock());
|
||||
BlockHitManager.breakBlock(event.getPlayer(), event.getBlock());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onBlockDamage(BlockDamageEvent event) {
|
||||
if (event.isCancelled() || !OrebfuscatorConfig.UpdateOnDamage) {
|
||||
if (!OrebfuscatorConfig.UpdateOnDamage) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -60,12 +56,8 @@ public class OrebfuscatorBlockListener implements Listener {
|
|||
BlockUpdate.update(event.getBlock());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onBlockPhysics(BlockPhysicsEvent event) {
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getBlock().getType() != Material.SAND && event.getBlock().getType() != Material.GRAVEL) {
|
||||
return;
|
||||
}
|
||||
|
@ -77,21 +69,13 @@ public class OrebfuscatorBlockListener implements Listener {
|
|||
BlockUpdate.update(event.getBlock());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onBlockPistonExtend(BlockPistonExtendEvent event) {
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
BlockUpdate.update(event.getBlocks());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
BlockUpdate.update(event.getBlock());
|
||||
}
|
||||
}
|
|
@ -24,12 +24,13 @@ import org.bukkit.event.entity.*;
|
|||
import com.lishid.orebfuscator.obfuscation.BlockUpdate;
|
||||
|
||||
public class OrebfuscatorEntityListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onEntityExplode(EntityExplodeEvent event) {
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
BlockUpdate.update(event.blockList());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onEntityChangeBlock(EntityChangeBlockEvent event) {
|
||||
BlockUpdate.update(event.getBlock());
|
||||
}
|
||||
}
|
|
@ -38,7 +38,7 @@ import com.lishid.orebfuscator.obfuscation.BlockUpdate;
|
|||
import com.lishid.orebfuscator.obfuscation.ProximityHider;
|
||||
|
||||
public class OrebfuscatorPlayerListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
|
@ -55,7 +55,7 @@ public class OrebfuscatorPlayerListener implements Listener {
|
|||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
BlockHitManager.clearHistory(event.getPlayer());
|
||||
if (OrebfuscatorConfig.UseProximityHider) {
|
||||
|
@ -63,7 +63,7 @@ public class OrebfuscatorPlayerListener implements Listener {
|
|||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
if (event.getAction() != Action.RIGHT_CLICK_BLOCK || event.useInteractedBlock() == Result.DENY)
|
||||
return;
|
||||
|
@ -81,7 +81,7 @@ public class OrebfuscatorPlayerListener implements Listener {
|
|||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPlayerChangeWorld(PlayerChangedWorldEvent event) {
|
||||
BlockHitManager.clearHistory(event.getPlayer());
|
||||
|
||||
|
|
|
@ -126,97 +126,99 @@ public class Calculations {
|
|||
|
||||
ChunkMapManager.blockDataToState(blockData, blockState);
|
||||
|
||||
if (blockState.id >= 256) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int x = startX | offsetX;
|
||||
int y = manager.getY();
|
||||
int z = startZ | offsetZ;
|
||||
|
||||
// Initialize data
|
||||
obfuscate = false;
|
||||
specialObfuscate = false;
|
||||
|
||||
// Check if the block should be obfuscated for the default engine modes
|
||||
if (OrebfuscatorConfig.isObfuscated(blockState.id, environment)) {
|
||||
if (initialRadius == 0) {
|
||||
// Do not interfere with PH
|
||||
if (OrebfuscatorConfig.UseProximityHider && OrebfuscatorConfig.isProximityObfuscated(y, blockState.id)) {
|
||||
if (!areAjacentBlocksTransparent(manager, player.getWorld(), false, x, y, z, 1)) {
|
||||
obfuscate = true;
|
||||
}
|
||||
} else {
|
||||
// Obfuscate all blocks
|
||||
obfuscate = true;
|
||||
}
|
||||
} else {
|
||||
// Check if any nearby blocks are transparent
|
||||
if (!areAjacentBlocksTransparent(manager, player.getWorld(), false, x, y, z, initialRadius)) {
|
||||
obfuscate = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the block should be obfuscated because of proximity check
|
||||
if (!obfuscate && OrebfuscatorConfig.UseProximityHider && OrebfuscatorConfig.isProximityObfuscated(y, blockState.id)) {
|
||||
if (OrebfuscatorConfig.isProximityHiderOn(y, blockState.id)) {
|
||||
BlockCoord block = new BlockCoord(x, y, z);
|
||||
if (block != null) {
|
||||
proximityBlocks.add(block);
|
||||
}
|
||||
|
||||
obfuscate = true;
|
||||
if (OrebfuscatorConfig.UseSpecialBlockForProximityHider) {
|
||||
specialObfuscate = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the block is obfuscated
|
||||
if (obfuscate) {
|
||||
if (specialObfuscate) {
|
||||
// Proximity hider
|
||||
blockState.id = OrebfuscatorConfig.ProximityHiderID;
|
||||
} else {
|
||||
randomIncrement2 = OrebfuscatorConfig.random(incrementMax);
|
||||
|
||||
if (engineMode == 1) {
|
||||
// Engine mode 1, replace with stone
|
||||
blockState.id = (environment == Environment.NETHER ? 87 : 1);
|
||||
} else if (engineMode == 2) {
|
||||
// Ending mode 2, replace with random block
|
||||
if (randomBlocksLength > 1) {
|
||||
randomIncrement = CalculationsUtil.increment(randomIncrement, randomBlocksLength);
|
||||
}
|
||||
|
||||
blockState.id = OrebfuscatorConfig.getRandomBlock(randomIncrement, randomAlternate, environment);
|
||||
randomAlternate = !randomAlternate;
|
||||
}
|
||||
// Anti texturepack and freecam
|
||||
if (OrebfuscatorConfig.AntiTexturePackAndFreecam) {
|
||||
// Add random air blocks
|
||||
if (randomIncrement2 == 0) {
|
||||
randomCave = 1 + OrebfuscatorConfig.random(3);
|
||||
}
|
||||
|
||||
if (randomCave > 0) {
|
||||
blockState.id = 0;
|
||||
randomCave--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
blockState.meta = 0;
|
||||
}
|
||||
|
||||
// Check if the block should be obfuscated because of the darkness
|
||||
if (!obfuscate && OrebfuscatorConfig.DarknessHideBlocks && OrebfuscatorConfig.isDarknessObfuscated(blockState.id)) {
|
||||
if (!areAjacentBlocksBright(player.getWorld(), x, y, z, 1)) {
|
||||
// Hide block, setting it to air
|
||||
blockState.id = 0;
|
||||
blockState.meta = 0;
|
||||
}
|
||||
if (blockState.id < 256) {
|
||||
int x = startX | offsetX;
|
||||
int y = manager.getY();
|
||||
int z = startZ | offsetZ;
|
||||
|
||||
// Initialize data
|
||||
obfuscate = false;
|
||||
specialObfuscate = false;
|
||||
|
||||
// Check if the block should be obfuscated for the default engine modes
|
||||
if (OrebfuscatorConfig.isObfuscated(blockState.id, environment)) {
|
||||
if (initialRadius == 0) {
|
||||
// Do not interfere with PH
|
||||
if (OrebfuscatorConfig.UseProximityHider && OrebfuscatorConfig.isProximityObfuscated(y, blockState.id)) {
|
||||
if (!areAjacentBlocksTransparent(manager, player.getWorld(), false, x, y, z, 1)) {
|
||||
obfuscate = true;
|
||||
}
|
||||
} else {
|
||||
// Obfuscate all blocks
|
||||
obfuscate = true;
|
||||
}
|
||||
} else {
|
||||
// Check if any nearby blocks are transparent
|
||||
if (!areAjacentBlocksTransparent(manager, player.getWorld(), false, x, y, z, initialRadius)) {
|
||||
obfuscate = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the block should be obfuscated because of proximity check
|
||||
if (!obfuscate && OrebfuscatorConfig.UseProximityHider && OrebfuscatorConfig.isProximityObfuscated(y, blockState.id)) {
|
||||
if (OrebfuscatorConfig.isProximityHiderOn(y, blockState.id)) {
|
||||
BlockCoord block = new BlockCoord(x, y, z);
|
||||
if (block != null) {
|
||||
proximityBlocks.add(block);
|
||||
}
|
||||
|
||||
obfuscate = true;
|
||||
if (OrebfuscatorConfig.UseSpecialBlockForProximityHider) {
|
||||
specialObfuscate = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the block is obfuscated
|
||||
if (obfuscate) {
|
||||
if (specialObfuscate) {
|
||||
// Proximity hider
|
||||
blockState.id = OrebfuscatorConfig.ProximityHiderID;
|
||||
} else {
|
||||
randomIncrement2 = OrebfuscatorConfig.random(incrementMax);
|
||||
|
||||
if (engineMode == 1) {
|
||||
// Engine mode 1, replace with stone
|
||||
blockState.id = (environment == Environment.NETHER ? 87 : 1);
|
||||
} else if (engineMode == 2) {
|
||||
// Ending mode 2, replace with random block
|
||||
if (randomBlocksLength > 1) {
|
||||
randomIncrement = CalculationsUtil.increment(randomIncrement, randomBlocksLength);
|
||||
}
|
||||
|
||||
blockState.id = OrebfuscatorConfig.getRandomBlock(randomIncrement, randomAlternate, environment);
|
||||
randomAlternate = !randomAlternate;
|
||||
}
|
||||
// Anti texturepack and freecam
|
||||
if (OrebfuscatorConfig.AntiTexturePackAndFreecam) {
|
||||
// Add random air blocks
|
||||
if (randomIncrement2 == 0) {
|
||||
randomCave = 1 + OrebfuscatorConfig.random(3);
|
||||
}
|
||||
|
||||
if (randomCave > 0) {
|
||||
blockState.id = 0;
|
||||
randomCave--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
blockState.meta = 0;
|
||||
}
|
||||
|
||||
// Check if the block should be obfuscated because of the darkness
|
||||
if (!obfuscate && OrebfuscatorConfig.DarknessHideBlocks && OrebfuscatorConfig.isDarknessObfuscated(blockState.id)) {
|
||||
if (!areAjacentBlocksBright(player.getWorld(), x, y, z, 1)) {
|
||||
// Hide block, setting it to air
|
||||
blockState.id = 0;
|
||||
blockState.meta = 0;
|
||||
}
|
||||
}
|
||||
|
||||
blockData = ChunkMapManager.blockStateToData(blockState);
|
||||
} else {
|
||||
blockData = 0;
|
||||
}
|
||||
|
||||
if(offsetY == 0 && offsetZ == 0 && offsetX == 0) {
|
||||
|
@ -226,8 +228,6 @@ public class Calculations {
|
|||
manager.initOutputSection();
|
||||
}
|
||||
|
||||
blockData = ChunkMapManager.blockStateToData(blockState);
|
||||
|
||||
manager.writeOutputBlock(blockData);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -188,6 +188,12 @@ public class ChunkReloader extends Thread implements Runnable {
|
|||
}
|
||||
|
||||
public static void addLoadedChunk(World world, int chunkX, int chunkZ) {
|
||||
if (!OrebfuscatorConfig.Enabled // Plugin enabled
|
||||
|| OrebfuscatorConfig.isWorldDisabled(world.getName())) // World not enabled
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
restart();
|
||||
|
||||
synchronized (loadedChunks) {
|
||||
|
@ -202,6 +208,12 @@ public class ChunkReloader extends Thread implements Runnable {
|
|||
}
|
||||
|
||||
public static void addUnloadedChunk(World world, int chunkX, int chunkZ) {
|
||||
if (!OrebfuscatorConfig.Enabled // Plugin enabled
|
||||
|| OrebfuscatorConfig.isWorldDisabled(world.getName())) // World not enabled
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
restart();
|
||||
|
||||
synchronized (unloadedChunks) {
|
||||
|
|
Loading…
Reference in New Issue