85 lines
2.3 KiB
Java
85 lines
2.3 KiB
Java
package com.zerohighdef.geoffrey.Models;
|
|
|
|
import com.google.gson.JsonElement;
|
|
import com.google.gson.JsonObject;
|
|
import org.bukkit.ChatColor;
|
|
|
|
public class GeoffreyLocation {
|
|
private int xCoord;
|
|
private int zCoord;
|
|
private String locationName;
|
|
private GeoffreyPlayer owner;
|
|
private String dimension;
|
|
private String tunnelString = null;
|
|
private String link = null;
|
|
|
|
public GeoffreyLocation(JsonObject locationJSON) {
|
|
this.xCoord = locationJSON.get("x_coord").getAsInt();
|
|
this.zCoord = locationJSON.get("z_coord").getAsInt();
|
|
this.locationName = locationJSON.get("name").getAsString();
|
|
this.owner = new GeoffreyPlayer(locationJSON.getAsJsonArray("owner").getAsJsonArray().get(0).getAsJsonObject());
|
|
this.dimension = locationJSON.get("dimension").getAsString();
|
|
this.link = locationJSON.get("link").getAsString();
|
|
|
|
JsonElement tunnelElement = locationJSON.get("tunnel");
|
|
|
|
if (!tunnelElement.isJsonNull()) {
|
|
this.tunnelString = tunnelElement.getAsString();
|
|
}
|
|
}
|
|
|
|
public GeoffreyLocation(int xCoord, int zCoord, String locationName, GeoffreyPlayer owner, String dimension) {
|
|
this.xCoord = xCoord;
|
|
this.zCoord = zCoord;
|
|
this.locationName = locationName;
|
|
this.owner = owner;
|
|
this.dimension = dimension;
|
|
}
|
|
|
|
public String getPositionString() {
|
|
return "(x=" + xCoord + ",z=" + zCoord + ")";
|
|
}
|
|
|
|
public String getFormattedLocationString() {
|
|
String locationString = locationName + " @ " + getPositionString() + " Owner: " + owner.getUsername();
|
|
|
|
if (tunnelString != null) {
|
|
locationString += " Tunnel: " + tunnelString;
|
|
}
|
|
|
|
return locationString;
|
|
}
|
|
|
|
public String getInfoString() {
|
|
return ChatColor.BOLD + getFormattedLocationString().replace(" ", " " + ChatColor.BOLD) + ChatColor.RESET;
|
|
}
|
|
|
|
public int getxCoord() {
|
|
return xCoord;
|
|
}
|
|
|
|
public int getzCoord() {
|
|
return zCoord;
|
|
}
|
|
|
|
public String getLocationName() {
|
|
return locationName;
|
|
}
|
|
|
|
public GeoffreyPlayer getOwner() {
|
|
return owner;
|
|
}
|
|
|
|
public String getDimension() {
|
|
return dimension;
|
|
}
|
|
|
|
public String getTunnel() {
|
|
return tunnelString;
|
|
}
|
|
|
|
public String getLink() {
|
|
return link;
|
|
}
|
|
}
|