sign.setLine(i, StringUtils.replace(sign.getLine(i), "[off]", ""));
player.printError("worldedit.ic.notfound");
} else {
if(CraftBookPlugin.plugins.getWorldEdit().getSelection(((BukkitPlayer) player).getPlayer()) != null && CraftBookPlugin.plugins.getWorldEdit().getSelection(((BukkitPlayer) player).getPlayer()).getRegionSelector() != null) {
RegionSelector selector = CraftBookPlugin.plugins.getWorldEdit().getSelection(((BukkitPlayer) player).getPlayer()).getRegionSelector();
try {
if(selector instanceof CuboidRegionSelector) {
Vector centre = selector.getRegion().getMaximumPoint().add(selector.getRegion().getMinimumPoint());
centre = centre.divide(2);
Vector offset = centre.subtract(sign.getBlockVector());
String x,y,z;
x = Double.toString(offset.getX());
if (x.endsWith(".0"))
x = StringUtils.replace(x, ".0", "");
y = Double.toString(offset.getY());
if (y.endsWith(".0"))
y = StringUtils.replace(y, ".0", "");
z = Double.toString(offset.getZ());
if (z.endsWith(".0"))
z = StringUtils.replace(z, ".0", "");
sign.setLine(i, StringUtils.replace(sign.getLine(i), "[off]", "&" + x + ":" + y + ":" + z));
} else if (selector instanceof SphereRegionSelector) {
Vector centre = ((SphereRegionSelector)selector).getRegion().getCenter();
Vector offset = centre.subtract(sign.getBlockVector());
String x,y,z;
x = Double.toString(offset.getX());
if (x.endsWith(".0"))
x = StringUtils.replace(x, ".0", "");
y = Double.toString(offset.getY());
if (y.endsWith(".0"))
y = StringUtils.replace(y, ".0", "");
z = Double.toString(offset.getZ());
if (z.endsWith(".0"))
z = StringUtils.replace(z, ".0", "");
sign.setLine(i, StringUtils.replace(sign.getLine(i), "[off]", "&" + x + ":" + y + ":" + z));
} else { // Unsupported.
sign.setLine(i, StringUtils.replace(sign.getLine(i), "[off]", ""));
player.printError("worldedit.ic.unsupported");
}
}
catch(IncompleteRegionException e) {
player.printError("worldedit.ic.noselection");
}
} else {
player.printError("worldedit.ic.noselection");
}
}
}
if(sign.getLine(i).contains("[rad]")) {
if(CraftBookPlugin.plugins.getWorldEdit() == null) {
sign.setLine(i, StringUtils.replace(sign.getLine(i), "[rad]", ""));
player.printError("worldedit.ic.notfound");
} else {
if(CraftBookPlugin.plugins.getWorldEdit().getSelection(((BukkitPlayer) player).getPlayer()) != null && CraftBookPlugin.plugins.getWorldEdit().getSelection(((BukkitPlayer) player).getPlayer()).getRegionSelector() != null) {
RegionSelector selector = CraftBookPlugin.plugins.getWorldEdit().getSelection(((BukkitPlayer) player).getPlayer()).getRegionSelector();
try {
if(selector instanceof CuboidRegionSelector) {
String x,y,z;
x = Double.toString(Math.abs(selector.getRegion().getMaximumPoint().getX() - selector.getRegion().getMinimumPoint().getX())/2);
if (x.endsWith(".0"))
x = StringUtils.replace(x, ".0", "");
y = Double.toString(Math.abs(selector.getRegion().getMaximumPoint().getY() - selector.getRegion().getMinimumPoint().getY())/2);
if (y.endsWith(".0"))
y = StringUtils.replace(y, ".0", "");
z = Double.toString(Math.abs(selector.getRegion().getMaximumPoint().getZ() - selector.getRegion().getMinimumPoint().getZ())/2);
if (z.endsWith(".0"))
z = StringUtils.replace(z, ".0", "");
sign.setLine(i, StringUtils.replace(sign.getLine(i), "[rad]", x + "," + y + "," + z));
} else if (selector instanceof SphereRegionSelector) {
String x;
double amounts = ((EllipsoidRegion) selector.getRegion()).getRadius().getX();
x = Double.toString(amounts);
if (x.endsWith(".0"))
x = StringUtils.replace(x, ".0", "");