Add server spawn protection config option as per someh4x0r's request.

This commit is contained in:
LexManos 2012-04-06 23:15:46 -07:00
parent 82ef183b5b
commit 6e93f65ba1
3 changed files with 45 additions and 10 deletions

View file

@ -44,7 +44,24 @@
/** True if the server is in online mode. */ /** True if the server is in online mode. */
public boolean onlineMode; public boolean onlineMode;
@@ -195,9 +199,11 @@ @@ -129,6 +133,8 @@
public long[] field_48082_x = new long[100];
private RConThreadQuery rconQueryThread;
private RConThreadMain rconMainThread;
+
+ public int spawnProtectionSize = 16;
public MinecraftServer()
{
@@ -163,6 +169,7 @@
this.allowFlight = this.propertyManagerObj.getBooleanProperty("allow-flight", false);
this.motd = this.propertyManagerObj.getStringProperty("motd", "A Minecraft Server");
this.motd.replace('\u00a7', '$');
+ spawnProtectionSize = this.propertyManagerObj.getIntProperty("spawn-protection-size", 16);
InetAddress var2 = null;
if (this.hostname.length() > 0)
@@ -195,9 +202,11 @@
FMLServerHandler.instance().onLoadComplete(); FMLServerHandler.instance().onLoadComplete();
this.configManager = new ServerConfigurationManager(this); this.configManager = new ServerConfigurationManager(this);
@ -56,7 +73,7 @@
long var3 = System.nanoTime(); long var3 = System.nanoTime();
String var5 = this.propertyManagerObj.getStringProperty("level-name", "world"); String var5 = this.propertyManagerObj.getStringProperty("level-name", "world");
String var6 = this.propertyManagerObj.getStringProperty("level-seed", ""); String var6 = this.propertyManagerObj.getStringProperty("level-seed", "");
@@ -265,53 +271,36 @@ @@ -265,53 +274,36 @@
logger.info("Converting map!"); logger.info("Converting map!");
par1ISaveFormat.convertMapFormat(par2Str, new ConvertProgressUpdater(this)); par1ISaveFormat.convertMapFormat(par2Str, new ConvertProgressUpdater(this));
} }
@ -126,7 +143,7 @@
ChunkCoordinates var15 = var14.getSpawnPoint(); ChunkCoordinates var15 = var14.getSpawnPoint();
for (int var16 = -var22; var16 <= var22 && this.serverRunning; var16 += 16) for (int var16 = -var22; var16 <= var22 && this.serverRunning; var16 += 16)
@@ -372,9 +361,9 @@ @@ -372,9 +364,9 @@
{ {
logger.info("Saving chunks"); logger.info("Saving chunks");
@ -138,7 +155,7 @@
var2.saveWorld(true, (IProgressUpdate)null); var2.saveWorld(true, (IProgressUpdate)null);
var2.func_30006_w(); var2.func_30006_w();
} }
@@ -392,13 +381,14 @@ @@ -392,13 +384,14 @@
this.configManager.savePlayerStates(); this.configManager.savePlayerStates();
} }
@ -155,7 +172,7 @@
} }
} }
} }
@@ -440,7 +430,7 @@ @@ -440,7 +433,7 @@
var3 += var7; var3 += var7;
var1 = var5; var1 = var5;
@ -164,7 +181,7 @@
{ {
this.doTick(); this.doTick();
var3 = 0L; var3 = 0L;
@@ -542,13 +532,13 @@ @@ -542,13 +535,13 @@
Vec3D.initialize(); Vec3D.initialize();
++this.deathTime; ++this.deathTime;
@ -181,7 +198,7 @@
if (this.deathTime % 20 == 0) if (this.deathTime % 20 == 0)
{ {
@@ -567,15 +557,15 @@ @@ -567,15 +560,15 @@
} }
} }
@ -200,7 +217,7 @@
} }
for (var9 = 0; var9 < this.playersOnline.size(); ++var9) for (var9 = 0; var9 < this.playersOnline.size(); ++var9)
@@ -689,7 +679,8 @@ @@ -689,7 +682,8 @@
*/ */
public WorldServer getWorldManager(int par1) public WorldServer getWorldManager(int par1)
{ {
@ -210,7 +227,7 @@
} }
/** /**
@@ -697,7 +688,7 @@ @@ -697,7 +691,7 @@
*/ */
public EntityTracker getEntityTracker(int par1) public EntityTracker getEntityTracker(int par1)
{ {

View file

@ -32,6 +32,15 @@
{ {
return; return;
} }
@@ -397,7 +403,7 @@
if (par1Packet14BlockDig.status == 0)
{
- if (var20 <= 16 && !var3)
+ if (var20 <= mcServer.spawnProtectionSize && !var3)
{
this.playerEntity.playerNetServerHandler.sendPacket(new Packet53BlockChange(var5, var6, var7, var2));
}
@@ -467,8 +473,9 @@ @@ -467,8 +473,9 @@
{ {
var12 = var11; var12 = var11;
@ -40,7 +49,7 @@
- if (this.hasMoved && this.playerEntity.getDistanceSq((double)var5 + 0.5D, (double)var6 + 0.5D, (double)var7 + 0.5D) < 64.0D && (var12 > 16 || var9)) - if (this.hasMoved && this.playerEntity.getDistanceSq((double)var5 + 0.5D, (double)var6 + 0.5D, (double)var7 + 0.5D) < 64.0D && (var12 > 16 || var9))
+ double dist = playerEntity.itemInWorldManager.getBlockReachDistance() + 1; + double dist = playerEntity.itemInWorldManager.getBlockReachDistance() + 1;
+ dist *= dist; + dist *= dist;
+ if (this.hasMoved && this.playerEntity.getDistanceSq((double)var5 + 0.5D, (double)var6 + 0.5D, (double)var7 + 0.5D) < dist && (var12 > 16 || var9)) + if (this.hasMoved && this.playerEntity.getDistanceSq((double)var5 + 0.5D, (double)var6 + 0.5D, (double)var7 + 0.5D) < dist && (var12 > mcServer.spawnProtectionSize || var9))
{ {
this.playerEntity.itemInWorldManager.activeBlockOrUseItem(this.playerEntity, var2, var3, var5, var6, var7, var8); this.playerEntity.itemInWorldManager.activeBlockOrUseItem(this.playerEntity, var2, var3, var5, var6, var7, var8);
} }

View file

@ -60,3 +60,12 @@
} }
} }
@@ -99,7 +117,7 @@
var6 = var5;
}
- return var6 > 16 || this.mcServer.configManager.isOp(par1EntityPlayer.username);
+ return var6 > mcServer.spawnProtectionSize || this.mcServer.configManager.isOp(par1EntityPlayer.username);
}
/**