Orebfuscator

This commit is contained in:
md_5 2013-06-20 18:52:23 +10:00
parent 9c9a514b77
commit 9d2daf140b
6 changed files with 109 additions and 190 deletions

View file

@ -1,4 +1,4 @@
From 7b1f1f56d04030711b34d012ffc342f5fe9c9bb4 Mon Sep 17 00:00:00 2001
From 98da2b7084a875327ad23ed8a913bf02e0e36fb6 Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Sat, 23 Mar 2013 09:52:41 +1100
Subject: [PATCH] View Distance
@ -19,60 +19,34 @@ index 0dfd190..c543bed 100644
} else {
this.e = i;
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
index 4a8d3f4..5375cb3 100644
index 6c3fcf1..614a17f 100644
--- a/src/main/java/net/minecraft/server/WorldServer.java
+++ b/src/main/java/net/minecraft/server/WorldServer.java
@@ -49,7 +49,7 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate
@@ -48,7 +48,7 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate
// CraftBukkit end
this.server = minecraftserver;
this.tracker = new EntityTracker(this);
- this.manager = new PlayerChunkMap(this, minecraftserver.getPlayerList().o());
+ this.manager = new PlayerChunkMap(this, getWorld().viewDistance); // Spigot
+ this.manager = new PlayerChunkMap(this, spigotConfig.viewDistance); // Spigot
if (this.entitiesById == null) {
this.entitiesById = new IntHashMap();
}
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index d49393d..4d022bd 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -83,6 +83,7 @@ public class CraftWorld implements World {
// Merge radius:
public double itemMergeRadius = 3.5;
public double expMergeRadius = 3.5;
+ public int viewDistance;
// Spigot end
// Spigot start
@@ -136,6 +137,9 @@ public class CraftWorld implements World {
itemMergeRadius = configuration.getDouble("world-settings." + name + ".item-merge-radius", itemMergeRadius);
expMergeRadius = configuration.getDouble("world-settings." + name + ".exp-merge-radius", expMergeRadius);
+ viewDistance = Bukkit.getServer().getViewDistance();
+ viewDistance = configuration.getInt( "world-settings." + name + ".view-distance", viewDistance );
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
index 4c16ed7..de5d17e 100644
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
@@ -128,4 +128,11 @@ public class SpigotWorldConfig
expMerge = getFloat( "merge-radius.exp", expMerge );
log( "Experience Merge Radius: " + expMerge );
}
+
if ( info )
{
server.getLogger().info( "-------------- Spigot ----------------" );
@@ -153,6 +157,7 @@ public class CraftWorld implements World {
server.getLogger().info( "Mushroom Growth Modifier: " + mushroomGrowthModifier );
server.getLogger().info( "Item Merge Radius: " + itemMergeRadius );
server.getLogger().info( "Exp Merge Radius: " + expMergeRadius );
+ server.getLogger().info( "View distance: " + viewDistance );
server.getLogger().info( "-------------------------------------------------" );
}
// Spigot end
diff --git a/src/main/resources/configurations/bukkit.yml b/src/main/resources/configurations/bukkit.yml
index 56873b6..fe257e2 100644
--- a/src/main/resources/configurations/bukkit.yml
+++ b/src/main/resources/configurations/bukkit.yml
@@ -50,6 +50,7 @@ world-settings:
world:
growth-chunks-per-tick: 1000
world_nether:
+ view-distance: 5
growth-chunks-per-tick: 0
random-light-updates: true
spawn-limits:
+ public int viewDistance;
+ private void viewDistance()
+ {
+ viewDistance = getInt( "view-distance", Bukkit.getViewDistance() );
+ log( "View Distance: " + viewDistance );
+ }
}
--
1.8.1.2

View file

@ -1,14 +1,14 @@
From a0681b71d66fe6a689ce28fd157ca6d7c07ff3a9 Mon Sep 17 00:00:00 2001
From 27aa389075a5b22ffad6e7c8d4d42b9315aa1bc0 Mon Sep 17 00:00:00 2001
From: Mike Primm <mike@primmhome.com>
Date: Wed, 16 Jan 2013 15:27:22 -0600
Subject: [PATCH] Sync Free Chunk Reference Cache
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index 1afc717..c00aa57 100644
index e353caa..a81e06d 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -299,15 +299,13 @@ public abstract class World implements IBlockAccess {
@@ -301,15 +301,13 @@ public abstract class World implements IBlockAccess {
// CraftBukkit start
public Chunk getChunkAt(int i, int j) {

View file

@ -1,4 +1,4 @@
From 1925b6e7b2f1f3f5673a20d5fd5e72c6c3effe2a Mon Sep 17 00:00:00 2001
From 47772fc5f951855c7814afa967489d5ce454554a Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Sun, 3 Feb 2013 12:28:17 +1100
Subject: [PATCH] Highly Optimized Tick Loop
@ -75,19 +75,6 @@ index 3e134fb..3c80340 100644
} else {
this.a((CrashReport) null);
}
diff --git a/src/main/java/org/bukkit/craftbukkit/Spigot.java b/src/main/java/org/bukkit/craftbukkit/Spigot.java
index fd90979..67477f4 100644
--- a/src/main/java/org/bukkit/craftbukkit/Spigot.java
+++ b/src/main/java/org/bukkit/craftbukkit/Spigot.java
@@ -10,6 +10,8 @@ public class Spigot {
private static boolean filterIps;
public static void initialize(CraftServer server, SimpleCommandMap commandMap, YamlConfiguration configuration) {
+ commandMap.register("bukkit", new org.bukkit.craftbukkit.command.TicksPerSecondCommand("tps"));
+
server.whitelistMessage = configuration.getString("settings.whitelist-message", server.whitelistMessage);
server.stopMessage = configuration.getString("settings.stop-message", server.stopMessage);
server.logCommands = configuration.getBoolean("settings.log-commands", true);
diff --git a/src/main/java/org/bukkit/craftbukkit/command/TicksPerSecondCommand.java b/src/main/java/org/bukkit/craftbukkit/command/TicksPerSecondCommand.java
new file mode 100644
index 0000000..f114a31

View file

@ -1,4 +1,4 @@
From 5f3f94a427dbc6c59a8cb7c9171f4961699ec34f Mon Sep 17 00:00:00 2001
From 48b529e33646533eb0028189bf7836e56423e991 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Thu, 10 Jan 2013 00:18:11 -0500
Subject: [PATCH] Improved Timings System
@ -213,7 +213,7 @@ index 3c80340..db396b3 100644
this.methodProfiler.b();
}
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index f6885d6..86a0acc 100644
index 52fa75a..93082ff 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -968,6 +968,7 @@ public class PlayerConnection extends Connection {
@ -233,7 +233,7 @@ index f6885d6..86a0acc 100644
}
try {
if (server.logCommands) this.minecraftServer.getLogger().info(event.getPlayer().getName() + " issued server command: " + event.getMessage()); // Spigot
if (org.spigotmc.SpigotConfig.logCommands) this.minecraftServer.getLogger().info(event.getPlayer().getName() + " issued server command: " + event.getMessage()); // Spigot
if (this.server.dispatchCommand(event.getPlayer(), event.getMessage().substring(1))) {
+ org.bukkit.craftbukkit.SpigotTimings.playerCommandTimer.stopTiming(); // Spigot
return;
@ -266,7 +266,7 @@ index db3fc42..ffa9bb6 100644
private static Map b = new HashMap();
protected World world;
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index c00aa57..4a5894a 100644
index a81e06d..da069f7 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -13,6 +13,7 @@ import java.util.concurrent.Callable;
@ -277,16 +277,16 @@ index c00aa57..4a5894a 100644
import org.bukkit.craftbukkit.util.UnsafeList;
import org.bukkit.generator.ChunkGenerator;
import org.bukkit.craftbukkit.CraftServer;
@@ -122,6 +123,8 @@ public abstract class World implements IBlockAccess {
int lastZAccessed = Integer.MIN_VALUE;
@@ -123,6 +124,8 @@ public abstract class World implements IBlockAccess {
final Object chunkLock = new Object();
public final org.spigotmc.SpigotWorldConfig spigotConfig; // Spigot
+ public final SpigotTimings.WorldTimingsHandler timings; // Spigot
+
public CraftWorld getWorld() {
return this.world;
}
@@ -199,6 +202,7 @@ public abstract class World implements IBlockAccess {
@@ -201,6 +204,7 @@ public abstract class World implements IBlockAccess {
this.a();
this.getServer().addWorld(this.world); // CraftBukkit
@ -294,7 +294,7 @@ index c00aa57..4a5894a 100644
}
protected abstract IChunkProvider j();
@@ -1271,6 +1275,7 @@ public abstract class World implements IBlockAccess {
@@ -1273,6 +1277,7 @@ public abstract class World implements IBlockAccess {
this.f.clear();
this.methodProfiler.c("regular");
@ -302,7 +302,7 @@ index c00aa57..4a5894a 100644
for (i = 0; i < this.entityList.size(); ++i) {
entity = (Entity) this.entityList.get(i);
@@ -1293,7 +1298,9 @@ public abstract class World implements IBlockAccess {
@@ -1295,7 +1300,9 @@ public abstract class World implements IBlockAccess {
this.methodProfiler.a("tick");
if (!entity.dead) {
try {
@ -312,7 +312,7 @@ index c00aa57..4a5894a 100644
} catch (Throwable throwable1) {
crashreport = CrashReport.a(throwable1, "Ticking entity");
crashreportsystemdetails = crashreport.a("Entity being ticked");
@@ -1318,7 +1325,9 @@ public abstract class World implements IBlockAccess {
@@ -1320,7 +1327,9 @@ public abstract class World implements IBlockAccess {
this.methodProfiler.b();
}
@ -322,7 +322,7 @@ index c00aa57..4a5894a 100644
this.N = true;
Iterator iterator = this.tileEntityList.iterator();
@@ -1333,8 +1342,11 @@ public abstract class World implements IBlockAccess {
@@ -1335,8 +1344,11 @@ public abstract class World implements IBlockAccess {
if (!tileentity.r() && tileentity.o() && this.isLoaded(tileentity.x, tileentity.y, tileentity.z)) {
try {
@ -334,7 +334,7 @@ index c00aa57..4a5894a 100644
crashreport = CrashReport.a(throwable2, "Ticking tile entity");
crashreportsystemdetails = crashreport.a("Tile entity being ticked");
tileentity.a(crashreportsystemdetails);
@@ -1354,6 +1366,8 @@ public abstract class World implements IBlockAccess {
@@ -1356,6 +1368,8 @@ public abstract class World implements IBlockAccess {
}
}
@ -343,7 +343,7 @@ index c00aa57..4a5894a 100644
this.N = false;
if (!this.b.isEmpty()) {
this.tileEntityList.removeAll(this.b);
@@ -1392,6 +1406,7 @@ public abstract class World implements IBlockAccess {
@@ -1394,6 +1408,7 @@ public abstract class World implements IBlockAccess {
this.a.clear();
}
@ -351,7 +351,7 @@ index c00aa57..4a5894a 100644
this.methodProfiler.b();
this.methodProfiler.b();
}
@@ -1414,6 +1429,7 @@ public abstract class World implements IBlockAccess {
@@ -1416,6 +1431,7 @@ public abstract class World implements IBlockAccess {
byte b0 = 32;
if (!flag || this.e(i - b0, 0, j - b0, i + b0, 0, j + b0)) {
@ -359,7 +359,7 @@ index c00aa57..4a5894a 100644
entity.U = entity.locX;
entity.V = entity.locY;
entity.W = entity.locZ;
@@ -1475,6 +1491,7 @@ public abstract class World implements IBlockAccess {
@@ -1477,6 +1493,7 @@ public abstract class World implements IBlockAccess {
entity.passenger = null;
}
}
@ -368,10 +368,10 @@ index c00aa57..4a5894a 100644
}
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
index 5375cb3..7b8e70c 100644
index 614a17f..69d955f 100644
--- a/src/main/java/net/minecraft/server/WorldServer.java
+++ b/src/main/java/net/minecraft/server/WorldServer.java
@@ -184,9 +184,12 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate
@@ -183,9 +183,12 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate
// CraftBukkit start - Only call spawner if we have players online and the world allows for mobs or animals
long time = this.worldData.getTime();
if (this.getGameRules().getBoolean("doMobSpawning") && (this.allowMonsters || this.allowAnimals) && (this instanceof WorldServer && this.players.size() > 0)) {
@ -384,7 +384,7 @@ index 5375cb3..7b8e70c 100644
this.methodProfiler.c("chunkSource");
this.chunkProvider.unloadChunks();
int j = this.a(1.0F);
@@ -197,21 +200,36 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate
@@ -196,21 +199,36 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate
this.worldData.setTime(this.worldData.getTime() + 1L);
this.worldData.setDayTime(this.worldData.getDayTime() + 1L);

View file

@ -1,47 +1,47 @@
From d270363d40175512df3af1f7dbbb4722d6ab684a Mon Sep 17 00:00:00 2001
From c50921dc69979fb97674486de51a073d19273170 Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Thu, 16 May 2013 18:51:05 +1000
Subject: [PATCH] Orebfuscator
diff --git a/src/main/java/net/minecraft/server/EntityFallingBlock.java b/src/main/java/net/minecraft/server/EntityFallingBlock.java
index 17d837d..d38eb4d 100644
index 17d837d..c7cd0ca 100644
--- a/src/main/java/net/minecraft/server/EntityFallingBlock.java
+++ b/src/main/java/net/minecraft/server/EntityFallingBlock.java
@@ -94,6 +94,7 @@ public class EntityFallingBlock extends Entity {
}
this.world.setAir(i, j, k);
+ org.spigotmc.OrebfuscatorManager.updateNearbyBlocks(world, i, j, k); // Spigot
+ world.spigotConfig.antiXrayInstance.updateNearbyBlocks(world, i, j, k); // Spigot
}
if (this.onGround) {
diff --git a/src/main/java/net/minecraft/server/Explosion.java b/src/main/java/net/minecraft/server/Explosion.java
index ef220c1..ae1cee9 100644
index ef220c1..2063769 100644
--- a/src/main/java/net/minecraft/server/Explosion.java
+++ b/src/main/java/net/minecraft/server/Explosion.java
@@ -240,6 +240,7 @@ public class Explosion {
j = chunkposition.y;
k = chunkposition.z;
l = this.world.getTypeId(i, j, k);
+ org.spigotmc.OrebfuscatorManager.updateNearbyBlocks(world, i, j, k); // Spigot
+ world.spigotConfig.antiXrayInstance.updateNearbyBlocks(world, i, j, k); // Spigot
if (flag) {
double d0 = (double) ((float) i + this.world.random.nextFloat());
double d1 = (double) ((float) j + this.world.random.nextFloat());
diff --git a/src/main/java/net/minecraft/server/Packet51MapChunk.java b/src/main/java/net/minecraft/server/Packet51MapChunk.java
index d11c0ea..7711629 100644
index d11c0ea..efe102e 100644
--- a/src/main/java/net/minecraft/server/Packet51MapChunk.java
+++ b/src/main/java/net/minecraft/server/Packet51MapChunk.java
@@ -46,6 +46,7 @@ public class Packet51MapChunk extends Packet {
this.d = chunkmap.c;
this.c = chunkmap.b;
+ org.spigotmc.OrebfuscatorManager.obfuscateSync(chunk.x, chunk.z, i, chunkmap.a, chunk.world); // Spigot
+ chunk.world.spigotConfig.antiXrayInstance.obfuscateSync(chunk.x, chunk.z, i, chunkmap.a, chunk.world); // Spigot
try {
this.inflatedBuffer = chunkmap.a;
diff --git a/src/main/java/net/minecraft/server/Packet56MapChunkBulk.java b/src/main/java/net/minecraft/server/Packet56MapChunkBulk.java
index 129dc4f..ce28495 100644
index 129dc4f..a2cd9b0 100644
--- a/src/main/java/net/minecraft/server/Packet56MapChunkBulk.java
+++ b/src/main/java/net/minecraft/server/Packet56MapChunkBulk.java
@@ -28,6 +28,7 @@ public class Packet56MapChunkBulk extends Packet {
@ -79,7 +79,7 @@ index 129dc4f..ce28495 100644
+ int finalBufferSize = 0;
+ // Obfuscate all sections
+ for (int i = 0; i < a.length; i++) {
+ org.spigotmc.OrebfuscatorManager.obfuscate(c[i], d[i], a[i], inflatedBuffers[i], world);
+ world.spigotConfig.antiXrayInstance.obfuscate(c[i], d[i], a[i], inflatedBuffers[i], world);
+ finalBufferSize += inflatedBuffers[i].length;
+ }
+
@ -95,110 +95,45 @@ index 129dc4f..ce28495 100644
Deflater deflater = localDeflater.get();
deflater.reset();
diff --git a/src/main/java/net/minecraft/server/PlayerInteractManager.java b/src/main/java/net/minecraft/server/PlayerInteractManager.java
index 1243d1d..e45bcd2 100644
index 1243d1d..9ec8997 100644
--- a/src/main/java/net/minecraft/server/PlayerInteractManager.java
+++ b/src/main/java/net/minecraft/server/PlayerInteractManager.java
@@ -184,6 +184,7 @@ public class PlayerInteractManager {
this.o = j1;
}
}
+ org.spigotmc.OrebfuscatorManager.updateNearbyBlocks(world, i, j, k); // Spigot
+ world.spigotConfig.antiXrayInstance.updateNearbyBlocks(world, i, j, k); // Spigot
}
}
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index c234cac..82dfef1 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -163,6 +163,12 @@ public final class CraftServer implements Server {
private final BooleanWrapper online = new BooleanWrapper();
public CraftScoreboardManager scoreboardManager;
+ // Orebfuscator use
+ public boolean orebfuscatorEnabled = false;
+ public int orebfuscatorEngineMode = 1;
+ public List<String> orebfuscatorDisabledWorlds;
+ public List<Short> orebfuscatorBlocks;
+
private final class BooleanWrapper {
private boolean value = true;
}
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index 4d022bd..0a39ed3 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -84,6 +84,7 @@ public class CraftWorld implements World {
public double itemMergeRadius = 3.5;
public double expMergeRadius = 3.5;
public int viewDistance;
+ public boolean obfuscated = false;
// Spigot end
// Spigot start
@@ -139,6 +140,7 @@ public class CraftWorld implements World {
viewDistance = Bukkit.getServer().getViewDistance();
viewDistance = configuration.getInt( "world-settings." + name + ".view-distance", viewDistance );
+ obfuscated = world.getServer().orebfuscatorEnabled && !world.getServer().orebfuscatorDisabledWorlds.contains( name );
if ( info )
{
@@ -158,6 +160,7 @@ public class CraftWorld implements World {
server.getLogger().info( "Item Merge Radius: " + itemMergeRadius );
server.getLogger().info( "Exp Merge Radius: " + expMergeRadius );
server.getLogger().info( "View distance: " + viewDistance );
+ server.getLogger().info( "Orebfuscator: " + obfuscated );
server.getLogger().info( "-------------------------------------------------" );
}
// Spigot end
diff --git a/src/main/java/org/bukkit/craftbukkit/Spigot.java b/src/main/java/org/bukkit/craftbukkit/Spigot.java
index 67477f4..e5004b3 100644
--- a/src/main/java/org/bukkit/craftbukkit/Spigot.java
+++ b/src/main/java/org/bukkit/craftbukkit/Spigot.java
@@ -19,6 +19,14 @@ public class Spigot {
server.spamGuardExclusions = configuration.getStringList("settings.spam-exclusions");
filterIps = configuration.getBoolean("settings.filter-unsafe-ips", false);
+ server.orebfuscatorEnabled = configuration.getBoolean("orebfuscator.enable", false);
+ server.orebfuscatorEngineMode = configuration.getInt("orebfuscator.engine-mode", 1);
+ server.orebfuscatorDisabledWorlds = configuration.getStringList("orebfuscator.disabled-worlds");
+ server.orebfuscatorBlocks = configuration.getShortList("orebfuscator.blocks");
+ if (server.orebfuscatorEngineMode != 1 && server.orebfuscatorEngineMode != 2) {
+ server.orebfuscatorEngineMode = 1;
+ }
+
if (server.chunkGCPeriod == 0) {
server.getLogger().severe("[Spigot] You should not disable chunk-gc, unexpected behaviour may occur!");
}
diff --git a/src/main/java/org/spigotmc/OrebfuscatorManager.java b/src/main/java/org/spigotmc/OrebfuscatorManager.java
diff --git a/src/main/java/org/spigotmc/AntiXray.java b/src/main/java/org/spigotmc/AntiXray.java
new file mode 100644
index 0000000..aa1ddfc
index 0000000..74ee741
--- /dev/null
+++ b/src/main/java/org/spigotmc/OrebfuscatorManager.java
@@ -0,0 +1,204 @@
+++ b/src/main/java/org/spigotmc/AntiXray.java
@@ -0,0 +1,203 @@
+package org.spigotmc;
+
+import gnu.trove.set.TByteSet;
+import gnu.trove.set.hash.TByteHashSet;
+import net.minecraft.server.Block;
+import net.minecraft.server.MinecraftServer;
+import net.minecraft.server.World;
+
+public class OrebfuscatorManager
+public class AntiXray
+{
+
+ private static final CustomTimingsHandler update = new CustomTimingsHandler( "xray - update" );
+ private static final CustomTimingsHandler obfuscate = new CustomTimingsHandler( "xray - obfuscate" );
+ /*========================================================================*/
+ // Used to keep track of which blocks to obfuscate
+ private static final boolean[] obfuscateBlocks = new boolean[ Short.MAX_VALUE ];
+ private final boolean[] obfuscateBlocks = new boolean[ Short.MAX_VALUE ];
+ // Used to select a random replacement ore
+ private static byte[] replacementOres;
+ private byte[] replacementOres;
+
+ static
+ public AntiXray(SpigotWorldConfig config)
+ {
+ // Set all listed blocks as true to be obfuscated
+ for ( short id : MinecraftServer.getServer().server.orebfuscatorBlocks )
+ for ( short id : config.blocks )
+ {
+ obfuscateBlocks[id] = true;
+ }
@ -227,9 +162,9 @@ index 0000000..aa1ddfc
+ * Starts the timings handler, then updates all blocks within the set radius
+ * of the given coordinate, revealing them if they are hidden ores.
+ */
+ public static void updateNearbyBlocks(World world, int x, int y, int z)
+ public void updateNearbyBlocks(World world, int x, int y, int z)
+ {
+ if ( world.getWorld().obfuscated )
+ if ( world.spigotConfig.antiXray )
+ {
+ update.startTiming();
+ updateNearbyBlocks( world, x, y, z, 2 ); // 2 is the radius, we shouldn't change it as that would make it exponentially slower
@ -241,9 +176,9 @@ index 0000000..aa1ddfc
+ * Starts the timings handler, and then removes all non exposed ores from
+ * the chunk buffer.
+ */
+ public static void obfuscateSync(int chunkX, int chunkY, int bitmask, byte[] buffer, World world)
+ public void obfuscateSync(int chunkX, int chunkY, int bitmask, byte[] buffer, World world)
+ {
+ if ( world.getWorld().obfuscated )
+ if ( world.spigotConfig.antiXray )
+ {
+ obfuscate.startTiming();
+ obfuscate( chunkX, chunkY, bitmask, buffer, world );
@ -254,10 +189,10 @@ index 0000000..aa1ddfc
+ /**
+ * Removes all non exposed ores from the chunk buffer.
+ */
+ public static void obfuscate(int chunkX, int chunkY, int bitmask, byte[] buffer, World world)
+ public void obfuscate(int chunkX, int chunkY, int bitmask, byte[] buffer, World world)
+ {
+ // If the world is marked as obfuscated
+ if ( world.getWorld().obfuscated )
+ if ( world.spigotConfig.antiXray )
+ {
+ // Initial radius to search around for air
+ int initialRadius = 1;
@ -297,7 +232,7 @@ index 0000000..aa1ddfc
+ // On the otherhand, if radius is 0, or the nearby blocks are all non air, we can obfuscate
+ if ( initialRadius == 0 || !hasTransparentBlockAdjacent( world, startX + x, ( i << 4 ) + y, startZ + z, initialRadius ) )
+ {
+ switch ( world.getServer().orebfuscatorEngineMode )
+ switch ( world.spigotConfig.engineMode )
+ {
+ case 1:
+ // Replace with stone
@ -328,7 +263,7 @@ index 0000000..aa1ddfc
+ }
+ }
+
+ private static void updateNearbyBlocks(World world, int x, int y, int z, int radius)
+ private void updateNearbyBlocks(World world, int x, int y, int z, int radius)
+ {
+ // If the block in question is loaded
+ if ( world.isLoaded( x, y, z ) )
@ -380,20 +315,43 @@ index 0000000..aa1ddfc
+ || hasTransparentBlockAdjacent( world, x, y, z - 1, radius - 1 ) ) );
+ }
+}
diff --git a/src/main/resources/configurations/bukkit.yml b/src/main/resources/configurations/bukkit.yml
index fe257e2..7860ccc 100644
--- a/src/main/resources/configurations/bukkit.yml
+++ b/src/main/resources/configurations/bukkit.yml
@@ -81,3 +81,9 @@ database:
driver: org.sqlite.JDBC
password: walrus
url: jdbc:sqlite:{DIR}{NAME}.db
+orebfuscator:
+ enable: false
+ engine-mode: 1
+ disabled-worlds:
+ - world_the_end
+ blocks: [1, 5, 14, 15, 16, 21, 48, 49, 54, 56, 73, 74, 82, 129, 130]
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
index de5d17e..2f514a0 100644
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
@@ -1,5 +1,6 @@
package org.spigotmc;
+import java.util.Arrays;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.YamlConfiguration;
@@ -135,4 +136,25 @@ public class SpigotWorldConfig
viewDistance = getInt( "view-distance", Bukkit.getViewDistance() );
log( "View Distance: " + viewDistance );
}
+
+ public boolean antiXray = true;
+ public int engineMode = 1;
+ public List<Short> blocks = Arrays.asList( new Short[]
+ {
+ 1, 5, 14, 15, 16, 21, 48, 49, 54, 56, 73, 74, 82, 129, 130
+ } );
+ public AntiXray antiXrayInstance;
+ private void antiXray()
+ {
+ antiXray = getBoolean( "anti-xray.enabled", antiXray );
+ log( "Anti X-Ray: " + antiXray );
+
+ engineMode = getInt( "anti-xray.engine-mode", engineMode );
+ log( "\tEngine Mode: " + engineMode );
+
+ blocks = getList( "anti-xray.blocks", blocks );
+ log( "\tBlocks: " + blocks );
+
+ antiXrayInstance = new AntiXray( this );
+ }
}
--
1.8.1.2

View file

@ -1,14 +1,14 @@
From 4cc67e6337594077f65722dff9e59db7ea30204f Mon Sep 17 00:00:00 2001
From 6231d399bc448b884b4b85b68f3ef632605b1ebd Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Sun, 3 Feb 2013 09:20:19 +1100
Subject: [PATCH] Handle Null Tile Entities
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index 4a5894a..3c6b51a 100644
index da069f7..d4d8f04 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -1333,6 +1333,13 @@ public abstract class World implements IBlockAccess {
@@ -1335,6 +1335,13 @@ public abstract class World implements IBlockAccess {
while (iterator.hasNext()) {
TileEntity tileentity = (TileEntity) iterator.next();