mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-26 22:40:21 +01:00
Added Location
By: Dinnerbone <dinnerbone@dinnerbone.com>
This commit is contained in:
parent
a2d9b84796
commit
e364e973c7
3 changed files with 145 additions and 0 deletions
124
paper-api/src/org/bukkit/Location.java
Normal file
124
paper-api/src/org/bukkit/Location.java
Normal file
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue