}
ItemStack i = inventory.getQuickbar().getSelectedSlot().get();
if (i == null || !(i.getMaterial() instanceof Map)) {
throw new CommandException("Held item is not a map");
}
Map m = (Map) i.getMaterial();
int bx = args.popInteger("bx");
int by = args.popInteger("by");
int tx = args.popInteger("tx");
int ty = args.popInteger("ty");
int col = args.popInteger("col");
args.assertCompletelyParsed();
if (bx < 0 || bx >= m.getWidth()) {
throw new CommandException("bx component is out of range");
}
if (by < 0 || by >= m.getHeight()) {
throw new CommandException("by component is out of range");
}
if (tx < 0 || tx >= m.getWidth()) {
throw new CommandException("tx component is out of range");
}
if (ty < 0 || ty >= m.getHeight()) {
throw new CommandException("ty component is out of range");
}
if (bx > tx) {
throw new CommandException("bx cannot be greater than tx");
}
if (by > ty) {
throw new CommandException("by cannot be greater than ty");
}
for (ProtocolEvent e : m.drawRectangle(i, bx, by, tx, ty, col)) {
player.getNetwork().callProtocolEvent(e);
}
}