mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2024-12-01 23:14:15 +01:00
Allow World Destinations to have a direction.
This commit is contained in:
parent
f9db8ef7f9
commit
4c4fd08dc8
@ -9,6 +9,7 @@ import com.onarandombox.MultiverseCore.MultiverseCore;
|
|||||||
public class WorldDestination extends Destination {
|
public class WorldDestination extends Destination {
|
||||||
private boolean isValid;
|
private boolean isValid;
|
||||||
private MVWorld world;
|
private MVWorld world;
|
||||||
|
float yaw = -1;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getIdentifer() {
|
public String getIdentifer() {
|
||||||
@ -18,13 +19,19 @@ public class WorldDestination extends Destination {
|
|||||||
@Override
|
@Override
|
||||||
public boolean isThisType(JavaPlugin plugin, String destination) {
|
public boolean isThisType(JavaPlugin plugin, String destination) {
|
||||||
String[] items = destination.split(":");
|
String[] items = destination.split(":");
|
||||||
if (items.length > 2) {
|
if (items.length > 3) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (items.length == 1 && ((MultiverseCore) plugin).isMVWorld(items[0])) {
|
if (items.length == 1 && ((MultiverseCore) plugin).isMVWorld(items[0])) {
|
||||||
|
// This case is: world
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (items[0].equalsIgnoreCase("w") && ((MultiverseCore) plugin).isMVWorld(items[1])) {
|
if (items.length == 2 && ((MultiverseCore) plugin).isMVWorld(items[0])) {
|
||||||
|
// This case is: world:n
|
||||||
|
return true;
|
||||||
|
} else if (items[0].equalsIgnoreCase("w") && ((MultiverseCore) plugin).isMVWorld(items[1])) {
|
||||||
|
// This case is: w:world
|
||||||
|
// and w:world:ne
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -32,7 +39,12 @@ public class WorldDestination extends Destination {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Location getLocation() {
|
public Location getLocation() {
|
||||||
return this.world.getCBWorld().getSpawnLocation();
|
Location spawnLoc = this.world.getCBWorld().getSpawnLocation();
|
||||||
|
if (this.yaw >= 0) {
|
||||||
|
// Only modify the yaw if its set.
|
||||||
|
spawnLoc.setYaw(this.yaw);
|
||||||
|
}
|
||||||
|
return spawnLoc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -43,19 +55,26 @@ public class WorldDestination extends Destination {
|
|||||||
@Override
|
@Override
|
||||||
public void setDestination(JavaPlugin plugin, String dest) {
|
public void setDestination(JavaPlugin plugin, String dest) {
|
||||||
String[] items = dest.split(":");
|
String[] items = dest.split(":");
|
||||||
if (items.length > 2) {
|
if (items.length > 3) {
|
||||||
isValid = false;
|
isValid = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(items.length == 1 && ((MultiverseCore) plugin).isMVWorld(items[0])) {
|
if (items.length == 1 && ((MultiverseCore) plugin).isMVWorld(items[0])) {
|
||||||
isValid = true;
|
isValid = true;
|
||||||
this.world = ((MultiverseCore) plugin).getMVWorld(items[0]);
|
this.world = ((MultiverseCore) plugin).getMVWorld(items[0]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (items.length == 2 && ((MultiverseCore) plugin).isMVWorld(items[0])) {
|
||||||
|
this.world = ((MultiverseCore) plugin).getMVWorld(items[0]);
|
||||||
|
this.yaw = LocationManipulation.getYaw(items[1]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (items[0].equalsIgnoreCase("w") && ((MultiverseCore) plugin).isMVWorld(items[1])) {
|
if (items[0].equalsIgnoreCase("w") && ((MultiverseCore) plugin).isMVWorld(items[1])) {
|
||||||
this.world = ((MultiverseCore) plugin).getMVWorld(items[1]);
|
this.world = ((MultiverseCore) plugin).getMVWorld(items[1]);
|
||||||
isValid = true;
|
isValid = true;
|
||||||
return;
|
if (items.length == 3) {
|
||||||
|
this.yaw = LocationManipulation.getYaw(items[2]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user