summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/org/bukkit/Location.java124
-rw-r--r--src/org/bukkit/Player.java14
-rw-r--r--src/org/bukkit/Server.java7
3 files changed, 145 insertions, 0 deletions
diff --git a/src/org/bukkit/Location.java b/src/org/bukkit/Location.java
new file mode 100644
index 00000000..4da77ad1
--- /dev/null
+++ b/src/org/bukkit/Location.java
@@ -0,0 +1,124 @@
+
+package org.bukkit;
+
+/**
+ * Represents a 3-dimensional position in a world
+ */
+public class Location {
+ private World world;
+ private double x;
+ private double y;
+ private double z;
+
+ public Location(final World world, final double x, final double y, final double z) {
+ this.world = world;
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ }
+
+ /**
+ * Sets the world that this location resides in
+ *
+ * @param world New world that this location resides in
+ */
+ public void setWorld(World world) {
+ this.world = world;
+ }
+
+ /**
+ * Gets the world that this location resides in
+ *
+ * @return World that contains this location
+ */
+ public World getWorld() {
+ return world;
+ }
+
+ /**
+ * Sets the x-coordinate of this location
+ *
+ * @param x X-coordinate
+ */
+ public void setX(double x) {
+ this.x = x;
+ }
+
+ /**
+ * Gets the x-coordinate of this location
+ *
+ * @return x-coordinate
+ */
+ public double getX() {
+ return x;
+ }
+
+ /**
+ * Sets the y-coordinate of this location
+ *
+ * @param y y-coordinate
+ */
+ public void setY(double y) {
+ this.y = y;
+ }
+
+ /**
+ * Gets the y-coordinate of this location
+ *
+ * @return y-coordinate
+ */
+ public double getY() {
+ return y;
+ }
+
+ /**
+ * Sets the z-coordinate of this location
+ *
+ * @param z z-coordinate
+ */
+ public void setZ(double z) {
+ this.z = z;
+ }
+
+ /**
+ * Gets the z-coordinate of this location
+ *
+ * @return z-coordinate
+ */
+ public double getZ() {
+ return z;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final Location other = (Location) obj;
+ if (this.world != other.world && (this.world == null || !this.world.equals(other.world))) {
+ return false;
+ }
+ if (Double.doubleToLongBits(this.x) != Double.doubleToLongBits(other.x)) {
+ return false;
+ }
+ if (Double.doubleToLongBits(this.y) != Double.doubleToLongBits(other.y)) {
+ return false;
+ }
+ if (Double.doubleToLongBits(this.z) != Double.doubleToLongBits(other.z)) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = 7;
+ hash = 23 * hash + (int) (Double.doubleToLongBits(this.x) ^ (Double.doubleToLongBits(this.x) >>> 32));
+ hash = 23 * hash + (int) (Double.doubleToLongBits(this.y) ^ (Double.doubleToLongBits(this.y) >>> 32));
+ hash = 23 * hash + (int) (Double.doubleToLongBits(this.z) ^ (Double.doubleToLongBits(this.z) >>> 32));
+ return hash;
+ }
+}
diff --git a/src/org/bukkit/Player.java b/src/org/bukkit/Player.java
index 3d143849..f12efa08 100644
--- a/src/org/bukkit/Player.java
+++ b/src/org/bukkit/Player.java
@@ -19,4 +19,18 @@ public interface Player {
* @return true if they are online
*/
public boolean isOnline();
+
+ /**
+ * Gets the players current position in the world
+ *
+ * @return Location of this player
+ */
+ public Location getLocation();
+
+ /**
+ * Gets the current world this player is on
+ *
+ * @return World
+ */
+ public World getWorld();
}
diff --git a/src/org/bukkit/Server.java b/src/org/bukkit/Server.java
index 2c2fae84..1019423f 100644
--- a/src/org/bukkit/Server.java
+++ b/src/org/bukkit/Server.java
@@ -34,4 +34,11 @@ public interface Server {
* @return PluginManager for this Server instance
*/
public PluginManager getPluginManager();
+
+ /**
+ * Gets a list of all worlds on this server
+ *
+ * @return An array of worlds
+ */
+ public World[] getWorlds();
}