summaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authorAndrew Ardill <andrew.ardill@gmail.com>2011-08-12 00:19:52 +1000
committerAndrew Ardill <andrew.ardill@gmail.com>2011-08-15 15:11:34 +1000
commit1c4aba8d1fe49d33826c506b062813718f5a6889 (patch)
tree77f59d9c92098e881dadf38adbb5254a253c7928 /src/main
parentb04d766ab0d46db216a3ef7f9c036755e80bb0b4 (diff)
downloadbukkit-1c4aba8d1fe49d33826c506b062813718f5a6889.tar
bukkit-1c4aba8d1fe49d33826c506b062813718f5a6889.tar.gz
bukkit-1c4aba8d1fe49d33826c506b062813718f5a6889.tar.lz
bukkit-1c4aba8d1fe49d33826c506b062813718f5a6889.tar.xz
bukkit-1c4aba8d1fe49d33826c506b062813718f5a6889.zip
Interface for changing the view distance.
Can be changed server wide, per world and per player. Only server wide changes are kept between server restarts. Setting the server or world view distance should fail if the view distance is not between 3 and 15
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/bukkit/Server.java37
-rw-r--r--src/main/java/org/bukkit/World.java40
-rw-r--r--src/main/java/org/bukkit/entity/Player.java21
3 files changed, 83 insertions, 15 deletions
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
index d7dfe92d..e8ef29c5 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -58,13 +58,6 @@ public interface Server {
public int getPort();
/**
- * Get the view distance from this server.
- *
- * @return The view distance from this server.
- */
- public int getViewDistance();
-
- /**
* Get the IP that this server is bound to or empty string if not specified
*
* @return The IP string that this server is bound to, otherwise empty string
@@ -247,18 +240,18 @@ public interface Server {
* @return World with the given Unique ID, or null if none exists.
*/
public World getWorld(UUID uid);
-
+
/**
* Gets the map from the given item ID.
- *
+ *
* @param id ID of the map to get.
* @return The MapView if it exists, or null otherwise.
*/
public MapView getMap(short id);
-
+
/**
* Create a new map with an automatically assigned ID.
- *
+ *
* @param world The world the map will belong to.
* @return The MapView just created.
*/
@@ -346,4 +339,26 @@ public interface Server {
* @return Whether this server allows flying or not.
*/
public boolean getAllowFlight();
+
+ /**
+ * Get the default view distance of this server.
+ *
+ * The view distance is a measure of how far a player can see.
+ * It affects the number of chunks loaded and updated around every player.
+ *
+ * @return The default view distance of the server.
+ */
+ public int getViewDistance();
+
+ /**
+ * Set the default view distance for this server.
+ *
+ * The view distance is a measure of how far a player can see.
+ * It affects the number of chunks loaded and updated around every player.
+ * The view distance must be in the range [3,15].
+ *
+ * @param viewDistance an integer between 3 and 15 inclusive
+ * @throws IllegalArgumentException If view distance is less than 3 or greater than 15
+ */
+ public void setViewDistance(int viewDistance) throws IllegalArgumentException;
}
diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java
index 3c416de1..d2b83eaf 100644
--- a/src/main/java/org/bukkit/World.java
+++ b/src/main/java/org/bukkit/World.java
@@ -694,13 +694,45 @@ public interface World {
public boolean getKeepSpawnInMemory();
/**
- * Sets whether the world's spawn area should be kept loaded into memory or not.
- *
- * @param keepLoaded if true then the world's spawn area will be kept loaded into memory.
- */
+ * Sets whether the world's spawn area should be kept loaded into memory or not.
+ *
+ * @param keepLoaded if true then the world's spawn area will be kept loaded into memory.
+ */
public void setKeepSpawnInMemory(boolean keepLoaded);
/**
+ * Get the view distance of this world.
+ *
+ * The view distance is a measure of how far a player can see.
+ * It affects the number of chunks loaded and updated around every player.
+ *
+ * @return Current view distance of the world
+ */
+ public int getViewDistance();
+
+ /**
+ * Set the view distance for this world.
+ *
+ * The view distance is a measure of how far a player can see.
+ * It affects the number of chunks loaded and updated around every player.
+ * The view distance must be in the range [3,15]
+ *
+ * @param viewDistance an integer between 3 and 15 inclusive
+ * @throws IllegalArgumentException If view distance is less than 3 or greater than 15
+ */
+ public void setViewDistance(int viewDistance) throws IllegalArgumentException;
+
+ /**
+ * Set the view distance for this world back to server defaults.
+ */
+ public void resetViewDistance();
+
+ /**
+ * @return if the view distance has been set for this world
+ */
+ boolean isViewDistanceSet();
+
+ /**
* Represents various map environment types that a world may be
*/
public enum Environment {
diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java
index 706f1fd9..b00d58aa 100644
--- a/src/main/java/org/bukkit/entity/Player.java
+++ b/src/main/java/org/bukkit/entity/Player.java
@@ -300,4 +300,25 @@ public interface Player extends HumanEntity, CommandSender {
*/
public void resetPlayerTime();
+ /**
+ * Set the view distance for this player.
+ * View distance will remain constant, even between worlds, until it is changed or reset to default.
+ * @param viewDistance the number of chunks this player can see.
+ */
+ void setViewDistance(int viewDistance);
+
+ /**
+ * @return the number of chunks this player can see
+ */
+ int getViewDistance();
+
+ /**
+ * Set this players view distance back to the same as whichever world they are on.
+ */
+ void resetViewDistance();
+
+ /**
+ * @return if the view distance has been set for this player specifically.
+ */
+ boolean isViewDistanceSet();
}