Implements interface for changing the view distance.

Uses default view distance if player's view distance is not set

Throws an illegal argument exception if view distance is set too high
or too low.

Pushes notifications of server and world view distance changes to the player.
Move view distance functions from PlayerManger to WorldServer.
Set player minimum view distance to 1 for now.
Reset player's 'last known' position when recalculating visible chunks.

Use per-player view distance in chunk distance checks
This commit is contained in:
Andrew Ardill
2011-08-12 00:37:22 +10:00
committed by unknown
parent a6c03ded28
commit 12e377501e
7 changed files with 294 additions and 33 deletions

View File

@@ -46,6 +46,7 @@ public class ServerConfigurationManager {
// CraftBukkit start
private CraftServer cserver;
private int viewDistance;
public ServerConfigurationManager(MinecraftServer minecraftserver) {
minecraftserver.server = new CraftServer(minecraftserver, this);
@@ -58,7 +59,7 @@ public class ServerConfigurationManager {
this.k = minecraftserver.a("banned-ips.txt");
this.l = minecraftserver.a("ops.txt");
this.m = minecraftserver.a("white-list.txt");
int i = minecraftserver.propertyManager.getInt("view-distance", 10);
this.viewDistance = minecraftserver.propertyManager.getInt("view-distance", 10); // CraftBukkit - add field viewDistance
// CraftBukkit - removed playermanagers
this.maxPlayers = minecraftserver.propertyManager.getInt("max-players", 20);
@@ -95,7 +96,7 @@ public class ServerConfigurationManager {
public int a() {
// CraftBukkit start
if (this.server.worlds.size() == 0) {
return this.server.propertyManager.getInt("view-distance", 10) * 16 - 16;
return this.viewDistance * 16 - 16; // Use field value
}
return this.server.worlds.get(0).manager.getFurthestViewableBlock();
// CraftBukkit end
@@ -637,4 +638,19 @@ public class ServerConfigurationManager {
entityplayer.updateInventory(entityplayer.defaultContainer);
entityplayer.C();
}
// CraftBukkit start - getters and setters for viewDistance
public void setViewDistance(int viewDistance) {
this.viewDistance = viewDistance;
}
public int getViewDistance() {
return viewDistance;
}
public void saveViewDistance() {
this.server.propertyManager.properties.setProperty("view-distance", Integer.toString(this.viewDistance));
this.server.propertyManager.savePropertiesFile();
}
// CraftBukkit end
}