This commit is contained in:
sauilitired 2015-05-24 03:15:30 +02:00
parent 81806a06f4
commit 2e06140e80
3 changed files with 39 additions and 6 deletions

View File

@ -163,9 +163,9 @@ public class Set extends SubCommand {
final Location base = MainUtil.getPlotBottomLoc(world, plot.id);
base.setY(0);
final Location relative = plr.getLocation().subtract(base.getX(), base.getY(), base.getZ());
final BlockLoc blockloc = new BlockLoc(relative.getX(), relative.getY(), relative.getZ());
final BlockLoc blockloc = new BlockLoc(relative.getX(), relative.getY(), relative.getZ(), relative.getY(), relative.getPitch());
plot.settings.setPosition(blockloc);
DBFunc.setPosition(loc.getWorld(), plot, relative.getX() + "," + relative.getY() + "," + relative.getZ());
DBFunc.setPosition(loc.getWorld(), plot, blockloc.toString());
return MainUtil.sendMessage(plr, C.POSITION_SET);
}
if (args[0].equalsIgnoreCase("alias")) {

View File

@ -913,9 +913,7 @@ public class SQLManager implements AbstractDB {
break;
default:
try {
final String[] split = pos.split(",");
final BlockLoc loc = new BlockLoc(Integer.parseInt(split[0]), Integer.parseInt(split[1]), Integer.parseInt(split[2]));
plot.settings.setPosition(loc);
plot.settings.setPosition(BlockLoc.fromString(pos));
} catch (final Exception e) {
}
}

View File

@ -5,10 +5,19 @@ public class BlockLoc {
public int y;
public int z;
public BlockLoc(final int x, final int y, final int z) {
public float yaw, pitch;
public BlockLoc(final int x, final int y, final int z, final float yaw, final float pitch) {
this.x = x;
this.y = y;
this.z = z;
this.yaw = yaw;
this.pitch = pitch;
}
public BlockLoc(final int x, final int y, final int z) {
this(x, y, z, 0f, 0f);
}
@Override
@ -35,4 +44,30 @@ public class BlockLoc {
final BlockLoc other = (BlockLoc) obj;
return ((this.x == other.x) && (this.y == other.y) && (this.z == other.z));
}
@Override
public String toString() {
return
x + "," + y + "," + z + "," + yaw + "," + pitch;
}
public static BlockLoc fromString(final String string) {
String[] parts = string.split(",");
float yaw, pitch;
if (parts.length == 3) {
yaw = 0f;
pitch = 0f;
} if (parts.length == 5) {
yaw = Float.parseFloat(parts[3]);
pitch = Float.parseFloat(parts[4]);
} else {
return new BlockLoc(0, 0, 0);
}
int x = Integer.parseInt(parts[0]);
int y = Integer.parseInt(parts[1]);
int z = Integer.parseInt(parts[2]);
return new BlockLoc(x, y, z, yaw, pitch);
}
}