mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2024-11-22 18:47:20 +01:00
Destination fixes.
This commit is contained in:
parent
45c76d8faa
commit
9bf993ef12
@ -12,4 +12,5 @@ public abstract class Destination {
|
||||
public abstract void setDestination(MultiverseCore plugin, String dest);
|
||||
public abstract String getType();
|
||||
public abstract String getName();
|
||||
public abstract String toString();
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ import org.bukkit.Location;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
|
||||
public class ExactDestination extends Destination {
|
||||
private final String coordRegex = "([\\d]+\\.?[\\d]*),([\\d]+\\.?[\\d]*),([\\d]+\\.?[\\d]*)";
|
||||
private final String coordRegex = "(-?[\\d]+\\.?[\\d]*),(-?[\\d]+\\.?[\\d]*),(-?[\\d]+\\.?[\\d]*)";
|
||||
private boolean isValid;
|
||||
private Location location;
|
||||
|
||||
@ -57,7 +57,7 @@ public class ExactDestination extends Destination {
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
|
||||
} catch (NumberFormatException e) {
|
||||
return false;
|
||||
}
|
||||
@ -113,13 +113,12 @@ public class ExactDestination extends Destination {
|
||||
this.location.setX(coords[0]);
|
||||
this.location.setY(coords[1]);
|
||||
this.location.setZ(coords[2]);
|
||||
|
||||
if(parsed.size() == 3) {
|
||||
|
||||
if (parsed.size() == 3) {
|
||||
this.isValid = true;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
try {
|
||||
this.location.setPitch(Float.parseFloat(parsed.get(3)));
|
||||
this.location.setYaw(Float.parseFloat(parsed.get(4)));
|
||||
@ -128,7 +127,7 @@ public class ExactDestination extends Destination {
|
||||
return;
|
||||
}
|
||||
this.isValid = true;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -138,6 +137,22 @@ public class ExactDestination extends Destination {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Exact (" + this.location.getX() + ", "+ this.location.getY() + ", "+ this.location.getZ() + ")";
|
||||
return "Exact (" + this.location.getX() + ", " + this.location.getY() + ", " + this.location.getZ() + ")";
|
||||
}
|
||||
|
||||
public void setDestination(Location location) {
|
||||
if (location != null) {
|
||||
this.location = location;
|
||||
this.isValid = false;
|
||||
}
|
||||
this.isValid = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (isValid) {
|
||||
return "e:" + location.getWorld().getName() + ":" + location.getX() + "," + location.getY() + "," + location.getZ() + ": " + location.getX() + ":" + location.getX();
|
||||
}
|
||||
return "i:Invalid Destination";
|
||||
}
|
||||
}
|
||||
|
@ -42,4 +42,9 @@ public class InvalidDestination extends Destination {
|
||||
return ChatColor.RED + "Invalid Destination";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "i:Invalid Destination";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -68,4 +68,9 @@ public class WorldDestination extends Destination {
|
||||
return this.world.getColoredWorldString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.world.getCBWorld().getName();
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user