@Override public void act(Player player, Item parentItem, HouseObject<?> targetHouseObject) { if (!player.getInventory().decreaseByObjectId(parentItem.getObjectId(), 1)) { return; } if (color.equals("no")) { targetHouseObject.setColor(null); } else { targetHouseObject.setColor(Integer.parseInt(color, 16)); } float x = targetHouseObject.getX(); float y = targetHouseObject.getY(); float z = targetHouseObject.getZ(); int rotation = targetHouseObject.getRotation(); PacketSendUtility.sendPacket(player, new SM_HOUSE_EDIT(7, 0, targetHouseObject.getObjectId())); PacketSendUtility.sendPacket( player, new SM_HOUSE_EDIT(5, targetHouseObject.getObjectId(), x, y, z, rotation)); targetHouseObject.spawn(); int objectName = targetHouseObject.getObjectTemplate().getNameId(); if (color.equals("no")) { PacketSendUtility.sendPacket( player, SM_SYSTEM_MESSAGE.STR_MSG_ITEM_PAINT_REMOVE_SUCCEED(objectName)); } else { int paintName = parentItem.getItemTemplate().getNameId(); PacketSendUtility.sendPacket( player, SM_SYSTEM_MESSAGE.STR_MSG_ITEM_PAINT_SUCCEED(objectName, paintName)); } }
@Override public boolean canAct(Player player, Item parentItem, HouseObject<?> targetHouseObject) { if (targetHouseObject == null) { PacketSendUtility.sendPacket(player, SM_SYSTEM_MESSAGE.STR_ITEM_COLOR_ERROR); return false; } if (color.equals("no") && targetHouseObject.getColor() == null) { PacketSendUtility.sendPacket(player, SM_SYSTEM_MESSAGE.STR_MSG_ITEM_PAINT_ERROR_CANNOTREMOVE); return false; } boolean canPaint = targetHouseObject.getObjectTemplate().getCanDye(); if (!canPaint) { PacketSendUtility.sendPacket(player, SM_SYSTEM_MESSAGE.STR_MSG_ITEM_PAINT_ERROR_CANNOTPAINT); } return canPaint; }